Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / commandline / cmdlineinit.cpp
index 5f42c0c44f97f46615de1dd2ced35b0952624b90..8fe171ee058c34e3ba807a752211baea35b95afd 100644 (file)
  * \author Teemu Murtola <teemu.murtola@gmail.com>
  * \ingroup module_commandline
  */
-#include "gromacs/commandline/cmdlineinit.h"
+#include "gmxpre.h"
+
+#include "cmdlineinit.h"
+
+#include "config.h"
 
 #include <cstring>
 
 #include <boost/scoped_ptr.hpp>
 
+#include "gromacs/commandline/cmdlinemodulemanager.h"
+#include "gromacs/commandline/cmdlineprogramcontext.h"
 #include "gromacs/legacyheaders/network.h"
-#include "gromacs/legacyheaders/smalloc.h"
 #include "gromacs/legacyheaders/types/commrec.h"
-
-#include "gromacs/commandline/cmdlineprogramcontext.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/gmxassert.h"
 #include "gromacs/utility/init.h"
 #include "gromacs/utility/programcontext.h"
+#include "gromacs/utility/smalloc.h"
 
 namespace gmx
 {
@@ -64,8 +68,8 @@ namespace
 //! \addtogroup module_commandline
 //! \{
 
-//! Global instance of ProgramInfo initialized in initForCommandLine().
-boost::scoped_ptr<ProgramInfo> g_commandLineContext;
+//! Global context instance initialized in initForCommandLine().
+boost::scoped_ptr<CommandLineProgramContext> g_commandLineContext;
 
 #ifdef GMX_LIB_MPI
 void broadcastArguments(const t_commrec *cr, int *argc, char ***argv)
@@ -97,7 +101,7 @@ void broadcastArguments(const t_commrec *cr, int *argc, char ***argv)
 
 }   // namespace
 
-ProgramInfo &initForCommandLine(int *argc, char ***argv)
+CommandLineProgramContext &initForCommandLine(int *argc, char ***argv)
 {
     gmx::init(argc, argv);
     GMX_RELEASE_ASSERT(!g_commandLineContext,
@@ -118,7 +122,7 @@ ProgramInfo &initForCommandLine(int *argc, char ***argv)
 #endif
     try
     {
-        g_commandLineContext.reset(new ProgramInfo(*argc, *argv));
+        g_commandLineContext.reset(new CommandLineProgramContext(*argc, *argv));
         setProgramContext(g_commandLineContext.get());
     }
     catch (const std::exception &ex)
@@ -136,4 +140,15 @@ void finalizeForCommandLine()
     g_commandLineContext.reset();
 }
 
+int runCommandLineModule(int argc, char *argv[],
+                         CommandLineModuleInterface *module)
+{
+    return gmx::CommandLineModuleManager::runAsMainSingleModule(argc, argv, module);
+}
+
 } // namespace gmx
+
+int gmx_run_cmain(int argc, char *argv[], int (*mainFunction)(int, char *[]))
+{
+    return gmx::CommandLineModuleManager::runAsMainCMain(argc, argv, mainFunction);
+}