yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis  1.9.0
IO.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // This file is part of YODA -- Yet more Objects for Data Analysis
4 // Copyright (C) 2008-2021 The YODA collaboration (see AUTHORS for details)
5 //
6 #ifndef YODA_IO_h
7 #define YODA_IO_h
8 
9 #include "YODA/Writer.h"
10 #include "YODA/Reader.h"
11 #include "YODA/Index.h"
12 
13 namespace YODA {
14 
15 
18 
20  inline void write(const std::string& filename, const AnalysisObject& ao) {
21  Writer& w = mkWriter(filename);
22  w.write(filename, ao);
23  }
24 
26  template <typename RANGE>
27  inline void write(const std::string& filename, const RANGE& aos) {
28  Writer& w = mkWriter(filename);
29  w.write(filename, aos);
30  }
31 
34  template <typename AOITER>
35  inline void write(const std::string& filename, const AOITER& begin, const AOITER& end) {
36  Writer& w = mkWriter(filename);
37  w.write(filename, begin, end);
38  }
39 
41 
42 
45 
47  inline void write(std::ostream& os, const AnalysisObject& ao, const std::string& fmt) {
48  Writer& w = mkWriter(fmt);
49  w.write(os, ao);
50  }
51 
53  template <typename RANGE>
54  inline void write(std::ostream& os, const RANGE& aos, const std::string& fmt) {
55  Writer& w = mkWriter(fmt);
56  w.write(os, aos);
57  }
58 
61  template <typename AOITER>
62  inline void write(std::ostream& os, const AOITER& begin, const AOITER& end, const std::string& fmt) {
63  Writer& w = mkWriter(fmt);
64  w.write(os, begin, end);
65  }
66 
68 
69 
72 
80  inline void read(const std::string& filename, std::vector<AnalysisObject*>& aos) {
81  Reader& r = mkReader(filename);
82  r.read(filename, aos);
83  }
84 
91  inline std::vector<AnalysisObject*> read(const std::string& filename) {
92  std::vector<AnalysisObject*> rtn;
93  read(filename, rtn);
94  return rtn;
95  }
96 
98  inline Index mkIndex(const std::string& filename) {
99  Reader& r = mkReader(filename);
100  return r.mkIndex(filename);
101  }
102 
104 
105 
108 
115  inline void read(std::istream& is, std::vector<AnalysisObject*>& aos, const std::string& fmt) {
116  Reader& r = mkReader(fmt);
117  r.read(is, aos);
118  }
119 
125  inline std::vector<AnalysisObject*> read(std::istream& is, const std::string& fmt) {
126  std::vector<AnalysisObject*> rtn;
127  read(is, rtn, fmt);
128  return rtn;
129  }
130 
132 
133 
134 }
135 
136 #endif
Index mkIndex(const std::string &filename)
Make index of a file.
Definition: IO.h:98
void write(const std::string &filename, const AnalysisObject &ao)
Write out object ao to file filename.
Definition: IO.h:20
Index mkIndex(const std::string &filename)
Make file index.
Definition: Reader.h:129
Index of a file.
Definition: Index.h:13
void write(const std::string &filename, const AnalysisObject &ao)
Write out object ao to file filename.
Definition: Writer.cc:50
Reader & mkReader(const std::string &format_name)
Factory function to make a writer object by format name or a filename.
Definition: Reader.cc:17
std::enable_if< YODA::Pushable< CONT, AnalysisObject * >::value >::type read(std::istream &stream, CONT &aos)
Read in a collection of objects objs from output stream stream.
Definition: Reader.h:41
void read(const std::string &filename, std::vector< AnalysisObject *> &aos)
Read in a collection of objects objs from file filename.
Definition: IO.h:80
Pure virtual base class for various output writers.
Definition: Writer.h:28
Pure virtual base class for various output writers.
Definition: Reader.h:23
AnalysisObject is the base class for histograms and scatters.
Writer & mkWriter(const std::string &format_name)
Factory function to make a writer object by format name or a filename.
Definition: Writer.cc:25