A class to handle the sources of configuration, both files and the command line.
More...
#include <Configurator.hpp>
|
static void | addFile (const std::string &filename) |
|
template<typename C > |
static void | addFiles (const C &container) |
| Adds several config files to the configuration sources.
|
|
static void | addStream (std::unique_ptr< std::istream > pis) |
| Adds a istream source of configuration data.
|
|
template<typename C > |
static void | addStreams (const C &container) |
| Adds several istream sources of configuration data.
|
|
static void | addSStream (const std::stringstream &sstream) |
| Adds a std::stringstream configuration stream, wrapping all the pointer mechanics.
|
|
static void | clearStreams () |
|
static void | clear () |
|
static void | setCommandLine (int argc, char *argv[]) |
| Sets the command line data to be parsed.
|
|
static void | getAdditionalConfiguration (const std::string &source) |
| Gets the additional configuration according to the supplied implementation.
|
|
static boost::program_options::variables_map | parse (const boost::program_options::options_description &opt) |
| Parses all configuration sources.
|
|
static void | setAdditionalConfiguration (AdditionalConfiguration *pAC) |
| Sets the source of any additional configuration data, such as a netCDF restart file.
|
|
A class to handle the sources of configuration, both files and the command line.
If an option is configured twice the value of the option will not be updated. Whatever is parsed first sets the value of that option. This allows the command line to override values in config files, as it is always parsed first
Definition at line 33 of file Configurator.hpp.
◆ addFile()
static void Nextsim::Configurator::addFile |
( |
const std::string & | filename | ) |
|
|
inlinestatic |
Adds a config file to the configuration sources
- Parameters
-
filename | the name of the file to be read. |
Definition at line 44 of file Configurator.hpp.
◆ addFiles()
template<typename C >
static void Nextsim::Configurator::addFiles |
( |
const C & | container | ) |
|
|
inlinestatic |
Adds several config files to the configuration sources.
Takes a container of the names of files to be used as configuration sources. The individual filenames should be stored as std::strings.
- Parameters
-
container | an iterable container holding std::string filenames. |
Definition at line 58 of file Configurator.hpp.
◆ addSStream()
void Nextsim::Configurator::addSStream |
( |
const std::stringstream & | sstream | ) |
|
|
static |
Adds a std::stringstream configuration stream, wrapping all the pointer mechanics.
- Parameters
-
sstream | The std::stringstream containiong the configuration text to be added. |
Definition at line 64 of file Configurator.cpp.
◆ addStream()
static void Nextsim::Configurator::addStream |
( |
std::unique_ptr< std::istream > | pis | ) |
|
|
inlinestatic |
Adds a istream source of configuration data.
- Parameters
-
pis | a std::unique_ptr to a std::istream containing the config data. |
Definition at line 68 of file Configurator.hpp.
◆ addStreams()
template<typename C >
static void Nextsim::Configurator::addStreams |
( |
const C & | container | ) |
|
|
inlinestatic |
Adds several istream sources of configuration data.
The container should hold std::unique_ptrs to std::istreams holding the data.
- Parameters
-
container | an iterable container of std::unique_ptrs to std::istream data sources. |
Definition at line 81 of file Configurator.hpp.
◆ clear()
static void Nextsim::Configurator::clear |
( |
| ) |
|
|
inlinestatic |
Removes all data sources, both streams and command line.
Definition at line 102 of file Configurator.hpp.
◆ clearStreams()
static void Nextsim::Configurator::clearStreams |
( |
| ) |
|
|
inlinestatic |
Removes previously assigned stream data sources, both files and istreams.
Definition at line 97 of file Configurator.hpp.
◆ getAdditionalConfiguration()
void Nextsim::Configurator::getAdditionalConfiguration |
( |
const std::string & | source | ) |
|
|
static |
Gets the additional configuration according to the supplied implementation.
- Parameters
-
source | the (implementation-dependent) source of additional configuration. |
Definition at line 71 of file Configurator.cpp.
◆ parse()
boost::program_options::variables_map Nextsim::Configurator::parse |
( |
const boost::program_options::options_description & | opt | ) |
|
|
static |
Parses all configuration sources.
Parses all the the stored configuration sources for the configuration options specified in the options description. The command line options are parsed first. Subsequent matching options will not update the value of the option, so whatever is parsed first sets the value of that option. This allows the command line to override values in config files.
- Parameters
-
opt | An instance of boost::program_options describing the options to be configured. |
Definition at line 20 of file Configurator.cpp.
◆ setAdditionalConfiguration()
Sets the source of any additional configuration data, such as a netCDF restart file.
- Parameters
-
pAC | a pointer to the object that will provide the read() function to read any additional configuration. |
Definition at line 69 of file Configurator.cpp.
◆ setCommandLine()
static void Nextsim::Configurator::setCommandLine |
( |
int | argc, |
|
|
char * | argv[] ) |
|
inlinestatic |
Sets the command line data to be parsed.
The data is formatted as the C standard argc and argv values. Any values defined here will override the corresponding values that might be found in the config files.
- Parameters
-
argc | the number of arguments to be parsed |
argv | an array of zero terminated character arrays making up the command line arguments, with an addition null at argv[argc]. |
Definition at line 118 of file Configurator.hpp.
The documentation for this class was generated from the following files: