A class encapsulating a lua table. More...
#include <ParameterSet.h>
Detailed Description
A class encapsulating a lua table.
All the items inside the table will be converted to plain C++ type, and can be accessed via the ParameterSet::get() functions.
Only the following types are supported:
int64_t
double
bool
std::string
InputTag
ParameterSet
std::vector<>
of one of the above types
Consider the following lua snippet:
- ```lua { x = 91., y = "string", z = {10, 20, 30, 40} }
```
The resulting
ParameterSet
will encapsulates three values:x
of typedouble
=91.
y
of typestd::string
="string"
z
of typestd::vector<int64_t>
=[10, 20, 30, 40]
and you would use the following code to access the
z
value:- ``` std::vector<int64_t> values = set.get<std::vector<int64_t>>("z");
- ```
- Todo:
- Document the freezing of the configuration in ConfigurationReader
- Note
- You should never try to create a ParameterSet yourself. Always use the ConfigurationReader class to parse the configuration file
Definition at line 77 of file ParameterSet.h.
Classes | |
struct | Element |
A small wrapper around a boost::any value. More... | |
Public Member Functions | |
template<typename T > | |
const T & | get (const std::string &name) const |
template<typename T > | |
const T & | get (const std::string &name, const T &defaultValue) const |
bool | exists (const std::string &name) const |
template<typename T > | |
bool | existsAs (const std::string &name) const |
template<typename T > | |
std::enable_if< std::is_same< T, bool >::value||std::is_same< T, InputTag >::value >::type | set (const std::string &name, const T &value) |
Change the value of a given parameter. If the parameter does not exist, it's first created. More... | |
template<typename T > | |
std::enable_if< is_string< T >::value >::type | set (const std::string &name, const T &value) |
Change the value of a given parameter. If the parameter does not exist, it's first created. More... | |
template<typename T > | |
std::enable_if< std::is_integral< T >::value &&!std::is_same< T, bool >::value >::type | set (const std::string &name, const T &value) |
Change the value of a given parameter. If the parameter does not exist, it's first created. More... | |
template<typename T > | |
std::enable_if< std::is_floating_point< T >::value >::type | set (const std::string &name, const T &value) |
Change the value of a given parameter. If the parameter does not exist, it's first created. More... | |
void | parse (lua_State *L, int index) |
Parse fields of a lua table. More... | |
std::string | getModuleName () const |
std::string | getModuleType () const |
const ParameterSet & | globalParameters () const |
Protected Member Functions | |
ParameterSet (const std::string &module_type, const std::string &module_name) | |
virtual std::pair< boost::any, bool > | parseItem (const std::string &key, lua_State *L, int index) |
virtual void | create (const std::string &name, const boost::any &value) |
Add a new element to the ParameterSet. More... | |
virtual void | setInternal (const std::string &name, Element &element, const boost::any &value) |
virtual void | freeze () |
Protected Attributes | |
std::map< std::string, Element > | m_set |
Friends | |
class | ConfigurationReader |
class | Configuration |
Member Function Documentation
|
protectedvirtual |
Add a new element to the ParameterSet.
- Parameters
-
name Name of the new parameter value Value of the new parameter
Reimplemented in LazyParameterSet.
Definition at line 72 of file ParameterSet.cc.
void ParameterSet::parse | ( | lua_State * | L, |
int | index | ||
) |
Parse fields of a lua table.
- Parameters
-
L the lua state index The index on the stack of the table to parse
Definition at line 31 of file ParameterSet.cc.
Referenced by lua::to_any().
|
inline |
Change the value of a given parameter. If the parameter does not exist, it's first created.
- Parameters
-
name The name of the parameter to change value The new value of the parameter
- Warning
- Vectors are currently not supported
Definition at line 113 of file ParameterSet.h.
|
inline |
Change the value of a given parameter. If the parameter does not exist, it's first created.
Specialization for string type, with implicit cast to std::string
- Parameters
-
name The name of the parameter to change value The new value of the parameter
- Warning
- Vectors are currently not supported
Definition at line 128 of file ParameterSet.h.
|
inline |
Change the value of a given parameter. If the parameter does not exist, it's first created.
Specialization for integral type, with implicit cast to int64_t
- Parameters
-
name The name of the parameter to change value The new value of the parameter
- Warning
- Vectors are currently not supported
Definition at line 143 of file ParameterSet.h.
|
inline |
Change the value of a given parameter. If the parameter does not exist, it's first created.
Specialization for floating-point type, with implicit cast to double
- Parameters
-
name The name of the parameter to change value The new value of the parameter
- Warning
- Vectors are currently not supported
Definition at line 158 of file ParameterSet.h.
The documentation for this class was generated from the following files:
- include/momemta/ParameterSet.h
- core/src/ParameterSet.cc