YODA::Reader Class Referenceabstract Pure virtual base class for various output writers. More...
Inheritance diagram for YODA::Reader:
Detailed DescriptionMember Typedef Documentation◆ TypeRegisterItr
Constructor & Destructor Documentation◆ ~Reader()
Virtual destructor. Definition at line 31 of file Reader.h. 31 {
32 // This is technically leaking memory, but since this
33 // is a (static) singleton, there should be no issue.
34 // Cython relies on it for data-structure alignment, too.
35 for (auto& aor : _register) { aor.second.release(); }
36 }
Member Function Documentation◆ patternCheck()
Check if a string matches any of the given patterns, and that it doesn't match any unpatterns (for path filtering) Definition at line 150 of file Reader.h. 151 {
152 bool skip = false;
153 if (patterns.size()) {
154 skip = true;
155 for (const std::regex& re : patterns) {
156 if (std::regex_search(path, re)) { skip = false; break; }
157 }
158 }
159 if (!skip && unpatterns.size()) {
160 for (const std::regex& re : unpatterns) {
161 if (std::regex_search(path, re)) { skip = true; break; }
162 }
163 }
164 return !skip;
165 }
◆ read() [1/6]
Read in a collection of objects from output stream stream. This version returns a vector by value, involving copying, and is hence less CPU efficient than the alternative version where a vector is filled by reference. Definition at line 128 of file Reader.h. 129 {
130 std::vector<AnalysisObject*> rtn;
131 read(filename, rtn, match, unmatch);
132 return rtn;
133 }
std::enable_if_t< YODA::Pushable< CONT, AnalysisObject * >::value > read(std::istream &stream, CONT &aos, const std::string &match="", const std::string &unmatch="") Read in a collection of objects objs from output stream stream. Definition Reader.h:50 References read(). ◆ read() [2/6]
template<typename CONT >
Read in a collection of objects objs from file filename. This version fills (actually, appends to) a variable supplied container Note: SFINAE is used to check for a void push_back(const AnalysisObject*) method Definition at line 88 of file Reader.h. 88 {
89 // if CONT==std::vector<AnalysisObject*>, the compiler should select
90 // the virtual method below, since it prefers non-templated methods in the lookup
91 // otherwise we would enter a endless recursion. Check in case of problems.
92 std::vector<AnalysisObject*> v_aos;
93 read(filename, v_aos, match, unmatch);
94 for (const AnalysisObject* ao : v_aos) aos.push_back(ao);
95 }
References read(). ◆ read() [3/6]
Read in a collection of objects objs from file filename. This version fills (actually, appends to) a supplied vector, avoiding copying, and is hence CPU efficient. Definition at line 102 of file Reader.h. 103 {
104 if (filename != "-") {
105 try {
106 std::ifstream instream;
107 instream.open(filename.c_str());
108 if (instream.fail())
109 throw ReadError("Reading from filename " + filename + " failed");
110 read(instream, aos, match, unmatch);
111 instream.close();
112 } catch (std::ifstream::failure& e) {
113 throw ReadError("Reading from filename " + filename + " failed: " + e.what());
114 }
115 } else {
116 try {
117 read(std::cin, aos, match, unmatch);
118 } catch (std::runtime_error& e) {
119 throw ReadError("Reading from stdin failed: " + std::string(e.what()));
120 }
121 }
122 }
References read(). ◆ read() [4/6]
◆ read() [5/6]
template<typename CONT >
Read in a collection of objects objs from output stream stream. This version fills (actually, appends to) a variable supplied container Note: SFINAE is used to check for a void push_back(const AnalysisObject*) method Definition at line 50 of file Reader.h. 50 {
51 // if CONT==std::vector<AnalysisObject*>, the compiler should select
52 // the virtual method below, since it prefers non-templated methods in the lookup
53 // otherwise we would enter a endless recursion. Check in case of problems.
54 std::vector<AnalysisObject*> v_aos;
55 read(stream, v_aos, match, unmatch);
56 for (const AnalysisObject* ao : v_aos) aos.push_back(ao);
57 }
References read(). Referenced by read(), read(), YODA::read(), read(), YODA::read(), read(), and read(). ◆ read() [6/6]
Read in a collection of objects objs from output stream stream. This version fills (actually, appends to) a supplied vector, avoiding copying, and is hence CPU efficient. Implemented in YODA::ReaderFLAT, and YODA::ReaderYODA. ◆ registerType()
template<typename T >
AO type registration. Definition at line 142 of file Reader.h. 142 {
143 const string key = Utils::toUpper(T().type());
145 if (res == _register.end()) _register[key] = std::make_unique<AOReader<T>>();
146 }
typename std::unordered_map< std::string, std::unique_ptr< AOReaderBase > >::const_iterator TypeRegisterItr Convenience alias for AO Reader. Definition Reader.h:28 The documentation for this class was generated from the following file:
Generated on Mon Oct 28 2024 13:47:24 for YODA - Yet more Objects for Data Analysis by 1.9.8 |