Bayeux  3.4.1
Core Foundation library for SuperNEMO
model_factory.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2010-02-24
4  * Last modified: 2010-02-24
5  *
6  * License:
7  *
8  * Description:
9  * Factory for geometry models
10  *
11  * History:
12  *
13  */
14 
15 #ifndef GEOMTOOLS_MODEL_FACTORY_H
16 #define GEOMTOOLS_MODEL_FACTORY_H 1
17 
18 // Standard library:
19 #include <iostream>
20 #include <string>
21 #include <vector>
22 
23 // Third party:
24 // - Bayeux/datatools:
26 #include <datatools/i_tree_dump.h>
27 #include <datatools/factory.h>
28 #include <datatools/logger.h>
29 
30 // This project:
32 #include <geomtools/i_model.h>
33 
34 namespace geomtools {
35 
36  // Forward declaration:
37  class shape_factory;
38 
41  {
42  public:
43 
45  static const std::string & default_world_label();
46 
48  static bool validate_name_for_gdml(const std::string & candidate_);
49 
51  bool is_locked() const;
52 
55 
58 
60  bool is_debug() const;
61 
63  bool is_trace() const;
64 
66  void set_debug(bool);
67 
69  const datatools::multi_properties & get_mp() const;
70 
73 
75  const models_col_type & get_models() const;
76 
79 
82 
84  model_factory(bool debug_, bool core_factory_verbose_ = false);
85 
87  virtual ~model_factory();
88 
90  void load(const std::string & mprop_file_);
91 
93  void load_geom_list(const std::string & geom_list_file_);
94 
96  void lock();
97 
99  void unlock();
100 
102  void reset();
103 
105  void add_property_prefix(const std::string & prefix_);
106 
108  const std::vector<std::string> & get_property_prefixes() const;
109 
111  virtual void tree_dump(std::ostream & out_ = std::clog,
112  const std::string & title_ = "",
113  const std::string & indent_ = "",
114  bool inherit_ = false) const;
115 
117  bool has_shape_factory() const;
118 
121 
124 
126  const shape_factory & get_shape_factory() const;
127 
129  static int print_list_of_models(const geomtools::model_factory & mf_,
130  const std::string & command_,
131  const std::string & argv_ = "",
132  std::ostream & out_ = std::clog);
133 
135  static int print_list_of_logicals(const geomtools::model_factory & mf_,
136  const std::string & command_,
137  const std::string & argv_ = "",
138  std::ostream & out_ = std::clog);
139 
140  private:
141 
143  void _basic_construct_();
144 
146  void _lock_();
147 
149  void _unlock_();
150 
152  void _construct_();
153 
154  private:
155 
156  shape_factory * _shape_factory_;
157  i_model::factory_register_type _factory_register_;
158  bool _locked_;
159  datatools::logger::priority _logging_priority_;
161  models_col_type _models_;
162  logical_volume::dict_type _logicals_;
163  std::vector<std::string> _property_prefixes_;
164 
165  };
166 
167 } // end of namespace geomtools
168 
169 /***************
170  * OCD support *
171  ***************/
172 #include <datatools/ocd_macros.h>
174 
175 #endif // GEOMTOOLS_MODEL_FACTORY_H
176 
177 /*
178 ** Local Variables: --
179 ** mode: c++ --
180 ** c-file-style: "gnu" --
181 ** tab-width: 2 --
182 ** End: --
183 */
bool is_trace() const
Check the logging trace flag.
void unlock()
Unlock the geometry model factory.
static bool validate_name_for_gdml(const std::string &candidate_)
Validate a name for logical volume with respect to forseen GDML export.
shape_factory & grab_shape_factory()
Return a reference to an external shape factory.
priority
Priority levels for logging from most to least critical.
Definition: logger.h:82
A container of mapped properties objects.
Definition: multi_properties.h:99
void add_property_prefix(const std::string &prefix_)
Add a property prefix to be preserved in logicals.
The factory of shapes.
Definition: shape_factory.h:36
static int print_list_of_logicals(const geomtools::model_factory &mf_, const std::string &command_, const std::string &argv_="", std::ostream &out_=std::clog)
Print the list of geometry logical volumes.
const datatools::multi_properties & get_mp() const
Return a non mutable reference to the embedded multi-container of parameters.
bool has_shape_factory() const
Check if an external shape factory is referenced.
void set_debug(bool)
Set the logging debug flag.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
A fatal error. The application will most likely terminate. This is the highest priority.
Definition: logger.h:85
bool is_locked() const
Check if the factory is locked.
std::map< std::string, i_model * > models_col_type
Type alias for dictionary of geometry model plain handles.
Definition: model_tools.h:29
void set_logging_priority(datatools::logger::priority)
Set the logging priority.
const shape_factory & get_shape_factory() const
Return a reference to an external shape factory.
datatools::logger::priority get_logging_priority() const
Get the logging priority.
virtual ~model_factory()
Destructor.
DOCD_CLASS_DECLARATION(my::algo)
Declaration of the OCD support for the my::algo class.
model_factory(datatools::logger::priority lp_=datatools::logger::PRIO_FATAL)
Constructor.
static const std::string & default_world_label()
Return the default world label used for the top-level logical volume.
datatools::multi_properties & grab_mp()
Return a mutable reference to the embedded multi-container of parameters.
static int print_list_of_models(const geomtools::model_factory &mf_, const std::string &command_, const std::string &argv_="", std::ostream &out_=std::clog)
Print the list of geometry models.
const logical_volume::dict_type & get_logicals() const
Get a non-mutable collection of geometry logicals associated to models.
std::map< std::string, const logical_volume * > dict_type
Definition: logical_volume.h:234
void load_geom_list(const std::string &geom_list_file_)
Load a file that contains a list of geometry models definition filenames :
void lock()
Lock the geometry model factory.
Utilities for logging information.
void set_shape_factory(shape_factory &)
Set a reference to an external shape factory.
The factory of geometry models.
Definition: model_factory.h:40
const models_col_type & get_models() const
Get a non-mutable collection of geometry models.
bool is_debug() const
Check the logging debug flag.
void load(const std::string &mprop_file_)
Load a geometry models definition file.
const std::vector< std::string > & get_property_prefixes() const
Return the array of exported property prefixes.
void reset()
Reset the factory.
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39