Bayeux  3.4.1
Core Foundation library for SuperNEMO
manager.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2010-09-22
4  * Last modified: 2016-02-11
5  *
6  * License:
7  *
8  * Description:
9  *
10  * A manager for isotopes, elements and materials (and material aliases)
11  *
12  * History:
13  *
14  */
15 
16 #ifndef MATERIALS_MANAGER_H
17 #define MATERIALS_MANAGER_H 1
18 
19 // Standard library:
20 #include <ostream>
21 #include <string>
22 #include <list>
23 #include <set>
24 
25 // Third party:
26 // - Boost:
27 #include <boost/scoped_ptr.hpp>
28 // - Bayeux/datatools:
29 #include <datatools/logger.h>
30 
31 // This project:
32 //#include <materials/factory.h>
33 #include <materials/isotope.h>
34 #include <materials/element.h>
35 #include <materials/material.h>
36 #include <materials/detail/tools.h>
37 
38 namespace datatools {
39  // Forward declaration:
40  class multi_properties;
41 }
42 
43 namespace materials {
44 
45  // Forward declaration:
46  class factory;
47 
54  {
55  public:
56 
58  static bool validate_name_for_gdml(const std::string & candidate_);
59 
61  manager();
62 
64  virtual ~manager();
65 
67  bool is_initialized() const;
68 
70  bool is_debug() const;
71 
73  void set_debug(bool);
74 
76  bool is_locked() const;
77 
79  bool is_alias_of_alias_allowed() const;
80 
82  void set_alias_of_alias_allowed(bool aoaa_);
83 
85  bool is_alias_allow_overload() const;
86 
88  void set_alias_allow_overload(bool aao_);
89 
91  bool has_isotope(const std::string & entry_name_) const;
92 
94  const isotope & get_isotope(const std::string & entry_name_) const;
95 
97  bool has_element(const std::string & entry_name_) const;
98 
100  const element & get_element(const std::string & entry_name_) const;
101 
103  bool has_material(const std::string & entry_name_) const;
104 
106  const material & get_material(const std::string & entry_name_) const;
107 
109  bool is_alias(const std::string & entry_name_) const;
110 
112  std::string alias_of(const std::string & entry_name_) const;
113 
115  const isotope_dict_type & get_isotopes() const;
116 
118  const element_dict_type & get_elements() const;
119 
121  const material_dict_type & get_materials() const;
122 
124  const std::list<std::string> & get_ordered_materials() const;
125 
127  void load(const datatools::multi_properties & config_);
128 
130  void initialize(const datatools::properties & setup_);
131 
133  void reset();
134 
136  void lock();
137 
139  void unlock();
140 
142  virtual void tree_dump(std::ostream & out_ = std::clog,
143  const std::string & title_ = "",
144  const std::string & indent_ = "",
145  bool inherit_ = false) const;
146 
149 
152 
154  bool is_load_isotope_mass_data() const;
155 
157  void set_load_isotope_mass_data(bool);
158 
160  bool is_load_isotope_decay_data() const;
161 
163  void set_load_isotope_decay_data(bool);
164 
166 
176  void add_material_exported_prefix(const std::string &);
177 
179  const std::set<std::string> & get_material_exported_prefixes() const;
180 
181  protected:
182 
184  void _set_defaults();
185 
186  private:
187 
188  // Management:
189  bool _locked_;
190  datatools::logger::priority _logging_priority_;
191  // Configuration attributes:
192  bool _load_isotope_mass_data_;
193  bool _load_isotope_decay_data_;
194  std::set<std::string> _material_exported_prefixes_;
195  bool _alias_allow_overload_;
196  bool _alias_of_alias_allowed_;
197  // Dynamic attributes:
198  boost::scoped_ptr<factory> _creator_;
199  isotope_dict_type _isotopes_;
200  element_dict_type _elements_;
201  material_dict_type _materials_;
202  std::list<std::string> _ordered_materials_;
203 
204  };
205 
206 } // end of namespace materials
207 
208 /***************
209  * OCD support *
210  ***************/
211 #include <datatools/ocd_macros.h>
213 
214 #endif // MATERIALS_MANAGER_H
215 
216 /*
217 ** Local Variables: --
218 ** mode: c++ --
219 ** c-file-style: "gnu" --
220 ** tab-width: 2 --
221 ** End: --
222 */
bool is_initialized() const
Check initialization flag.
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
bool has_material(const std::string &entry_name_) const
Check if a given material is defined.
std::map< std::string, smart_ref< element > > element_dict_type
Definition: tools.h:149
const element & get_element(const std::string &entry_name_) const
Return a reference to a element, given its name.
static bool validate_name_for_gdml(const std::string &candidate_)
Validate a name for isotope, element or material with respect to forseen GDML export.
bool is_load_isotope_mass_data() const
Test the flag to load mass data for isotopes.
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
const std::set< std::string > & get_material_exported_prefixes() const
Return the set of exported property prefixes for materials.
bool is_alias_of_alias_allowed() const
Check if alias of alias are allowed.
void reset()
Reset.
void set_alias_allow_overload(bool aao_)
Set the alias overloading flag.
bool has_element(const std::string &entry_name_) const
Check if a given element is defined.
const material_dict_type & get_materials() const
Return the dictionary of materials.
void set_alias_of_alias_allowed(bool aoaa_)
Set the alias of alias allow flag.
The manager object for isotopes, elements and materials.
Definition: manager.h:53
void _set_defaults()
Set default values to attributes.
manager()
Default constructor.
void lock()
Lock the manager.
std::map< std::string, smart_ref< isotope > > isotope_dict_type
Definition: tools.h:146
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_isotope(const std::string &entry_name_) const
Check if a given isotope is defined.
DOCD_CLASS_DECLARATION(my::algo)
Declaration of the OCD support for the my::algo class.
bool is_alias(const std::string &entry_name_) const
Check if an alias with given name is defined.
virtual ~manager()
Destructor.
void set_logging_priority(datatools::logger::priority)
Set logging priority.
void load(const datatools::multi_properties &config_)
Load a configuration file.
void initialize(const datatools::properties &setup_)
Initialize.
std::map< std::string, smart_ref< material > > material_dict_type
Definition: tools.h:150
std::string alias_of(const std::string &entry_name_) const
Return the material name of which an alias is associated.
A simple class to handle known isotopes (ZAI) and their basic properties (mass & decays).
Definition: isotope.h:60
void unlock()
Unlock the manager.
const isotope_dict_type & get_isotopes() const
Return the dictionary of isotopes.
bool is_load_isotope_decay_data() const
Test the flag to load decay data for isotopes.
void set_debug(bool)
Set debug flag.
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
Utilities for logging information.
const isotope & get_isotope(const std::string &entry_name_) const
Return a reference to a isotope, given its name.
void set_load_isotope_mass_data(bool)
Set the flag to load mass data for isotopes.
void add_material_exported_prefix(const std::string &)
Add an exported property prefix for materials.
const element_dict_type & get_elements() const
Return the dictionary of elements.
const material & get_material(const std::string &entry_name_) const
Return a reference to a material, given its name.
bool is_alias_allow_overload() const
Check if aliases can be overloaded by other aliases declared after them.
void set_load_isotope_decay_data(bool)
Set the flag to load decay data for isotopes.
The description of a material.
Definition: material.h:116
const std::list< std::string > & get_ordered_materials() const
Return the ordered list of materials.
datatools::logger::priority get_logging_priority() const
Return the logging priority.
bool is_debug() const
Check debug flag.
The description of an element.
Definition: element.h:93
Top-level namespace of the Bayeux/materials module library.
Definition: geom_manager_utils.h:14
bool is_locked() const
Check lock flag.
A dictionary of arbitrary properties.
Definition: properties.h:125