A list/table of parameter names and values. More...
#include <ParameterTable.h>
Public Member Functions | |
ParameterTable () | |
void | setParameter (Parameter p) |
add a parameter to the table or, if already there, reset its value More... | |
Parameter | getParameter (const std::string &name) const |
get a parameter by name. throw an exception of a well defined type if we don't have it More... | |
double | getParameterValue (const std::string &name) const |
get the value of a parameter. throw an exception of a well defined type if we don't have it More... | |
bool | hasParameter (const std::string &name) const |
is the named parameter in the table? More... | |
const boost::interprocess::flat_map< std::string, double > & | getMap () const |
Protected Member Functions | |
void | mapify () const |
Move the parameters from the vector to the map. More... | |
Protected Attributes | |
boost::interprocess::flat_map< std::string, double > | table |
std::vector< std::pair< std::string, double > > | m_vector |
bool | m_vectorMode |
A list/table of parameter names and values.
The memory overhead of std::map turns out to be large for our case, so we use a boost::flat_map instead. This uses an ordered vector, so memory overhead is small. Insertion is slow, though, so we start out by putting all our parameters in a vector. At the first request for parameter or the entire map, we sort the vector, copy it into the map and free the vector. This is efficient when there is a "filling" phase when no reads are done, and a "reading" phase, when no more fills are done.
Definition at line 30 of file ParameterTable.h.
|
inline |
Definition at line 32 of file ParameterTable.h.
|
inline |
Definition at line 45 of file ParameterTable.h.
Parameter NeutrinoFluxReweight::ParameterTable::getParameter | ( | const std::string & | name | ) | const |
get a parameter by name. throw an exception of a well defined type if we don't have it
Definition at line 17 of file ParameterTable.cpp.
double NeutrinoFluxReweight::ParameterTable::getParameterValue | ( | const std::string & | name | ) | const |
get the value of a parameter. throw an exception of a well defined type if we don't have it
Definition at line 33 of file ParameterTable.cpp.
bool NeutrinoFluxReweight::ParameterTable::hasParameter | ( | const std::string & | name | ) | const |
is the named parameter in the table?
Definition at line 50 of file ParameterTable.cpp.
|
protected |
Move the parameters from the vector to the map.
Definition at line 55 of file ParameterTable.cpp.
void NeutrinoFluxReweight::ParameterTable::setParameter | ( | Parameter | p | ) |
add a parameter to the table or, if already there, reset its value
Definition at line 8 of file ParameterTable.cpp.
|
mutableprotected |
Definition at line 51 of file ParameterTable.h.
|
mutableprotected |
Definition at line 52 of file ParameterTable.h.
|
mutableprotected |
Definition at line 50 of file ParameterTable.h.