GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GApplicationPar.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GApplicationPar.hpp - Application parameter class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2010-2018 by Juergen Knoedlseder *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 /**
22  * @file GApplicationPar.hpp
23  * @brief Application parameter class definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GAPPLICATIONPAR_HPP
28 #define GAPPLICATIONPAR_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include <vector>
33 #include "GBase.hpp"
34 #include "GTime.hpp"
35 
36 /* __ Forward declarations _______________________________________________ */
37 class GFilename;
38 class GTimeReference;
39 
40 
41 /***********************************************************************//**
42  * @class GApplicationPar
43  *
44  * @brief Application parameter class
45  ***************************************************************************/
46 class GApplicationPar : public GBase {
47 
48  // Friend classes
49  friend class GApplicationPars;
50  friend class GApplication;
51 
52 public:
53  // Constructors and destructors
54  GApplicationPar(void);
55  GApplicationPar(const std::string& name, const std::string& type,
56  const std::string& mode, const std::string& value,
57  const std::string& min, const std::string& max,
58  const std::string& prompt);
59  GApplicationPar(const GApplicationPar& par);
60  virtual ~GApplicationPar(void);
61 
62  // Operators
64 
65  // Methods
66  void clear(void);
67  GApplicationPar* clone(void) const;
68  std::string classname(void) const;
69  void type(const std::string& type);
70  void mode(const std::string& mode);
71  void value(const std::string& value);
72  void string(const std::string& value);
73  void filename(const GFilename& value);
74  void time(const GTime& value);
75  void boolean(const bool& value);
76  void integer(const int& value);
77  void real(const double& value);
78  const std::string& name(void) const;
79  const std::string& type(void) const;
80  const std::string& mode(void) const;
81  void query(void);
82  std::string value(void);
83  std::string string(void);
84  GFilename filename(void);
85  GTime time(void);
86  GTime time(const GTimeReference& ref);
87  bool boolean(void);
88  int integer(void);
89  double real(void);
90  const std::string& current_value(void) const;
91  const std::string& min(void) const;
92  const std::string& max(void) const;
93  const std::string& prompt(void) const;
94  bool is_learn(void) const;
95  bool is_query(void) const;
96  bool is_filename(void) const;
97  bool is_valid(void);
98  bool is_undefined(void);
99  bool is_notanumber(void);
100  bool was_queried(void) const;
101  void pickle(const std::vector<std::string>& string);
102  std::vector<std::string> pickle(void) const;
103  std::string print(const GChatter& chatter = NORMAL) const;
104 
105 protected:
106  // Protected enumerators
107  enum Status {
113  };
114 
115  // Protected methods
116  void init_members(void);
117  void copy_members(const GApplicationPar& par);
118  void free_members(void);
119  void check_type(const std::string& type) const;
120  void check_mode(const std::string& mode) const;
121  void check_value(const std::string& value) const;
122  void check_value_bool(const std::string& value) const;
123  void check_value_int(const std::string& value) const;
124  void check_value_real(const std::string& value) const;
125  void check_value_string(const std::string& value) const;
126  void check_value_filename(const std::string& value) const;
127  void check_value_time(const std::string& value) const;
128  bool check_options(const std::string& value) const;
129  std::string set_status(const std::string& value);
130  void set_value(const std::string& value);
131  void stop_query(void);
132  std::string par_type_string(const std::string& type) const;
133  std::string par_status_string(void) const;
134 
135  // Protected data members
136  bool m_update; //!< Signal value updating
137  bool m_queried; //!< Signal that parameter was queried
138  std::string m_name; //!< Parameter name
139  std::string m_type; //!< Parameter type
140  std::string m_mode; //!< Parameter mode
141  std::string m_value; //!< Parameter value
142  std::string m_min; //!< Parameter minimum
143  std::string m_max; //!< Parameter maximum
144  std::string m_prompt; //!< Parameter prompt
145  Status m_status; //!< Parameter status
146 };
147 
148 
149 /***********************************************************************//**
150  * @brief Return class name
151  *
152  * @return String containing the class name ("GApplicationPar").
153  ***************************************************************************/
154 inline
155 std::string GApplicationPar::classname(void) const
156 {
157  return ("GApplicationPar");
158 }
159 
160 
161 /***********************************************************************//**
162  * @brief Returns parameter name
163  *
164  * @return Parameter name
165  ***************************************************************************/
166 inline
167 const std::string& GApplicationPar::name(void) const
168 {
169  return m_name;
170 }
171 
172 
173 /***********************************************************************//**
174  * @brief Returns parameter type
175  *
176  * @return Parameter type
177  ***************************************************************************/
178 inline
179 const std::string& GApplicationPar::type(void) const
180 {
181  return m_type;
182 }
183 
184 
185 /***********************************************************************//**
186  * @brief Returns parameter mode
187  *
188  * @return Parameter mode
189  ***************************************************************************/
190 inline
191 const std::string& GApplicationPar::mode(void) const
192 {
193  return m_mode;
194 }
195 
196 
197 /***********************************************************************//**
198  * @brief Returns current parameter value without querying
199  *
200  * @return Current parameter value
201  ***************************************************************************/
202 inline
203 const std::string& GApplicationPar::current_value(void) const
204 {
205  return m_value;
206 }
207 
208 
209 /***********************************************************************//**
210  * @brief Returns parameter minimum
211  *
212  * @return Parameter minimum
213  ***************************************************************************/
214 inline
215 const std::string& GApplicationPar::min(void) const
216 {
217  return m_min;
218 }
219 
220 
221 /***********************************************************************//**
222  * @brief Returns parameter maximum
223  *
224  * @return Parameter maximum
225  ***************************************************************************/
226 inline
227 const std::string& GApplicationPar::max(void) const
228 {
229  return m_max;
230 }
231 
232 
233 /***********************************************************************//**
234  * @brief Returns parameter prompt
235  *
236  * @return Parameter prompt
237  ***************************************************************************/
238 inline
239 const std::string& GApplicationPar::prompt(void) const
240 {
241  return m_prompt;
242 }
243 
244 /***********************************************************************//**
245  * @brief Return time in native reference system
246  *
247  * @return Time.
248  ***************************************************************************/
249 inline
251 {
252  GTime native;
253  return (time(native.reference()));
254 }
255 
256 
257 /***********************************************************************//**
258  * @brief Signals if parameter was queried
259  *
260  * @return True if parameter was queried, false otherwise.
261  ***************************************************************************/
262 inline
264 {
265  return m_queried;
266 }
267 
268 #endif /* GAPPLICATIONPAR_HPP */
const std::string & prompt(void) const
Returns parameter prompt.
Application parameter container class.
bool is_learn(void) const
Signals if parameter mode is &quot;learn&quot;.
GTimeReference reference(void) const
Returns native time reference.
Definition: GTime.cpp:1170
void copy_members(const GApplicationPar &par)
Copy class members.
Status m_status
Parameter status.
bool m_queried
Signal that parameter was queried.
bool was_queried(void) const
Signals if parameter was queried.
std::string m_name
Parameter name.
GApplicationPar & operator=(const GApplicationPar &par)
Assignment operator.
bool is_valid(void)
Signals if parameter is valid.
bool m_update
Signal value updating.
void check_value_bool(const std::string &value) const
Test validity of boolean value string.
virtual ~GApplicationPar(void)
Destructor.
std::string par_type_string(const std::string &type) const
Return type string.
Definition of interface for all GammaLib classes.
bool is_undefined(void)
Signals if parameter is undefined.
bool boolean(void)
Returns boolean.
Time class.
Definition: GTime.hpp:55
void check_type(const std::string &type) const
Test validity of type string.
void check_value_real(const std::string &value) const
Test validity of real parameter value.
int integer(void)
Returns integer.
GTime time(void)
Return time in native reference system.
GApplicationPar(void)
Void constructor.
std::string print(const GChatter &chatter=NORMAL) const
Print parameter.
bool is_notanumber(void)
Signals if parameter is not a number.
std::string classname(void) const
Return class name.
bool is_filename(void) const
Signals if parameter mode is of type &quot;filename&quot;.
bool check_options(const std::string &value) const
Test if parameter value satisfies possible options.
void check_value_time(const std::string &value) const
Test validity of time parameter value.
void stop_query(void)
Don&#39;t query parameter again.
void clear(void)
Clear parameter.
std::string m_mode
Parameter mode.
const std::string & type(void) const
Returns parameter type.
const std::string & name(void) const
Returns parameter name.
Filename class.
Definition: GFilename.hpp:62
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
GApplicationPar * clone(void) const
Clone parameter.
const std::string & mode(void) const
Returns parameter mode.
std::string m_type
Parameter type.
std::vector< std::string > pickle(void) const
Return pickled string vector.
const std::string & max(void) const
Returns parameter maximum.
GChatter
Definition: GTypemaps.hpp:33
void check_value_filename(const std::string &value) const
Test validity of filename parameter value.
void init_members(void)
Initialise class members.
double real(void)
Returns real.
bool is_query(void) const
Signals if parameter mode is &quot;query&quot;.
void check_value_string(const std::string &value) const
Test validity of string parameter value.
const std::string & current_value(void) const
Returns current parameter value without querying.
std::string m_prompt
Parameter prompt.
void set_value(const std::string &value)
Set parameter value.
std::string m_min
Parameter minimum.
void check_value_int(const std::string &value) const
Test validity of integer parameter value.
Application parameter class.
GFilename filename(void)
Returns filename parameter value.
Implements a time reference.
std::string string(void)
Returns string parameter value.
void free_members(void)
Delete class members.
GammaLib application interface definition.
void check_mode(const std::string &mode) const
Test validity of mode string.
const std::string & min(void) const
Returns parameter minimum.
std::string par_status_string(void) const
Return status string.
void query(void)
Query parameter if required.
Time class interface definition.
std::string m_max
Parameter maximum.
std::string set_status(const std::string &value)
Set parameter status.
std::string value(void)
Returns parameter value as string.
std::string m_value
Parameter value.
void check_value(const std::string &value) const
Test validity of value string.