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 43 of file Reader.h. 43 {
44 // This is technically leaking memory, but since this
45 // is a (static) singleton, there should be no issue.
46 // Cython relies on it for data-structure alignment, too.
47 for (auto& aor : _register) { aor.second.release(); }
48 }
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 200 of file Reader.h. 201 {
202 bool skip = false;
203 if (patterns.size()) {
204 skip = true;
205 for (const std::regex& re : patterns) {
206 if (std::regex_search(path, re)) { skip = false; break; }
207 }
208 }
209 if (!skip && unpatterns.size()) {
210 for (const std::regex& re : unpatterns) {
211 if (std::regex_search(path, re)) { skip = true; break; }
212 }
213 }
214 return !skip;
215 }
Referenced by YODA::ReaderH5::read(). ◆ read() [1/8]
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 178 of file Reader.h. 179 {
180 std::vector<AnalysisObject*> rtn;
181 read(filename, rtn, match, unmatch);
182 return rtn;
183 }
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:62 References read(). ◆ read() [2/8]
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 124 of file Reader.h. 124 {
125 // if CONT==std::vector<AnalysisObject*>, the compiler should select
126 // the virtual method below, since it prefers non-templated methods in the lookup
127 // otherwise we would enter a endless recursion. Check in case of problems.
128 std::vector<AnalysisObject*> v_aos;
129 read(filename, v_aos, match, unmatch);
130 for (const AnalysisObject* ao : v_aos) aos.push_back(ao);
131 }
References read(). ◆ read() [3/8]
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 138 of file Reader.h. 139 {
140 if (filename != "-") {
141 try {
142 const size_t lastdot = filename.find_last_of(".");
143 std::string fmt = Utils::toLower(lastdot == std::string::npos ? filename : filename.substr(lastdot+1));
144 #ifdef HAVE_HDF5
145 // check if the requested format is H5
146 if (Utils::startswith(fmt, "h5")) {
147 try {
148 const YODA_H5::File h5(filename, YODA_H5::File::ReadOnly);
149 read(h5, aos, match, unmatch);
151 throw ReadError("Reading from filename " + filename + " failed: " + e.what());
152 }
153 return;
154 }
155 #endif
156 std::ifstream instream;
157 instream.open(filename.c_str());
158 if (instream.fail())
159 throw ReadError("Reading from filename " + filename + " failed");
160 read(instream, aos, match, unmatch);
161 instream.close();
162 } catch (std::ifstream::failure& e) {
163 throw ReadError("Reading from filename " + filename + " failed: " + e.what());
164 }
165 } else {
166 try {
167 read(std::cin, aos, match, unmatch);
168 } catch (std::runtime_error& e) {
169 throw ReadError("Reading from stdin failed: " + std::string(e.what()));
170 }
171 }
172 }
References read(). ◆ read() [4/8]
Read in a collection of objects from an H5 file. 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 106 of file Reader.h. 107 {
108 std::vector<AnalysisObject*> rtn;
109 read(file, rtn, match, unmatch);
110 return rtn;
111 }
References read(). ◆ read() [5/8]
Read in a collection of objects objs from an HDF5 file. This version fills (actually, appends to) a supplied vector, avoiding copying, and is hence CPU efficient. Implemented in YODA::ReaderH5. ◆ read() [6/8]
◆ read() [7/8]
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 62 of file Reader.h. 62 {
63 // if CONT==std::vector<AnalysisObject*>, the compiler should select
64 // the virtual method below, since it prefers non-templated methods in the lookup
65 // otherwise we would enter a endless recursion. Check in case of problems.
66 std::vector<AnalysisObject*> v_aos;
67 read(stream, v_aos, match, unmatch);
68 for (const AnalysisObject* ao : v_aos) aos.push_back(ao);
69 }
References read(). Referenced by read(), read(), YODA::read(), read(), read(), YODA::read(), read(), and read(). ◆ read() [8/8]
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 192 of file Reader.h. 192 {
193 const string key = Utils::toUpper(T().type());
195 if (res == _register.end()) _register[key] = std::make_unique<AOReader<T>>();
196 }
typename std::unordered_map< std::string, std::unique_ptr< AOReaderBase > >::const_iterator TypeRegisterItr Convenience alias for AO Reader. Definition Reader.h:40 The documentation for this class was generated from the following file:
Generated on Fri Mar 7 2025 09:06:41 for YODA - Yet more Objects for Data Analysis by |