1 #ifndef SIO_LCIORandomAccessMgr_H
2 #define SIO_LCIORandomAccessMgr_H 1
10 #include <sio/definitions.h>
11 #include <sio/buffer.h>
20 class LCIORandomAccessMgr ;
21 class SIOIndexHandler ;
22 class SIORandomAccessHandler ;
Manager class for LCIO direct access.
std::shared_ptr< LCIORandomAccess > _fileRecord
The file record summary.
bool createEventMap(sio::ifstream &stream)
Get the run and event header map from the stream - either by reading the random access records or by ...
std::list< std::shared_ptr< LCIORandomAccess > > LCIORandomAccessList
LCIORandomAccessMgr()=default
bool initAppend(sio::ifstream &stream)
Initialize random access for append mode: read last LCIORandomAccess record if it exists - recreate t...
std::shared_ptr< LCIORandomAccess > createFromEventMap() const
Prepare an LCIORandomAccess object from the current contents of RunEventMap (all file locations set t...
Helper struct that stores run and event positions in the file.
bool readLCIOIndex(sio::ifstream &stream)
Helper for reading the next LCIOIndex record (need preceeding call to LCSIO::seek() ) ...
void addLCIORandomAccess(std::shared_ptr< LCIORandomAccess > ra)
Add a new LCIORandomAccess object to the list.
std::ostream & operator<<(std::ostream &os, const LCIORandomAccess &ra)
bool recreateEventMap(sio::ifstream &stream)
Fill the RunEventMap from the event and run header records in the file.
bool readLCIORandomAccess(sio::ifstream &stream)
Helper for reading the next LCIORandomAccess record (need preceeding call to LCSIO::seek() ) ...
void add(const RunEvent &re, long64 pos)
Add a new entry to the event map - if the RunEvent already exists the new position will be stored...
~LCIORandomAccessMgr()=default
Handler for LCIOrandomAccess and LCIOIndex objects/blocks.
friend std::ostream & operator<<(std::ostream &os, const LCIORandomAccessMgr &ra)
const std::shared_ptr< LCIORandomAccess > lastLCIORandomAccess() const
Pointer to the last LCIORandomAccess in the list.
bool readLCIORandomAccessAt(sio::ifstream &stream, long64 pos)
Read the LCIORandomAccess record at the specified position.
sio::buffer _compressBuffer
bool readLCIOIndexAt(sio::ifstream &stream, long64 pos)
Read the LCIOIndex record at the specified position.
void writeRandomAccessRecords(sio::ofstream &stream)
Write the current random access records LCIOIndex and LCIORandomAccess to the stream.
void createFileRecord()
Create file record from all LCIORandomAccess records.
LCIORandomAccessList _list
List of LCIORandomAccess objects.
std::shared_ptr< RunEventMap > getEventMap()
Return the event map - it will be empty, if not yet created.
std::shared_ptr< RunEventMap > _runEvtMap
Map with RunHeader and EventHeader record positions.
void clear()
Clear all lists and maps before closing a file.
void seekStream(sio::ifstream &stream, long64 pos)
Seek the stream at the given position.
long64 getPosition(const RunEvent &re)
Return the position of the specified Event record or Run record respectively (if EventNum == -1 )...
Handler for LCIOrandomAccess and LCIOIndex objects/blocks.
LCIORandomAccessMgr & operator=(const LCIORandomAccessMgr &)=delete