Bayeux  3.4.1
Core Foundation library for SuperNEMO
base_module.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date : 2011-06-07
4  * Last modified : 2013-12-13
5  *
6  * Copyright (C) 2011-2013 Francois Mauger <mauger@lpccaen.in2p3.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or (at
11  * your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  *
23  * Description:
24  *
25  * Base data processing module.
26  *
27  */
28 
29 #ifndef DPP_BASE_MODULE_H
30 #define DPP_BASE_MODULE_H 1
31 
32 // Standard library:
33 #include <iostream>
34 #include <string>
35 
36 // Third party:
37 // - Bayeux/datatools:
38 #include <datatools/bit_mask.h>
39 #include <datatools/i_tree_dump.h>
41 #include <datatools/logger.h>
42 #include <datatools/things.h>
43 
44 // This project:
45 #include <dpp/dpp_config.h>
46 #include <dpp/module_tools.h>
47 
48 namespace datatools {
49  // Forward class declarations :
50  class properties;
51  class multi_properties;
52  class service_manager;
53 }
54 
56 namespace dpp {
57 
61  {
62  public:
63 
66  PROCESS_OK = 0,
92  };
93 
96 
98  virtual ~base_module();
99 
101  bool has_name() const;
102 
104  void set_name(const std::string &);
105 
107  const std::string & get_name() const;
108 
110  bool has_description() const;
111 
113  const std::string & get_description() const;
114 
116  void set_description(const std::string & description_);
117 
119  bool has_last_error_message() const;
120 
122  void set_last_error_message(const std::string &);
123 
125  void append_last_error_message(const std::string & errmsg_);
126 
129 
131  const std::string & get_last_error_message() const;
132 
134  bool is_initialized() const;
135 
137  virtual void initialize_simple();
138 
140  virtual void initialize_simple_with_service(datatools::service_manager & service_manager_);
141 
143  virtual void initialize_standalone(const datatools::properties & config_);
144 
146  virtual void initialize_with_service(const datatools::properties & config_,
147  datatools::service_manager & service_manager_);
148 
150  virtual void initialize_without_service(const datatools::properties & config,
151  module_handle_dict_type & module_dictionnary_);
152 
159  virtual void initialize(const datatools::properties & config_,
160  datatools::service_manager & service_manager_,
161  module_handle_dict_type & module_dictionary_) = 0;
162 
167  virtual process_status process(datatools::things & data_model_) = 0;
168 
170  virtual void reset() = 0;
171 
173  virtual void tree_dump(std::ostream & out_ = std::clog,
174  const std::string & title_ = "",
175  const std::string & indent_ = "",
176  bool inherit_ = false) const;
177 
179  void print(std::ostream & out_ = std::clog) const;
180 
183 
186 
189 
190  protected:
191 
193  void _set_name(const std::string & name_);
194 
196  void _set_initialized(bool initialized_);
197 
199  void _common_initialize(const datatools::properties & config_);
200 
201  protected:
202 
203  std::string _name;
204  std::string _description;
206 
208  std::string _last_error_message;
209 
210  // Factory stuff :
212 
213  };
214 
215 } // end of namespace dpp
216 
217 /* Macros for interface/implementation of static creator methods in module classes */
218 
231 #define DPP_MODULE_REGISTRATION_INTERFACE(T) \
232  private: \
233  DATATOOLS_FACTORY_SYSTEM_AUTO_REGISTRATION_INTERFACE(::dpp::base_module,T) \
234 
235 
244 #define DPP_MODULE_REGISTRATION_IMPLEMENT(T,ModuleID) \
245  DATATOOLS_FACTORY_SYSTEM_AUTO_REGISTRATION_IMPLEMENTATION(::dpp::base_module,T,ModuleID) \
246 
247 
248 #endif // DPP_BASE_MODULE_H
249 
250 // Local Variables: --
251 // mode: c++ --
252 // c-file-style: "gnu" --
253 // tab-width: 2 --
254 // End: --
Definition: base_module.h:87
bool has_name() const
Check the module name.
A generic serializable and noncopyable container for arbitrary serializable objects.
Definition: things.h:85
const std::string & get_last_error_message() const
Return the module last error message.
virtual void initialize_standalone(const datatools::properties &config_)
Initialize the module only using a set of parameters.
void append_last_error_message(const std::string &errmsg_)
Append an error message.
priority
Priority levels for logging from most to least critical.
Definition: logger.h:82
Definition: base_module.h:77
Definition: base_module.h:91
Definition: base_module.h:75
Top-level namespace of the Bayeux/dpp module library.
Definition: base_module.h:56
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 _initialized
The initialization flag.
Definition: base_module.h:207
static const uint32_t bit01
Definition: bit_mask.h:28
void _set_initialized(bool initialized_)
Set the initialization flag of the module.
datatools::logger::priority _logging
The logging priority threshold.
Definition: base_module.h:205
Definition: base_module.h:82
process_status
Processing status flags used as the returned value of data processing methods through the pipeline.
Definition: base_module.h:65
const std::string & get_name() const
Return the module name.
virtual void initialize_simple()
Initialize the module without external resource.
virtual void initialize_with_service(const datatools::properties &config_, datatools::service_manager &service_manager_)
Initialize the module using a set of parameters and a service manager.
void set_description(const std::string &description_)
Set the module description.
void _set_name(const std::string &name_)
Set the name of the module.
const std::string & get_description() const
Return the module description.
An object that describes the way an object of a given class can be configured through properties.
Definition: object_configuration_description.h:234
static const uint32_t bit31
Definition: bit_mask.h:58
virtual void initialize_without_service(const datatools::properties &config, module_handle_dict_type &module_dictionnary_)
Initialize the module using a set of parameters and a map of modules.
virtual void reset()=0
The main termination method.
base_module(datatools::logger::priority p_=datatools::logger::PRIO_FATAL)
Default constructor :
bool has_description() const
Check the module description.
Definition: base_module.h:66
void print(std::ostream &out_=std::clog) const
Default print.
virtual process_status process(datatools::things &data_model_)=0
void reset_last_error_message()
Reset the module last error message.
Definition: base_module.h:70
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
std::map< std::string, module_entry_type > module_handle_dict_type
Definition: module_tools.h:141
Base processing module (abstract interface)
Definition: base_module.h:59
void set_logging_priority(datatools::logger::priority p_)
Set logging priority.
static const uint32_t bit02
Definition: bit_mask.h:29
static void common_ocd(datatools::object_configuration_description &ocd_)
Basic OCD support shared by all inherited modules.
header file
virtual ~base_module()
Destructor :
bool has_last_error_message() const
Check the module last error message.
std::string _last_error_message
Last error message (questionable)
Definition: base_module.h:208
Definition: base_module.h:69
std::string _description
The description of the module.
Definition: base_module.h:204
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
Utilities for logging information.
void set_name(const std::string &)
Set the module name.
std::string _name
The name of the module.
Definition: base_module.h:203
static const uint32_t bit00
Definition: bit_mask.h:27
Definition: base_module.h:72
void _common_initialize(const datatools::properties &config_)
Basic initialization shared by all inherited modules.
#define DATATOOLS_FACTORY_SYSTEM_REGISTER_INTERFACE(BaseType)
Declaration of a system (allocator/functor) factory register as a static member of a base class and s...
Definition: factory_macros.h:52
virtual void initialize(const datatools::properties &config_, datatools::service_manager &service_manager_, module_handle_dict_type &module_dictionary_)=0
Service management class.
Definition: service_manager.h:57
bool is_initialized() const
Check initialization flag.
datatools::logger::priority get_logging_priority() const
Returns logging priority.
virtual void initialize_simple_with_service(datatools::service_manager &service_manager_)
Initialize the module with a service manager only.
void set_last_error_message(const std::string &)
Set the module last error message.
A dictionary of arbitrary properties.
Definition: properties.h:125