argos::CARGoSCommandLineArgParser Class Reference

The command line argument parser used by the main ARGoS executable. More...

#include <argos_command_line_arg_parser.h>

Inheritance diagram for argos::CARGoSCommandLineArgParser:
Collaboration diagram for argos::CARGoSCommandLineArgParser:

Public Types

enum  EAction {
  ACTION_UNKNOWN = 0, ACTION_SHOW_HELP, ACTION_SHOW_VERSION, ACTION_RUN_EXPERIMENT,
  ACTION_QUERY
}
 The possible actions that can be done. More...
 

Public Member Functions

 CARGoSCommandLineArgParser ()
 Class constructor. More...
 
virtual ~CARGoSCommandLineArgParser ()
 Class destructor. More...
 
virtual void PrintUsage (CARGoSLog &c_log)
 Prints usage information to the wanted log. More...
 
virtual void PrintVersion ()
 Prints the current ARGoS version and release. More...
 
virtual void Parse (SInt32 n_argc, char **ppch_argv)
 Parses the command line. More...
 
EAction GetAction ()
 Returns the action parsed by Parse(). More...
 
const std::string & GetExperimentConfigFile ()
 Returns the experiment configuration file as parsed by Parse(). More...
 
const std::string & GetQuery ()
 Returns the query on the plugins as parsed by Parse(). More...
 
bool IsLogColored ()
 Returns true if color is enabled for LOG and LOGERR. More...
 
bool IsHelpWanted ()
 Returns true if color if a help message must be displayed. More...
 
- Public Member Functions inherited from argos::CCommandLineArgParser
 CCommandLineArgParser ()
 Class constructor. More...
 
virtual ~CCommandLineArgParser ()
 Class destructor. More...
 
void AddFlag (char ch_short_option, const std::string &str_long_option, const std::string &str_description, bool &b_flag)
 Adds a flag to the parser. More...
 
template<typename T >
void AddArgument (char ch_short_option, const std::string &str_long_option, const std::string &str_description, T &t_buffer)
 Adds an argument to the parser. More...
 

Detailed Description

The command line argument parser used by the main ARGoS executable.

If you plan to write your own main.cpp file, and want to keep the same command line arguments, use this class.

See also
CCommandLineArgParser

Definition at line 25 of file argos_command_line_arg_parser.h.

Member Enumeration Documentation

The possible actions that can be done.

Enumerator
ACTION_UNKNOWN 
ACTION_SHOW_HELP 
ACTION_SHOW_VERSION 
ACTION_RUN_EXPERIMENT 
ACTION_QUERY 

Definition at line 32 of file argos_command_line_arg_parser.h.

Constructor & Destructor Documentation

argos::CARGoSCommandLineArgParser::CARGoSCommandLineArgParser ( )

Class constructor.

Definition at line 15 of file argos_command_line_arg_parser.cpp.

argos::CARGoSCommandLineArgParser::~CARGoSCommandLineArgParser ( )
virtual

Class destructor.

Definition at line 66 of file argos_command_line_arg_parser.cpp.

Member Function Documentation

EAction argos::CARGoSCommandLineArgParser::GetAction ( )
inline

Returns the action parsed by Parse().

Returns
The action parsed by Parse().
See also
Parse()

Definition at line 87 of file argos_command_line_arg_parser.h.

const std::string& argos::CARGoSCommandLineArgParser::GetExperimentConfigFile ( )
inline

Returns the experiment configuration file as parsed by Parse().

The returned value is meaningful only if GetAction() returns ACTION_RUN_EXPERIMENT.

Returns
The experiment configuration file as parsed by Parse().
See also
Parse()

Definition at line 97 of file argos_command_line_arg_parser.h.

const std::string& argos::CARGoSCommandLineArgParser::GetQuery ( )
inline

Returns the query on the plugins as parsed by Parse().

The returned value is meaningful only if GetAction() returns ACTION_QUERY.

Returns
The query on the plugins as parsed by Parse().
See also
Parse()

Definition at line 107 of file argos_command_line_arg_parser.h.

bool argos::CARGoSCommandLineArgParser::IsHelpWanted ( )
inline

Returns true if color if a help message must be displayed.

Help maybe be necessary either in case of parsing error, or because the –help</t> argument was passed on the command line.

See also
Parse()

Definition at line 128 of file argos_command_line_arg_parser.h.

bool argos::CARGoSCommandLineArgParser::IsLogColored ( )
inline

Returns true if color is enabled for LOG and LOGERR.

See also
Parse()
CARGoSLogger
LOG
LOGERR

Definition at line 118 of file argos_command_line_arg_parser.h.

void argos::CARGoSCommandLineArgParser::Parse ( SInt32  n_argc,
char **  ppch_argv 
)
virtual

Parses the command line.

In parsing is successful, it sets m_eAction to the action to perform, along with the relevant operands.

Parameters
n_argcThe number of command line arguments.
ppch_argvAn array of C-style strings containing the arguments.
Exceptions
CARGoSExceptionif a parse error occurs.
See also
GetAction()
GetExperimentConfigFile()
GetQuery()
IsLogColored()
IsHelpWanted()

Reimplemented from argos::CCommandLineArgParser.

Definition at line 80 of file argos_command_line_arg_parser.cpp.

void argos::CARGoSCommandLineArgParser::PrintUsage ( CARGoSLog c_log)
virtual

Prints usage information to the wanted log.

Parameters
c_logThe output log (LOG or LOGERR)
See also
CARGoSLogger
LOG
LOGERR

Reimplemented from argos::CCommandLineArgParser.

Definition at line 143 of file argos_command_line_arg_parser.cpp.

void argos::CARGoSCommandLineArgParser::PrintVersion ( )
virtual

Prints the current ARGoS version and release.

Definition at line 180 of file argos_command_line_arg_parser.cpp.