OpenMPCD
|
Represents the configuration of the simulation. More...
#include <Configuration.hpp>
Classes | |
class | List |
Represents a list, or an array, of values. More... | |
class | Setting |
Represents a setting in the configuration. More... | |
Public Member Functions | |
Configuration () | |
The constructor. More... | |
Configuration (const std::string &filename) | |
The constructor. More... | |
Configuration (const Configuration &rhs) | |
The copy constructor. More... | |
bool | has (const std::string &setting) const |
Returns whether a setting with the given name exists. More... | |
template<typename ValueType , unsigned int settingsCount> | |
void | read (const std::pair< const char *, ValueType * >(&settingsAndValues)[settingsCount]) const |
Reads the specified settings from the given configuration file and stores them in the given location. More... | |
template<typename ValueType > | |
void | read (const std::string &setting, ValueType *const value) const |
Reads the specified setting from the given configuration file and stores them in the given location. More... | |
template<typename ValueType > | |
ValueType | read (const std::string &setting) const |
Returns the specified setting from the given configuration file. More... | |
const Setting | getSetting (const std::string &name) const |
Returns the setting object with the given name. More... | |
const List | getList (const std::string &name) const |
Returns the list with the given name. More... | |
template<typename ValueType > | |
void | assertValue (const std::string &setting, const ValueType &value) const |
Asserts that the given setting exists, and has the specified type and value. More... | |
template<int N> | |
void | assertValue (const std::string &setting, const char(&value)[N]) const |
Asserts that the given setting exists, and has the specified type and value. More... | |
template<typename ValueType > | |
void | set (const std::string &setting, const ValueType value) |
Sets a setting's value. More... | |
void | createGroup (const std::string &name) |
Creates a settings group. More... | |
void | createList (const std::string &name) |
Creates a settings list. More... | |
void | writeToFile (const std::string &path) const |
Writes the configuration to the given path. More... | |
const Configuration & | operator= (const Configuration &rhs) |
The assignment operator. More... | |
template<> | |
void | set (const std::string &setting, const unsigned int value) |
Sets a setting's value. More... | |
Represents the configuration of the simulation.
Definition at line 28 of file Configuration.hpp.
|
inline |
The constructor.
Definition at line 479 of file Configuration.hpp.
|
inline |
The constructor.
OpenMPCD::IOException | Throws if the configuration file could not be read. |
OpenMPCD::MalformedFileException | Throws if the configuration file is malformed. |
[in] | filename | The filename for the configuration file. |
Definition at line 15 of file ImplementationDetails/Configuration/Configuration.hpp.
|
inline |
The copy constructor.
[in] | rhs | The instance to copy. |
Definition at line 499 of file Configuration.hpp.
|
inline |
Asserts that the given setting exists, and has the specified type and value.
std::runtime_error | Throws if the assertion fails. |
ValueType | The type of the settings value. |
[in] | setting | The name of the setting to read. |
[in] | value | The value that the setting should have. |
Definition at line 639 of file Configuration.hpp.
|
inline |
Asserts that the given setting exists, and has the specified type and value.
std::runtime_error | Throws if the assertion fails. |
ValueType | The type of the settings value. |
[in] | setting | The name of the setting to read. |
[in] | value | The value that the setting should have. |
Definition at line 617 of file Configuration.hpp.
|
inline |
Creates a settings group.
Parent groups are created as necessary.
[in] | name | The name of the group. |
Exception | Throws if the name is already in use. |
Definition at line 719 of file Configuration.hpp.
|
inline |
Creates a settings list.
Parent groups are created as necessary.
[in] | name | The name of the list. |
Exception | Throws if the name is already in use. |
Definition at line 730 of file Configuration.hpp.
|
inline |
Returns the list with the given name.
[in] | name | The list name. |
InvalidConfigurationException | Throws if the given name does not exist or is not a list. |
Definition at line 596 of file Configuration.hpp.
|
inline |
Returns the setting object with the given name.
OpenMPCD::InvalidConfigurationException | Throws if the given name does not exist. |
[in] | name | The setting name. |
Definition at line 579 of file Configuration.hpp.
|
inline |
Returns whether a setting with the given name exists.
[in] | setting | The setting name. |
Definition at line 509 of file Configuration.hpp.
|
inline |
The assignment operator.
[in] | rhs | The instance to copy. |
Definition at line 752 of file Configuration.hpp.
|
inline |
Reads the specified settings from the given configuration file and stores them in the given location.
std::runtime_error | Throws if any of the settings could not be read into the specified type. |
std::runtime_error | If OPENMPCD_DEBUG is defined, throws if any of given pointers is NULL. |
ValueType | The types of the settings values. |
settingsCount | The number of settings to read. |
[in,out] | settingsAndValues | The names of the settings to read, and the locations to store their values into. |
Definition at line 523 of file Configuration.hpp.
|
inline |
Returns the specified setting from the given configuration file.
std::runtime_error | Throws if the settings could not be read into the specified type. |
ValueType | The type of the settings value. |
[in] | setting | The name of the setting to read. |
Definition at line 564 of file Configuration.hpp.
|
inline |
Reads the specified setting from the given configuration file and stores them in the given location.
std::runtime_error | Throws if the settings could not be read into the specified type. |
std::runtime_error | If OPENMPCD_DEBUG is defined, throws if the given pointer is NULL. |
ValueType | The type of the settings value. |
[in] | setting | The name of the setting to read. |
[out] | value | The location to read the setting value into. |
Definition at line 538 of file Configuration.hpp.
|
inline |
Sets a setting's value.
OpenMPCD::InvalidArgumentException | Throws if the setting already exists, but is of the wrong type. |
[in] | setting | The name of the setting to set. |
[in] | value | The value to set the setting to. |
Definition at line 839 of file Configuration.hpp.
|
inline |
Sets a setting's value.
InvalidArgumentException | Throws if the setting already exists, but is of the wrong type. |
ValueType | The type of the setting's value. |
[in] | setting | The name of the setting to set. |
[in] | value | The value to set the setting to. |
Definition at line 661 of file Configuration.hpp.
|
inline |
Writes the configuration to the given path.
[in] | path | The path to write to. |
Definition at line 739 of file Configuration.hpp.