EventAnalysis  1.4.0
Classes | Public Member Functions | Private Types | Private Attributes | Static Private Attributes | List of all members
EA::CommandLineParameters Class Reference

A class to store parameters passed from command line. More...

#include <CommandLineParameters.h>

Classes

struct  MultipleDefinitionExc
 

Public Member Functions

bool AddDataSource (const std::string &dataProviderName, const std::string &dataSource)
 Adds a output configuration string for a given persistence service. More...
 
bool AddOutput (const std::string &persistenceName, const std::string &output)
 Adds an output configuration string for a given persistence service. More...
 
bool AddParameter (const std::string &algoName, const std::string &paramName, const std::string &parameter)
 Adds a parameter setting string for a given configurable object. More...
 
const std::string & GetDataSource (const std::string &dataProviderName) const
 Gets the output string for the given data provider. More...
 
std::vector< std::string > GetProviders () const
 Get a list of providers whose data source has been specified on the command line. More...
 
const std::string & GetOutput (const std::string &persistenceName) const
 Gets the output string for the given persistence service. More...
 
std::vector< std::string > GetPersistences () const
 Get a list of persistence services whose output has been specified on the command line. More...
 
const std::string & GetParameter (const std::string &confObjName, const std::string &parName) const
 Gets the value of the given parameter for the given configurable object. More...
 
std::vector< std::pair< std::string, std::vector< std::string > > > GetParameters () const
 Get a list of parameters for configurable objects that has been specified on the command line. More...
 
std::vector< std::string > GetParameters (const std::string &confObjName) const
 Get a list of parameters for configurable objects that has been specified on the command line for a given configurable object. More...
 

Private Types

typedef std::unordered_map< std::string, std::string > StringMap
 
typedef std::unordered_map< std::string, StringMapStringMapMap
 

Private Attributes

StringMap _dataSourceMap
 
StringMap _outputMap
 
StringMapMap _parameterMap
 

Static Private Attributes

static const std::string _nullString = ""
 

Detailed Description

A class to store parameters passed from command line.

Configuring an analysis only with a configuration file might be awkward in some situations, e.g. when launching different jobs each one with different input or output. In this case it is impractical to produce one configuration file per job; a better solution is to specify these "variable parameters" on the command line. This class is a container for these command line parameters. Currently the class handles the definitions of: data sources for data providers, output for persistence services, parameter values for algorithms.

Member Typedef Documentation

◆ StringMap

typedef std::unordered_map<std::string, std::string> EA::CommandLineParameters::StringMap
private

◆ StringMapMap

typedef std::unordered_map<std::string, StringMap> EA::CommandLineParameters::StringMapMap
private

Member Function Documentation

◆ AddDataSource()

bool EA::CommandLineParameters::AddDataSource ( const std::string &  dataProviderName,
const std::string &  dataSource 
)

Adds a output configuration string for a given persistence service.

Sets the output string for the given provider. Note that this method actually doesn't configure the persistence service; it only stores the output string. The configuration of the provider must be done separately, by retrieving the output string with the GetDataSource method.

Parameters
dataProviderNameThe persistence service.
dataSourceThe output.
Returns
true if the output string has been correctly set.

◆ AddOutput()

bool EA::CommandLineParameters::AddOutput ( const std::string &  persistenceName,
const std::string &  output 
)

Adds an output configuration string for a given persistence service.

Sets the output string for the given persistence. Note that this method actually doesn't configure the persistence service; it only stores the output string. The configuration of the persistence must be done separately, by retrieving the output string with the GetOutput method.

Parameters
persistenceNameThe persistence service.
outputThe output.
Returns
true if the output string has been correctly set.

◆ AddParameter()

bool EA::CommandLineParameters::AddParameter ( const std::string &  algoName,
const std::string &  paramName,
const std::string &  parameter 
)

Adds a parameter setting string for a given configurable object.

A configurable object is an object of a class which inherits from Configurable, like an algorithm or a data provider. This method sets the value string for the given configurable object and parameter. Note that this method actually doesn't configure the configurable object; it only stores the value string. The configuration of the configurable object must be done separately, by retrieving the value string with the GetParameter method.

Parameters
algoNameThe configurable object.
paramNameThe parameter name.
paramThe parameter value.
Returns
true if the string value has been correctly set.

◆ GetDataSource()

const std::string & EA::CommandLineParameters::GetDataSource ( const std::string &  dataProviderName) const

Gets the output string for the given data provider.

Parameters
dataProviderNameThe data provider.
Returns
The output string for the given provider, or an empty string if the output for the given provider has not been set.

◆ GetOutput()

const std::string & EA::CommandLineParameters::GetOutput ( const std::string &  persistenceName) const

Gets the output string for the given persistence service.

Parameters
persistenceNameThe persistence service.
Returns
The output string for the given persistence, or an empty string if the output for the given persistence has not been set.

◆ GetParameter()

const std::string & EA::CommandLineParameters::GetParameter ( const std::string &  confObjName,
const std::string &  parName 
) const

Gets the value of the given parameter for the given configurable object.

A configurable object is an object of a class which inherits from Configurable, like an algorithm or a data provider. The value is searched among those given on command line by matching both the configurable object name and the parameter name separately. On failure, eventual command line configurable object names given as glob expression are matched to confObjName, and in case of success the parameter name is matched. If the desired parameter is defined by two or more matching glob configurable object names then an exception is thrown, e.g. the following two parameter definitions:

confObj*,par,value confObj?,par,value

will make GetParameter("confObj1", "par") throw.

Parameters
confObjNameThe configurable object.
parNameThe parameter.
Returns
The value string of the parameter.
Exceptions
MultipleDefinitionExcif more than one matching glob define a value for the same parameter.

◆ GetParameters() [1/2]

std::vector< std::pair< std::string, std::vector< std::string > > > EA::CommandLineParameters::GetParameters ( ) const

Get a list of parameters for configurable objects that has been specified on the command line.

A configurable object is an object of a class which inherits from Configurable, like an algorithm or a data provider. Each element of the returned vector is a pair, the first element being the name of the configurable object and the second one being the vector of the parameters defined for that object.

Each element of the returned vector is a pair, whose first object is the name of the configurable object and the second one is a vector containing the names of the parameters that have been given in the command line.

Returns
The parameters of the configurable object.

◆ GetParameters() [2/2]

std::vector< std::string > EA::CommandLineParameters::GetParameters ( const std::string &  confObjName) const

Get a list of parameters for configurable objects that has been specified on the command line for a given configurable object.

A configurable object is an object of a class which inherits from Configurable, like an algorithm or a data provider. The returned vector contains the names of the parameters defined on the command line for the specified configurable object.

Parameters
algoNameThe name of the requested configurable object.
Returns
The command line parameters for the requested configurable object.

◆ GetPersistences()

std::vector< std::string > EA::CommandLineParameters::GetPersistences ( ) const

Get a list of persistence services whose output has been specified on the command line.

Returns
The persistence services.

◆ GetProviders()

std::vector< std::string > EA::CommandLineParameters::GetProviders ( ) const

Get a list of providers whose data source has been specified on the command line.

Returns
The providers.

Member Data Documentation

◆ _dataSourceMap

StringMap EA::CommandLineParameters::_dataSourceMap
private

◆ _nullString

const std::string EA::CommandLineParameters::_nullString = ""
staticprivate

◆ _outputMap

StringMap EA::CommandLineParameters::_outputMap
private

◆ _parameterMap

StringMapMap EA::CommandLineParameters::_parameterMap
private

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