Bayeux  3.4.1
Core Foundation library for SuperNEMO
multiparameter_system.h
Go to the documentation of this file.
1 
3 #ifndef MYGSL_MULTIPARAMETER_SYSTEM_H
4 #define MYGSL_MULTIPARAMETER_SYSTEM_H 1
5 
6 // Standard library:
7 #include <iostream>
8 #include <vector>
9 
10 // This project:
11 #include <mygsl/param_entry.h>
12 
13 namespace mygsl {
14 
17  {
18  public:
19 
20  typedef std::vector<param_entry *> params_col_type;
21 
22  bool is_lock_params () const;
23 
24  size_t get_number_of_params () const;
25 
26  size_t get_number_of_free_params () const;
27 
28  size_t get_number_of_auto_params () const;
29 
30  size_t get_number_of_const_params () const;
31 
32  void init ();
33 
34  void reset ();
35 
36  void lock_params ();
37 
38  void unlock_params ();
39 
40  bool has_param_with_name (const std::string & name_) const;
41 
42  const param_entry & get_param_by_name (const std::string & name_) const;
43 
44  param_entry & grab_param_by_name (const std::string & name_);
45 
46  const param_entry & get_param (int i_) const;
47 
48  param_entry & grab_param (int i_);
49 
50  const param_entry & get_free_param (int i_) const;
51 
52  param_entry & grab_free_param (int i_);
53 
54  const param_entry & get_auto_param (int i_) const;
55 
56  param_entry & grab_auto_param (int i_);
57 
58  void add_param (const param_entry & pe_, const std::string & comment_ = "");
59 
61 
62  virtual ~multiparameter_system ();
63 
64  void print (std::ostream & out_ = std::clog,
65  const std::string & title_ = "Multi-parameter system",
66  const std::string & indent_ = "") const;
67 
68  void print_line (std::ostream & out_ = std::clog) const;
69 
70  void print_status (std::ostream & out_ = std::clog) const;
71 
72  void load_parameters (const std::string & filename_);
73 
74  void load_params (const std::string & filename_);
75 
76  void load_parameters (std::istream & in_ );
77 
78  void store_parameters (const std::string & filename_) const;
79 
80  void store_params (const std::string & filename_) const;
81 
82  void store_parameters (std::ostream & out_) const;
83 
84  virtual void compute_automatic_params ();
85 
86  /* Any sub-class inherited from the 'multiparameter_system'
87  * class must implement the virtual 'compute_automatic_params'
88  * method in order to set valid values to the parameters marked
89  * as 'automatic'.
90  *
91  * At least these automatic parameters should invoke
92  * the 'set_auto_computed (true)' or the 'set_value (XXX)' methods
93  *
94  * Example:
95  *
96  * class my_system : public multiparameter_system::compute_automatic_params ()
97  * {
98  * public:
99  * void multiparameter_system::compute_automatic_params ()
100  * {
101  * for (int i = 0; i < _auto_params_.size (); i++)
102  * {
103  * _auto_params_[i]->set_value (666.);
104  * _auto_params_[i]->set_auto_computed (true);
105  * }
106  * }
107  * };
108  *
109  */
110 
111  private:
112 
113  bool _lock_params_;
114  params_col_type _params_;
115  params_col_type _free_params_;
116  params_col_type _auto_params_;
117  params_col_type _const_params_;
118 
119  };
120 
122  {
123  virtual void compute_automatic_params ()
124  {
125  for (size_t i = 0; i < get_number_of_auto_params (); i++)
126  {
129  }
130  return;
131  }
132  };
133 
134 } // namespace mygsl
135 
136 #endif // MYGSL_MULTIPARAMETER_SYSTEM_H
137 
138 /* Local Variables: */
139 /* mode: c++ */
140 /* coding: utf-8 */
141 /* End: */
virtual void compute_automatic_params()
Definition: multiparameter_system.h:121
void print_line(std::ostream &out_=std::clog) const
void store_parameters(const std::string &filename_) const
void print(std::ostream &out_=std::clog, const std::string &title_="Multi-parameter system", const std::string &indent_="") const
void set_value_no_check(double value_)
void set_auto_computed(bool=true)
size_t get_number_of_const_params() const
Definition: param_entry.h:15
void add_param(const param_entry &pe_, const std::string &comment_="")
param_entry & grab_param_by_name(const std::string &name_)
const param_entry & get_free_param(int i_) const
const param_entry & get_auto_param(int i_) const
std::vector< param_entry * > params_col_type
Definition: multiparameter_system.h:20
size_t get_number_of_free_params() const
size_t get_number_of_auto_params() const
void load_params(const std::string &filename_)
Top-level namespace of the Bayeux/mygsl module library.
Definition: base_decay_driver.h:47
void store_params(const std::string &filename_) const
void print_status(std::ostream &out_=std::clog) const
param_entry & grab_free_param(int i_)
const param_entry & get_param(int i_) const
param_entry & grab_param(int i_)
param_entry & grab_auto_param(int i_)
bool has_param_with_name(const std::string &name_) const
virtual void compute_automatic_params()
Definition: multiparameter_system.h:123
size_t get_number_of_params() const
const param_entry & get_param_by_name(const std::string &name_) const
void load_parameters(const std::string &filename_)
System with several parameters.
Definition: multiparameter_system.h:16