23#ifndef READPARAMETERS_H
24#define READPARAMETERS_H
26#include <boost/program_options.hpp>
52 static void add(
const std::string& name,
const std::string& desc,
const std::string& defValue) {
54 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
59 name.c_str(), boost::program_options::value<std::string>(&(
options[name]))->default_value(defValue),
64 template <
typename T>
static void add(
const std::string& name,
const std::string& desc,
const T& defValue) {
66 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
70 static constexpr bool n = (std::is_floating_point<T>::value);
72 ss << std::setprecision(std::numeric_limits<double>::digits10 + 1) << defValue;
79 name.c_str(), boost::program_options::value<std::string>(&(
options[name]))->default_value(ss.str()),
90 static void get(
const std::string& name, std::string& value) {
95 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
97 std::cerr << __FILE__ <<
":" << __LINE__ <<
" " << name +
" not declared using the add() function!" << std::endl;
98 MPI_Abort(MPI_COMM_WORLD, 1);
103 static void get(
const std::string& name, std::vector<std::string>& value) {
108 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
110 std::cerr << __FILE__ <<
":" << __LINE__ << name +
" not declared using the add() function!" << std::endl;
111 MPI_Abort(MPI_COMM_WORLD, 1);
116 template <
typename T>
static void get(
const std::string& name, T& value) {
121 value = boost::lexical_cast<T>(sval);
124 MPI_Comm_rank(MPI_COMM_WORLD, &
myRank);
126 std::cerr << __FILE__ <<
":" << __LINE__
127 << std::string(
" Problems casting ") + name +
" " + sval + std::string(
" to ") +
typeid(T).name()
130 MPI_Abort(MPI_COMM_WORLD, 1);
141 template <
typename T>
static void get(
const std::string& name, std::vector<T>& value) {
142 std::vector<std::string> stringValue;
143 get(name, stringValue);
145 for (std::vector<std::string>::iterator
i = stringValue.begin();
i != stringValue.end(); ++
i) {
147 value.push_back(boost::lexical_cast<T>(*
i));
150 MPI_Comm_rank(MPI_COMM_WORLD, &
myRank);
152 std::cerr << __FILE__ <<
":" << __LINE__
153 << std::string(
" Problems casting ") + name + *
i + std::string(
" to ") +
typeid(T).name()
156 MPI_Abort(MPI_COMM_WORLD, 1);
163 static bool isSet(
const std::string& name) {
167 static void addComposing(
const std::string& name,
const std::string& desc);
177 static bool parse(
const bool needsRunConfig =
true,
const bool allowUnknown =
true);
186 static boost::program_options::variables_map*
variables;
188 static std::map<std::string, std::string>
options;
static bool versionMessage()
static void addDefaultParameters()
static boost::program_options::variables_map * variables
static void get(const std::string &name, std::vector< std::string > &value)
static std::map< std::string, std::vector< std::string > > vectorOptions
static void addComposing(const std::string &name, const std::string &desc)
static std::string user_config_file_name
static void get(const std::string &name, std::vector< T > &value)
static std::map< std::string, bool > isVectorOptionParsed
static boost::program_options::options_description * descriptions
static std::map< std::string, std::string > options
static std::string configInfo()
static bool helpRequested
static void get(const std::string &name, std::string &value)
static std::string global_config_file_name
static std::string run_config_file_name
static void add(const std::string &name, const std::string &desc, const T &defValue)
static void helpMessage()
static void add(const std::string &name, const std::string &desc, const std::string &defValue)
static std::string versionInfo()
static void get(const std::string &name, T &value)
static bool parse(const bool needsRunConfig=true, const bool allowUnknown=true)
static std::map< std::string, bool > isOptionParsed
Readparameters(int cmdargc, char *cmdargv[])
static bool isSet(const std::string &name)