Bayeux  3.4.1
Core Foundation library for SuperNEMO
shape_factory.h
Go to the documentation of this file.
1 /* Author (s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2015-02-03
4  * Last modified: 2015-02-03
5  *
6  * License:
7  *
8  * Description:
9  * Factory for shapes (3D objects)
10  *
11  * History:
12  *
13  */
14 
15 #ifndef GEOMTOOLS_SHAPE_FACTORY_H
16 #define GEOMTOOLS_SHAPE_FACTORY_H 1
17 
18 // Standard library:
19 #include <iostream>
20 #include <string>
21 #include <map>
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:
31 #include <geomtools/i_object_3d.h>
32 
33 namespace geomtools {
34 
37  {
38  public:
39 
41  shape_factory();
42 
44  virtual ~shape_factory();
45 
48 
50  i_object_3d & create(const std::string & name_,
51  const std::string & type_id_,
52  const datatools::properties & config_,
53  bool store_ = true);
54 
56  i_object_3d * create_ptr(const std::string & name_,
57  const std::string & type_id_,
58  const datatools::properties & config_);
59 
61  bool has(const std::string & name_, const std::string & type_id_ = "") const;
62 
64  const i_object_3d & get(const std::string & name_) const;
65 
67  void keys(std::vector<std::string> & keys_) const;
68 
71 
74 
76  bool is_initialized() const;
77 
79  void initialize_simple();
80 
82  void initialize(const datatools::properties & config_);
83 
85  void reset();
86 
88  void load(const std::string & shapes_def_file_);
89 
91  void load_list(const std::string & list_file_);
92 
94  void parse_shapes(const datatools::properties & defs_);
95 
97  virtual void tree_dump(std::ostream & out_ = std::clog,
98  const std::string & title_ = "",
99  const std::string & indent_ = "",
100  bool inherit_ = false) const;
101 
102  protected:
103 
105  void _at_init();
106 
108  i_object_3d * _create(const std::string & name_,
109  const std::string & type_id_,
110  const datatools::properties & config_,
111  bool store_);
112 
113  private:
114 
115  datatools::logger::priority _logging_priority_;
116  bool _initialized_;
117  i_object_3d::factory_register_type _factory_register_;
119 
120  };
121 
122 } // end of namespace geomtools
123 
124 /***************
125  * OCD support *
126  ***************/
127 #include <datatools/ocd_macros.h>
129 
130 #endif // GEOMTOOLS_SHAPE_FACTORY_H
131 
132 /*
133 ** Local Variables: --
134 ** mode: c++ --
135 ** c-file-style: "gnu" --
136 ** tab-width: 2 --
137 ** End: --
138 */
Mother abstract class for all 3D object classes.
Definition: i_object_3d.h:49
i_object_3d * _create(const std::string &name_, const std::string &type_id_, const datatools::properties &config_, bool store_)
Create a new 3D object and return the pointer to it.
priority
Priority levels for logging from most to least critical.
Definition: logger.h:82
The factory of shapes.
Definition: shape_factory.h:36
i_object_3d * create_ptr(const std::string &name_, const std::string &type_id_, const datatools::properties &config_)
Create a new 3D object and return the pointer to it.
void load(const std::string &shapes_def_file_)
Load a shapes definition file.
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
i_object_3d & create(const std::string &name_, const std::string &type_id_, const datatools::properties &config_, bool store_=true)
Create a new 3D object and return the reference to it.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
datatools::logger::priority get_logging_priority() const
Return the logging priority.
bool has(const std::string &name_, const std::string &type_id_="") const
Check if a shape with given name and optional type exists.
void parse_shapes(const datatools::properties &defs_)
Parse a container of properties and extract a set of shapes from it.
void keys(std::vector< std::string > &keys_) const
Build the list of shapes' names.
DOCD_CLASS_DECLARATION(my::algo)
Declaration of the OCD support for the my::algo class.
void initialize_simple()
Simple initialization.
virtual ~shape_factory()
Destructor.
std::map< std::string, object_entry > handle_dict_type
Dictionary of handle of 3D object entries.
Definition: i_object_3d.h:124
const i_object_3d & get(const std::string &name_) const
Get a reference to the const shape given its name.
void set_logging_priority(datatools::logger::priority)
Set the logging priority.
Utilities for logging information.
void initialize(const datatools::properties &config_)
Initialization.
void load_list(const std::string &list_file_)
Load a file that contains a list of shapes definition filenames :
void _at_init()
Initialization action.
const i_object_3d::handle_dict_type & get_shapes() const
Return a reference to a non mutable dictionary of shapes.
shape_factory()
Default constructor.
bool is_initialized() const
Check initialization flag.
Top-level namespace of the Bayeux/geomtools module library.
Definition: electromagnetic_field_manager.h:39
A dictionary of arbitrary properties.
Definition: properties.h:125