Gromacs
5.1
|
#include <gromacs/trajectoryanalysis/cmdlinerunner.h>
Runner class for command-line analysis tools.
This class implements a command-line analysis program, given a TrajectoryAnalysisModule object. It takes care of converting command-line parameters to a form understood by the module, as well as parsing common options, initializing and evaluating selections, and looping over trajectory frames.
Public Types | |
typedef TrajectoryAnalysisModulePointer(* | ModuleFactoryMethod )() |
Factory method type for creating a trajectory analysis module. More... | |
Public Member Functions | |
TrajectoryAnalysisCommandLineRunner (TrajectoryAnalysisModule *module) | |
Create a new runner with the provided module. More... | |
void | setUseDefaultGroups (bool bUseDefaults) |
Sets whether default index groups are initialized. More... | |
void | setSelectionDebugLevel (int debuglevel) |
Sets the default debugging level for selections. More... | |
int | run (int argc, char *argv[]) |
Parses options from the given command line and runs the analysis. More... | |
void | writeHelp (const CommandLineHelpContext &context) |
Prints help for the module, including common options from the runner. More... | |
Static Public Member Functions | |
template<class ModuleType > | |
static int | runAsMain (int argc, char *argv[]) |
Implements a main() method that runs a given module. More... | |
template<class ModuleType > | |
static void | registerModule (CommandLineModuleManager *manager, const char *name, const char *description) |
Registers a command-line module that runs a given module. More... | |
static void | registerModule (CommandLineModuleManager *manager, const char *name, const char *description, ModuleFactoryMethod factory) |
Registers a command-line module that runs a given module. More... | |
typedef TrajectoryAnalysisModulePointer(* gmx::TrajectoryAnalysisCommandLineRunner::ModuleFactoryMethod)() |
Factory method type for creating a trajectory analysis module.
This method allows the module creation to be postponed to be inside the try/catch block in runAsMain()/registerModule() implementation methods and still keep the implementation out of the header, making the ABI more stable.
gmx::TrajectoryAnalysisCommandLineRunner::TrajectoryAnalysisCommandLineRunner | ( | TrajectoryAnalysisModule * | module | ) |
Create a new runner with the provided module.
module | Analysis module to run using the runner. |
std::bad_alloc | if out of memory. |
The caller should ensure that the provided module is not destroyed while the runner exists.
|
inlinestatic |
Registers a command-line module that runs a given module.
ModuleType | Trajectory analysis module. |
manager | Manager to register the module to. |
name | Name of the module to register. |
description | One-line description for the module to register. |
ModuleType
should be default-constructible and derive from TrajectoryAnalysisModule.
name
and descriptions
must be string constants or otherwise stay valid for the duration of the program execution.
|
static |
Registers a command-line module that runs a given module.
ModuleType | Trajectory analysis module. |
manager | Manager to register the module to. |
name | Name of the module to register. |
description | One-line description for the module to register. |
factory | Function that creates the module on demand. |
name
and descriptions
must be string constants or otherwise stay valid for the duration of the program execution.
Implements the template registerModule() method, but can also be used independently.
int gmx::TrajectoryAnalysisCommandLineRunner::run | ( | int | argc, |
char * | argv[] | ||
) |
Parses options from the given command line and runs the analysis.
multiple | Exceptions are used to indicate errors. |
|
inlinestatic |
Implements a main() method that runs a given module.
ModuleType | Trajectory analysis module. |
This method abstracts away all the logic required to implement a main() method in user tools, allowing that to be changed without requiring changes to the tools themselves.
ModuleType
should be default-constructible and derive from TrajectoryAnalysisModule.
Does not throw. All exceptions are caught and handled internally.
void gmx::TrajectoryAnalysisCommandLineRunner::setSelectionDebugLevel | ( | int | debuglevel | ) |
Sets the default debugging level for selections.
[in] | debuglevel | Level of debugging verbosity. |
This is intended only for use by internal debugging tools.
Does not throw.
void gmx::TrajectoryAnalysisCommandLineRunner::setUseDefaultGroups | ( | bool | bUseDefaults | ) |
Sets whether default index groups are initialized.
This is intended only for internal unit testing purposes to avoid repeated, unnecessary initialization of the default groups, which can be expensive under, e.g., valgrind.
Does not throw.
void gmx::TrajectoryAnalysisCommandLineRunner::writeHelp | ( | const CommandLineHelpContext & | context | ) |
Prints help for the module, including common options from the runner.
[in] | context | Context object for writing the help. |
std::bad_alloc | if out of memory. |
FileIOError | on any I/O error. |