8#ifndef CONFIGURATOR_HPP
9#define CONFIGURATOR_HPP
13#include <boost/program_options.hpp>
23class NoAdditionalConfiguration;
44 inline static void addFile(
const std::string& filename)
46 addStream(std::unique_ptr<std::istream>(
new std::fstream(filename)));
58 template <
typename C>
static void addFiles(
const C& container)
60 for (
auto& filename : container)
68 inline static void addStream(std::unique_ptr<std::istream> pis)
70 sources.push_back(std::move(pis));
81 template <
typename C>
static void addStreams(
const C& container)
83 for (
auto& stream : container) {
92 static void addSStream(
const std::stringstream& sstream);
144 static boost::program_options::variables_map
parse(
145 const boost::program_options::options_description& opt);
148 static std::vector<std::unique_ptr<std::istream>> sources;
151 static char** m_argv;
162 virtual std::stringstream
read(
const std::string& source) = 0;
179 std::stringstream read(
const std::string& source)
override {
return std::stringstream(); }
virtual std::stringstream read(const std::string &source)=0
Reads the additional configuration from the provided source, which is interpreted in an implementatio...
A class to handle the sources of configuration, both files and the command line.
static void addStream(std::unique_ptr< std::istream > pis)
Adds a istream source of configuration data.
static void addFile(const std::string &filename)
static void addFiles(const C &container)
Adds several config files to the configuration sources.
static void setAdditionalConfiguration(AdditionalConfiguration *pAC)
Sets the source of any additional configuration data, such as a netCDF restart file.
static void clearStreams()
static void addSStream(const std::stringstream &sstream)
Adds a std::stringstream configuration stream, wrapping all the pointer mechanics.
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 addStreams(const C &container)
Adds several istream sources of configuration data.
static void setCommandLine(int argc, char *argv[])
Sets the command line data to be parsed.
A default implementation of Configurator::AdditionalConfiguration.