PFASST++
config_impl.hpp
Go to the documentation of this file.
1 #include "pfasst/config.hpp"
2 
3 #include <fstream>
4 #include <sstream>
5 #include <utility>
6 using namespace std;
7 
8 
9 namespace pfasst
10 {
11  namespace config
12  {
13  options::options()
14  {}
15 
16  options& options::get_instance()
17  {
18  static options instance;
19  return instance;
20  }
21 
22  po::variables_map& options::get_variables_map()
23  {
24  return this->variables_map;
25  }
26 
27  po::options_description& options::get_all_options()
28  {
29  return this->all_options;
30  }
31 
32  vector<string>& options::get_unrecognized_args()
33  {
34  return this->unrecognized_args;
35  }
36 
41  void options::add_option(const string& group, const string& option, const string& help)
42  {
43  auto& opts = get_instance();
44  opts.option_groups.emplace(make_pair<string,
45  po::options_description>(string(group),
46  po::options_description(string(group),
47  LINE_WIDTH)));
48  opts.option_groups[group].add_options()
49  (option.c_str(), help.c_str());
50  }
51 
56  template<typename T>
57  void options::add_option(const string& group, const string& option, const string& help)
58  {
59  auto& opts = get_instance();
60 
61  opts.option_groups.emplace(make_pair<string,
62  po::options_description>(string(group),
63  po::options_description(string(group),
64  LINE_WIDTH)));
65  opts.option_groups[group].add_options()
66  (option.c_str(), po::value<T>(), help.c_str());
67  }
68 
73  {
74  if (!this->initialized) {
75  for (auto const& kv : this->option_groups) {
76  this->all_options.add(kv.second);
77  }
78  }
79  this->initialized = true;
80  }
81  } // ::pfasst::config
82 } // ::pfasst
STL namespace.
Runtime config options provider.
Definition: config.hpp:65
static bool initialized
internal flag identifying whether the default logger has been initialized.
Definition: logging.hpp:247
static void init()
Initialize options detection and parsing.
Definition: config.hpp:300