OMSim
Geant4 for IceCube optical module studies
|
A class used to hold OMSim command arguments with global instance access. More...
This class uses a map to hold key-value pairs of simulation command arguments. It provides a method to write the parameters to a JSON file. Its lifecycle is managed by the OMSim class.
Public Types | |
using | Key = std::string |
using | Value = boost::any |
Public Member Functions | |
void | setParameter (const Key &p_key, const Value &p_value) |
Sets a parameter in the arg table. | |
bool | keyExists (const Key &p_key) |
void | writeToJson (std::string p_fileName) |
Writes the parameters to a JSON-formatted file. | |
void | finalize () |
Finalizes the table, setting a random seed if none was provided. m_finalized is set to true preventing any further modifications. | |
template<typename T > | |
T | get (const std::string &p_key) |
Retrieves a parameter from the table. | |
Static Public Member Functions | |
static void | init () |
Initializes the global instance of OMSimCommandArgsTable. | |
static void | shutdown () |
Deletes the global instance of OMSimCommandArgsTable. | |
static OMSimCommandArgsTable & | getInstance () |
Private Member Functions | |
OMSimCommandArgsTable (const OMSimCommandArgsTable &)=delete | |
OMSimCommandArgsTable & | operator= (const OMSimCommandArgsTable &)=delete |
Private Attributes | |
bool | m_finalized = false |
std::map< Key, Value > | m_parameters |
|
inline |
p_key | The key for the parameter. |
std::invalid_argument | If the parameter is not of type T, or if the key does not exist. |
|
static |
std::runtime_error | if accessed before initialization or after shutdown. |
|
static |
This method is normally called in the constructor of OMSim.
p_key | The key for the parameter. |
p_value | The value for the parameter. |
std::runtime_error | If the table is already finalized (i.e. somebody is trying to set a new arg parameter after args were parsed (?!)). |
|
static |
This method is normally called in the destructor ~OMSim.
void OMSimCommandArgsTable::writeToJson | ( | std::string | p_fileName | ) |
p_fileName | The name of the JSON file. |
std::runtime_error | If the file fails to open. |