Bayeux  3.4.1
Core Foundation library for SuperNEMO
input_module.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date : 2013-08-16
4  * Last modified : 2013-12-13
5  *
6  * Copyright (C) 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  *
24  * Description:
25  *
26  * An input data processing module.
27  *
28  */
29 
30 #ifndef DPP_INPUT_MODULE_H
31 #define DPP_INPUT_MODULE_H 1
32 
33 // Third party:
34 // - Boost:
35 #include <boost/scoped_ptr.hpp>
36 // - Bayeux/datatools:
38 
39 // This project:
40 #include <dpp/base_module.h>
41 
42 
43 namespace dpp {
44 
45  // Forward declarations:
46  class i_data_source;
47  class io_common;
48 
51  : public base_module
52  {
53  public:
54 
56  void set_limits(int max_record_total_,
57  int max_record_per_file_ = 0,
58  int max_files_ = -1);
59 
61  void set_single_input_file(const std::string & filepath_);
62 
64  void set_list_of_input_files(const std::vector<std::string> & filepaths_,
65  bool allow_duplicate_ = false);
66 
68  void set_incremental_input_files(const std::string & path_,
69  const std::string & prefix_,
70  const std::string & extension_,
71  unsigned int stop_,
72  unsigned int start_ = 0,
73  int increment_ = 1);
74 
76  void set_context_label(const std::string &);
77 
79  void import_context_metadata(const std::string &);
80 
82  void set_import_context_all(bool);
83 
86 
88  virtual ~input_module();
89 
91  virtual void initialize(const ::datatools::properties & /* config_ */,
92  datatools::service_manager & /* service_mgr_ */,
93  dpp::module_handle_dict_type & /* modules_map_ */);
94 
96  virtual void reset();
97 
99  virtual process_status process(::datatools::things & /* data_ */);
100 
102  virtual void tree_dump(std::ostream & a_out = std::clog,
103  const std::string & a_title = "",
104  const std::string & a_indent = "",
105  bool a_inherit = false) const;
106 
108  bool is_terminated() const;
109 
111  const io_common & get_common() const;
112 
114  bool has_metadata_store() const;
115 
117  void set_clear_record(bool);
118 
120  bool is_clear_record() const;
121 
122  // /// Set the preload flag
123  // void set_preload_metadata(bool);
124 
127 
129  void clear_metadata_store();
130 
132  bool metadata_was_updated() const;
133 
135  bool has_source() const;
136 
138  const i_data_source & get_source() const;
139 
140  protected:
141 
143  process_status _load(datatools::things & a_data_record);
144 
147 
149  void _check_limits();
150 
152  void _set_defaults();
153 
156 
157  private:
158 
160  void _load_metadata_();
161 
162  private:
163 
164  bool _clear_record_;
165  boost::scoped_ptr<io_common> _common_;
166  i_data_source * _source_ = nullptr;
167  bool _metadata_updated_ = false;
168 
169  // Macro to automate the registration of the module :
171 
172  };
173 
174 } // namespace dpp
175 
176 #endif // DPP_INPUT_MODULE_H
177 
178 // Local Variables: --
179 // mode: c++ --
180 // c-file-style: "gnu" --
181 // tab-width: 2 --
182 // End: --
void set_list_of_input_files(const std::vector< std::string > &filepaths_, bool allow_duplicate_=false)
Set the filenames of a list of input files.
A generic serializable and noncopyable container for arbitrary serializable objects.
Definition: things.h:85
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.
void set_incremental_input_files(const std::string &path_, const std::string &prefix_, const std::string &extension_, unsigned int stop_, unsigned int start_=0, int increment_=1)
Set the incremented filenames of input files.
const datatools::multi_properties & get_metadata_store() const
Return a const reference to the existing embedded metadata store.
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 set_single_input_file(const std::string &filepath_)
Set the filename of a single input file.
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
bool metadata_was_updated() const
Check is metadata has been possibly updated after last data record processing.
void import_context_metadata(const std::string &)
Import a metadata section with given label from the input stream to the context service.
process_status
Processing status flags used as the returned value of data processing methods through the pipeline.
Definition: base_module.h:65
virtual void reset()
Reset.
void set_import_context_all(bool)
Import all metadata sections from the input stream to the context service.
bool has_source() const
Check source.
void set_clear_record(bool)
Set clear record flag.
void _set_defaults()
Set default values before explicit settings and initialization.
bool is_terminated() const
Check input termination.
void set_context_label(const std::string &)
Set the label/name of the context service to be used.
const io_common & get_common() const
Return a reference to the non mutable internal I/O data structure.
void _check_limits()
Check the limits on input file(s)
Some common data structure for I/O modules.
Definition: io_common.h:50
An input data processing module for automated I/O operations.
Definition: input_module.h:50
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
input_module(datatools::logger::priority=datatools::logger::PRIO_FATAL)
Constructor.
Data source/reader abstract interface.
Definition: i_data_source.h:50
#define DPP_MODULE_REGISTRATION_INTERFACE(T)
Definition: base_module.h:231
void clear_metadata_store()
Clear the embedded metadata store.
process_status _load(datatools::things &a_data_record)
Load a data record.
virtual ~input_module()
Destructor.
const i_data_source & get_source() const
Get source.
process_status _open_source()
Open the data record source.
void set_limits(int max_record_total_, int max_record_per_file_=0, int max_files_=-1)
Set limits.
io_common & _grab_common()
Return a reference to the mutable internal I/O data structure.
virtual void initialize(const ::datatools::properties &, datatools::service_manager &, dpp::module_handle_dict_type &)
Initialization.
bool has_metadata_store() const
Check if an embedded metadata store exists.
Service management class.
Definition: service_manager.h:57
bool is_clear_record() const
Check the Set clear record flag.