Bayeux  3.4.1
Core Foundation library for SuperNEMO
cut_manager.h
Go to the documentation of this file.
1 
3 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
4  * Creation date : 2011-06-22
5  * Last modified : 2013-05-17
6  *
7  * Copyright (C) 2011-2013 Francois Mauger <mauger@lpccaen.in2p3.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or (at
12  * your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  * Boston, MA 02110-1301, USA.
23  *
24  * Description:
25  *
26  * A generic manager for cuts on arbitrary data.
27  *
28  * History:
29  *
30  */
31 
32 #ifndef CUTS_CUT_MANAGER_H
33 #define CUTS_CUT_MANAGER_H 1
34 
35 // Standard library:
36 #include <string>
37 
38 // Third party:
39 // - Boost:
40 #include <boost/cstdint.hpp>
41 // - Bayeux/datatools:
42 #include <datatools/i_tree_dump.h>
43 #include <datatools/properties.h>
44 #include <datatools/logger.h>
45 
46 // This project:
47 #include <cuts/i_cut.h>
48 #include <cuts/cut_tools.h>
49 
50 // Forward declaration :
51 namespace datatools {
52  class multi_properties;
53  class service_manager;
54 }
55 
56 namespace cuts {
57 
60 
61  {
62  public:
63 
66  BLANK = 0,
69  };
70 
73 
76 
78  bool is_no_preload() const;
79 
81  bool is_initialization_at_load() const;
82 
84  bool has_print_report() const;
85 
87  bool has(const std::string & a_cut_name) const;
88 
90  void remove(const std::string & a_cut_name);
91 
93  i_cut & grab(const std::string & a_cut_name);
94 
96  const i_cut & get(const std::string & a_cut_name) const;
97 
100 
102  const cut_handle_dict_type & get_cuts() const;
103 
105  bool is_initialized() const;
106 
108  void initialize(const datatools::properties & a_setup);
109 
111  void reset();
112 
114  cut_manager(uint32_t the_flags = BLANK);
115 
117  virtual ~cut_manager();
118 
120  bool has_service_manager() const;
121 
124 
127 
129  void set_service_manager(datatools::service_manager & a_service_manager);
130 
132  void install_service_manager(const datatools::properties & a_service_manager_configuration);
133 
135  virtual void tree_dump(std::ostream & a_out = std::clog,
136  const std::string & a_title = "",
137  const std::string & a_indent = "",
138  bool a_inherit = false) const;
139 
141  void print_report(std::ostream & a_out = std::clog) const;
142 
144  void load_cut(const std::string & cut_name_,
145  const std::string & cut_id_,
146  const datatools::properties & cut_config_);
147 
149  void load_cuts(const datatools::multi_properties & cuts_config_);
150 
152  bool has_cut_type(const std::string & cut_id_) const;
153 
155  template <class CutClass>
156  void register_cut_type(const std::string & cut_id_)
157  {
158  _factory_register_.registration(cut_id_, boost::factory<CutClass*>());
159  return;
160  }
161 
163  void unregister_cut_type(const std::string & cut_id_);
164 
165  protected:
166 
167  void _load_cut(const std::string & cut_name_,
168  const std::string & cut_id_,
169  const datatools::properties & cut_config_);
170 
171  void _load_cuts(const datatools::multi_properties & cuts_config_);
172 
173  void _create_cut(cut_entry_type & cut_entry_);
174 
175  void _initialize_cut(cut_entry_type & cut_entry_);
176 
177  void _reset_cut(cut_entry_type & cut_entry_);
178 
179  void _preload_global_dict();
180 
181  private:
182 
183  datatools::logger::priority _logging_;
184  bool _initialized_;
185  uint32_t _flags_;
186  i_cut::factory_register_type _factory_register_;
187  cut_handle_dict_type _cuts_;
188  bool _service_manager_owner_;
189  datatools::service_manager * _service_manager_;
190  bool _print_report_;
191  ordered_cut_list_type _ordered_cuts_;
192 
193  friend class cut_entry_type;
194  };
195 
196 } // end of namespace cuts
197 
198 
199 /***************
200  * OCD support *
201  ***************/
202 #include <datatools/ocd_macros.h>
204 
205 #endif // CUTS_CUT_MANAGER_H
206 
207 /*
208 ** Local Variables: --
209 ** mode: c++ --
210 ** c-file-style: "gnu" --
211 ** tab-width: 2 --
212 ** End: --
213 */
datatools::logger::priority get_logging_priority() const
Returns logging priority.
bool is_no_preload() const
Check the 'no-preload' 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
void initialize(const datatools::properties &a_setup)
Initialization.
cut_manager(uint32_t the_flags=BLANK)
Default constructor.
bool has_cut_type(const std::string &cut_id_) const
Check if a given cut factory is registered.
virtual ~cut_manager()
Destructor.
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
The cut abstract base class (interface)
Definition: i_cut.h:62
static const uint32_t bit01
Definition: bit_mask.h:28
void load_cut(const std::string &cut_name_, const std::string &cut_id_, const datatools::properties &cut_config_)
Load a cut.
void set_logging_priority(datatools::logger::priority p)
Set logging priority.
Definition: cut_manager.h:66
const i_cut & get(const std::string &a_cut_name) const
Return a non mutable reference to a cut given its name.
void _reset_cut(cut_entry_type &cut_entry_)
virtual void tree_dump(std::ostream &a_out=std::clog, const std::string &a_title="", const std::string &a_indent="", bool a_inherit=false) const
Smart print.
Top-level namespace of the Bayeux/cuts module library.
Definition: accept_cut.h:21
void remove(const std::string &a_cut_name)
Remove cut with given name.
void install_service_manager(const datatools::properties &a_service_manager_configuration)
Install an embedded service manager.
bool has_service_manager() const
Check availability of the service manager.
void load_cuts(const datatools::multi_properties &cuts_config_)
Load several cuts.
cut_handle_dict_type & get_cuts()
Return a mutable reference to the embedded dictionary of cuts.
void _load_cuts(const datatools::multi_properties &cuts_config_)
ctor_flag_type
Factory flags.
Definition: cut_manager.h:65
DOCD_CLASS_DECLARATION(my::algo)
Declaration of the OCD support for the my::algo class.
The cut manager class.
Definition: cut_manager.h:59
void register_cut_type(const std::string &cut_id_)
Register a cut factory.
Definition: cut_manager.h:156
bool is_initialized() const
Check initialization flag.
std::vector< std::string > ordered_cut_list_type
Alias type of an array of cut names.
Definition: cut_tools.h:178
Internal record that handles a dynamically allocated cut.
Definition: cut_tools.h:75
bool has(const std::string &a_cut_name) const
Check if cut with given name is defined.
void _preload_global_dict()
datatools::service_manager & grab_service_manager()
Return a mutable reference to the service manager.
void print_report(std::ostream &a_out=std::clog) const
Print report.
const datatools::service_manager & get_service_manager() const
Return a non mutable reference to the service manager.
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
void _initialize_cut(cut_entry_type &cut_entry_)
Utilities for logging information.
void reset()
Reset.
bool is_initialization_at_load() const
Check the 'initialization_at_load' flag.
void set_service_manager(datatools::service_manager &a_service_manager)
Set service manager.
std::map< std::string, cut_entry_type > cut_handle_dict_type
Alias type of a dictionary of cut entry.
Definition: cut_tools.h:175
void unregister_cut_type(const std::string &cut_id_)
Unregister a cut factory.
static const uint32_t bit00
Definition: bit_mask.h:27
Definition: cut_manager.h:67
void _create_cut(cut_entry_type &cut_entry_)
bool has_print_report() const
Check if print report is available.
i_cut & grab(const std::string &a_cut_name)
Return a mutable reference to a cut given its name.
Service management class.
Definition: service_manager.h:57
void _load_cut(const std::string &cut_name_, const std::string &cut_id_, const datatools::properties &cut_config_)
A dictionary of arbitrary properties.
Definition: properties.h:125