Gromacs  2018.1
 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...
 
virtual const char * name () const
 Returns the name of the module.
 
virtual const char * shortDescription () const
 Returns a one-line description of the module.
 
virtual void init (CommandLineModuleSettings *settings)
 Initializes the module and provides settings for the runner. More...
 
virtual int run (int argc, char *argv[])
 Runs the module with the given arguments. More...
 
virtual void writeHelp (const CommandLineHelpContext &context) const
 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

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

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.

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

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.

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

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: