Bayeux  3.4.1
Core Foundation library for SuperNEMO
step_hit_processor_factory.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2010-06-04
4  * Last modified: 2014-04-30
5  *
6  * License:
7  *
8  * Description:
9  *
10  * Step hit processor factory
11  *
12  */
13 
14 #ifndef MCTOOLS_STEP_HIT_PROCESSOR_FACTORY_H
15 #define MCTOOLS_STEP_HIT_PROCESSOR_FACTORY_H 1
16 
17 // Standard library:
18 #include <sstream>
19 #include <string>
20 #include <map>
21 #include <stdexcept>
22 #include <set>
23 
24 // Third party:
25 // - Bayeux/datatools:
26 #include <datatools/ioutils.h>
27 #include <datatools/properties.h>
29 #include <datatools/handle.h>
30 #include <datatools/i_tree_dump.h>
31 
32 // This project:
34 
35 namespace datatools {
36  class properties;
37  class service_manager;
38 }
39 
40 namespace mygsl {
41  class rng;
42 }
43 
44 namespace mctools {
45 
49  {
50  public:
51 
53 
56  std::string name;
57  std::string type;
60  virtual ~processor_entry_type();
61  void reset();
62  };
63  typedef std::map<std::string, processor_entry_type> processor_entry_dict_type;
64  typedef std::map<std::string, base_step_hit_processor *> processor_dict_type;
65 
67  static const std::string & default_detailed_hit_collection();
68 
70  static const std::string & matching_output_profiles_key();
71 
73  bool is_initialized () const;
74 
76  const std::string & get_description () const;
77 
79  void set_description (const std::string & description_);
80 
82  bool has_geometry_manager () const;
83 
85  void set_geometry_manager (const geomtools::manager & gmgr_);
86 
89 
91  bool has_service_manager () const;
92 
95 
98 
101 
103  void set_instantiate_at_loading(bool);
104 
106  bool has_external_prng () const;
107 
109  void set_external_prng (mygsl::rng & prng_);
110 
113 
115  void set_output_profiles(const std::set<std::string> & output_profiles_);
116 
118  void reset_output_profiles();
119 
121  void initialize();
122 
124  void initialize(const datatools::properties & config_);
125 
127  void reset ();
128 
131 
133  virtual ~step_hit_processor_factory ();
134 
135  // /// Returns the mutable dictionary of instantiated processors
136  // processor_dict_type & grab_processors ();
137 
140  const processor_dict_type & get_processors () const;
141 
143  void fetch_processor_names(std::vector<std::string> & vprocs_, bool only_instantiated_ = false) const;
144 
146  bool create(const std::string & name_,
147  const std::string & type_,
148  const datatools::properties & config_);
149 
151  bool has_processor (const std::string & name_) const;
152 
154  bool is_processor_instantiated(const std::string & name_) const;
155 
157  bool is_processor_instantiable(const std::string & name_) const;
158 
160  base_step_hit_processor & grab_processor (const std::string & name_);
161 
163  const base_step_hit_processor & get_processor (const std::string & name_) const;
164 
166  void dump (std::ostream & out_) const;
167 
169  virtual void tree_dump (std::ostream & out_ = std::clog,
170  const std::string & title_ = "",
171  const std::string & indent_ = "",
172  bool inherit_ = false) const;
173 
175  void load (const datatools::multi_properties & mprop_);
176 
179 
182 
183  protected:
184 
186  base_step_hit_processor * _create(const std::string & name_);
187 
189  void _initialize();
190 
191  private:
192 
193  base_step_hit_processor::factory_register_type _factory_register_;
194 
195  bool _initialized_ = false;
196  datatools::logger::priority _logging_priority_;
197  std::string _description_;
198  datatools::service_manager * _service_manager_ = nullptr;
199  const geomtools::manager * _geom_manager_ = nullptr;
200  mygsl::rng * _external_prng_ = nullptr;
201  std::set<std::string> _output_profiles_;
202  bool _instantiate_at_loading_ = false;
203  processor_entry_dict_type _entries_;
204  processor_dict_type _processors_;
205 
206  };
207 
208 
209 } // end of namespace mctools
210 
211 
212 /***************
213  * OCD support *
214  ***************/
215 #include <datatools/ocd_macros.h>
217 
218 #endif // MCTOOLS_STEP_HIT_PROCESSOR_FACTORY_H
219 
220 // Local Variables: --
221 // mode: c++ --
222 // c-file-style: "gnu" --
223 // tab-width: 2 --
224 // End: --
void reset_output_profiles()
Reset output profiles.
bool is_processor_instantiable(const std::string &name_) const
Check if a processor can be instantiated with respect to the setup (output profiles....
static const std::string & matching_output_profiles_key()
Property key for the set of output profiles a processor is associated to.
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
Definition: base_step_hit.h:32
std::string name
Definition: step_hit_processor_factory.h:56
void set_service_manager(datatools::service_manager &smgr_)
Set the service manager.
virtual ~processor_entry_type()
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
static const std::string & default_detailed_hit_collection()
Default name for the output collection of detailed hits (a.k.a. "visu tracks")
const processor_dict_type & get_processors() const
void dump(std::ostream &out_) const
Default print.
bool is_processor_instantiated(const std::string &name_) const
Check if a processor is instantiated.
bool has_processor(const std::string &name_) const
Check if a processor exists given its name.
const std::string & get_description() const
Returns the description.
bool has_external_prng() const
Check for a PRNG.
void set_geometry_manager(const geomtools::manager &gmgr_)
Set the geometry manager.
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_service_manager() const
Check for an existing service manager.
void reset()
datatools::handle< base_step_hit_processor > processor_handle_type
Definition: step_hit_processor_factory.h:52
const datatools::service_manager & get_service_manager() const
Return a non mutable reference to the service manager.
base_step_hit_processor & grab_processor(const std::string &name_)
Returns a mutable reference to a given processor addressed by its by name.
A processor entry in the factory's embedded dictionary.
Definition: step_hit_processor_factory.h:55
void load(const datatools::multi_properties &mprop_)
Load a configuration object.
void set_logging_priority(datatools::logger::priority)
Set the logging priority threshold.
datatools::service_manager & grab_service_manager()
Return a mutable reference to the service manager.
step_hit_processor_factory(datatools::logger::priority logging_=datatools::logger::PRIO_WARNING)
Constructor.
const base_step_hit_processor & get_processor(const std::string &name_) const
Returns a non mutable reference to a given processor addressed by its by name.
Definition: base_step_hit_processor.h:50
void set_external_prng(mygsl::rng &prng_)
Set the PRNG.
bool is_initialized() const
Check the initialization flag.
mygsl::rng & grab_external_prng()
Get a mutable reference to the PRNG.
DOCD_CLASS_DECLARATION(my::algo)
Declaration of the OCD support for the my::algo class.
virtual ~step_hit_processor_factory()
Destructor.
The factory responsible of the step hit processors.
Definition: step_hit_processor_factory.h:47
void set_instantiate_at_loading(bool)
Set the flag for instantiation of processor at load stage.
Top-level namespace of the Bayeux/mygsl module library.
Definition: base_decay_driver.h:47
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
Geometry manager for virtual geometry modelling. Main geometry manager for the modelisation of variou...
Definition: manager.h:70
datatools::logger::priority get_logging_priority() const
Return the logging priority threshold.
void set_description(const std::string &description_)
Set the description.
void fetch_processor_names(std::vector< std::string > &vprocs_, bool only_instantiated_=false) const
Build the list of names of the processors managed by the factory.
const geomtools::manager & get_geometry_manager() const
Return a non mutable reference to the geometry manager.
bool has_geometry_manager() const
Check for an existing geometry manager.
A warning. An operation completed with an unexpected result.
Definition: logger.h:88
void set_output_profiles(const std::set< std::string > &output_profiles_)
Set output profiles.
datatools::properties config
Definition: step_hit_processor_factory.h:58
std::map< std::string, base_step_hit_processor * > processor_dict_type
Definition: step_hit_processor_factory.h:64
processor_handle_type handle
Definition: step_hit_processor_factory.h:59
base_step_hit_processor * _create(const std::string &name_)
Instantiate a processor object.
void initialize()
Initialization method.
std::string type
Definition: step_hit_processor_factory.h:57
void _initialize()
Initialization method.
Service management class.
Definition: service_manager.h:57
std::map< std::string, processor_entry_type > processor_entry_dict_type
Definition: step_hit_processor_factory.h:63
Pseudo random number generator.
Definition: rng.h:53
bool create(const std::string &name_, const std::string &type_, const datatools::properties &config_)
Create a processor object.
A dictionary of arbitrary properties.
Definition: properties.h:125