evio  6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
evio::FileEventIndex Class Reference

Class used to handle event indexes in the context of a file (or buffer) and having to change records. More...

#include <FileEventIndex.h>

Public Member Functions

 FileEventIndex ()=default
 Constructor. More...
 
void clear ()
 Clear the entire object. More...
 
void resetIndex ()
 Resets the current index to 0. More...
 
void show ()
 Prints the content of the event index array on the screen. More...
 
void addEventSize (uint32_t size)
 Adds the number of events in the next record to the index of records. More...
 
uint32_t getEventNumber () const
 Gets the current event number which is set by advance(), retreat() or setEvent(uint32_t) (which also sets the record number that the event belongs to). More...
 
uint32_t getRecordNumber () const
 Gets the current record number which is set by setEvent(uint32_t), or by using advance() or retreat() (which set the event number to the next available or previous available respectively). More...
 
uint32_t getRecordEventNumber () const
 Gets the event number inside the record that corresponds to the current global event number from the file. More...
 
uint32_t getMaxEvents () const
 Gets the total number of events in file. More...
 
bool canAdvance () const
 Checks to see if the event counter reached the end. More...
 
bool canRetreat () const
 Checks if the event index can retreat (decrease). More...
 
bool advance ()
 Advances the current event number by one. More...
 
bool retreat ()
 Reduces current event number by one. More...
 
bool setEvent (uint32_t event)
 Set the current event to the desired position. More...
 
std::string toString ()
 Get a string representation of this object. More...
 
int main (int argc, char **argv)
 

Detailed Description

Class used to handle event indexes in the context of a file (or buffer) and having to change records.

Date
09/25/2019
Author
gavalian (original java)
timmer

Constructor & Destructor Documentation

evio::FileEventIndex::FileEventIndex ( )
default

Constructor.

Member Function Documentation

void evio::FileEventIndex::addEventSize ( uint32_t  size)

Adds the number of events in the next record to the index of records.

Internally, what is stored is the total number of events in the file up to and including the record of this entry.

Parameters
sizenumber of events in the next record.

Referenced by evio::Reader::forceScanFile(), main(), evio::Reader::scanBuffer(), evio::Reader::scanFile(), and evio::Reader::scanUncompressedBuffer().

bool evio::FileEventIndex::advance ( )

Advances the current event number by one.

If the event is not from current record, the record number will also be changed. If calling this would advance the current event number beyond its maximum limit, nothing is done.

Returns
false if the record number is the same, and true if the record number has changed.

Referenced by main().

bool evio::FileEventIndex::canAdvance ( ) const

Checks to see if the event counter reached the end.

Returns
true if there are more events to advance to, false otherwise.

References getMaxEvents().

Referenced by evio::Reader::hasNext().

bool evio::FileEventIndex::canRetreat ( ) const

Checks if the event index can retreat (decrease).

Convenience function.

Returns
true if the event index can be lowered by one.

Referenced by evio::Reader::hasPrev().

uint32_t evio::FileEventIndex::getEventNumber ( ) const

Gets the current event number which is set by advance(), retreat() or setEvent(uint32_t) (which also sets the record number that the event belongs to).

Returns
current event number.
uint32_t evio::FileEventIndex::getMaxEvents ( ) const

Gets the total number of events in file.

Returns
returns the number of events corresponding to the all records.

Referenced by canAdvance(), evio::Reader::getEvent(), evio::Reader::getEventCount(), evio::Reader::getEventLength(), evio::Reader::getEventNode(), evio::Reader::getNextEventNode(), evio::Reader::getNumEventsRemaining(), setEvent(), show(), and toString().

uint32_t evio::FileEventIndex::getRecordEventNumber ( ) const

Gets the event number inside the record that corresponds to the current global event number from the file.

Returns
event offset in the record.

Referenced by evio::Reader::getEvent(), and evio::Reader::getEventLength().

uint32_t evio::FileEventIndex::getRecordNumber ( ) const

Gets the current record number which is set by setEvent(uint32_t), or by using advance() or retreat() (which set the event number to the next available or previous available respectively).

Returns
current record number.

Referenced by evio::Reader::getEvent(), and evio::Reader::getEventLength().

int evio::FileEventIndex::main ( int  argc,
char **  argv 
)
void evio::FileEventIndex::resetIndex ( )

Resets the current index to 0.

The corresponding record number is recalculated by calling the setEvent(uint32_t) method.

References setEvent().

bool evio::FileEventIndex::retreat ( )

Reduces current event number by one.

If the record number changes, it returns true.

Returns
false if the record number is the same, and true is the record number has changed.

Referenced by main().

bool evio::FileEventIndex::setEvent ( uint32_t  event)

Set the current event to the desired position.

The current record and event offset inside of the record are updated as well.

Parameters
eventevent number in the stream, must be 0 to getMaxEvents()-1.
Returns
true if record is different from previous one, false if it is the same.

References getMaxEvents().

Referenced by evio::Reader::getEvent(), evio::Reader::getEventLength(), main(), and resetIndex().

void evio::FileEventIndex::show ( )

Prints the content of the event index array on the screen.

References getMaxEvents().

Referenced by main().

std::string evio::FileEventIndex::toString ( )

Get a string representation of this object.

Returns
a string representation of this object.

References getMaxEvents().

Referenced by main().


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