OpenMPCD
Public Member Functions | List of all members
OpenMPCD::Configuration::Setting Class Reference

Represents a setting in the configuration. More...

#include <Configuration.hpp>

Public Member Functions

 Setting (const libconfig::Setting &s)
 The constructor. More...
 
bool hasName () const
 Returns whether the setting has a name. More...
 
const std::string getName () const
 Returns the name of the setting. More...
 
bool has (const std::string &settingName) const
 Returns whether a setting with the given name exists. More...
 
template<typename ValueType >
void read (const std::string &name, ValueType *const value) const
 Reads the specified setting and stores it at the given location. More...
 
void read (const std::string &name, std::size_t *const value) const
 Reads the specified setting and stores it at the given location. More...
 
template<typename ValueType >
ValueType read (const std::string &name) const
 Returns the specified setting. More...
 
std::size_t getChildCount () const
 Returns the number of direct child settings in this setting. More...
 
const Setting getChild (const std::size_t childIndex) const
 Returns the child setting with the given index. 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 object with the given name. More...
 
bool childrenHaveNamesInCollection (const std::set< std::string > &names, std::string *const offender=NULL) const
 Returns whether all children in this setting have names that are in the given set. More...
 

Detailed Description

Represents a setting in the configuration.

Definition at line 36 of file Configuration.hpp.

Constructor & Destructor Documentation

◆ Setting()

OpenMPCD::Configuration::Setting::Setting ( const libconfig::Setting &  s)
inline

The constructor.

The instance is only valid as long as the Configuration instance it originated from is valid.

Parameters
[in]sThe setting.

Definition at line 46 of file Configuration.hpp.

Member Function Documentation

◆ childrenHaveNamesInCollection()

bool OpenMPCD::Configuration::Setting::childrenHaveNamesInCollection ( const std::set< std::string > &  names,
std::string *const  offender = NULL 
) const

Returns whether all children in this setting have names that are in the given set.

Parameters
[in]namesThe names against to compare the children's names to.
[out]offenderIf not NULL and if true is returned, the pointee is set to the name of the first child encountered whose name is not in the given set names.

Definition at line 12 of file Configuration.cpp.

◆ getChild()

const Setting OpenMPCD::Configuration::Setting::getChild ( const std::size_t  childIndex) const
inline

Returns the child setting with the given index.

Parameters
[in]childIndexThe index of the child setting, which must be less than getChildCount().
Exceptions
OpenMPCD::InvalidArgumentExceptionThrows if the index is illegal.

Definition at line 250 of file Configuration.hpp.

◆ getChildCount()

std::size_t OpenMPCD::Configuration::Setting::getChildCount ( ) const
inline

Returns the number of direct child settings in this setting.

This function does not count children of children.

Definition at line 235 of file Configuration.hpp.

◆ getList()

const Configuration::List OpenMPCD::Configuration::Setting::getList ( const std::string &  name) const
inline

Returns the list object with the given name.

Exceptions
OpenMPCD::InvalidArgumentExceptionThrows if the setting name is illegal.
OpenMPCD::InvalidConfigurationExceptionThrows if the given name does not exist.
Parameters
[in]nameThe setting name.

Definition at line 812 of file Configuration.hpp.

◆ getName()

const std::string OpenMPCD::Configuration::Setting::getName ( ) const
inline

Returns the name of the setting.

Exceptions
OpenMPCD::InvalidCallExceptionIf OPENMPCD_DEBUG is defined, throws if !hasName().

Definition at line 64 of file Configuration.hpp.

◆ getSetting()

const Setting OpenMPCD::Configuration::Setting::getSetting ( const std::string &  name) const
inline

Returns the setting object with the given name.

Exceptions
OpenMPCD::InvalidArgumentExceptionThrows if the setting name is illegal.
OpenMPCD::InvalidConfigurationExceptionThrows if the given name does not exist.
Parameters
[in]nameThe setting name.

Definition at line 275 of file Configuration.hpp.

◆ has()

bool OpenMPCD::Configuration::Setting::has ( const std::string &  settingName) const
inline

Returns whether a setting with the given name exists.

Exceptions
OpenMPCD::InvalidArgumentExceptionThrows if the setting name is illegal.
Parameters
[in]settingNameThe setting name.

Definition at line 82 of file Configuration.hpp.

◆ hasName()

bool OpenMPCD::Configuration::Setting::hasName ( ) const
inline

Returns whether the setting has a name.

Definition at line 53 of file Configuration.hpp.

◆ read() [1/3]

template<typename ValueType >
ValueType OpenMPCD::Configuration::Setting::read ( const std::string &  name) const
inline

Returns the specified setting.

Exceptions
OpenMPCD::InvalidConfigurationExceptionThrows if the settings could not be read into the specified type.
Template Parameters
ValueTypeThe type of the settings value.
Parameters
[in]nameThe setting name, relative to this setting.

Definition at line 223 of file Configuration.hpp.

◆ read() [2/3]

void OpenMPCD::Configuration::Setting::read ( const std::string &  name,
std::size_t *const  value 
) const
inline

Reads the specified setting and stores it at the given location.

Exceptions
OpenMPCD::InvalidArgumentExceptionThrows if the setting name is illegal.
OpenMPCD::InvalidConfigurationExceptionThrows if the setting does not exist.
OpenMPCD::InvalidConfigurationExceptionThrows if the setting could not be read into the specified type.
OpenMPCD::NULLPointerExceptionIf OPENMPCD_DEBUG is defined, throws if the given pointer is NULL.
Parameters
[in]nameThe setting name, relative to this setting.
[out]valueThe location to read the setting value into.

Definition at line 203 of file Configuration.hpp.

◆ read() [3/3]

template<typename ValueType >
void OpenMPCD::Configuration::Setting::read ( const std::string &  name,
ValueType *const  value 
) const
inline

Reads the specified setting and stores it at the given location.

Exceptions
OpenMPCD::InvalidArgumentExceptionThrows if the setting name is illegal.
OpenMPCD::InvalidConfigurationExceptionThrows if the setting does not exist.
OpenMPCD::InvalidConfigurationExceptionThrows if the setting could not be read into the specified type.
OpenMPCD::NULLPointerExceptionIf OPENMPCD_DEBUG is defined, throws if the given pointer is NULL.
Template Parameters
ValueTypeThe type of the settings value.
Parameters
[in]nameThe setting name, relative to this setting.
[out]valueThe location to read the setting value into.

Definition at line 131 of file Configuration.hpp.


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