yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis 2.0.2
ReaderMethods.icc
Go to the documentation of this file.
1// This file contains boilerplate code for static reader functions in all
2// classes inheriting from Reader. These methods just forward to the methods on
3// the Reader base class, but code duplication can't be avoided without a
4// preprocessor hack like this, AFAIK.
5
6/// @name Reading multiple analysis objects into arbitrary collections.
7//@{
8
9// template <typename RANGE>
10// static typename std::enable_if<CIterable<RANGE>::value>::type
11// read(std::ostream& stream, const RANGE& aos) {
12// create().write(stream, std::begin(aos), std::end(aos));
13// }
14
15// template <typename RANGE>
16// static typename std::enable_if<CIterable<RANGE>::value>::type
17// write(const std::string& filename, const RANGE& aos) {
18// create().write(filename, std::begin(aos), std::end(aos));
19// }
20
21
22
23/// @brief Read in a collection of objects @a objs from output stream @a stream.
24///
25/// This version fills (actually, appends to) a variable supplied container
26/// Note: SFINAE is used to check for a void push_back(const AnalysisObject*) method
27template<typename CONT>
28static typename std::enable_if<YODA::Pushable<CONT,AnalysisObject*>::value>::type
29read(std::istream& stream, CONT& aos, const std::string& match = "", const std::string& unmatch = "") {
30 create().read(stream, aos, match, unmatch);
31}
32
33// /// @brief Read in a collection of objects @a objs from output stream @a stream.
34// ///
35// /// This version fills (actually, appends to) a supplied vector, avoiding copying,
36// /// and is hence CPU efficient.
37// ///
38// static void read(std::istream& stream, std::vector<AnalysisObject*>& aos) {
39// create().read(stream, aos);
40// }
41
42/// @brief Read in a collection of objects from output stream @a stream.
43///
44/// This version returns a vector by value, involving copying, and is hence less
45/// CPU efficient than the alternative version where a vector is filled by reference.
46static std::vector<AnalysisObject*> read(std::istream& stream, const std::string& match = "",
47 const std::string& unmatch = "") {
48 return create().read(stream, match, unmatch);
49}
50
51
52/// @brief Read in a collection of objects @a objs from file @a filename.
53///
54///
55/// This version fills (actually, appends to) a variable supplied container
56/// Note: SFINAE is used to check for a void push_back(const AnalysisObject*) method
57template<typename CONT>
58static typename std::enable_if<YODA::Pushable<CONT,AnalysisObject*>::value>::type
59read(const std::string& filename, CONT& aos, const std::string& match = "", const std::string& unmatch = "") {
60 return create().read(filename, aos, match, unmatch);
61}
62
63// /// @brief Read in a collection of objects @a objs from file @a filename.
64// ///
65// /// This version fills (actually, appends to) a supplied vector, avoiding copying,
66// /// and is hence CPU efficient.
67// ///
68// static void read(const std::string& filename, std::vector<AnalysisObject*>& aos) {
69// return create().read(filename, aos);
70// }
71
72/// @brief Read in a collection of objects from output stream @a stream.
73///
74/// This version returns a vector by value, involving copying, and is hence less
75/// CPU efficient than the alternative version where a vector is filled by reference.
76static std::vector<AnalysisObject*> read(const std::string& filename, const std::string& match = "",
77 const std::string& unmatch = "") {
78 return create().read(filename, match, unmatch);
79}
80
81//@}