Cambridge SMT System
ucam::util::RegistryPO Class Reference

#include <registrypo.hpp>

Public Member Functions

std::string dump (const std::string &decorator_start="", const std::string &decorator_end="")
 Dumps all configuration parameters into a string with a reasonably pretty format. More...
 
 RegistryPO (const bpo::variables_map &vm)
 Trivial Constructor. More...
 
 RegistryPO (int argc, const char *argv[])
 Constructor Runs init_param_options to parse and store in a bpo::variables_map all the values. Once this object is loaded, all command-line/config parameters have been parsed and we know it is safe to get values. More...
 
 RegistryPO (const std::unordered_map< std::string, boost::any > &v)
 Constructor Forces a set of values using program_options. The hashmap can contain either bools, (u)ints, chars or strings, floats. Possibly there is a better way to fill in manually program_options::variables_map variable. This constructor is only recommended for testing purposes. More...
 
template<typename T >
get (const std::string &key) const
 Returns parsed value associated to key. More...
 
std::string getString (const std::string &key) const
 Performs get<string> and checks whether the real value is to be loaded from file (–param=file://.....) More...
 
bool getBool (const std::string &key) const
 To handle yes|no program option values. More...
 
bool exists (const std::string &key) const
 Determines whether a program option (key) has been defined by the user. More...
 
std::vector< std::string > getVectorString (const std::string &key) const
 Convenience method that returns a vector of strings taking "," as the separator character. More...
 
std::string getVectorString (const std::string &key, uint index) const
 Convenience method that returns a vector of strings taking "," as the separator character. More...
 
unordered_set< std::string > getSetString (const std::string &key) const
 Convenience method that returns a set of strings taking "," as the separator character. More...
 
template<typename NumberT >
unordered_set< NumberT > getSetNumber (const std::string &key) const
 Templated method that returns a set of numbers taking "," as the separator character. More...
 
unordered_map< uint, std::string > getMappedIndexString (const std::string &key) const
 Convenience method that returns a hash of strings indexed by position and taking "," as the separator character. More...
 
unordered_map< std::string, uint > getMappedStringIndex (const std::string &key) const
 Convenience method that returns a hash of indices indexed by string and taking "," as the separator character. More...
 
unordered_map< std::string, uint > getPairMappedStringUInt (const std::string &key) const
 Convenience method that builds a hash with pairs taking "," as the separator character. Pair elements assumed to be unsigned integers. For instance, –param=X,3,T,5 => hash["X"]=3 and hash["T"]=5. More...
 

Detailed Description

Definition at line 95 of file registrypo.hpp.

Constructor & Destructor Documentation

ucam::util::RegistryPO::RegistryPO ( const bpo::variables_map &  vm)
inline

Trivial Constructor.

Definition at line 134 of file registrypo.hpp.

ucam::util::RegistryPO::RegistryPO ( int  argc,
const char *  argv[] 
)
inline

Constructor Runs init_param_options to parse and store in a bpo::variables_map all the values. Once this object is loaded, all command-line/config parameters have been parsed and we know it is safe to get values.

Parameters
argcparameter counter (identical to that of main function)
argvholds command-line parameter values (identical to that of main function)
Remarks
init_param_options has a forward definition. It must be implemented by the user of this class.

Definition at line 143 of file registrypo.hpp.

Here is the call graph for this function:

ucam::util::RegistryPO::RegistryPO ( const std::unordered_map< std::string, boost::any > &  v)
inline

Constructor Forces a set of values using program_options. The hashmap can contain either bools, (u)ints, chars or strings, floats. Possibly there is a better way to fill in manually program_options::variables_map variable. This constructor is only recommended for testing purposes.

Definition at line 155 of file registrypo.hpp.

Member Function Documentation

std::string ucam::util::RegistryPO::dump ( const std::string &  decorator_start = "",
const std::string &  decorator_end = "" 
)
inline

Dumps all configuration parameters into a string with a reasonably pretty format.

Parameters
decorator_start: A user-defined string prepended as a head to the parameter list
decorator_end: user-defined string appended as a foot to the parameter list
Remarks
Not an efficient implementation, but there seems to be no other choice with boost::any but checking individually each type.

Definition at line 108 of file registrypo.hpp.

Here is the caller graph for this function:

bool ucam::util::RegistryPO::exists ( const std::string &  key) const
inline

Determines whether a program option (key) has been defined by the user.

Definition at line 235 of file registrypo.hpp.

Here is the caller graph for this function:

template<typename T >
T ucam::util::RegistryPO::get ( const std::string &  key) const
inline

Returns parsed value associated to key.

Definition at line 194 of file registrypo.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool ucam::util::RegistryPO::getBool ( const std::string &  key) const
inline

To handle yes|no program option values.

Definition at line 225 of file registrypo.hpp.

Here is the caller graph for this function:

unordered_map<uint, std::string> ucam::util::RegistryPO::getMappedIndexString ( const std::string &  key) const
inline

Convenience method that returns a hash of strings indexed by position and taking "," as the separator character.

Parameters
keykey to query.
Returns
unordered set indexed by position (starting at 1).

Definition at line 308 of file registrypo.hpp.

Here is the caller graph for this function:

unordered_map<std::string, uint> ucam::util::RegistryPO::getMappedStringIndex ( const std::string &  key) const
inline

Convenience method that returns a hash of indices indexed by string and taking "," as the separator character.

Parameters
keykey to query.
Returns
unordered_map indexed by string returning position (starting at 1).

Definition at line 323 of file registrypo.hpp.

Here is the caller graph for this function:

unordered_map<std::string, uint> ucam::util::RegistryPO::getPairMappedStringUInt ( const std::string &  key) const
inline

Convenience method that builds a hash with pairs taking "," as the separator character. Pair elements assumed to be unsigned integers. For instance, –param=X,3,T,5 => hash["X"]=3 and hash["T"]=5.

Parameters
keykey to query.
Returns
unordered_map indexed by string returning position (starting at 1).

Definition at line 340 of file registrypo.hpp.

Here is the caller graph for this function:

template<typename NumberT >
unordered_set<NumberT> ucam::util::RegistryPO::getSetNumber ( const std::string &  key) const
inline

Templated method that returns a set of numbers taking "," as the separator character.

Parameters
keykey to query.
Returns
value splitted by commas into a set of numbers (i.e. int, float,...)

Definition at line 294 of file registrypo.hpp.

Here is the caller graph for this function:

unordered_set<std::string> ucam::util::RegistryPO::getSetString ( const std::string &  key) const
inline

Convenience method that returns a set of strings taking "," as the separator character.

Parameters
keykey to query.
Returns
value splitted by commas into a set of strings.

Definition at line 279 of file registrypo.hpp.

Here is the caller graph for this function:

std::string ucam::util::RegistryPO::getString ( const std::string &  key) const
inline

Performs get<string> and checks whether the real value is to be loaded from file (–param=file://.....)

Definition at line 205 of file registrypo.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector<std::string> ucam::util::RegistryPO::getVectorString ( const std::string &  key) const
inline

Convenience method that returns a vector of strings taking "," as the separator character.

Parameters
keykey to query.
Returns
value splitted by commas or spaces into a vector of strings.

Definition at line 245 of file registrypo.hpp.

Here is the caller graph for this function:

std::string ucam::util::RegistryPO::getVectorString ( const std::string &  key,
uint  index 
) const
inline

Convenience method that returns a vector of strings taking "," as the separator character.

Parameters
keykey to query.
indexPoints to index-th element in the vector
Returns
value splitted by commas into a vector of strings.

Definition at line 261 of file registrypo.hpp.


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