yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis  1.7.2
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-2017 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 
12 namespace YODA {
13 
14 
16 
17 
19  void write(const std::string& filename, const AnalysisObject& ao) {
20  Writer& w = mkWriter(filename);
21  w.write(filename, ao);
22  }
23 
25  template <typename RANGE>
26  void write(const std::string& filename, const RANGE& aos) {
27  Writer& w = mkWriter(filename);
28  w.write(filename, aos);
29  }
30 
33  template <typename AOITER>
34  void write(const std::string& filename, const AOITER& begin, const AOITER& end) {
35  Writer& w = mkWriter(filename);
36  w.write(filename, begin, end);
37  }
38 
40 
41 
43 
44 
46  void write(std::ostream& os, const AnalysisObject& ao, const std::string& fmt) {
47  Writer& w = mkWriter(fmt);
48  w.write(os, ao);
49  }
50 
52  template <typename RANGE>
53  void write(std::ostream& os, const RANGE& aos, const std::string& fmt) {
54  Writer& w = mkWriter(fmt);
55  w.write(os, aos);
56  }
57 
60  template <typename AOITER>
61  void write(std::ostream& os, const AOITER& begin, const AOITER& end, const std::string& fmt) {
62  Writer& w = mkWriter(fmt);
63  w.write(os, begin, end);
64  }
65 
67 
68 
70 
71 
79  void read(const std::string& filename, std::vector<AnalysisObject*>& aos) {
80  Reader& r = mkReader(filename);
81  r.read(filename, aos);
82  }
83 
90  std::vector<AnalysisObject*> read(const std::string& filename) {
91  std::vector<AnalysisObject*> rtn;
92  read(filename, rtn);
93  return rtn;
94  }
95 
97 
98 
100 
101 
108  void read(std::istream& is, std::vector<AnalysisObject*>& aos, const std::string& fmt) {
109  Reader& r = mkReader(fmt);
110  r.read(is, aos);
111  }
112 
118  std::vector<AnalysisObject*> read(std::istream& is, const std::string& fmt) {
119  std::vector<AnalysisObject*> rtn;
120  read(is, rtn, fmt);
121  return rtn;
122  }
123 
125 
126 
127 }
128 
129 #endif
void write(const std::string &filename, const AnalysisObject &ao)
Write out object ao to file filename.
Definition: IO.h:19
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:39
void read(const std::string &filename, std::vector< AnalysisObject *> &aos)
Read in a collection of objects objs from file filename.
Definition: IO.h:79
Pure virtual base class for various output writers.
Definition: Writer.h:28
Pure virtual base class for various output writers.
Definition: Reader.h:21
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