netxsimdg
Loading...
Searching...
No Matches
Nextsim::Configurator Class Reference

A class to handle the sources of configuration, both files and the command line. More...

#include <Configurator.hpp>

Collaboration diagram for Nextsim::Configurator:
Collaboration graph

Classes

class  AdditionalConfiguration
 

Static Public Member Functions

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.
 

Detailed Description

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.

Member Function Documentation

◆ addFile()

static void Nextsim::Configurator::addFile ( const std::string & filename)
inlinestatic

Adds a config file to the configuration sources

Parameters
filenamethe name of the file to be read.

Definition at line 44 of file Configurator.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
containeran iterable container holding std::string filenames.

Definition at line 58 of file Configurator.hpp.

Here is the call graph for this function:

◆ addSStream()

void Nextsim::Configurator::addSStream ( const std::stringstream & sstream)
static

Adds a std::stringstream configuration stream, wrapping all the pointer mechanics.

Parameters
sstreamThe std::stringstream containiong the configuration text to be added.

Definition at line 64 of file Configurator.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addStream()

static void Nextsim::Configurator::addStream ( std::unique_ptr< std::istream > pis)
inlinestatic

Adds a istream source of configuration data.

Parameters
pisa std::unique_ptr to a std::istream containing the config data.

Definition at line 68 of file Configurator.hpp.

Here is the caller graph for this function:

◆ 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
containeran iterable container of std::unique_ptrs to std::istream data sources.

Definition at line 81 of file Configurator.hpp.

Here is the call graph for this function:

◆ clear()

static void Nextsim::Configurator::clear ( )
inlinestatic

Removes all data sources, both streams and command line.

Definition at line 102 of file Configurator.hpp.

Here is the call graph for this function:

◆ 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.

Here is the caller graph for this function:

◆ getAdditionalConfiguration()

void Nextsim::Configurator::getAdditionalConfiguration ( const std::string & source)
static

Gets the additional configuration according to the supplied implementation.

Parameters
sourcethe (implementation-dependent) source of additional configuration.

Definition at line 71 of file Configurator.cpp.

Here is the call graph for this function:

◆ 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
optAn instance of boost::program_options describing the options to be configured.

Definition at line 20 of file Configurator.cpp.

Here is the caller graph for this function:

◆ setAdditionalConfiguration()

void Nextsim::Configurator::setAdditionalConfiguration ( AdditionalConfiguration * pAC)
static

Sets the source of any additional configuration data, such as a netCDF restart file.

Parameters
pACa 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
argcthe number of arguments to be parsed
argvan 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.

Here is the caller graph for this function:

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