GammaLib 2.0.0
Loading...
Searching...
No Matches
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 _______________________________________________ */
37class GFilename;
38class GTimeReference;
39
40
41/***********************************************************************//**
42 * @class GApplicationPar
43 *
44 * @brief Application parameter class
45 ***************************************************************************/
46class GApplicationPar : public GBase {
47
48 // Friend classes
49 friend class GApplicationPars;
50 friend class GApplication;
51
52public:
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);
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
105protected:
106 // Protected enumerators
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 ***************************************************************************/
154inline
155std::string GApplicationPar::classname(void) const
156{
157 return ("GApplicationPar");
158}
159
160
161/***********************************************************************//**
162 * @brief Returns parameter name
163 *
164 * @return Parameter name
165 ***************************************************************************/
166inline
167const 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 ***************************************************************************/
178inline
179const 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 ***************************************************************************/
190inline
191const 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 ***************************************************************************/
202inline
203const 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 ***************************************************************************/
214inline
215const 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 ***************************************************************************/
226inline
227const 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 ***************************************************************************/
238inline
239const 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 ***************************************************************************/
249inline
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 ***************************************************************************/
262inline
264{
265 return m_queried;
266}
267
268#endif /* GAPPLICATIONPAR_HPP */
Definition of interface for all GammaLib classes.
Time class interface definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
Application parameter class.
bool check_options(const std::string &value) const
Test if parameter value satisfies possible options.
std::string m_name
Parameter name.
std::string m_min
Parameter minimum.
void copy_members(const GApplicationPar &par)
Copy class members.
std::vector< std::string > pickle(void) const
Return pickled string vector.
std::string m_value
Parameter value.
void check_value_bool(const std::string &value) const
Test validity of boolean value string.
std::string m_type
Parameter type.
const std::string & mode(void) const
Returns parameter mode.
void check_value_time(const std::string &value) const
Test validity of time parameter value.
void check_value_int(const std::string &value) const
Test validity of integer parameter value.
double real(void)
Returns real.
bool is_learn(void) const
Signals if parameter mode is "learn".
void clear(void)
Clear parameter.
std::string classname(void) const
Return class name.
GApplicationPar & operator=(const GApplicationPar &par)
Assignment operator.
const std::string & max(void) const
Returns parameter maximum.
const std::string & current_value(void) const
Returns current parameter value without querying.
std::string m_mode
Parameter mode.
bool is_valid(void)
Signals if parameter is valid.
GTime time(void)
Return time in native reference system.
std::string string(void)
Returns string parameter value.
void init_members(void)
Initialise class members.
GApplicationPar * clone(void) const
Clone parameter.
void free_members(void)
Delete class members.
bool m_update
Signal value updating.
bool m_queried
Signal that parameter was queried.
std::string par_type_string(const std::string &type) const
Return type string.
std::string print(const GChatter &chatter=NORMAL) const
Print parameter.
std::string m_max
Parameter maximum.
bool is_notanumber(void)
Signals if parameter is not a number.
void check_value_string(const std::string &value) const
Test validity of string parameter value.
GApplicationPar(void)
Void constructor.
void check_type(const std::string &type) const
Test validity of type string.
void query(void)
Query parameter if required.
bool boolean(void)
Returns boolean.
const std::string & name(void) const
Returns parameter name.
std::string value(void)
Returns parameter value as string.
const std::string & type(void) const
Returns parameter type.
std::string par_status_string(void) const
Return status string.
GFilename filename(void)
Returns filename parameter value.
bool is_undefined(void)
Signals if parameter is undefined.
std::string set_status(const std::string &value)
Set parameter status.
void check_mode(const std::string &mode) const
Test validity of mode string.
const std::string & prompt(void) const
Returns parameter prompt.
void set_value(const std::string &value)
Set parameter value.
const std::string & min(void) const
Returns parameter minimum.
bool is_filename(void) const
Signals if parameter mode is of type "filename".
virtual ~GApplicationPar(void)
Destructor.
void check_value_real(const std::string &value) const
Test validity of real parameter value.
void check_value_filename(const std::string &value) const
Test validity of filename parameter value.
Status m_status
Parameter status.
void stop_query(void)
Don't query parameter again.
bool was_queried(void) const
Signals if parameter was queried.
bool is_query(void) const
Signals if parameter mode is "query".
int integer(void)
Returns integer.
void check_value(const std::string &value) const
Test validity of value string.
std::string m_prompt
Parameter prompt.
Application parameter container class.
GammaLib application interface definition.
Interface class for all GammaLib classes.
Definition GBase.hpp:52
Filename class.
Definition GFilename.hpp:62
Implements a time reference.
Time class.
Definition GTime.hpp:55
GTimeReference reference(void) const
Returns native time reference.
Definition GTime.cpp:1170