Gromacs  2025-dev-20240614-602a366
 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:


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

Public Types

 Function pointer type for a C main function. More...
 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 

Creates a wrapper module for the given main function.

[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)

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[] 

Runs the module with the given arguments.

[in]argcNumber of elements in argv.
[in]argvCommand-line arguments.
unspecifiedMay throw exceptions to indicate errors.
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

Prints help for the module.

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

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

Implements gmx::ICommandLineModule.

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