MAK Legion 1.1 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Legion::Configuration Class Reference

The configuration object parses the command line and loads a configuration file to provide the user configurable data to the application. More...

+ Collaboration diagram for Legion::Configuration:

Public Member Functions

 Configuration ()
 Constructor for default version. More...
 
 Configuration (const std::string &fileName)
 Constructor from a config file. More...
 
virtual ~Configuration ()
 Destructor. More...
 
virtual Configurationclone () const
 Clone a copy of the configuration. More...
 
template<typename DATA_TYPE >
void registerParameter (const std::string &string)
 Register a parameter to be searched for in the config files or command line. More...
 
virtual int processArguments (int argc, char **argv)
 Process command line arguments as parameter name-value pairs. More...
 
virtual bool processParameters (const std::map< std::string, std::string > &parameterValuePairs)
 Process parameter name-value pairs. More...
 
virtual bool hasParameter (const std::string &parameterName) const
 Return whether a parameter with the given name has been registered in this Configuration, but may be not set. More...
 
virtual bool isParameterSet (const std::string &parameterName) const
 Return whether a parameter with the given name has been registered and has a value in this Configuration. More...
 
virtual bool loadParameters (const std::string &fileName)
 Load parameters from a file Return whether the parameters were loaded successfully. More...
 
virtual bool saveParameters (const std::string &filename) const
 Save parameters to a file Return whether the parameters were saved successfully. More...
 
template<typename DATA_TYPE >
void setParameter (const std::string &parameterName, DATA_TYPE parameterValue)
 Set the parameter value of the specified type for the given parameter name. More...
 
template<typename DATA_TYPE >
DATA_TYPE parameter (const std::string &parameterName) const
 Get the parameter value with the given name as the expected type. More...
 
template<typename DATA_TYPE >
DATA_TYPE parameterOr (const std::string &parameterName, DATA_TYPE defaultValue) const
 Get the parameter value with the given name as the expected type Supplied default value is used if parameter is not found. More...
 
virtual void setUnitMultiplier (const std::string &parameterName, float multiplier)
 Set a unit multiplier that is applied to numeric values of the given parameter name Only applies to numeric parameters. More...
 
virtual float unitMultiplier (const std::string &parameterName) const
 Get the unit multiplier for the given parameter name. More...
 
virtual std::string helpString () const
 
ConfigHandle handle () const
 

Protected Member Functions

 Configuration (ConfigHandle handle)
 

Protected Attributes

ConfigHandle myHandle
 

Detailed Description

The configuration object parses the command line and loads a configuration file to provide the user configurable data to the application.

Constructor & Destructor Documentation

Legion::Configuration::Configuration ( )

Constructor for default version.

Legion::Configuration::Configuration ( const std::string &  fileName)

Constructor from a config file.

virtual Legion::Configuration::~Configuration ( )
virtual

Destructor.

Legion::Configuration::Configuration ( ConfigHandle  handle)
protected

Member Function Documentation

virtual Configuration* Legion::Configuration::clone ( ) const
virtual

Clone a copy of the configuration.

ConfigHandle Legion::Configuration::handle ( ) const
inline
virtual bool Legion::Configuration::hasParameter ( const std::string &  parameterName) const
virtual

Return whether a parameter with the given name has been registered in this Configuration, but may be not set.

virtual std::string Legion::Configuration::helpString ( ) const
virtual
virtual bool Legion::Configuration::isParameterSet ( const std::string &  parameterName) const
virtual

Return whether a parameter with the given name has been registered and has a value in this Configuration.

virtual bool Legion::Configuration::loadParameters ( const std::string &  fileName)
virtual

Load parameters from a file Return whether the parameters were loaded successfully.

Referenced by main(), and processArgumentsAndConfiguration().

template<typename DATA_TYPE >
DATA_TYPE Legion::Configuration::parameter ( const std::string &  parameterName) const

Get the parameter value with the given name as the expected type.

Referenced by main(), and processArgumentsAndConfiguration().

template<typename DATA_TYPE >
DATA_TYPE Legion::Configuration::parameterOr ( const std::string &  parameterName,
DATA_TYPE  defaultValue 
) const

Get the parameter value with the given name as the expected type Supplied default value is used if parameter is not found.

Referenced by main().

virtual int Legion::Configuration::processArguments ( int  argc,
char **  argv 
)
virtual

Process command line arguments as parameter name-value pairs.

Names are expected to have argument prefix "-" or "--" and values are not optional Parameters are added to or replace existing configuration parameters and values. Data for existing parameters is expected to be in format of the parameter's existing data type

Referenced by main(), and processArgumentsAndConfiguration().

virtual bool Legion::Configuration::processParameters ( const std::map< std::string, std::string > &  parameterValuePairs)
virtual

Process parameter name-value pairs.

Parameters are added to or replace existing configuration parameters and values. Data for existing parameters is expected to be in format of the parameter's existing data type

template<typename DATA_TYPE >
void Legion::Configuration::registerParameter ( const std::string &  string)

Register a parameter to be searched for in the config files or command line.

This does not set a default value and the parameter is considered not set until found on the command line, in a config file, or set manually though the API

virtual bool Legion::Configuration::saveParameters ( const std::string &  filename) const
virtual

Save parameters to a file Return whether the parameters were saved successfully.

template<typename DATA_TYPE >
void Legion::Configuration::setParameter ( const std::string &  parameterName,
DATA_TYPE  parameterValue 
)

Set the parameter value of the specified type for the given parameter name.

Referenced by main(), processArgumentsAndConfiguration(), and registerConfigParameters().

virtual void Legion::Configuration::setUnitMultiplier ( const std::string &  parameterName,
float  multiplier 
)
virtual

Set a unit multiplier that is applied to numeric values of the given parameter name Only applies to numeric parameters.

virtual float Legion::Configuration::unitMultiplier ( const std::string &  parameterName) const
virtual

Get the unit multiplier for the given parameter name.

Member Data Documentation

ConfigHandle Legion::Configuration::myHandle
protected

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

Document ID: Generated on Wed May 26 15:17:05 EDT 2021 from SVN revision 229676
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)