EventAnalysis  1.3.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 algorithm. 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 &algoName, const std::string &parName) const
 Gets the value of the given parameter for the given algorithm. More...
 
std::vector< std::pair< std::string, std::vector< std::string > > > GetAlgorithmParameters () const
 Get a list of algorithm parameters that has been specified on the command line. More...
 
std::vector< std::string > GetAlgorithmParameters (const std::string &algoName) const
 Get a list of algorithm parameters that has been specified on the command line for a given algorithm. 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 output 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 algorithm.

Sets the value string for the given algorithm and parameter. Note that this method actually doesn't configure the algorithm; it only stores the value string. The configuration of the algorithm must be done separately, by retrieving the value string with the GetParameter method.

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

◆ GetAlgorithmParameters() [1/2]

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

Get a list of algorithm parameters that has been specified on the command line.

Each element of the returned vector is a pair, the first element being the name of the algorithm and the second one being the vector of the parameters defined for that algorithm

Returns
The algorithm parameters.

◆ GetAlgorithmParameters() [2/2]

std::vector< std::string > EA::CommandLineParameters::GetAlgorithmParameters ( const std::string &  algoName) const

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

The returned vector contains the names of the parameters defined on the command line for the specified algorithm.

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

◆ 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 &  algoName,
const std::string &  parName 
) const

Gets the value of the given parameter for the given algorithm.

The value is searched among those given on command line by matching both the algorithm name and the parameter name separately. On failure, eventual command line algorithm names given as glob expression are matched to algoName, and in case of success the parameter name is matched. If the desired parameter is defined by two or more matching glob algorithm names then an exception is thrown, e.g. the following two parameter definitions:

algo*,par,value algo?,par,value

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

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

◆ 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: