Bayeux  3.4.1
Core Foundation library for SuperNEMO
i_model.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2010-02-20
4  * Last modified: 2015-07-07
5  *
6  * License:
7  *
8  * Description:
9  *
10  * Interface/base class for all geometry models
11  *
12  * History:
13  *
14  */
15 
16 #ifndef GEOMTOOLS_I_MODEL_H
17 #define GEOMTOOLS_I_MODEL_H 1
18 
19 // Standard library:
20 #include <iostream>
21 #include <string>
22 
23 // Third party:
24 // - Boost
25 #include <boost/scoped_ptr.hpp>
26 
27 // Bayeux:
28 #include <datatools/i_tree_dump.h>
29 #include <datatools/properties.h>
30 #include <datatools/logger.h>
32 #include <datatools/ocd_macros.h>
33 
34 // This library:
38 
39 namespace geomtools {
40 
41  // Forward declaration:
42  class shape_factory;
43 
45  class i_model
47  {
48  public:
49 
50  // Constants parameters used by geometry models:
51  static const std::string & solid_suffix();
52  static const std::string & logical_suffix();
53  static const std::string & physical_suffix();
54  static const std::string & phantom_solid_flag();
55  static const std::string & exported_properties_prefixes_key();
56 
59 
61 
63 
65  bool is_constructed() const;
66 
68  bool is_phantom_solid() const;
69 
71  bool has_name() const;
72 
74  void set_name(const std::string & name_);
75 
77  const std::string & get_name() const;
78 
80  const datatools::properties & parameters() const;
81 
84 
86  i_model(const std::string & dummy_ = "");
87 
89  virtual ~i_model();
90 
92  virtual void tree_dump(std::ostream & out_ = std::clog,
93  const std::string & title_ = "",
94  const std::string & indent_ = "",
95  bool inherit_ = false) const;
96 
98  const geomtools::logical_volume & get_logical() const;
99 
102 
104  virtual void construct(const std::string & name_,
105  const datatools::properties & setup_,
106  models_col_type * models_ = 0);
107 
109  virtual void construct(const std::string & name_,
110  const datatools::properties & setup_,
111  const std::vector<std::string> & properties_prefixes_,
112  models_col_type * models_);
113 
115  virtual std::string get_model_id() const = 0;
116 
119 
122 
124  bool is_debug() const;
125 
127  void set_debug(bool);
128 
131 
133  bool has_shape_factory() const;
134 
137 
140 
142  const shape_factory & get_shape_factory() const;
143 
144  protected:
145 
147  void _set_phantom_solid(bool);
148 
151 
153  virtual void _pre_construct(datatools::properties & setup_, models_col_type * models_);
154 
156  virtual void _at_construct(const std::string & name_,
157  const datatools::properties & setup_,
158  models_col_type * models_ = 0) = 0;
159 
161  virtual void _post_construct(datatools::properties & setup_, models_col_type * models_);
162 
165 
166  protected:
167 
171 
172  private:
173 
174  bool _constructed_;
175  datatools::properties _parameters_;
176  std::string _name_;
178 
179  // Work:
180  shape_factory * _shape_factory_;
181 
182 
183  public:
184 
185  static std::string make_solid_name(const std::string & basename_);
186 
187  static std::string make_logical_volume_name(const std::string & basename_);
188 
189  static std::string make_physical_volume_name(const std::string & basename_);
190 
191  static std::string make_physical_volume_name_per_item(const std::string & basename_,
192  int i_);
193 
194  static std::string make_physical_volume_name_per_item(const std::string & basename_,
195  int i_, int j_);
196 
197  static std::string make_physical_volume_name(const std::string & basename_,
198  int nitems_);
199 
200  static std::string make_physical_volume_name(const std::string & basename_,
201  int ncols_,
202  int nrows_);
203 
204  static std::string extract_label_from_physical_volume_name(const std::string & physical_volume_name_);
205 
206  // Factory stuff :
208 
209  }; // class i_model
210 
211 } // end of namespace geomtools
212 
213 #include <geomtools/model_macros.h>
214 
215 #endif // GEOMTOOLS_I_MODEL_H
216 
217 /*
218 ** Local Variables: --
219 ** mode: c++ --
220 ** c-file-style: "gnu" --
221 ** tab-width: 2 --
222 ** End: --
223 */
bool has_shape_factory() const
Check if an external shape factory is referenced.
static std::string make_solid_name(const std::string &basename_)
bool is_constructed() const
Check if the construction of the geometry model is completed.
The base class for geometry models.
Definition: i_model.h:45
virtual void _pre_construct(datatools::properties &setup_, models_col_type *models_)
Pre-construction hook.
priority
Priority levels for logging from most to least critical.
Definition: logger.h:82
The factory of shapes.
Definition: shape_factory.h:36
virtual void _post_construct(datatools::properties &setup_, models_col_type *models_)
Post-construction hook.
virtual void _at_construct(const std::string &name_, const datatools::properties &setup_, models_col_type *models_=0)=0
The main construction hook.
static void init_ocd(datatools::object_configuration_description &ocd_)
OCD support.
bool is_debug() const
Check for debug logging priority threshold.
static const std::string & solid_suffix()
void _set_phantom_solid(bool)
Set the phantom solid flag.
const model_with_internal_mesh_data & get_meshes() const
i_model(const std::string &dummy_="")
Constructor.
const geomtools::logical_volume & get_logical() const
Get a non mutable reference to the embedded logical volume.
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
Handler to add daughter volumes on a regular 3D mesh in a mother logical volume.
Definition: model_with_internal_mesh_tools.h:44
void set_shape_factory(shape_factory &)
Set a reference to an external shape factory.
A logical geometry volume (ala GDML)
Definition: logical_volume.h:40
std::map< std::string, i_model * > models_col_type
Type alias for dictionary of geometry model plain handles.
Definition: model_tools.h:29
An object that describes the way an object of a given class can be configured through properties.
Definition: object_configuration_description.h:234
void _mandatory_pre_construct(datatools::properties &setup_, models_col_type *models_)
Mandatory pre construction.
void set_logging_priority(datatools::logger::priority)
Set the logging priority threshold.
datatools::logger::priority get_logging_priority() const
Get the logging priority threshold.
void set_debug(bool)
Force the debug logging priority threshold.
static std::string make_physical_volume_name_per_item(const std::string &basename_, int i_)
geomtools::logical_volume & grab_logical()
Get a mutable reference to the embedded logical volume.
static std::string extract_label_from_physical_volume_name(const std::string &physical_volume_name_)
static const std::string & exported_properties_prefixes_key()
virtual ~i_model()
Destructor.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
bool has_name() const
Check if the name of the geometry model exists.
void _mandatory_post_construct(datatools::properties &setup_, models_col_type *models_)
Mandatory post construction.
geomtools::models_col_type models_col_type
The collection of geometry models:
Definition: i_model.h:58
static std::string make_physical_volume_name(const std::string &basename_)
static const std::string & physical_suffix()
const datatools::properties & parameters() const
Configuration parameters (should be get_)
void set_name(const std::string &name_)
Set the name of the geometry model.
virtual void construct(const std::string &name_, const datatools::properties &setup_, models_col_type *models_=0)
Method that constructs the geometry model.
Utilities for logging information.
const shape_factory & get_shape_factory() const
Return a reference to an external shape factory.
static std::string make_logical_volume_name(const std::string &basename_)
static const std::string & phantom_solid_flag()
datatools::logger::priority _logging_priority
Logging priority threshold.
Definition: i_model.h:168
geomtools::logical_volume _logical
Top logical volume attached to the model.
Definition: i_model.h:170
bool _phantom_solid
Special flag (not used yet)
Definition: i_model.h:169
virtual std::string get_model_id() const =0
Get the model ID.
#define DATATOOLS_FACTORY_SYSTEM_REGISTER_INTERFACE(BaseType)
Declaration of a system (allocator/functor) factory register as a static member of a base class and s...
Definition: factory_macros.h:52
model_with_internal_mesh_data & grab_meshes()
static const std::string & logical_suffix()
shape_factory & grab_shape_factory()
Return a reference to an external shape factory.
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39
const std::string & get_name() const
Get the name of the geometry model.
A dictionary of arbitrary properties.
Definition: properties.h:125
bool is_phantom_solid() const
Check if the geometry model is "phantom".