Bayeux  3.4.1
Core Foundation library for SuperNEMO
i_data_source.h
Go to the documentation of this file.
1 /* Author(s) : Xavier Garrido <garrido@lal.in2p3.fr>
3  * Creation date : 2011-08-05
4  * Last modified : 2013-02-15
5  *
6  * Copyright (C) 2011-2013 Xavier Garrido <garrido@lal.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  * Abstract data source reader class.
27  *
28  */
29 
30 #ifndef DPP_I_DATA_SOURCE_H
31 #define DPP_I_DATA_SOURCE_H 1
32 
33 // Standard library:
34 #include <ostream>
35 #include <string>
36 
37 // Third party:
38 // - Boost:
39 #include <boost/cstdint.hpp>
40 // - Bayeux/datatools:
41 #include <datatools/properties.h>
42 #include <datatools/things.h>
43 
44 // This project:
45 #include <dpp/dpp_config.h>
46 
47 namespace dpp {
48 
51  {
52  public:
53 
54  static const int64_t UNKNOWN_NUMBER_OF_ENTRIES = -1;
55 
58  {
59  static const int STATUS_CLOSED = 0;
60  static const int STATUS_OPENED = 1;
61  std::string label;
62  std::string effective_label;
63  int status;
64  bool processed;
65 
66  source_record(const std::string & label_ = "");
67  void reset();
68  };
69 
72 
75 
76  virtual bool is_open() const;
77 
78  virtual bool is_sequential() const;
79 
80  virtual bool is_random() const;
81 
82  virtual void set(const std::string & source_label_);
83 
84  virtual void open() = 0;
85 
86  virtual bool can_load_record(int64_t entry_);
87 
88  virtual bool has_next_record() = 0;
89 
90  virtual bool load_next_record(datatools::things & event_record_) = 0;
91 
92  // Default failing load method :
93  virtual bool has_number_of_entries() const;
94 
95  virtual int64_t get_number_of_entries() const;
96 
97  virtual bool load_record(datatools::things & event_record_, int64_t entry_);
98 
99  virtual int64_t get_number_of_metadata() const = 0;
100 
101  virtual bool load_metadata(datatools::properties & metadata_, int64_t entry_) = 0;
102 
103  virtual void close() = 0;
104 
105  virtual void reset() = 0;
106 
109 
111  i_data_source(const std::string & source_label_,
113 
115  virtual ~i_data_source();
116 
117  protected:
118 
120 
121  virtual void _check_next_record() = 0;
122 
123  // Default failing load method :
124  virtual bool _load_record(datatools::things & event_record_,
125  int64_t entry_);
126 
127  // Default failing getter method :
128  virtual int64_t _get_number_of_entries() const;
129 
130  protected:
131 
135 
136  };
137 
138 } // end of namespace dpp
139 
140 #endif // DPP_I_DATA_SOURCE_H
141 
142 // Local Variables: --
143 // mode: c++ --
144 // c-file-style: "gnu" --
145 // tab-width: 2 --
146 // End: --
static const int STATUS_CLOSED
Definition: i_data_source.h:59
A generic serializable and noncopyable container for arbitrary serializable objects.
Definition: things.h:85
virtual bool load_record(datatools::things &event_record_, int64_t entry_)
priority
Priority levels for logging from most to least critical.
Definition: logger.h:82
virtual void set(const std::string &source_label_)
Top-level namespace of the Bayeux/dpp module library.
Definition: base_module.h:56
virtual bool is_open() const
virtual int64_t get_number_of_metadata() const =0
datatools::logger::priority _logging
The logging priority.
Definition: i_data_source.h:132
An error. An operation did not complete successfully, but the application as a whole is not affected.
Definition: logger.h:87
virtual bool has_next_record()=0
std::string label
Definition: i_data_source.h:61
i_data_source(datatools::logger::priority priority_=datatools::logger::PRIO_ERROR)
Constructor.
int status
Definition: i_data_source.h:63
virtual int64_t get_number_of_entries() const
source_record _source_record
Record dynamic informations about the data source.
Definition: i_data_source.h:134
virtual int64_t _get_number_of_entries() const
virtual bool load_metadata(datatools::properties &metadata_, int64_t entry_)=0
virtual ~i_data_source()
Destructor:
bool _has_next_record
Next record flag.
Definition: i_data_source.h:133
std::string effective_label
Definition: i_data_source.h:62
static const int64_t UNKNOWN_NUMBER_OF_ENTRIES
Definition: i_data_source.h:54
virtual bool is_random() const
Data source/reader abstract interface.
Definition: i_data_source.h:50
virtual bool is_sequential() const
void set_logging_priority(datatools::logger::priority p_)
Set logging priority.
bool processed
Definition: i_data_source.h:64
virtual void reset()=0
header file
virtual void close()=0
Internal class of the i_data_source interface class.
Definition: i_data_source.h:57
virtual bool can_load_record(int64_t entry_)
virtual bool has_number_of_entries() const
virtual void _check_next_record()=0
void _set_defaults(datatools::logger::priority priority_)
virtual void open()=0
virtual bool load_next_record(datatools::things &event_record_)=0
datatools::logger::priority get_logging_priority() const
Returns logging priority.
source_record(const std::string &label_="")
static const int STATUS_OPENED
Definition: i_data_source.h:60
virtual bool _load_record(datatools::things &event_record_, int64_t entry_)
A dictionary of arbitrary properties.
Definition: properties.h:125