Bayeux  3.4.1
Core Foundation library for SuperNEMO
if_module.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date : 2011-06-19
4  * Last modified : 2013-05-15
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  * A skip data processing module.
26  *
27  */
28 
29 #ifndef DPP_IF_MODULE_H
30 #define DPP_IF_MODULE_H 1
31 
32 // Standard library:
33 #include <string>
34 
35 // Third party:
36 // - Bayeux/cuts:
37 #include <cuts/cut_tools.h>
38 
39 // This project:
40 #include <dpp/base_module.h>
41 
42 namespace dpp {
43 
45  class if_module
46  : public base_module
47  {
48  public:
49 
51  struct cut_entry {
52  std::string label;
54  };
55 
57  struct module_entry {
58  std::string label;
60  };
61 
63  static const std::string & default_cut_service_label();
64 
66  void set_cut_service_label (const std::string & label_);
67 
69  const std::string & get_cut_service_label () const;
70 
71  void set_condition_cut (const std::string & label_,
72  const cuts::cut_handle_type & condition_cut_);
73 
74  bool has_then_module () const;
75 
76  void set_then_module (const module_entry & then_module_);
77 
78  bool has_else_module () const;
79 
80  void set_else_module (const module_entry & else_module_);
81 
82  bool has_then_status () const;
83 
84  void set_then_status (process_status status_);
85 
86  bool has_else_status () const;
87 
88  void set_else_status (process_status status_);
89 
92 
94  virtual ~if_module();
95 
97  virtual void initialize(const ::datatools::properties & /* config_ */,
98  datatools::service_manager & /* service_mgr_ */,
99  dpp::module_handle_dict_type & /* modules_map_ */);
100 
102  virtual void reset();
103 
105  virtual process_status process(::datatools::things & /* data_ */);
106 
108  virtual void tree_dump (std::ostream & out_ = std::clog,
109  const std::string & title_ = "",
110  const std::string & indent_ = "",
111  bool inherit_ = false) const;
112 
113  protected:
114 
116  void _set_defaults ();
117 
118  private:
119 
120  std::string _cut_service_label_;
121  cut_entry _condition_cut_;
122  process_status _then_status_;
123  module_entry _then_module_;
124  process_status _else_status_;
125  module_entry _else_module_;
126 
127  // Macro to automate the registration of the module :
129 
130  };
131 
132 } // end of namespace dpp
133 
134 #endif // DPP_IF_MODULE_H
135 
136 // Local Variables: --
137 // mode: c++ --
138 // c-file-style: "gnu" --
139 // tab-width: 2 --
140 // End: --
std::string label
Module label.
Definition: if_module.h:58
A generic serializable and noncopyable container for arbitrary serializable objects.
Definition: things.h:85
priority
Priority levels for logging from most to least critical.
Definition: logger.h:82
void set_condition_cut(const std::string &label_, const cuts::cut_handle_type &condition_cut_)
virtual process_status process(::datatools::things &)
Data record processing.
Top-level namespace of the Bayeux/dpp module library.
Definition: base_module.h:56
A fatal error. The application will most likely terminate. This is the highest priority.
Definition: logger.h:85
static const std::string & default_cut_service_label()
Return the default label of an external cut service.
process_status
Processing status flags used as the returned value of data processing methods through the pipeline.
Definition: base_module.h:65
if_module(datatools::logger::priority=datatools::logger::PRIO_FATAL)
Constructor.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
void set_cut_service_label(const std::string &label_)
Set the label of the external cut service.
Internal module record entry.
Definition: if_module.h:57
void set_then_module(const module_entry &then_module_)
void _set_defaults()
Set default values before explicit settings and initialization.
bool has_else_status() const
void set_then_status(process_status status_)
void set_else_module(const module_entry &else_module_)
module_handle_type handle
Module handle.
Definition: if_module.h:59
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
#define DPP_MODULE_REGISTRATION_INTERFACE(T)
Definition: base_module.h:231
cuts::cut_handle_type handle
Cut handle.
Definition: if_module.h:53
void set_else_status(process_status status_)
std::string label
Cut label.
Definition: if_module.h:52
virtual ~if_module()
Destructor.
bool has_then_status() const
Cut record entry.
Definition: if_module.h:51
const std::string & get_cut_service_label() const
Return the label of the external cut service.
virtual void initialize(const ::datatools::properties &, datatools::service_manager &, dpp::module_handle_dict_type &)
Initialization.
bool has_then_module() const
A data processing module to be apply only if some cut is fulfilled.
Definition: if_module.h:45
virtual void reset()
Reset.
Service management class.
Definition: service_manager.h:57
bool has_else_module() const