Gromacs  2021.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions
gmx::anonymous_namespace{cmdlinemodulemanager.cpp}::CMainCommandLineModule Class Reference
+ Inheritance diagram for gmx::anonymous_namespace{cmdlinemodulemanager.cpp}::CMainCommandLineModule:
+ Collaboration diagram for gmx::anonymous_namespace{cmdlinemodulemanager.cpp}::CMainCommandLineModule:

Description

Implements a ICommandLineModule, given a function with C/C++ main() signature.

Public Types

typedef
CommandLineModuleManager::CMainFunction 
CMainFunction
 Function pointer type for a C main function. More...
 
typedef
CommandLineModuleManager::InitSettingsFunction 
InitSettingsFunction
 Function pointer to a settings provider. More...
 

Public Member Functions

 CMainCommandLineModule (const char *name, const char *shortDescription, CMainFunction mainFunction, InitSettingsFunction settingsFunction)
 Creates a wrapper module for the given main function. More...
 
const char * name () const override
 Returns the name of the module.
 
const char * shortDescription () const override
 Returns a one-line description of the module.
 
void init (CommandLineModuleSettings *settings) override
 Initializes the module and provides settings for the runner. More...
 
int run (int argc, char *argv[]) override
 Runs the module with the given arguments. More...
 
void writeHelp (const CommandLineHelpContext &context) const override
 Prints help for the module. More...
 

Member Typedef Documentation

typedef CommandLineModuleManager::CMainFunction gmx::anonymous_namespace{cmdlinemodulemanager.cpp}::CMainCommandLineModule::CMainFunction

Function pointer type for a C main function.

typedef CommandLineModuleManager::InitSettingsFunction gmx::anonymous_namespace{cmdlinemodulemanager.cpp}::CMainCommandLineModule::InitSettingsFunction

Function pointer to a settings provider.

Constructor & Destructor Documentation

gmx::anonymous_namespace{cmdlinemodulemanager.cpp}::CMainCommandLineModule::CMainCommandLineModule ( const char *  name,
const char *  shortDescription,
CMainFunction  mainFunction,
InitSettingsFunction  settingsFunction 
)
inline

Creates a wrapper module for the given main function.

Parameters
[in]nameName for the module.
[in]shortDescriptionOne-line description for the module.
[in]mainFunctionMain function to wrap.
[in]settingsFunctionInitializer for settings (can be null).

Does not throw. This is essential for correct implementation of CommandLineModuleManager::runAsMainCMain().

Member Function Documentation

void gmx::anonymous_namespace{cmdlinemodulemanager.cpp}::CMainCommandLineModule::init ( CommandLineModuleSettings settings)
inlineoverridevirtual

Initializes the module and provides settings for the runner.

This will be called before run(), and can be used to adjust initialization that the runner does.

This method is currently not called when writing the help.

Implements gmx::ICommandLineModule.

int gmx::anonymous_namespace{cmdlinemodulemanager.cpp}::CMainCommandLineModule::run ( int  argc,
char *  argv[] 
)
inlineoverridevirtual

Runs the module with the given arguments.

Parameters
[in]argcNumber of elements in argv.
[in]argvCommand-line arguments.
Exceptions
unspecifiedMay throw exceptions to indicate errors.
Returns
Exit code for the program.
Return values
0on successful termination.

argv[0] is the name of the module, i.e., the arguments are as if the module was run as a standalone executable.

Implements gmx::ICommandLineModule.

void gmx::anonymous_namespace{cmdlinemodulemanager.cpp}::CMainCommandLineModule::writeHelp ( const CommandLineHelpContext context) const
inlineoverridevirtual

Prints help for the module.

Parameters
[in]contextContext object for writing the help.
Exceptions
std::bad_allocif out of memory.
FileIOErroron any I/O error.

Note that for MPI-enabled builds, this is called only on the master rank.

Implements gmx::ICommandLineModule.


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