Scarab  v2.4.2
Project 8 C++ Utility Library
configurator.hh
Go to the documentation of this file.
1 /*
2  * configurator.hh
3  *
4  * Created on: Nov 5, 2013
5  * Author: nsoblath
6  */
7 
8 #ifndef SCARAB_CONFIGURATOR_HH_
9 #define SCARAB_CONFIGURATOR_HH_
10 
11 #include "error.hh"
12 #include "param.hh"
13 
14 namespace scarab
15 {
17  {
18  public:
19  configurator( int an_argc, char** an_argv, const scarab::param_node& a_default = scarab::param_node() );
20  virtual ~configurator();
21 
22  const std::string& exe_name() const;
23 
25  const scarab::param_node& config() const;
26 
27  bool help_flag() const;
28  bool version_flag() const;
29 
30  template< typename XReturnType >
31  XReturnType get( const std::string& a_name ) const;
32 
33  template< typename XReturnType >
34  XReturnType get( const std::string& a_name, XReturnType a_default ) const;
35 
36  private:
37  std::string f_exe_name; // the name of the executable being used
38 
42  };
43 
44  template< typename XReturnType >
45  XReturnType configurator::get( const std::string& a_name ) const
46  {
47  return f_master_config[ a_name ]().as< XReturnType >();
48  }
49 
50  template< typename XReturnType >
51  XReturnType configurator::get( const std::string& a_name, XReturnType a_default ) const
52  {
53  return f_master_config.get_value< XReturnType >( a_name, a_default );
54  }
55 
56  inline bool configurator::help_flag() const
57  {
58  return f_help_flag;
59  }
60 
61  inline bool configurator::version_flag() const
62  {
63  return f_version_flag;
64  }
65 
66  inline const std::string& configurator::exe_name() const
67  {
68  return f_exe_name;
69  }
70 
72  {
73  return f_master_config;
74  }
75 
77  {
78  return f_master_config;
79  }
80 
81 
82 } /* namespace psyllid */
83 #endif /* PSYLLID_CONFIGURATOR_HH_ */
configurator(int an_argc, char **an_argv, const scarab::param_node &a_default=scarab::param_node())
Definition: configurator.cc:32
scarab::param_node f_master_config
Definition: configurator.hh:39
bool help_flag() const
Definition: configurator.hh:56
XReturnType get(const std::string &a_name) const
Definition: configurator.hh:45
std::string get_value(const std::string &a_name, const std::string &a_default) const
Definition: param_node.hh:208
const std::string & exe_name() const
Definition: configurator.hh:66
bool version_flag() const
Definition: configurator.hh:61
scarab::param_node & config()
Definition: configurator.hh:71
std::string f_exe_name
Definition: configurator.hh:37