Gromacs  2024.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Types | Static Public Member Functions
gmx::TrajectoryAnalysisCommandLineRunner Class Reference

#include <gromacs/trajectoryanalysis/cmdlinerunner.h>

Description

Runner for command-line trajectory analysis tools.

This class provides static methods to implement a command-line analysis program, given a TrajectoryAnalysisModule object (or a factory of such). It takes care of common command-line parameters, initializing and evaluating selections, and looping over trajectory frames.

Public Types

typedef std::function
< TrajectoryAnalysisModulePointer()> 
ModuleFactoryMethod
 Factory method type for creating a trajectory analysis module. 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...
 
static int runAsMain (int argc, char *argv[], const ModuleFactoryMethod &factory)
 Implements a main() method that runs a given module. More...
 
static void registerModule (CommandLineModuleManager *manager, const char *name, const char *description, const ModuleFactoryMethod &factory)
 Registers a command-line module that runs a given module. More...
 
static std::unique_ptr
< ICommandLineOptionsModule
createModule (TrajectoryAnalysisModulePointer module)
 Create a command-line module that runs the provided analysis module. More...
 

Member Typedef Documentation

Factory method type for creating a trajectory analysis module.

This method allows the module creation to be postponed to the point where the module is needed, reducing initialization costs in, e.g., the gmx binary, and simplifying exception handling.

Member Function Documentation

std::unique_ptr< ICommandLineOptionsModule > gmx::TrajectoryAnalysisCommandLineRunner::createModule ( TrajectoryAnalysisModulePointer  module)
static

Create a command-line module that runs the provided analysis module.

Parameters
[in]moduleModule to run.
Returns
Command-line module that runs the provided analysis module.
Exceptions
std::bad_allocif out of memory.

This is mainly provided for testing purposes that want to bypass CommandLineModuleManager.

void gmx::TrajectoryAnalysisCommandLineRunner::registerModule ( CommandLineModuleManager manager,
const char *  name,
const char *  description,
const ModuleFactoryMethod factory 
)
static

Registers a command-line module that runs a given module.

Parameters
managerManager to register the module to.
nameName of the module to register.
descriptionOne-line description for the module to register.
factoryFunction that creates the module on demand.

name and descriptions must be string constants or otherwise stay valid for the duration of the program execution.

template<class ModuleType >
static int gmx::TrajectoryAnalysisCommandLineRunner::runAsMain ( int  argc,
char *  argv[] 
)
inlinestatic

Implements a main() method that runs a given module.

Template Parameters
ModuleTypeTrajectory analysis module.
Parameters
argcargc passed to main().
argvargv passed to main().

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.

int gmx::TrajectoryAnalysisCommandLineRunner::runAsMain ( int  argc,
char *  argv[],
const ModuleFactoryMethod factory 
)
static

Implements a main() method that runs a given module.

Parameters
argcargc passed to main().
argvargv passed to main().
factoryFunction that creates the module on demand.

Implements the template runAsMain(), but can also be used independently.

Does not throw. All exceptions are caught and handled internally.


The documentation for this class was generated from the following files: