fire v0.19.0
Framework for sImulation and Reconstruction of Events
fire::io::Reader Class Referenceabstract

Prototype for reading files within fire. More...

#include <Reader.h>

Inheritance diagram for fire::io::Reader:
[legend]

Public Types

using Factory = ::fire::factory::Factory< Reader, std::unique_ptr< Reader >, const std::string & >
 Type of factory used to create readers.
 

Public Member Functions

 Reader (const std::string &file_name)
 open the file at the passed location More...
 
virtual ~Reader ()=default
 virtual destructor so derived classes can be closed
 
virtual void load_into (BaseData &d)=0
 Load the current event into the passed data object. More...
 
virtual std::string name () const =0
 Return the name of the file. More...
 
virtual std::size_t entries () const =0
 Return the number of events in the file. More...
 
virtual std::size_t runs () const =0
 Return the number of runs in the file. More...
 
virtual std::vector< std::pair< std::string, std::string > > availableObjects ()=0
 Get the event objects available in the file. More...
 
virtual std::pair< std::string, int > type (const std::string &path)=0
 Get the type of the input object. More...
 
virtual bool canCopy () const
 Event::get needs to know if the reader implements a copy that advances the entry index of the data sets being read. More...
 
virtual void copy (long unsigned int i_entry, const std::string &path, Writer &output)
 Copy the input object into the output file. More...
 

Detailed Description

Prototype for reading files within fire.

This is a prototype class in the sense of fire::factory::Factory, derived classes can register themselves and then the fire::Process can use io::Reader::Factory to create readers from their types.

A reader has a lot of responsiblities in fire, so developing a new one should not be taken lightly.

Besides deriving this class, additional io::Data::load methods need to be defined so that the Reader and successfully interact with the in-memory data objects.

Constructor & Destructor Documentation

◆ Reader()

fire::io::Reader::Reader ( const std::string file_name)
inline

open the file at the passed location

Parameters
[in]file_namefull path to file to open

Member Function Documentation

◆ availableObjects()

virtual std::vector< std::pair< std::string, std::string > > fire::io::Reader::availableObjects ( )
pure virtual

Get the event objects available in the file.

Returns
vector of string pairs { obj_name, pass }

Implemented in fire::io::h5::Reader, and fire::io::root::Reader.

◆ canCopy()

virtual bool fire::io::Reader::canCopy ( ) const
inlinevirtual

Event::get needs to know if the reader implements a copy that advances the entry index of the data sets being read.

Returns
true if the reader implements a copy

Reimplemented in fire::io::h5::Reader.

◆ copy()

virtual void fire::io::Reader::copy ( long unsigned int  i_entry,
const std::string path,
Writer output 
)
inlinevirtual

Copy the input object into the output file.

Parameters
[in]i_entrythe entry index that is being copied from this reader to output
[in]paththe full object path that should be copied
[out]outputthe writer we should write the copy to

◆ entries()

virtual std::size_t fire::io::Reader::entries ( ) const
pure virtual

Return the number of events in the file.

Returns
number of events in the file

Implemented in fire::io::h5::Reader, and fire::io::root::Reader.

◆ load_into()

virtual void fire::io::Reader::load_into ( BaseData d)
pure virtual

Load the current event into the passed data object.

This must be defined in derived classes to be

virtual void load_into(BaseData& d) final override {
d.load(*this);
}
virtual void load_into(BaseData &d)=0
Load the current event into the passed data object.

We require this function so that the different implementations of io::Data::load are correctly called based on the type of the derived reader.

Parameters
[in]ddata object to load into

Implemented in fire::io::h5::Reader, and fire::io::root::Reader.

◆ name()

virtual std::string fire::io::Reader::name ( ) const
pure virtual

Return the name of the file.

Returns
name of file

Implemented in fire::io::h5::Reader, and fire::io::root::Reader.

◆ runs()

virtual std::size_t fire::io::Reader::runs ( ) const
pure virtual

Return the number of runs in the file.

Returns
number of runs in the file

Implemented in fire::io::h5::Reader, and fire::io::root::Reader.

◆ type()

virtual std::pair< std::string, int > fire::io::Reader::type ( const std::string path)
pure virtual

Get the type of the input object.

Returns
pair of string type of input full object name and its version

Implemented in fire::io::h5::Reader, and fire::io::root::Reader.


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