Bayeux  3.4.1
Core Foundation library for SuperNEMO
mapping.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2010-02-21
4  * Last modified: 2010-23-20
5  *
6  * License:
7  *
8  * Description:
9  * Default geometry mapping: given a model factory (class model_factory)
10  * and a ID manager (class id_mgr), this geometry mapping dictionnary
11  * is auto generated.
12  *
13  * History:
14  *
15  */
16 
17 #ifndef GEOMTOOLS_MAPPING_H
18 #define GEOMTOOLS_MAPPING_H 1
19 
20 // Standard library:
21 #include <string>
22 #include <list>
23 
24 // Third party library:
25 // - Bayeux/datatools:
26 #include <datatools/ioutils.h>
27 #include <datatools/bit_mask.h>
29 
30 // This project:
31 #include <geomtools/utils.h>
32 #include <geomtools/geom_map.h>
33 
34 namespace geomtools {
35 
36  // Forward declarations:
37  class model_factory;
38  class placement;
39  class logical_volume;
40  class geom_id;
41 
43  class mapping : public geom_map
44  {
45  public:
46 
48  static const size_t NO_MAX_DEPTH = 0;
49 
50  // \brief Constants
51  struct constants {
52  std::string MAPPING_PREFIX;
54  constants ();
55  static const constants & instance ();
56  };
57 
58  // \brief Mothership modes
63  };
64 
65  // \brief Mode for including/excluding some geoemtry categories
66  enum mode_type {
67  MODE_NONE = 0,
68  MODE_ONLY = 1,
70  };
71 
72  // Tools to manipulate 'mapping' properties:
73  static std::string make_key (const std::string & flag_);
74 
75  static void extract (const datatools::properties & source_,
76  datatools::properties & target_);
77 
78  static bool has_flag (const datatools::properties & config_,
79  const std::string & flag_);
80 
81  static bool has_key (const datatools::properties & config_,
82  const std::string & key_);
83 
85  bool is_initialized () const;
86 
88  bool is_mode_none () const;
89 
91  bool is_mode_only () const;
92 
94  bool is_mode_excluded () const;
95 
97  void add_only (const std::string &);
98 
100  void add_excluded (const std::string &);
101 
103  int get_build_mode () const;
104 
106  void set_build_mode (int bm_);
107 
109  bool is_build_mode_strict_mothership () const;
110 
112  bool is_build_mode_lazy_mothership () const;
113 
115  void set_max_depth (size_t max_depth_);
116 
118  size_t get_max_depth () const;
119 
121  mapping ();
122 
124  virtual ~mapping ();
125 
127  void initialize (const datatools::properties & config_);
128 
130  virtual void build_from (const model_factory & factory_,
131  const std::string & mother_ = "world");
132 
134  void dump_dictionnary (std::ostream & out_ = std::clog) const;
135 
140  };
141 
143  void smart_print (std::ostream & out_ = std::clog,
144  const std::string & indent_ = "",
145  uint32_t flags_ = 0) const;
146 
147  private:
148 
150  void _build_ ();
151 
152  void _build_logical_children_ (const logical_volume & log_,
153  const placement & mother_world_placement_,
154  const geom_id & mother_id_);
155 
156  void _build_logical_children_2_ (const logical_volume & log_,
157  const placement & mother_world_placement_,
158  const std::vector<geom_id> & mother_ids_);
159 
160  private:
161 
162  // Status:
163  bool _initialized_;
164 
165  // Configuration:
166  bool _world_mapping_;
167  size_t _max_depth_;
168  int _build_mode_;
169  int _mode_;
170  std::list<std::string> _only_excluded_list_;
171 
172  // Working data:
173  const model_factory * _factory_;
174  const logical_volume * _top_logical_;
175  size_t _depth_;
176 
177  // Debug display utility:
178  datatools::io::indenter _indenter_;
179 
180  };
181 
182 } // end of namespace geomtools
183 
184 #include <datatools/ocd_macros.h>
186 
187 #endif // GEOMTOOLS_MAPPING_H
188 
189 /*
190 ** Local Variables: --
191 ** mode: c++ --
192 ** c-file-style: "gnu" --
193 ** tab-width: 2 --
194 ** End: --
195 */
bool is_build_mode_lazy_mothership() const
Check the 'lazy mothership' build mode.
std::string MAPPING_PREFIX
Definition: mapping.h:52
The geometry ID mapping.
Definition: mapping.h:43
static void extract(const datatools::properties &source_, datatools::properties &target_)
static const size_t NO_MAX_DEPTH
Constant representing unlimited mapping depth.
Definition: mapping.h:48
build_mode_type
Definition: mapping.h:59
Definition: mapping.h:67
static const uint32_t bit01
Definition: bit_mask.h:28
static bool has_key(const datatools::properties &config_, const std::string &key_)
I/O indenter class.
Definition: ioutils.h:116
void add_excluded(const std::string &)
Add a geometry category in the list of excluded geometry categories.
A logical geometry volume (ala GDML)
Definition: logical_volume.h:40
std::string MAPPING_DAUGHTER_ID_PREFIX
Definition: mapping.h:53
void set_max_depth(size_t max_depth_)
Set the max mapping depth.
bool is_build_mode_strict_mothership() const
Check the 'strict mothership' build mode.
Definition: mapping.h:68
Definition: mapping.h:138
bool is_mode_excluded() const
Check that the exclusion mode is set.
void dump_dictionnary(std::ostream &out_=std::clog) const
Basic print of the embedded mapping dictionary.
bool is_mode_only() const
Check that the inclusion mode is set.
void initialize(const datatools::properties &config_)
Configure the mapping.
void add_only(const std::string &)
Add a geometry category in the list of processed geometry categories.
virtual ~mapping()
Destructor.
DOCD_CLASS_DECLARATION(my::algo)
Declaration of the OCD support for the my::algo class.
static bool has_flag(const datatools::properties &config_, const std::string &flag_)
mode_type
Definition: mapping.h:66
Definition: mapping.h:51
Definition: geom_map.h:48
static const constants & instance()
size_t get_max_depth() const
Return the max mapping depth.
bool is_initialized() const
Check initialization flag.
void set_build_mode(int bm_)
Set the build mode.
The placement for a geometry volume with its translation and rotation with respect to some mother ref...
Definition: placement.h:34
void smart_print(std::ostream &out_=std::clog, const std::string &indent_="", uint32_t flags_=0) const
Smart print.
The factory of geometry models.
Definition: model_factory.h:40
Definition: geom_id.h:41
bool is_mode_none() const
Check that no inclusion/exclusion of geometry categories mode is set.
int get_build_mode() const
Return the build mode.
static const uint32_t bit00
Definition: bit_mask.h:27
mapping()
Default constructor.
static std::string make_key(const std::string &flag_)
smart_print_flags_type
Print flags.
Definition: mapping.h:137
Definition: mapping.h:69
Definition: mapping.h:139
virtual void build_from(const model_factory &factory_, const std::string &mother_="world")
Build the mapping information.
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39
A dictionary of arbitrary properties.
Definition: properties.h:125