votca 2024-dev
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
votca::tools::Application Class Referenceabstract

#include <application.h>

Inheritance diagram for votca::tools::Application:
Inheritance graph
[legend]
Collaboration diagram for votca::tools::Application:
Collaboration graph
[legend]

Public Member Functions

 Application ()
 
virtual ~Application ()
 
int Exec (int argc, char **argv)
 executes the program
 
virtual std::string ProgramName ()=0
 program name
 
virtual std::string VersionString ()
 version string of application
 
virtual void HelpText (std::ostream &out)=0
 help text of application without version information
 
virtual void Initialize ()=0
 Initialize application data.
 
virtual bool EvaluateOptions ()=0
 Process command line options.
 
void CheckRequired (const std::string &option_name, const std::string &error_msg="")
 Check weather required option is set.
 
virtual void Run ()=0
 Main body of application.
 
boost::program_options::options_description_easy_init AddProgramOptions (const std::string &group="")
 add option for command line
 
boost::program_options::variables_map & OptionsMap ()
 get available program options & descriptions
 
boost::program_options::options_description & OptionsDesc ()
 
boost::program_options::options_description & VisibleOptions ()
 filters out the Hidden group from the options descriptions
 
void StopExecution ()
 call StopExecution after EvaluateOptions
 

Protected Member Functions

virtual void ShowHelpText (std::ostream &out)
 

Protected Attributes

std::map< std::string, boost::program_options::options_description > op_groups_
 
bool continue_execution_ = true
 

Private Member Functions

void ParseCommandLine (int argc, char **argv)
 get input parameters from file, location may be specified in command line
 

Private Attributes

boost::program_options::options_description op_desc_
 program options required by all applications
 
boost::program_options::variables_map op_vm_
 Variable map containing all program options.
 
boost::program_options::options_description visible_options_
 program options without the Hidden group
 

Detailed Description

Definition at line 30 of file application.h.

Constructor & Destructor Documentation

◆ Application()

votca::tools::Application::Application ( )

Definition at line 36 of file application.cc.

◆ ~Application()

votca::tools::Application::~Application ( )
virtualdefault

Member Function Documentation

◆ AddProgramOptions()

boost::program_options::options_description_easy_init votca::tools::Application::AddProgramOptions ( const std::string &  group = "")

add option for command line

Parameters
groupgroup string
Returns
easy_init of boost, see documentation

Adds an option to the available command line options. If no group is specified, it is added to the standard group (Allowed Options). If group is given, a sub group for this set of options will be created.

Definition at line 105 of file application.cc.

◆ CheckRequired()

void votca::tools::Application::CheckRequired ( const std::string &  option_name,
const std::string &  error_msg = "" 
)

Check weather required option is set.

Parameters
option_namename of the option
error_msgerror message if option is missing

CheckRequired is called from EvaluateOptions if a required options is set. If not, the list of possible options is shown and an exception with the error message given in error_msg is thrown

Definition at line 148 of file application.cc.

◆ EvaluateOptions()

virtual bool votca::tools::Application::EvaluateOptions ( )
pure virtual

Process command line options.

Returns
true to continue, false to stop

EvaluateOptions is called by Run after parsing the command line. return true if everything is ok, false to stop and show help text.

Implemented in CsgBoltzmann, VotcaProperty, votca::xtp::XtpApplication, votca::csg::CsgApplication, CsgFluctuations, CsgPartialRdfApp, CGOrderParam, TrajForce, CsgDensityApp, CGForceMatching, CG_IMC_solve, CsgMapApp, CsgREupdate, CsgStatApp, XtpMap, DLPTopolApp, and GmxTopolApp.

◆ Exec()

int votca::tools::Application::Exec ( int  argc,
char **  argv 
)

executes the program

Parameters
argcargc from main
argvargv from main
Returns
return code

Definition at line 58 of file application.cc.

◆ HelpText()

virtual void votca::tools::Application::HelpText ( std::ostream &  out)
pure virtual

◆ Initialize()

virtual void votca::tools::Application::Initialize ( )
pure virtual

Initialize application data.

Initialize is called by run before parsing the command line. All necessary command line arguments can be added here

Implemented in CsgBoltzmann, VotcaProperty, votca::xtp::XtpApplication, votca::csg::CsgApplication, CsgTestApp, CsgParallelTestApp, CsgFluctuations, OrientCorrApp, CsgPartialRdfApp, CsgRadiiApp, CGOrderParam, CsgDensityApp, CsgDumpApp, CG_IMC_solve, CsgMapApp, CsgREupdate, CsgStatApp, XtpMap, TrajForce, DLPTopolApp, CGForceMatching, and GmxTopolApp.

◆ OptionsDesc()

boost::program_options::options_description & votca::tools::Application::OptionsDesc ( )
inline

Definition at line 117 of file application.h.

◆ OptionsMap()

boost::program_options::variables_map & votca::tools::Application::OptionsMap ( )
inline

get available program options & descriptions

Returns
variables_map (see boost documentation)

Definition at line 116 of file application.h.

◆ ParseCommandLine()

void votca::tools::Application::ParseCommandLine ( int  argc,
char **  argv 
)
private

get input parameters from file, location may be specified in command line

Definition at line 125 of file application.cc.

◆ ProgramName()

virtual std::string votca::tools::Application::ProgramName ( )
pure virtual

◆ Run()

virtual void votca::tools::Application::Run ( )
pure virtual

Main body of application.

Run is called after command line was parsed + evaluated. All the work should be done in here.

Implemented in CsgBoltzmann, VotcaProperty, votca::xtp::XtpApplication, CG_IMC_solve, CsgREupdate, XtpMap, and votca::csg::CsgApplication.

◆ ShowHelpText()

void votca::tools::Application::ShowHelpText ( std::ostream &  out)
protectedvirtual

Reimplemented in votca::xtp::XtpApplication, votca::csg::CsgApplication, CG_IMC_solve, and XtpMap.

Definition at line 40 of file application.cc.

◆ StopExecution()

void votca::tools::Application::StopExecution ( )
inline

call StopExecution after EvaluateOptions

This is useful if the program executes an operation in EvaluateOptions and then wants to stop execution successfully. Call StopExecution and return true in EvaluateOptions.

Definition at line 136 of file application.h.

◆ VersionString()

virtual std::string votca::tools::Application::VersionString ( )
inlinevirtual

version string of application

Returns
version string

Definition at line 55 of file application.h.

◆ VisibleOptions()

boost::program_options::options_description & votca::tools::Application::VisibleOptions ( )
inline

filters out the Hidden group from the options descriptions

Returns
Option descriptions without the "Hidden" group

Definition at line 125 of file application.h.

Member Data Documentation

◆ continue_execution_

bool votca::tools::Application::continue_execution_ = true
protected

Definition at line 143 of file application.h.

◆ op_desc_

boost::program_options::options_description votca::tools::Application::op_desc_
private

program options required by all applications

Definition at line 147 of file application.h.

◆ op_groups_

std::map<std::string, boost::program_options::options_description> votca::tools::Application::op_groups_
protected

Definition at line 139 of file application.h.

◆ op_vm_

boost::program_options::variables_map votca::tools::Application::op_vm_
private

Variable map containing all program options.

Definition at line 149 of file application.h.

◆ visible_options_

boost::program_options::options_description votca::tools::Application::visible_options_
private

program options without the Hidden group

Definition at line 154 of file application.h.


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