Bayeux  3.4.1
Core Foundation library for SuperNEMO
reader.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2010-11-01
4  * Last modified: 2019-05-21
5  *
6  * License: GPL3
7  *
8  * Description:
9  *
10  * A Boost archive from ROOT file reader
11  *
12  */
13 
14 #ifndef BRIO_READER_H
15 #define BRIO_READER_H 1
16 
17 // Standard Library:
18 #include <iostream>
19 #include <stdexcept>
20 #include <sstream>
21 #include <string>
22 
23 // Third Party:
24 // - Boost:
25 #include <boost/iostreams/stream.hpp>
26 #include <boost/iostreams/device/array.hpp>
27 
28 // Supress known unused parameter warning from Boost's smart_cast header
29 #ifdef __clang__
30 #pragma clang diagnostic push
31 #pragma clang diagnostic ignored "-Wunused-parameter"
32 #endif
33 #include <boost/archive/text_iarchive.hpp>
34 #ifdef __clang__
35 #pragma clang diagnostic pop
36 #endif
37 
38 // - Bayeux/datatools:
40 #include <datatools/logger.h>
41 #include <datatools/exception.h>
42 
43 // This Project:
44 #include <brio/detail/base_io.h>
45 
46 namespace brio {
47 
49  class reader
50  : public detail::base_io
51  {
52  public:
54  reader();
55 
57  reader(const std::string & filename_,
59 
61  reader(const std::string & filename_,
62  const std::string & format_str_,
64 
66  virtual ~reader();
67 
77  void set_check_serial_tag(bool new_value_ = true);
78 
79  bool is_check_serial_tag() const;
80 
84  void rewind_store(const std::string & label_ = "");
85 
89  void unwind_store(const std::string& label_ = "");
90 
93  bool has_previous(const std::string & label_ = "") const;
94 
97  bool has_next(const std::string & label_ = "") const;
98 
100  template<typename T>
101  int load_next(T & data_, const std::string & label_ = "");
102 
104  template<typename T>
105  int load_previous(T & data_, const std::string & label_ = "");
106 
108  template<typename T>
109  int load(T & data_, int64_t nentry_ = -1);
110 
112  template<typename T>
113  int load(T & data_, const std::string & label_, int64_t nentry_ = -1);
114 
116  virtual void tree_dump(std::ostream & out_ = std::clog,
117  const std::string & title_ = "",
118  const std::string & indent_ = "",
119  bool inherit_ = false) const;
120 
122  void print_info(std::ostream& out_ = std::clog) const;
123 
124  protected:
125  virtual void _at_open(const std::string & filename_);
126 
127  template<class T>
128  int _at_load(T & data_, store_info * ptr_si_, int64_t nentry_);
129 
130  void _set_default();
131 
132  private:
133 
136  const store_info * get_store_or_throw(const std::string & label_) const;
137  store_info * get_store_or_throw(const std::string & label_);
138 
139  private:
140  bool _allow_mixed_types_in_stores_;
141  bool _allow_automatic_store_;
142  bool _check_serial_tag_;
143  store_info * _automatic_store_ = nullptr;
144  };
145 
146 } // end of namespace brio
147 
148 #include <brio/reader-inl.h>
149 
150 #endif // BRIO_READER_H
151 
152 // Local Variables: --
153 // mode: c++ --
154 // c-file-style: "gnu" --
155 // tab-width: 2 --
156 // End: --
The brio generic reader class.
Definition: reader.h:49
void set_check_serial_tag(bool new_value_=true)
priority
Priority levels for logging from most to least critical.
Definition: logger.h:82
void rewind_store(const std::string &label_="")
reader()
Default constructor.
A fatal error. The application will most likely terminate. This is the highest priority.
Definition: logger.h:85
A class that contains internal dynamic informations for a given store.
Definition: utils.h:33
int load(T &data_, int64_t nentry_=-1)
Load template method for arbitrary entry.
Definition: reader-inl.h:53
virtual ~reader()
Destructor.
The internal I/O base class.
Definition: base_io.h:43
Utility macros for exception handling.
int load_next(T &data_, const std::string &label_="")
Load template method for next entry.
Definition: reader-inl.h:39
void unwind_store(const std::string &label_="")
void _set_default()
int _at_load(T &data_, store_info *ptr_si_, int64_t nentry_)
Definition: reader-inl.h:80
Definitions of brio::reader template functions.
int load_previous(T &data_, const std::string &label_="")
Load template method for previous entry.
Definition: reader-inl.h:46
bool has_previous(const std::string &label_="") const
Utilities for logging information.
virtual void _at_open(const std::string &filename_)
bool has_next(const std::string &label_="") const
bool is_check_serial_tag() const
void print_info(std::ostream &out_=std::clog) const
Print.
Top-level namespace of the Bayeux/brio module library.
Definition: base_io.h:37
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.