Module that can be run from a command line and uses gmx::Options for argument processing.
This class provides a higher-level interface on top of gmx::CommandLineModuleInterface for cases where gmx::Options will be used for declaring the command-line arguments. The module only needs to declare the options it uses, and the framework takes care of command-line parsing and help output. The module typically consists of the following parts:
- init() allows for some interaction between the module and the framework when running the module; see CommandLineModuleInterface::init(). If no such customization is necessary, an empty implementation is sufficient.
- initOptions() is called both for running the module and for printing help for the module, and it should add the options that the module understands. Values provided for the options are typically stored in member variables.
- optionsFinished() can be implemented in case additional processing is needed (e.g., checking whether an option was set by the user).
- run() is called when running the module, after command-line options have been parsed and their values stored in the corresponding member variables.
registerModule(), runAsMain(), or createModule() can be used to use modules of this type in all contexts where a gmx::CommandLineModuleInterface is expected. These methods create a gmx::CommandLineModuleInterface implementation that contains the common code needed to parse command-line options and write help, based on the information provided from the methods in this class.
|
static CommandLineModuleInterface * | createModule (const char *name, const char *description, FactoryMethod factory) |
| Creates a CommandLineModuleInterface to run the specified module. More...
|
|
static int | runAsMain (int argc, char *argv[], const char *name, const char *description, FactoryMethod factory) |
| Implements a main() method that runs a single module. More...
|
|
static void | registerModule (CommandLineModuleManager *manager, const char *name, const char *description, FactoryMethod factory) |
| Registers a module of a certain type to this manager. More...
|
|
static void | registerModule (CommandLineModuleManager *manager, const char *name, const char *description, CommandLineOptionsModuleInterface *module) |
| Registers a module to this manager. More...
|
|
virtual void gmx::CommandLineOptionsModuleInterface::initOptions |
( |
Options * |
options | ) |
|
|
pure virtual |
Initializes command-line arguments understood by the module.
- Parameters
-
[in,out] | options | Options object to add the options to. |
When running the module, this method is called after init(). When printing help, there is no call to init(), and this is the only method called. In both cases, the implementation should add options understood by the module to options
. Output values from options should be stored in member variables.
virtual void gmx::CommandLineOptionsModuleInterface::optionsFinished |
( |
Options * |
options | ) |
|
|
pure virtual |
Called after all option values have been set.
- Parameters
-
[in,out] | options | Options object in which options are stored. |
When running the module, this method is called after all command-line arguments have been parsed, but while the Options object still exists.
If the module needs to call, e.g., Options::isSet(), this is the place to do that.