Class Configurator¶
Defined in File Configurator.hpp
Nested Relationships¶
Nested Types¶
Class Documentation¶
-
class Configurator¶
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
Public Static Functions
-
static inline void addFile(const std::string &filename)¶
Adds a config file to the configuration sources
- Parameters:
filename – the name of the file to be read.
-
template<typename C>
static inline void addFiles(const C &container)¶ 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.
-
static inline void addStream(std::unique_ptr<std::istream> pis)¶
Adds a istream source of configuration data.
- Parameters:
pis – a std::unique_ptr to a std::istream containing the config data.
-
template<typename C>
static inline void addStreams(const C &container)¶ 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.
-
static void addSStream(const std::stringstream &sstream)¶
Adds a std::stringstream configuration stream, wrapping all the pointer mechanics.
- Parameters:
sstream – The std::stringstream containiong the configuration text to be added.
-
static inline void clearStreams()¶
Removes previously assigned stream data sources, both files and istreams.
-
static inline void clear()¶
Removes all data sources, both streams and command line.
-
static inline void setCommandLine(int argc, char *argv[])¶
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].
-
static void getAdditionalConfiguration(const std::string &source)¶
Gets the additional configuration according to the supplied implementation.
- Parameters:
source – the (implementation-dependent) source of additional configuration.
-
static boost::program_options::variables_map parse(const boost::program_options::options_description &opt)¶
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.
-
static void setAdditionalConfiguration(AdditionalConfiguration *pAC)¶
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.
-
class AdditionalConfiguration¶
Subclassed by Nextsim::NetcdfMetadataConfiguration
Public Functions
-
virtual ~AdditionalConfiguration() = default¶
-
virtual ~AdditionalConfiguration() = default¶
-
static inline void addFile(const std::string &filename)¶