-
-void
-TrajectoryAnalysisCommandLineRunner::writeHelp(const CommandLineHelpContext &context)
-{
- // TODO: This method duplicates some code from run().
- // See how to best refactor it to share the common code.
- SelectionCollection selections;
- TrajectoryAnalysisSettings settings;
- TrajectoryAnalysisRunnerCommon common(&settings);
-
- SelectionOptionManager seloptManager(&selections);
- Options options(NULL, NULL);
-
- options.addManager(&seloptManager);
- IOptionsContainer &commonOptions = options.addGroup();
- IOptionsContainer &moduleOptions = options.addGroup();
-
- impl_->module_->initOptions(&moduleOptions, &settings);
- common.initOptions(&commonOptions);
- selections.initOptions(&commonOptions);
-
- CommandLineHelpWriter(options)
- .setHelpText(settings.helpText())
- .setTimeUnitString(settings.timeUnitManager().timeUnitAsString())
- .writeHelp(context);
-}
-
-
-/*! \internal \brief
- * Command line module for a trajectory analysis module.
- *
- * \ingroup module_trajectoryanalysis
- */
-class TrajectoryAnalysisCommandLineRunner::Impl::RunnerCommandLineModule
- : public ICommandLineModule
-{
- public:
- /*! \brief
- * Constructs a module.
- *
- * \param[in] name Name for the module.
- * \param[in] description One-line description for the module.
- * \param[in] factory Factory method to create the analysis module.
- *
- * Does not throw. This is important for correct implementation of
- * runAsMain().
- */
- RunnerCommandLineModule(const char *name, const char *description,
- ModuleFactoryMethod factory)
- : name_(name), description_(description), hasFunction_(true), factory_(factory), functor_(NULL)
- {
- }
-
- /*! \brief
- * Overloaded constructor accepting a functor instead of function pointer.
- */
- RunnerCommandLineModule(const char *name, const char *description,
- ModuleFactoryFunctor *factory)
- : name_(name), description_(description), hasFunction_(false), factory_(NULL), functor_(factory)
- {
- }
-
- virtual const char *name() const { return name_; }
- virtual const char *shortDescription() const { return description_; };
-
- virtual void init(CommandLineModuleSettings *settings);
- virtual int run(int argc, char *argv[]);
- virtual void writeHelp(const CommandLineHelpContext &context) const;
-
- private:
- const char *name_;
- const char *description_;
- bool hasFunction_;
- ModuleFactoryMethod factory_;
- ModuleFactoryFunctor *functor_;
-
- GMX_DISALLOW_COPY_AND_ASSIGN(RunnerCommandLineModule);
-};
-
-void TrajectoryAnalysisCommandLineRunner::Impl::RunnerCommandLineModule::init(
- CommandLineModuleSettings * /*settings*/)
-{
-}
-
-int TrajectoryAnalysisCommandLineRunner::Impl::RunnerCommandLineModule::run(
- int argc, char *argv[])
-{
- TrajectoryAnalysisModulePointer module(hasFunction_ ? factory_() : (*functor_)());
- TrajectoryAnalysisCommandLineRunner runner(module.get());
- return runner.run(argc, argv);
-}
-
-void TrajectoryAnalysisCommandLineRunner::Impl::RunnerCommandLineModule::writeHelp(
- const CommandLineHelpContext &context) const
-{
- TrajectoryAnalysisModulePointer module(hasFunction_ ? factory_() : (*functor_)());
- TrajectoryAnalysisCommandLineRunner runner(module.get());
- runner.writeHelp(context);
-}
-