LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
SIO::LCIORandomAccessMgr Class Reference

Manager class for LCIO direct access. More...

#include <LCIORandomAccessMgr.h>

Public Types

typedef RunEvent::long64 long64
 
typedef std::list
< std::shared_ptr
< LCIORandomAccess > > 
LCIORandomAccessList
 

Public Member Functions

 LCIORandomAccessMgr ()=default
 
 LCIORandomAccessMgr (const LCIORandomAccessMgr &)=delete
 
LCIORandomAccessMgroperator= (const LCIORandomAccessMgr &)=delete
 
 ~LCIORandomAccessMgr ()=default
 
long64 getPosition (const RunEvent &re)
 Return the position of the specified Event record or Run record respectively (if EventNum == -1 ). More...
 
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. More...
 
bool createEventMap (sio::ifstream &stream)
 Get the run and event header map from the stream - either by reading the random access records or by recreating it for old files. More...
 
std::shared_ptr< RunEventMapgetEventMap ()
 Return the event map - it will be empty, if not yet created. More...
 
bool initAppend (sio::ifstream &stream)
 Initialize random access for append mode: read last LCIORandomAccess record if it exists - recreate the RunEvent map from the file if not (old files). More...
 
void writeRandomAccessRecords (sio::ofstream &stream)
 Write the current random access records LCIOIndex and LCIORandomAccess to the stream. More...
 
void clear ()
 Clear all lists and maps before closing a file. More...
 
void seekStream (sio::ifstream &stream, long64 pos)
 Seek the stream at the given position. More...
 

Protected Member Functions

std::shared_ptr< LCIORandomAccesscreateFromEventMap () const
 Prepare an LCIORandomAccess object from the current contents of RunEventMap (all file locations set to 0). More...
 
void addLCIORandomAccess (std::shared_ptr< LCIORandomAccess > ra)
 Add a new LCIORandomAccess object to the list. More...
 
bool readLCIORandomAccessAt (sio::ifstream &stream, long64 pos)
 Read the LCIORandomAccess record at the specified position. More...
 
bool readLCIOIndexAt (sio::ifstream &stream, long64 pos)
 Read the LCIOIndex record at the specified position. More...
 
bool recreateEventMap (sio::ifstream &stream)
 Fill the RunEventMap from the event and run header records in the file. More...
 
bool readLCIORandomAccess (sio::ifstream &stream)
 Helper for reading the next LCIORandomAccess record (need preceeding call to LCSIO::seek() ) More...
 
bool readLCIOIndex (sio::ifstream &stream)
 Helper for reading the next LCIOIndex record (need preceeding call to LCSIO::seek() ) More...
 
void createFileRecord ()
 Create file record from all LCIORandomAccess records. More...
 
const std::shared_ptr
< LCIORandomAccess
lastLCIORandomAccess () const
 Pointer to the last LCIORandomAccess in the list. More...
 

Private Attributes

sio::buffer _rawBuffer { 32*sio::kbyte }
 
sio::buffer _compressBuffer { 32*sio::kbyte }
 
std::shared_ptr< RunEventMap_runEvtMap {std::make_shared<RunEventMap>()}
 Map with RunHeader and EventHeader record positions. More...
 
LCIORandomAccessList _list {}
 List of LCIORandomAccess objects. More...
 
std::shared_ptr< LCIORandomAccess_fileRecord {nullptr}
 The file record summary. More...
 

Friends

class SIOIndexHandler
 
class SIORandomAccessHandler
 
std::ostreamoperator<< (std::ostream &os, const LCIORandomAccessMgr &ra)
 

Detailed Description

Manager class for LCIO direct access.

Provides the functionality for reading and writing the LCIORandomAccess and LCIOIndex records as needed by SIOReader and SIOWriter. Direct Access is implemented through appending LCIOIndex and LCIORandomAccess and records to the end of the LCIO file. The LCIOIndex records hold the locations of the RunHeader and EventHeader in the file and are referenced by corresponding LCIORandomAccess records. The last record in the file will always be an LCIORandomAccess record - and previous records can be found through pointers to the previous record (simply linked list). LCIORandomAccess are always stored uncompressed. When reading a file with direct access mode a RunEvent map is created by reading all LCIORandomAccess and LCIOIndex records or - for old files - is recreated from all RunHeader and EventHeader records in the file. If an old file is opened in APPEND mode the corresponding records are created and written at the end on close()

See Also
writeRandomAccessRecords(). : currently the last LCIORandomAccess record is found by seeking a fixed size from the end - need to store the actual length as last word in the file for future changes of the records length
Author
gaede
Version
Id:
LCIORandomAccessMgr.h,v 1.3 2011-03-03 16:00:12 gaede Exp

Definition at line 43 of file LCIORandomAccessMgr.h.

Member Typedef Documentation

Definition at line 50 of file LCIORandomAccessMgr.h.

Definition at line 49 of file LCIORandomAccessMgr.h.

Constructor & Destructor Documentation

SIO::LCIORandomAccessMgr::LCIORandomAccessMgr ( )
default
SIO::LCIORandomAccessMgr::LCIORandomAccessMgr ( const LCIORandomAccessMgr )
delete
SIO::LCIORandomAccessMgr::~LCIORandomAccessMgr ( )
default

Member Function Documentation

void SIO::LCIORandomAccessMgr::add ( const RunEvent re,
long64  pos 
)
inline

Add a new entry to the event map - if the RunEvent already exists the new position will be stored.

Definition at line 67 of file LCIORandomAccessMgr.h.

References _runEvtMap.

Referenced by SIO::SIOWriter::writeEvent(), and SIO::SIOWriter::writeRunHeader().

void SIO::LCIORandomAccessMgr::addLCIORandomAccess ( std::shared_ptr< LCIORandomAccess ra)
protected

Add a new LCIORandomAccess object to the list.

Definition at line 80 of file LCIORandomAccessMgr.cc.

References _list, and std::list< T >::push_back().

Referenced by readLCIORandomAccess(), and writeRandomAccessRecords().

void SIO::LCIORandomAccessMgr::clear ( )

Clear all lists and maps before closing a file.

Definition at line 23 of file LCIORandomAccessMgr.cc.

References _fileRecord, _list, _runEvtMap, and std::list< T >::clear().

Referenced by SIO::SIOWriter::close().

bool SIO::LCIORandomAccessMgr::createEventMap ( sio::ifstream &  stream)

Get the run and event header map from the stream - either by reading the random access records or by recreating it for old files.

Definition at line 191 of file LCIORandomAccessMgr.cc.

References _fileRecord, _list, std::list< T >::back(), lastLCIORandomAccess(), std::list< T >::pop_back(), SIO::LCSIO::RandomAccessSize, readLCIOIndexAt(), readLCIORandomAccessAt(), recreateEventMap(), and seekStream().

void SIO::LCIORandomAccessMgr::createFileRecord ( )
protected

Create file record from all LCIORandomAccess records.

Definition at line 47 of file LCIORandomAccessMgr.cc.

References _fileRecord, _list, std::list< T >::begin(), and std::list< T >::end().

Referenced by writeRandomAccessRecords().

std::shared_ptr< LCIORandomAccess > SIO::LCIORandomAccessMgr::createFromEventMap ( ) const
protected

Prepare an LCIORandomAccess object from the current contents of RunEventMap (all file locations set to 0).

Definition at line 31 of file LCIORandomAccessMgr.cc.

References _runEvtMap.

Referenced by writeRandomAccessRecords().

std::shared_ptr<RunEventMap> SIO::LCIORandomAccessMgr::getEventMap ( )
inline

Return the event map - it will be empty, if not yet created.

Definition at line 78 of file LCIORandomAccessMgr.h.

References _runEvtMap.

long64 SIO::LCIORandomAccessMgr::getPosition ( const RunEvent re)
inline

Return the position of the specified Event record or Run record respectively (if EventNum == -1 ).

Returns RunEventMap::NPos if no record found.

Definition at line 61 of file LCIORandomAccessMgr.h.

References _runEvtMap.

bool SIO::LCIORandomAccessMgr::initAppend ( sio::ifstream &  stream)

Initialize random access for append mode: read last LCIORandomAccess record if it exists - recreate the RunEvent map from the file if not (old files).

Definition at line 175 of file LCIORandomAccessMgr.cc.

References _fileRecord, _list, std::list< T >::back(), std::list< T >::pop_back(), SIO::LCSIO::RandomAccessSize, readLCIORandomAccessAt(), and recreateEventMap().

Referenced by SIO::SIOWriter::open().

const std::shared_ptr<LCIORandomAccess> SIO::LCIORandomAccessMgr::lastLCIORandomAccess ( ) const
inlineprotected

Pointer to the last LCIORandomAccess in the list.

Definition at line 124 of file LCIORandomAccessMgr.h.

References _list, std::list< T >::back(), and std::list< T >::empty().

Referenced by createEventMap(), and writeRandomAccessRecords().

LCIORandomAccessMgr& SIO::LCIORandomAccessMgr::operator= ( const LCIORandomAccessMgr )
delete
bool SIO::LCIORandomAccessMgr::readLCIOIndex ( sio::ifstream &  stream)
protected

Helper for reading the next LCIOIndex record (need preceeding call to LCSIO::seek() )

Definition at line 134 of file LCIORandomAccessMgr.cc.

References _rawBuffer, _runEvtMap, SIO::LCSIO::IndexRecordName, and seekStream().

Referenced by readLCIOIndexAt().

bool SIO::LCIORandomAccessMgr::readLCIOIndexAt ( sio::ifstream &  stream,
long64  pos 
)
protected

Read the LCIOIndex record at the specified position.

Definition at line 127 of file LCIORandomAccessMgr.cc.

References readLCIOIndex(), and seekStream().

Referenced by createEventMap().

bool SIO::LCIORandomAccessMgr::readLCIORandomAccess ( sio::ifstream &  stream)
protected

Helper for reading the next LCIORandomAccess record (need preceeding call to LCSIO::seek() )

Definition at line 93 of file LCIORandomAccessMgr.cc.

References _rawBuffer, SIO::LCSIO::AccessRecordName, addLCIORandomAccess(), and seekStream().

Referenced by readLCIORandomAccessAt().

bool SIO::LCIORandomAccessMgr::readLCIORandomAccessAt ( sio::ifstream &  stream,
long64  pos 
)
protected

Read the LCIORandomAccess record at the specified position.

Definition at line 86 of file LCIORandomAccessMgr.cc.

References readLCIORandomAccess(), and seekStream().

Referenced by createEventMap(), and initAppend().

bool SIO::LCIORandomAccessMgr::recreateEventMap ( sio::ifstream &  stream)
protected
void SIO::LCIORandomAccessMgr::seekStream ( sio::ifstream &  stream,
long64  pos 
)
void SIO::LCIORandomAccessMgr::writeRandomAccessRecords ( sio::ofstream &  stream)

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream os,
const LCIORandomAccessMgr ra 
)
friend
friend class SIOIndexHandler
friend

Definition at line 44 of file LCIORandomAccessMgr.h.

friend class SIORandomAccessHandler
friend

Definition at line 45 of file LCIORandomAccessMgr.h.

Member Data Documentation

sio::buffer SIO::LCIORandomAccessMgr::_compressBuffer { 32*sio::kbyte }
private

Definition at line 131 of file LCIORandomAccessMgr.h.

Referenced by recreateEventMap().

std::shared_ptr<LCIORandomAccess> SIO::LCIORandomAccessMgr::_fileRecord {nullptr}
private

The file record summary.

Definition at line 137 of file LCIORandomAccessMgr.h.

Referenced by clear(), createEventMap(), createFileRecord(), initAppend(), and writeRandomAccessRecords().

LCIORandomAccessList SIO::LCIORandomAccessMgr::_list {}
private
sio::buffer SIO::LCIORandomAccessMgr::_rawBuffer { 32*sio::kbyte }
private
std::shared_ptr<RunEventMap> SIO::LCIORandomAccessMgr::_runEvtMap {std::make_shared<RunEventMap>()}
private

Map with RunHeader and EventHeader record positions.

Definition at line 133 of file LCIORandomAccessMgr.h.

Referenced by add(), clear(), createFromEventMap(), getEventMap(), getPosition(), SIO::operator<<(), readLCIOIndex(), recreateEventMap(), and writeRandomAccessRecords().


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