Bayeux  3.4.1
Core Foundation library for SuperNEMO
param_entry.h
Go to the documentation of this file.
1 
3 #ifndef MYGSL_PARAM_ENTRY_H
4 #define MYGSL_PARAM_ENTRY_H 1
5 
6 // Standard library:
7 #include <iostream>
8 #include <string>
9 
10 // This project:
11 #include <mygsl/best_value.h>
12 
13 namespace mygsl {
14 
16  {
17  public:
18 
19  static const double NO_MIN_VALUE;
20  static const double NO_MAX_VALUE;
21  static const double NO_VALUE;
22  static const double DEFAULT_STEP;
23  static const double AUTO_STEP;
24  static const std::string AUTO_LABEL;
25  static const std::string FREE_LABEL;
26  static const std::string CONST_LABEL;
27 
28  enum limit_t
29  {
30  LIMIT_NO = 0x0,
31  LIMIT_MIN = 0x1,
32  LIMIT_MAX = 0x2,
34  };
35 
36  enum type_t
37  {
38  TYPE_NULL = 0x0,
39  TYPE_FREE = 0x1,
40  TYPE_CONST = 0x2,
41  TYPE_AUTO = 0x4,
43  };
44 
45  bool has_step () const;
46 
47  bool has_value () const;
48 
49  const std::string & get_name () const;
50 
51  const std::string & get_comment () const;
52 
53  void set_name (const std::string & name_);
54 
55  void set_comment (const std::string & comment_);
56 
57  void set_best_value (const best_value & best_value_);
58 
59  void reset_best_value ();
60 
61  bool is_auto_computed () const;
62 
63  void set_auto_computed (bool = true);
64 
65  bool has_best_value () const;
66 
67  const best_value & get_best_value () const;
68 
70 
71  bool is_const () const;
72 
73  bool is_free () const;
74 
75  bool is_auto () const;
76 
77  bool has_limit () const;
78 
79  bool has_no_limit () const;
80 
81  bool has_min () const;
82 
83  bool has_max () const;
84 
85  //bool is_in_range (double value_) const;
86 
87  bool is_in_range () const;
88 
89  bool is_in_safe_range () const;
90 
91  //bool is_in_safe_range (double value_) const;
92 
93  bool is_in_range_but_close_to_min () const;
94 
95  bool is_in_range_but_close_to_max () const;
96 
97  double get_overflow () const;
98 
99  double get_underflow () const;
100 
101  double get_dist_to_min () const;
102 
103  double get_dist_to_max () const;
104 
105  double get_dist_to_limit () const;
106 
107  double get_sign_limit () const;
108 
109  double get_value () const;
110 
111  double get_value_safe () const;
112 
113  double get_value_safe (double & dist_) const;
114 
115  double get_step () const;
116 
117  double get_min () const;
118 
119  double get_max () const;
120 
121  void set_min_max (double min_, double max_);
122 
123  void set_min (double min_);
124 
125  void set_no_min ();
126 
127  void set_max (double max_);
128 
129  void set_no_max ();
130 
131  void set_step (double step_);
132 
133  void set_value (double value_);
134 
135  void set_value_no_check (double value_);
136 
137  bool check_value () const;
138 
139  static param_entry make_auto (const std::string & name_,
140  double step_ = AUTO_STEP);
141 
142  static param_entry make_auto_range (const std::string & name_,
143  double min_,
144  double max_,
145  double step_ = AUTO_STEP);
146 
147  static param_entry make_auto_min (const std::string & name_,
148  double min_,
149  double step_ = AUTO_STEP);
150 
151  static param_entry make_auto_max (const std::string & name_,
152  double max_,
153  double step_ = AUTO_STEP);
154 
155  static param_entry make_free (const std::string & name_,
156  double value_,
157  double step_ = AUTO_STEP);
158 
159  static param_entry make_free_range (const std::string & name_,
160  double min_,
161  double max_,
162  double value_,
163  double step_ = AUTO_STEP);
164 
165  static param_entry make_free_min (const std::string & name_,
166  double min_,
167  double value_,
168  double step_ = AUTO_STEP);
169 
170  static param_entry make_free_max (const std::string & name_,
171  double max_,
172  double value_,
173  double step_ = AUTO_STEP);
174 
175  static param_entry make_const (const std::string & name_,
176  double value_);
177 
178  void print (std::ostream & out_ = std::clog,
179  const std::string & title_ = "Parameter",
180  const std::string & indent_ = "") const;
181 
182  void print_status (std::ostream & out_ = std::clog) const;
183 
184  private:
185 
186  param_entry (const std::string & name_ = "parameter");
187 
188  private:
189 
190  std::string _name_;
191  int _type_;
192  int _limit_;
193  double _min_;
194  double _max_;
195  double _value_;
196  double _step_;
197  std::string _comment_;
198  best_value _best_value_;
199 
200  };
201 
202  // predicate:
203  struct param_has_name : std::unary_function<bool,param_entry>
204  {
205  std::string _name_;
206 
207  param_has_name (const std::string & name_) : _name_ (name_)
208  {
209  }
210 
211  bool operator () (const param_entry & pe_)
212  {
213  return pe_.get_name () == _name_;
214  }
215  };
216 
217  // predicate:
218  struct param_ptr_has_name : std::unary_function<bool,param_entry *>
219  {
220  std::string _name_;
221 
222  param_ptr_has_name (const std::string & name_) : _name_ (name_)
223  {
224  }
225 
226  bool operator () (const param_entry * pe_)
227  {
228  return pe_->get_name () == _name_;
229  }
230  };
231 
232  // predicate:
233  struct param_is_free : std::unary_function<bool,param_entry>
234  {
236  {
237  return;
238  }
239 
240  bool operator () (const param_entry & pe_)
241  {
242  return pe_.is_free ();
243  }
244  };
245 
246  // predicate:
247  struct param_is_const : std::unary_function<bool,param_entry>
248  {
250  {
251  return;
252  }
253 
254  bool operator () (const param_entry & pe_)
255  {
256  return pe_.is_const ();
257  }
258  };
259 
260  // predicate:
261  struct param_is_auto : std::unary_function<bool,param_entry>
262  {
264  {
265  return;
266  }
267 
268  bool operator () (const param_entry & pe_)
269  {
270  return pe_.is_auto ();
271  }
272  };
273 
274 } // namespace mygsl
275 
276 #endif // MYGSL_PARAM_ENTRY_H
277 
278 /* Local Variables: */
279 /* mode: c++ */
280 /* coding: utf-8 */
281 /* End: */
static const std::string FREE_LABEL
Definition: param_entry.h:25
Definition: param_entry.h:39
Definition: param_entry.h:42
Definition: param_entry.h:33
limit_t
Definition: param_entry.h:28
type_t
Definition: param_entry.h:36
static param_entry make_free_range(const std::string &name_, double min_, double max_, double value_, double step_=AUTO_STEP)
Definition: param_entry.h:40
std::string _name_
Definition: param_entry.h:205
bool is_auto() const
bool has_best_value() const
double get_min() const
void set_no_max()
void reset_best_value()
double get_step() const
double get_overflow() const
param_is_auto()
Definition: param_entry.h:263
Definition: param_entry.h:30
A data structure representing a numeric value and its associated error.
Definition: best_value.h:17
bool is_auto_computed() const
bool is_in_range() const
param_is_free()
Definition: param_entry.h:235
bool check_value() const
Definition: param_entry.h:41
void set_min(double min_)
double get_dist_to_max() const
void set_value_no_check(double value_)
Definition: param_entry.h:31
bool has_min() const
bool is_const() const
bool operator()(const param_entry &pe_)
Definition: param_entry.h:268
Definition: param_entry.h:38
void set_auto_computed(bool=true)
double get_dist_to_limit() const
double get_underflow() const
static param_entry make_const(const std::string &name_, double value_)
void set_comment(const std::string &comment_)
bool is_in_range_but_close_to_max() const
Definition: param_entry.h:247
static const std::string CONST_LABEL
Definition: param_entry.h:26
Definition: param_entry.h:15
param_ptr_has_name(const std::string &name_)
Definition: param_entry.h:222
static const double DEFAULT_STEP
Definition: param_entry.h:22
void set_step(double step_)
void set_no_min()
static param_entry make_free(const std::string &name_, double value_, double step_=AUTO_STEP)
bool has_max() const
bool operator()(const param_entry &pe_)
Definition: param_entry.h:240
void set_best_value(const best_value &best_value_)
double get_value_safe() const
bool operator()(const param_entry &pe_)
Definition: param_entry.h:254
void set_name(const std::string &name_)
static param_entry make_free_max(const std::string &name_, double max_, double value_, double step_=AUTO_STEP)
bool is_in_range_but_close_to_min() const
bool is_in_safe_range() const
Definition: param_entry.h:261
std::string _name_
Definition: param_entry.h:220
bool has_value() const
static const std::string AUTO_LABEL
Definition: param_entry.h:24
static param_entry make_auto_min(const std::string &name_, double min_, double step_=AUTO_STEP)
static const double NO_VALUE
Definition: param_entry.h:21
bool has_no_limit() const
bool has_limit() const
static param_entry make_auto_max(const std::string &name_, double max_, double step_=AUTO_STEP)
static const double AUTO_STEP
Definition: param_entry.h:23
void print_status(std::ostream &out_=std::clog) const
void set_min_max(double min_, double max_)
Definition: param_entry.h:32
void set_max(double max_)
bool is_free() const
Top-level namespace of the Bayeux/mygsl module library.
Definition: base_decay_driver.h:47
void set_value(double value_)
const std::string & get_name() const
static param_entry make_auto(const std::string &name_, double step_=AUTO_STEP)
bool operator()(const param_entry &pe_)
Definition: param_entry.h:211
double get_value() const
static param_entry make_auto_range(const std::string &name_, double min_, double max_, double step_=AUTO_STEP)
param_is_const()
Definition: param_entry.h:249
param_has_name(const std::string &name_)
Definition: param_entry.h:207
Definition: param_entry.h:218
double get_max() const
bool operator()(const param_entry *pe_)
Definition: param_entry.h:226
Definition: param_entry.h:203
double get_dist_to_min() const
Definition: param_entry.h:233
static const double NO_MAX_VALUE
Definition: param_entry.h:20
const std::string & get_comment() const
bool has_step() const
void print(std::ostream &out_=std::clog, const std::string &title_="Parameter", const std::string &indent_="") const
double get_sign_limit() const
static const double NO_MIN_VALUE
Definition: param_entry.h:19
const best_value & get_best_value() const
static param_entry make_free_min(const std::string &name_, double min_, double value_, double step_=AUTO_STEP)