Bayeux  3.4.1
Core Foundation library for SuperNEMO
i_stackable.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2010-04-02
4  * Last modified: 2017-02-22
5  *
6  * Description:
7  *
8  * Abstract interface for stackable shape objects
9  * and stackable data.
10  */
11 
12 #ifndef GEOMTOOLS_I_STACKABLE_H
13 #define GEOMTOOLS_I_STACKABLE_H 1
14 
15 // Standard library:
16 #include <iostream>
17 #include <string>
18 
19 // Third party:
20 // - Bayeux/datatools:
21 #include <datatools/utils.h>
22 #include <datatools/properties.h>
23 #include <datatools/i_tree_dump.h>
24 #include <datatools/bit_mask.h>
25 
26 // This project:
27 #include <geomtools/utils.h>
28 
29 namespace geomtools {
30 
33  {
34 
35  public:
36 
37  i_stackable();
38  virtual ~i_stackable();
39  bool has_xmin() const;
40  bool has_xmax() const;
41  bool has_ymin() const;
42  bool has_ymax() const;
43  bool has_zmin() const;
44  bool has_zmax() const;
45  virtual double get_xmin() const = 0;
46  virtual double get_xmax() const = 0;
47  virtual double get_ymin() const = 0;
48  virtual double get_ymax() const = 0;
49  virtual double get_zmin() const = 0;
50  virtual double get_zmax() const = 0;
51 
52  };
53 
55  class stackable
56  {
57  public:
58  static const std::string STACKABLE_PREFIX;
59  static const std::string STACKABLE_LENGTH_UNIT_PROPERTY;
60  static const std::string STACKABLE_XMIN_PROPERTY;
61  static const std::string STACKABLE_XMAX_PROPERTY;
62  static const std::string STACKABLE_YMIN_PROPERTY;
63  static const std::string STACKABLE_YMAX_PROPERTY;
64  static const std::string STACKABLE_ZMIN_PROPERTY;
65  static const std::string STACKABLE_ZMAX_PROPERTY;
66  static const std::string STACKABLE_PLAY_PROPERTY;
67  static const std::string STACKABLE_LIMITS_PROPERTY;
68 
70  STACKABILITY_NONE = 0, // 00000000
86  };
87 
88  static std::string make_key(const std::string & flag_);
89 
90  static void extract(const datatools::properties & source_,
91  datatools::properties & target_);
92 
93  static bool has_xmin(const datatools::properties & source_);
94 
95  static bool has_xmax(const datatools::properties & source_);
96 
97  static bool has_ymin(const datatools::properties & source_);
98 
99  static bool has_ymax(const datatools::properties & source_);
100 
101  static bool has_zmin(const datatools::properties & source_);
102 
103  static bool has_zmax(const datatools::properties & source_);
104 
105  static double get_xmin(const datatools::properties & source_,
106  double length_unit_ = -1.0);
107 
108  static double get_xmax(const datatools::properties & source_,
109  double length_unit_ = -1.0);
110 
111  static double get_ymin(const datatools::properties & source_,
112  double length_unit_ = -1.0);
113 
114  static double get_ymax(const datatools::properties & source_,
115  double length_unit_ = -1.0);
116 
117  static double get_zmin(const datatools::properties & source_,
118  double length_unit_ = -1.0);
119 
120  static double get_zmax(const datatools::properties & source_,
121  double length_unit_ = -1.0);
122 
123  static void set_xmin(datatools::properties & target_,
124  double xmin_);
125 
126  static void set_xmax(datatools::properties & target_,
127  double xmax_);
128 
129  static void set_ymin(datatools::properties & target_,
130  double ymin_);
131 
132  static void set_ymax(datatools::properties & target_,
133  double ymax_);
134 
135  static void set_zmin(datatools::properties & target_,
136  double zmin_);
137 
138  static void set_zmax(datatools::properties & target_,
139  double zmax_);
140 
141  static void unset_xmin(datatools::properties & target_);
142 
143  static void unset_xmax(datatools::properties & target_);
144 
145  static void unset_ymin(datatools::properties & target_);
146 
147  static void unset_ymax(datatools::properties & target_);
148 
149  static void unset_zmin(datatools::properties & target__);
150 
151  static void unset_zmax(datatools::properties & target_);
152 
153  static void unset(datatools::properties & target_);
154 
155  static void set(datatools::properties & target_,
156  const i_stackable & sd_);
157 
158  };
159 
162  : public i_stackable
164  {
165  public:
166 
168  stackable_data();
169 
171  virtual ~stackable_data();
172 
174 
176  bool is_valid_x() const;
177 
179  bool is_valid_y() const;
180 
182  bool is_valid_z() const;
183 
185  bool is_valid() const;
186 
188  bool is_valid_by_axis(axis_type) const;
189 
191  bool is_valid_weak() const;
192 
194  bool is_valid_very_weak() const;
195 
197  void invalidate();
198 
200  virtual double get_xmin() const;
201 
203  virtual double get_xmax() const;
204 
206  virtual double get_ymin() const;
207 
209  virtual double get_ymax() const;
210 
212  virtual double get_zmin() const;
213 
215  virtual double get_zmax() const;
216 
218  virtual void tree_dump(std::ostream & out_ = std::clog,
219  const std::string & title_ = "",
220  const std::string & indent_ = "",
221  bool inherit_ = false) const;
222 
224  void dump(std::ostream & out_ = std::clog) const;
225 
227  bool initialize(const datatools::properties & config_);
228 
230  void reset();
231 
232  public:
233 
234  double xmin;
235  double xmax;
236  double ymin;
237  double ymax;
238  double zmin;
239  double zmax;
240 
241  };
242 
243 } // end of namespace geomtools
244 
245 #endif // GEOMTOOLS_I_STACKABLE_H
246 
247 // Local Variables: --
248 // mode: c++ --
249 // c-file-style: "gnu" --
250 // tab-width: 2 --
251 // End: --
Definition: i_stackable.h:78
static const std::string STACKABLE_PREFIX
Definition: i_stackable.h:58
Definition: i_stackable.h:76
static double get_zmax(const datatools::properties &source_, double length_unit_=-1.0)
static const std::string STACKABLE_XMIN_PROPERTY
Definition: i_stackable.h:60
virtual double get_ymax() const =0
bool is_valid_weak() const
Check the validity of stacking information at least for one axis.
Definition: i_stackable.h:84
virtual double get_xmin() const
Return the minimum X.
static bool has_zmax(const datatools::properties &source_)
static const uint32_t bit07
Definition: bit_mask.h:34
double xmin
Minimum X.
Definition: i_stackable.h:234
stackable_data()
Constructor.
bool is_valid_x() const
Check the validity of stacking information along the X axis.
static bool has_zmin(const datatools::properties &source_)
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
static const std::string STACKABLE_LIMITS_PROPERTY
Definition: i_stackable.h:67
virtual double get_zmin() const
Return the minimum Z.
virtual double get_ymin() const =0
static const uint32_t bit01
Definition: bit_mask.h:28
static const std::string STACKABLE_ZMIN_PROPERTY
Definition: i_stackable.h:64
Definition: i_stackable.h:85
static const uint32_t bit03
Definition: bit_mask.h:30
static bool has_ymin(const datatools::properties &source_)
static void unset_xmin(datatools::properties &target_)
static bool has_xmax(const datatools::properties &source_)
static const std::string STACKABLE_LENGTH_UNIT_PROPERTY
Definition: i_stackable.h:59
static const std::string STACKABLE_YMAX_PROPERTY
Definition: i_stackable.h:63
static const uint32_t bit04
Definition: bit_mask.h:31
static bool has_xmin(const datatools::properties &source_)
virtual double get_zmax() const =0
void dump(std::ostream &out_=std::clog) const
Print.
static const uint32_t bit06
Definition: bit_mask.h:33
bool is_valid_very_weak() const
Check if at least one stacking information is set (X/Y/Z, min/max)
Definition: i_stackable.h:82
double ymax
Maximum Y.
Definition: i_stackable.h:237
Definition: i_stackable.h:72
Definition: i_stackable.h:71
static std::string make_key(const std::string &flag_)
static void set_xmax(datatools::properties &target_, double xmax_)
static double get_xmin(const datatools::properties &source_, double length_unit_=-1.0)
bool check(const stackable::stackability_mode flags_=stackable::STACKABILITY_STRONG) const
static void set(datatools::properties &target_, const i_stackable &sd_)
double zmin
Minimum Z.
Definition: i_stackable.h:238
Abstract base stackable object.
Definition: i_stackable.h:32
virtual double get_xmax() const =0
static void set_xmin(datatools::properties &target_, double xmin_)
virtual double get_ymax() const
Return the maximum Y.
static double get_ymax(const datatools::properties &source_, double length_unit_=-1.0)
static void unset_zmax(datatools::properties &target_)
static void set_ymax(datatools::properties &target_, double ymax_)
virtual ~stackable_data()
Destructor.
Definition: i_stackable.h:80
Definition: i_stackable.h:70
virtual double get_xmax() const
Return the maximum X.
bool initialize(const datatools::properties &config_)
Initialization.
static void set_zmax(datatools::properties &target_, double zmax_)
static double get_ymin(const datatools::properties &source_, double length_unit_=-1.0)
static const uint32_t bit02
Definition: bit_mask.h:29
static void unset_ymin(datatools::properties &target_)
static const uint32_t bit05
Definition: bit_mask.h:32
Definition: i_stackable.h:74
Definition: i_stackable.h:77
bool is_valid_y() const
Check the validity of stacking information along the Y axis.
bool is_valid() const
Check the validity of stacking information for all axis.
static void unset_ymax(datatools::properties &target_)
Static methods and constants to handle stackable data/information.
Definition: i_stackable.h:55
virtual double get_ymin() const
Return the minimum Y.
double xmax
Maximum X.
Definition: i_stackable.h:235
static double get_xmax(const datatools::properties &source_, double length_unit_=-1.0)
static void extract(const datatools::properties &source_, datatools::properties &target_)
virtual double get_zmax() const
Return the maximum Z.
stackability_mode
Definition: i_stackable.h:69
static double get_zmin(const datatools::properties &source_, double length_unit_=-1.0)
bool is_valid_by_axis(axis_type) const
Check the validity of stacking information for one given axis.
static void unset(datatools::properties &target_)
static const std::string STACKABLE_PLAY_PROPERTY
Definition: i_stackable.h:66
static void set_ymin(datatools::properties &target_, double ymin_)
static void unset_xmax(datatools::properties &target_)
Definition: i_stackable.h:75
Definition: i_stackable.h:79
static void unset_zmin(datatools::properties &target__)
Definition: i_stackable.h:81
Data for stacking along X, Y and/or Z axis.
Definition: i_stackable.h:161
virtual double get_xmin() const =0
double zmax
Maximum Z.
Definition: i_stackable.h:239
static const uint32_t bit00
Definition: bit_mask.h:27
Definition: i_stackable.h:73
virtual double get_zmin() const =0
static bool has_ymax(const datatools::properties &source_)
axis_type
Axis type.
Definition: utils.h:387
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
static const std::string STACKABLE_YMIN_PROPERTY
Definition: i_stackable.h:62
bool is_valid_z() const
Check the validity of stacking information along the Z axis.
double ymin
Minimum Y.
Definition: i_stackable.h:236
static const std::string STACKABLE_ZMAX_PROPERTY
Definition: i_stackable.h:65
static const std::string STACKABLE_XMAX_PROPERTY
Definition: i_stackable.h:61
static void set_zmin(datatools::properties &target_, double zmin_)
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39
A dictionary of arbitrary properties.
Definition: properties.h:125
void invalidate()
Invalidate.