yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis 2.1.0

Persistency reader from YODA text data format. More...

#include <ReaderH5.h>

Inheritance diagram for YODA::ReaderH5:
YODA::Reader

Public Member Functions

 ReaderH5 (const ReaderH5 &)=delete
 Disable copy and move constructors.
 
 ReaderH5 (ReaderH5 &&)=delete
 
void operator= (const ReaderH5 &)=delete
 Disable copy and move assignments.
 
void operator= (ReaderH5 &&)=delete
 
void read (const YODA_H5::File &file, std::vector< AnalysisObject * > &aos, const std::string &match="", const std::string &unmatch="")
 Read in a collection of objects objs from an HDF5 file.
 
- Public Member Functions inherited from YODA::Reader
virtual ~Reader ()
 Virtual destructor.
 
template<typename CONT >
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.
 
std::vector< AnalysisObject * > read (std::istream &stream, const std::string &match="", const std::string &unmatch="")
 Read in a collection of objects from output stream stream.
 
std::vector< AnalysisObject * > read (const YODA_H5::File &file, const std::string &match="", const std::string &unmatch="")
 Read in a collection of objects from an H5 file.
 
template<typename CONT >
std::enable_if_t< YODA::Pushable< CONT, AnalysisObject * >::value > read (const std::string &filename, CONT &aos, const std::string &match="", const std::string &unmatch="")
 Read in a collection of objects objs from file filename.
 
void read (const std::string &filename, std::vector< AnalysisObject * > &aos, const std::string &match="", const std::string &unmatch="")
 Read in a collection of objects objs from file filename.
 
std::vector< AnalysisObject * > read (const std::string &filename, const std::string &match="", const std::string &unmatch="")
 Read in a collection of objects from output stream stream.
 
template<typename T >
void registerType ()
 AO type registration.
 
bool patternCheck (const std::string &path, const std::vector< std::regex > &patterns, const std::vector< std::regex > &unpatterns)
 Check if a string matches any of the given patterns, and that it doesn't match any unpatterns (for path filtering)
 

Static Public Member Functions

static Readercreate ()
 Singleton creation function.
 

Additional Inherited Members

- Public Types inherited from YODA::Reader
using TypeRegisterItr = typename std::unordered_map< std::string, std::unique_ptr< AOReaderBase > >::const_iterator
 Convenience alias for AO Reader.
 

Detailed Description

Persistency reader from YODA text data format.

Definition at line 15 of file ReaderH5.h.

Constructor & Destructor Documentation

◆ ReaderH5() [1/2]

YODA::ReaderH5::ReaderH5 ( const ReaderH5 )
delete

Disable copy and move constructors.

◆ ReaderH5() [2/2]

YODA::ReaderH5::ReaderH5 ( ReaderH5 &&  )
delete

Member Function Documentation

◆ create()

Reader & YODA::ReaderH5::create ( )
static

Singleton creation function.

Definition at line 28 of file ReaderH5.cc.

28 {
29 static ReaderH5 _instance;
30 _instance.registerDefaultTypes<double,int,string>();
31 return _instance;
32 }
ReaderH5(const ReaderH5 &)=delete
Disable copy and move constructors.

Referenced by YODA::mkReader().

◆ operator=() [1/2]

void YODA::ReaderH5::operator= ( const ReaderH5 )
delete

Disable copy and move assignments.

◆ operator=() [2/2]

void YODA::ReaderH5::operator= ( ReaderH5 &&  )
delete

◆ read()

void YODA::ReaderH5::read ( const YODA_H5::File &  file,
std::vector< AnalysisObject * > &  aos,
const std::string &  match = "",
const std::string &  unmatch = "" 
)
virtual

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.

Implements YODA::Reader.

Definition at line 78 of file ReaderH5.cc.

79 {
80
81 vector<regex> patterns, unpatterns;
82 for (const string& pat : Utils::split(match, ",")) { patterns.push_back(regex(pat)); }
83 for (const string& pat : Utils::split(unmatch, ",")) { unpatterns.push_back(regex(pat)); }
84
85 // Load edge information
86 H5FileManager reader(file);
87
88 // Prepare registry
89 TypeRegisterItr thisAOR = _register.cend();
90 const TypeRegisterItr endAOR = _register.cend();
91
92 while (reader.next()) {
93
94 // Check that type has been loaded
95 thisAOR = _register.find(reader.type());
96 if (thisAOR == endAOR) {
97 throw ReadError("Unexpected context found: " + reader.type());
98 }
99
100 // Check if path is being (un-)matched
101 //
102 // Since the edge types are not known until run time,
103 // (empty) objects still need to be instantiated
104 // from the type registry in order to be able to
105 // choose the correct set of edges to skip.
106 const bool pattern_pass = patternCheck(reader.path(), patterns, unpatterns);
107 if (!pattern_pass) {
108 thisAOR->second->skip(reader);
109 continue;
110 }
111
112 // Construct AO
113 aos.push_back(thisAOR->second->mkFromH5(reader));
114 }
115 }
typename std::unordered_map< std::string, std::unique_ptr< AOReaderBase > >::const_iterator TypeRegisterItr
Convenience alias for AO Reader.
Definition Reader.h:40
bool patternCheck(const std::string &path, const std::vector< std::regex > &patterns, const std::vector< std::regex > &unpatterns)
Check if a string matches any of the given patterns, and that it doesn't match any unpatterns (for pa...
Definition Reader.h:200

References YODA::H5FileManager::next(), YODA::H5FileManager::path(), YODA::Reader::patternCheck(), and YODA::H5FileManager::type().


The documentation for this class was generated from the following files: