cmdlinerunner.cpp: use ICommandLineOptionsModule
[alexxy/gromacs.git] / src / gromacs / trajectoryanalysis / cmdlinerunner.h
index 0b703ea268485300ab0d70954064217634a8870d..54f945560c6034b5ea375c007f7b138e4bcb0218 100644 (file)
@@ -43,6 +43,7 @@
 #ifndef GMX_TRAJECTORYANALYSIS_CMDLINERUNNER_H
 #define GMX_TRAJECTORYANALYSIS_CMDLINERUNNER_H
 
+#include "gromacs/commandline/cmdlineoptionsmodule.h"
 #include "gromacs/trajectoryanalysis/analysismodule.h"
 #include "gromacs/utility/classhelpers.h"
 
@@ -64,7 +65,7 @@ class CommandLineHelpContext;
  * \inpublicapi
  * \ingroup module_trajectoryanalysis
  */
-class TrajectoryAnalysisCommandLineRunner
+class TrajectoryAnalysisCommandLineRunner : public ICommandLineOptionsModule
 {
     public:
         /*! \brief
@@ -158,15 +159,19 @@ class TrajectoryAnalysisCommandLineRunner
                                    ModuleFactoryMethod factory);
 
         /*! \brief
-         * Create a new runner with the provided module.
+         * Constructs a module.
          *
-         * \param  module  Analysis module to run using the runner.
-         * \throws std::bad_alloc if out of memory.
+         * \param[in] factory      Factory method to create the analysis module.
          *
-         * The caller should ensure that the provided module is not destroyed
-         * while the runner exists.
+         * Does not throw.  This is important for correct implementation of
+         * runAsMain().
          */
-        TrajectoryAnalysisCommandLineRunner(TrajectoryAnalysisModule *module);
+        TrajectoryAnalysisCommandLineRunner(ModuleFactoryMethod factory);
+
+        /*! \brief
+         * Overloaded constructor accepting a functor instead of function pointer.
+         */
+        TrajectoryAnalysisCommandLineRunner(ModuleFactoryFunctor *factory);
         ~TrajectoryAnalysisCommandLineRunner();
 
         /*! \brief
@@ -191,21 +196,13 @@ class TrajectoryAnalysisCommandLineRunner
          * \see SelectionCollection::setDebugLevel()
          */
         void setSelectionDebugLevel(int debuglevel);
-        /*! \brief
-         * Parses options from the given command line and runs the analysis.
-         *
-         * \throws  multiple  Exceptions are used to indicate errors.
-         * \returns Zero on success.
-         */
-        int run(int argc, char *argv[]);
-        /*! \brief
-         * Prints help for the module, including common options from the runner.
-         *
-         * \param[in] context  Context object for writing the help.
-         * \throws    std::bad_alloc if out of memory.
-         * \throws    FileIOError on any I/O error.
-         */
-        void writeHelp(const CommandLineHelpContext &context);
+
+        // From ICommandLineOptionsModule
+        virtual void init(CommandLineModuleSettings *settings);
+        void initOptions(IOptionsContainer                 *options,
+                         ICommandLineOptionsModuleSettings *settings);
+        void optionsFinished();
+        int run();
 
         //! Implements the template runAsMain() method.
         static int runAsMain(int argc, char *argv[],