Scarab  v2.0.1
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, scarab::param_node* a_default = NULL );
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 
44 
45  std::string f_string_buffer;
46  };
47 
48  template< typename XReturnType >
49  XReturnType configurator::get( const std::string& a_name ) const
50  {
51  return f_master_config->get_value< XReturnType >( a_name );
52  }
53 
54  template< typename XReturnType >
55  XReturnType configurator::get( const std::string& a_name, XReturnType a_default ) const
56  {
57  return f_master_config->get_value< XReturnType >( a_name, a_default );
58  }
59 
60  inline bool configurator::help_flag() const
61  {
62  return f_help_flag;
63  }
64 
65  inline bool configurator::version_flag() const
66  {
67  return f_version_flag;
68  }
69 
70  inline const std::string& configurator::exe_name() const
71  {
72  return f_exe_name;
73  }
74 
76  {
77  return *f_master_config;
78  }
79 
81  {
82  return *f_master_config;
83  }
84 
85 
86 } /* namespace psyllid */
87 #endif /* PSYLLID_CONFIGURATOR_HH_ */
bool help_flag() const
Definition: configurator.hh:60
std::string get_value(const std::string &a_name) const
Definition: param_node.hh:225
bool version_flag() const
Definition: configurator.hh:65
const std::string & exe_name() const
Definition: configurator.hh:70
scarab::param * f_param_buffer
Definition: configurator.hh:43
scarab::param_node & config()
Definition: configurator.hh:75
scarab::param_node * f_master_config
Definition: configurator.hh:39
std::string f_string_buffer
Definition: configurator.hh:45
configurator(int an_argc, char **an_argv, scarab::param_node *a_default=NULL)
Definition: configurator.cc:31
XReturnType get(const std::string &a_name) const
Definition: configurator.hh:49
std::string f_exe_name
Definition: configurator.hh:37