Bayeux  3.4.1
Core Foundation library for SuperNEMO
angular_range.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2016-03-09
4  * Last modified: 2016-03-09
5  *
6  * License:
7  *
8  * Description:
9  *
10  * Angular range
11  *
12  * History:
13  *
14  */
15 
16 #ifndef GEOMTOOLS_ANGULAR_RANGE_H
17 #define GEOMTOOLS_ANGULAR_RANGE_H 1
18 
19 // Standard library:
20 #include <string>
21 
22 // Third party:
23 // - Bayeux/datatools:
24 #include <datatools/properties.h>
25 #include <datatools/i_tree_dump.h>
28 #include <datatools/ocd_macros.h>
29 
30 namespace geomtools {
31 
33  class angular_range :
36  {
37  public:
38 
40  enum range_type {
44  };
45 
47  static std::string type_to_label(range_type rt_);
48 
50  static range_type label_to_type(const std::string &);
51 
53  static double min_start_angle(range_type);
54 
56  static double max_start_angle(range_type);
57 
60 
62  explicit angular_range(const std::string & type_label_);
63 
65  angular_range(range_type rt_, double start_angle_, double delta_angle_);
66 
68  bool has_type() const;
69 
71  void set_type(range_type);
72 
74  range_type get_type() const;
75 
77  bool is_polar() const;
78 
80  bool is_azimuthal() const;
81 
83  double get_min_start_angle() const;
84 
86  double get_max_start_angle() const;
87 
89  bool has_start_angle() const;
90 
92  void set_start_angle(double);
93 
95  double get_start_angle() const;
96 
98  bool has_delta_angle() const;
99 
101  void set_delta_angle(double);
102 
104  double get_delta_angle() const;
105 
107  bool is_partial() const;
108 
110  void set_partial_angles(double start_angle_, double delta_angle_);
111 
113  void reset_partial_angles();
114 
116  double get_first_angle() const;
117 
119  double get_last_angle() const;
120 
122  double get_angle_spread() const;
123 
125  bool contains(double angle_, double tolerance_ = 0.0, bool strict_range_ = false) const;
126 
128  bool is_valid() const;
129 
131  void invalidate();
132 
134  void initialize(const datatools::properties & config_);
135 
137  void reset();
138 
140  virtual void tree_dump(std::ostream & out_ = std::clog,
141  const std::string & title_ = "",
142  const std::string & indent_ = "",
143  bool inherit_= false) const;
144 
147  const std::string & prefix_ = "");
148 
151  public:
152 
156  iterator(const angular_range & ar_, unsigned int nsteps_ = 36);
157 
160  unsigned int get_nsamples() const;
161 
163  int get_current_step() const;
164 
166  double get_current_angle() const;
167 
169  bool is_at_first() const;
170 
172  bool is_at_last() const;
173 
175  bool is_finished() const;
176 
178  void set_first();
179 
181  void set_last();
182 
184  void set_finished();
185 
187  void step();
188 
190  void tree_dump(std::ostream & out_ = std::clog,
191  const std::string & title_ = "",
192  const std::string & indent_ = "",
193  bool inherit_= false) const;
194 
197  double operator*() const;
198 
201 
203  bool operator!() const;
204 
205  private:
206 
207  const angular_range & _ref_;
208  unsigned int _nsamples_;
209  double _step_angle_;
210  unsigned int _current_step_;
211  double _current_angle_;
212 
213  };
214 
215  protected:
216 
218  void _set_defaults();
219 
220  private:
221 
222  range_type _type_;
223  double _start_angle_;
224  double _delta_angle_;
225 
226  // Serialization interface:
228 
229  };
230 
231 } // end of namespace geomtools
232 
233 #ifdef __clang__
234 #pragma clang diagnostic push
235 #pragma clang diagnostic ignored "-Wunused-local-typedef"
236 #endif
237 #include <boost/serialization/export.hpp>
238 #ifdef __clang__
239 #pragma clang diagnostic pop
240 #endif
241 BOOST_CLASS_EXPORT_KEY2(geomtools::angular_range, "geomtools::angular_range")
242 
243 // @param geomtools::angular_range the name the class with registered OCD support
245 DOCD_CLASS_DECLARATION(geomtools::angular_range)
246 
247 #endif // GEOMTOOLS_ANGULAR_RANGE_H
248 
249 // Local Variables: --
250 // mode: c++ --
251 // c-file-style: "gnu" --
252 // tab-width: 2 --
253 // End: --
double get_max_start_angle() const
Return the max start angle.
Base abstract class of all serializable (and possibly introspectable) classes.
Definition: i_serializable.h:51
angular_range(range_type rt_=RANGE_TYPE_INVALID)
Default constructor.
int get_current_step() const
Return the current step index.
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
double get_angle_spread() const
Return the angular spread.
void invalidate()
Invalidate.
void _set_defaults()
Set default value foe attibutes.
void set_first()
Set the iterator at first position.
void set_partial_angles(double start_angle_, double delta_angle_)
Set angles.
An object that describes the way an object of a given class can be configured through properties.
Definition: object_configuration_description.h:234
#define DATATOOLS_SERIALIZATION_DECLARATION()
Definition: i_serializable.h:266
bool is_finished() const
Check if the iterator is finished (past-the-end)
double get_start_angle() const
Return the start angle.
double get_current_angle() const
Return the current angle value.
void set_type(range_type)
Set the range type.
double get_delta_angle() const
Return the delta angle.
Polar angle.
Definition: angular_range.h:42
bool operator!() const
Check the validity of the iterator.
double get_first_angle() const
Return the first angle.
bool is_at_first() const
Check if the iterator is positioned at the first sample.
void set_last()
Set the iterator at last position.
DOCD_CLASS_DECLARATION(my::algo)
Declaration of the OCD support for the my::algo class.
range_type
The type of angular range.
Definition: angular_range.h:40
void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
bool is_partial() const
Check for the partial angle.
unsigned int get_nsamples() const
double get_last_angle() const
Return the last angle.
Angular range.
Definition: angular_range.h:33
iterator(const angular_range &ar_, unsigned int nsteps_=36)
static double max_start_angle(range_type)
Return the max start angle.
bool has_delta_angle() const
Check the dedislta angle.
bool has_type() const
Check if the range type is set.
void set_delta_angle(double)
Set the delta angle.
bool is_valid() const
Check if the range is valid.
bool is_azimuthal() const
Check if the type of the range is 'azimuthal'.
void initialize(const datatools::properties &config_)
Initialize from a set of parameters.
bool contains(double angle_, double tolerance_=0.0, bool strict_range_=false) const
Check if a given angle is contains in the range.
range_type get_type() const
Return the range type.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
static std::string type_to_label(range_type rt_)
Return the label associated to a range type.
bool is_polar() const
Check if the type of the range is 'polar'.
Forward iterator associated to an angular range.
Definition: angular_range.h:150
void reset_partial_angles()
Invalidate.
void step()
Increment the iterator position by one unit.
void set_finished()
Set the iterator at finished (past-the-end)
iterator operator++()
Increment operator.
Azimuthal range.
Definition: angular_range.h:43
bool has_start_angle() const
Check the start angle.
double get_min_start_angle() const
Return the min start angle.
static double min_start_angle(range_type)
Return the min start angle.
bool is_at_last() const
Check if the iterator is positioned at the last sample.
static void init_ocd(datatools::object_configuration_description &, const std::string &prefix_="")
OCD support.
void set_start_angle(double)
Set the start angle.
static range_type label_to_type(const std::string &)
Return the range type associated to a label.
Invalid range type.
Definition: angular_range.h:41
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39
A dictionary of arbitrary properties.
Definition: properties.h:125