evio
6.0
|
#include <RecordHeader.h>
Public Member Functions | |
RecordHeader () | |
Default, no-arg constructor. More... | |
RecordHeader (const RecordHeader &head) | |
Copy constructor. More... | |
RecordHeader (const HeaderType &type) | |
Constructor which sets the type of header this is. More... | |
RecordHeader (size_t pos, uint32_t len, uint32_t ent) | |
Constructor. More... | |
~RecordHeader ()=default | |
RecordHeader & | operator= (const RecordHeader &head) |
void | copy (std::shared_ptr< RecordHeader > const &head) |
Copy method. More... | |
void | reset () |
Reset generated data. More... | |
const HeaderType & | getHeaderType () const |
Get the type of header this is. More... | |
uint32_t | getUncompressedRecordLength () const |
Get the padded length in bytes of the entire uncompressed record. More... | |
uint32_t | getCompressedRecordLength () const |
Get the padded length in bytes of the entire compressed record. More... | |
uint32_t | getLength () const |
Get the total length of this record in bytes. More... | |
uint32_t | getLengthWords () const |
Get the total length of this record in 32 bit words. More... | |
uint32_t | getEntries () const |
Get the number of events or entries in index. More... | |
uint32_t | getUserHeaderLength () const |
Get the length of the user-defined header in bytes. More... | |
uint32_t | getUserHeaderLengthWords () const |
Get the length of the user-defined header in words. More... | |
uint32_t | getDataLength () const |
Get the length of the uncompressed data in bytes. More... | |
uint32_t | getDataLengthWords () const |
Get the length of the uncompressed data in words (padded). More... | |
uint32_t | getIndexLength () const |
Get the length of the index array in bytes. More... | |
uint32_t | getCompressedDataLength () const |
Get the length of the compressed data in bytes. More... | |
uint32_t | getCompressedDataLengthPadding () const |
Get the padding of the compressed data in bytes. More... | |
uint32_t | getCompressedDataLengthWords () const |
Get the length of the compressed data in words (padded). More... | |
uint32_t | getHeaderLength () const |
Get the length of this header in bytes (NOT including user header or index). More... | |
uint32_t | getRecordNumber () const |
Get the record number. More... | |
uint64_t | getUserRegisterFirst () const |
Get the first user-defined 64-bit register. More... | |
uint64_t | getUserRegisterSecond () const |
Get the second user-defined 64-bit register. More... | |
size_t | getPosition () const |
Get the position of this record in a file. More... | |
Compressor::CompressionType | getCompressionType () override |
Get the type of compression used. More... | |
uint32_t | setBitInfo (bool isLastRecord, bool haveDictionary) |
Set the bit info word for a record header. More... | |
uint32_t | getBitInfoWord () const |
Get the bit info word. More... | |
void | setBitInfoWord (uint32_t word) |
Set the bit info word and related values. More... | |
void | setBitInfoWord (std::bitset< 24 > const &set) |
Set the bit info word and related values. More... | |
uint32_t | hasDictionary (bool hasFirst) |
Set the bit which says record has a dictionary in the user header. More... | |
uint32_t | isLastRecord (bool isLast) |
Set the bit which says record is last in file/buffer. More... | |
bool | isLastRecord () const |
Is this the header of the last record? More... | |
bool | isCompressed () override |
Does this header indicate compressed data? More... | |
bool | isEvioTrailer () const |
Is this header an evio trailer? More... | |
bool | isEvioRecord () const |
Is this header an evio record? More... | |
bool | isHipoTrailer () const |
Is this header a hipo trailer? More... | |
bool | isHipoRecord () const |
Is this header a hipo record? More... | |
uint32_t | setBitInfoEventType (uint32_t type) |
Set the bit info of a record header for a specified CODA event type. More... | |
RecordHeader & | setHeaderType (HeaderType const &type) |
Set this header's type. More... | |
RecordHeader & | setPosition (size_t pos) |
Set the position of this record in a file. More... | |
RecordHeader & | setRecordNumber (uint32_t num) |
Set the record number. More... | |
RecordHeader & | setLength (uint32_t length) |
Set the record length in bytes & words. More... | |
RecordHeader & | setDataLength (uint32_t length) |
Set the uncompressed data length in bytes & words and the padding. More... | |
RecordHeader & | setCompressedDataLength (uint32_t length) |
Set the compressed data length in bytes & words and the padding. More... | |
RecordHeader & | setIndexLength (uint32_t length) |
Set the length of the index array in bytes. More... | |
RecordHeader & | setCompressionType (Compressor::CompressionType type) |
Set the compression type. More... | |
RecordHeader & | setEntries (uint32_t n) |
Set the number of events or index entries. More... | |
RecordHeader & | setUserHeaderLength (uint32_t length) |
Set the user-defined header's length in bytes & words and the padding. More... | |
RecordHeader & | setHeaderLength (uint32_t length) |
Set the this header's length in bytes & words. More... | |
RecordHeader & | setUserRegisterFirst (uint64_t reg) |
Set the first, 64-bit, user-defined register. More... | |
RecordHeader & | setUserRegisterSecond (uint64_t reg) |
Set the second, 64-bit, user-defined register. More... | |
void | writeHeader (ByteBuffer &buf, size_t off=0) |
Writes this header into the given byte buffer. More... | |
void | writeHeader (std::shared_ptr< ByteBuffer > &buffer, size_t off=0) |
Writes this header into the given byte buffer. More... | |
void | writeHeader (uint8_t *array, const ByteOrder &order) |
Writes this header at the given pointer. More... | |
void | readHeader (ByteBuffer &buffer, size_t offset=0) |
Reads the header information from a byte buffer and validates it by checking the magic word (8th word). More... | |
void | readHeader (std::shared_ptr< ByteBuffer > &buffer, size_t offset=0) |
Reads the header information from a byte buffer and validates it by checking the magic word (8th word). More... | |
void | readHeader (uint8_t *src, ByteOrder order) |
Reads the header information from a byte buffer and validates it by checking the magic word (8th word). More... | |
std::string | eventTypeToString () const |
Return a meaningful string associated with event type. More... | |
uint32_t | getSize () override |
Get the size of the record)in 32 bit words. More... | |
uint32_t | getNumber () override |
Get the block number for this record) In a file, this is usually sequential. More... | |
uint32_t | getHeaderWords () override |
Get the length of this header in words. More... | |
uint32_t | getSourceId () override |
Get the source ID number if in CODA online context and data is coming from ROC. More... | |
bool | hasFirstEvent () override |
Does this header have a first event in the user header? More... | |
uint32_t | getEventType () override |
Get the type of events in record (see values of DataType. More... | |
uint32_t | getVersion () override |
Get the Evio format version number. More... | |
uint32_t | getMagicNumber () override |
Get the magic number the record)header which should be 0xc0da0100. More... | |
ByteOrder & | getByteOrder () override |
Get the byte order of the file/buffer this header was read from. More... | |
bool | hasDictionary () override |
Does this record have a dictionary in the user header? More... | |
bool | isLastBlock () override |
Is this the last record in the file or being sent over the network? More... | |
std::string | toString () override |
Returns a string representation of this record. More... | |
size_t | write (ByteBuffer &byteBuffer) override |
Write myself out into a byte buffer. More... | |
size_t | getBufferEndingPosition () override |
Get the position in the buffer (bytes) of this record's last data word. More... | |
size_t | getBufferStartingPosition () override |
Get the starting position in the buffer (bytes) from which this header was read–if that happened. More... | |
void | setBufferStartingPosition (size_t bufferStartingPosition) override |
Set the starting position in the buffer (bytes) from which this header was read–if that happened. More... | |
size_t | nextBufferStartingPosition () override |
Determines where the start of the next record header in some buffer is located (bytes). More... | |
size_t | firstEventStartingPosition () override |
Determines where the start of the first event in this record is located (bytes). More... | |
size_t | bytesRemaining (size_t pos) override |
Gives the bytes remaining in this record given a buffer position. More... | |
int | main (int argc, char **argv) |
Run this class as an executable which tests the writing and reading of a record. More... | |
Static Public Member Functions | |
static uint32_t | getWords (uint32_t length) |
Returns length padded to 4-byte boundary for given length in bytes. More... | |
static uint32_t | getPadding (uint32_t length) |
Returns number of bytes needed to pad to 4-byte boundary for the given length. More... | |
static uint32_t | generateSixthWord (std::bitset< 24 > const &set) |
Calculates the sixth word of this header which has the version number (6) in the lowest 8 bits and the set in the upper 24 bits. More... | |
static uint32_t | generateSixthWord (uint32_t version, bool hasDictionary, bool isEnd, uint32_t eventType) |
Calculates the sixth word of this header which has the version number in the lowest 8 bits. More... | |
static uint32_t | generateSixthWord (std::bitset< 24 > const &set, uint32_t version, bool hasDictionary, bool isEnd, uint32_t eventType, uint32_t headerType=0) |
Calculates the sixth word of this header which has the version number (4) in the lowest 8 bits and the set in the upper 24 bits. More... | |
static bool | hasDictionary (int bitInfo) |
Does this bitInfo arg indicate the existence of a dictionary in the user header? More... | |
static bool | isLastRecord (uint32_t bitInfo) |
Does this word indicate this is the header of the last record? More... | |
static bool | isEvioTrailer (uint32_t bitInfo) |
Does this arg indicate its header is an evio trailer? More... | |
static bool | isEvioRecord (uint32_t bitInfo) |
Does this arg indicate its header is an evio record? More... | |
static bool | isHipoTrailer (uint32_t bitInfo) |
Does this arg indicate its header is a hipo trailer? More... | |
static bool | isHipoRecord (uint32_t bitInfo) |
Does this arg indicate its header is a hipo record? More... | |
static uint32_t | clearLastRecordBit (uint32_t i) |
Clear the bit in the given arg to indicate it is NOT the last record. More... | |
static void | writeTrailer (uint8_t *array, size_t arrayLen, uint32_t recordNum, const ByteOrder &order, const std::shared_ptr< std::vector< uint32_t >> &recordLengths=nullptr) |
static void | writeTrailer (std::vector< uint8_t > &array, size_t off, uint32_t recordNum, const ByteOrder &order, const std::shared_ptr< std::vector< uint32_t >> &recordLengths=nullptr) |
static void | writeTrailer (ByteBuffer &buf, size_t off, uint32_t recordNum, const std::shared_ptr< std::vector< uint32_t >> &recordLengths=nullptr) |
static void | writeTrailer (std::shared_ptr< ByteBuffer > &buf, size_t off, uint32_t recordNum, const std::shared_ptr< std::vector< uint32_t >> &recordLengths=nullptr) |
static bool | isCompressed (ByteBuffer &buffer, size_t offset) |
Quickly check to see if this buffer contains compressed data or not. More... | |
static bool | isCompressed (std::shared_ptr< ByteBuffer > &buffer, size_t offset) |
Quickly check to see if this buffer contains compressed data or not. More... | |
Static Public Attributes | |
static const uint32_t | HEADER_SIZE_WORDS = 14 |
Number of 32-bit words in a normal sized header. More... | |
static const uint32_t | HEADER_SIZE_BYTES = 56 |
Number of bytes in a normal sized header. More... | |
static const uint32_t | HEADER_MAGIC = 0xc0da0100 |
Magic number used to track endianness. More... | |
static const uint32_t | RECORD_LENGTH_OFFSET = 0 |
Byte offset from beginning of header to the record length. More... | |
static const uint32_t | RECORD_NUMBER_OFFSET = 4 |
Byte offset from beginning of header to the record number. More... | |
static const uint32_t | HEADER_LENGTH_OFFSET = 8 |
Byte offset from beginning of header to the header length. More... | |
static const uint32_t | EVENT_COUNT_OFFSET = 12 |
Byte offset from beginning of header to the event index count. More... | |
static const uint32_t | INDEX_ARRAY_OFFSET = 16 |
Byte offset from beginning of header to the index array length. More... | |
static const uint32_t | BIT_INFO_OFFSET = 20 |
Byte offset from beginning of header to bit info word. More... | |
static const uint32_t | USER_LENGTH_OFFSET = 24 |
Byte offset from beginning of header to the user header length. More... | |
static const uint32_t | MAGIC_OFFSET = 28 |
Byte offset from beginning of header to the magic number. More... | |
static const uint32_t | UNCOMPRESSED_LENGTH_OFFSET = 32 |
Byte offset from beginning of header to the uncompressed data length. More... | |
static const uint32_t | COMPRESSION_TYPE_OFFSET = 36 |
Byte offset from beginning of header to the compression type & compressed data length word. More... | |
static const uint32_t | REGISTER1_OFFSET = 40 |
Byte offset from beginning of header to the user register #1. More... | |
static const uint32_t | REGISTER2_OFFSET = 48 |
Byte offset from beginning of header to the user register #2. More... | |
static const uint32_t | DICTIONARY_BIT = 0x100 |
8th bit set in bitInfo word in header means contains dictionary. More... | |
static const uint32_t | LAST_RECORD_BIT = 0x200 |
9th bit set in bitInfo word in header means is last in stream or file. More... | |
static const uint32_t | DATA_ROC_RAW_BITS = 0x000 |
11-14th bits in bitInfo word in header for CODA data type, ROC raw = 0. More... | |
static const uint32_t | DATA_PHYSICS_BITS = 0x800 |
11-14th bits in bitInfo word in header for CODA data type, physics = 1. More... | |
static const uint32_t | DATA_PARTIAL_BITS = 0x1000 |
11-14th bits in bitInfo word in header for CODA data type, partial physics = 2. More... | |
static const uint32_t | DATA_DISENTANGLED_BITS = 0x1800 |
11-14th bits in bitInfo word in header for CODA data type, disentangled = 3. More... | |
static const uint32_t | DATA_USER_BITS = 0x2000 |
11-14th bits in bitInfo word in header for CODA data type, user = 4. More... | |
static const uint32_t | DATA_CONTROL_BITS = 0x2800 |
11-14th bits in bitInfo word in record header for CODA data type, control = 5. More... | |
static const uint32_t | DATA_OTHER_BITS = 0x7800 |
11-14th bits in bitInfo word in record header for CODA data type, other = 15. More... | |
static const uint32_t | VERSION_MASK = 0xff |
Mask to get version number from 6th int in header. More... | |
static const uint32_t | LAST_RECORD_MASK = 0x400 |
"Last record" is 11th bit in bitInfo word. More... | |
static const uint32_t | MAGIC_NUMBER = 0xc0da0100 |
The magic number, should be the value of magicNumber . More... | |
GENERAL RECORD HEADER STRUCTURE ( 56 bytes, 14 integers (32 bit) )
+----------------------------------+
1 | Record Length | // 32bit words, inclusive
+----------------------------------+
2 + Record Number |
+----------------------------------+
3 + Header Length | // 14 (words)
+----------------------------------+
4 + Event (Index) Count |
+----------------------------------+
5 + Index Array Length | // bytes
+-----------------------+----------+
6 + Bit Info | Version | // version (8 bits)
+-----------------------+----------+
7 + User Header Length | // bytes
+----------------------------------+
8 + Magic Number | // 0xc0da0100
+----------------------------------+
9 + Uncompressed Data Length | // bytes
+------+---------------------------+
10 + CT | Data Length Compressed | // CT = compression type (4 bits); compressed len in words
+----------------------------------+
11 + User Register 1 | // UID 1st (64 bits)
+-- --+
12 + |
+----------------------------------+
13 + User Register 2 | // UID 2nd (64 bits)
+-- --+
14 + |
+----------------------------------+
-------------------
Compression Type
-------------------
0 = none
1 = LZ4 fastest
2 = LZ4 best
3 = gzip
-------------------
Bit Info Word
-------------------
0-7 = version
8 = true if dictionary is included (relevant for first record only)
9 = true if this record has "first" event (to be in every split file)
10 = true if this record is the last in file or stream
11-14 = type of events contained: 0 = ROC Raw,
1 = Physics
2 = PartialPhysics
3 = DisentangledPhysics
4 = User
5 = Control
15 = Other
15-19 = reserved
20-21 = pad 1
22-23 = pad 2
24-25 = pad 3
26-27 = reserved
28-31 = general header type: 0 = Evio record,
3 = Evio file trailer
4 = HIPO record,
7 = HIPO file trailer
------------------------------------------------------------
------------------------------------------------------------
TRAILER HEADER STRUCTURE ( 56 bytes, 14 integers (32 bit) )
+----------------------------------+
1 | Record Length | // 32bit words, inclusive
+----------------------------------+
2 + Record Number |
+----------------------------------+
3 + 14 |
+----------------------------------+
4 + 0 |
+----------------------------------+
5 + Index Array Length | // bytes
+-----------------------+----------+
6 + Bit Info | Version |
+-----------------------+----------+
7 + 0 |
+----------------------------------+
8 + 0xc0da0100 |
+----------------------------------+
9 + Uncompressed Data Length | // bytes
+----------------------------------+
10 + 0 |
+----------------------------------+
11 + 0 |
+-- --+
12 + 0 |
+----------------------------------+
13 + 0 |
+-- --+
14 + 0 |
+----------------------------------+
-------------------
Bit Info Word
bit number = value
-------------------
0-7 = 6
8 = 0
9 = 0
10 = 1
11-14 = 0
15-19 = 0
20-21 = 0
22-23 = 0
24-25 = 0
26-27 = 0
28-31 = 3
THE FULL TRAILER FORMAT IS:
+----------------------------------+
| Trailer Header |
| (14 words) |
+----------------------------------+
+----------------------------------+
| Optional |
| Uncompressed Array of |
| a record length in bytes, |
| followed by |
| an event count for that record |
| (2 words / record) |
| (all records) |
+----------------------------------+
------------------------------------------------------------
evio::RecordHeader::RecordHeader | ( | ) |
Default, no-arg constructor.
evio::RecordHeader::RecordHeader | ( | const RecordHeader & | head | ) |
Copy constructor.
head | header to copy. |
|
explicit |
Constructor which sets the type of header this is.
type | type of header this is |
EvioException | if type is for file |
evio::RecordHeader::RecordHeader | ( | size_t | pos, |
uint32_t | len, | ||
uint32_t | ent | ||
) |
Constructor.
pos | position in file. |
len | length of record in bytes |
ent | number of events |
|
default |
|
overridevirtual |
Gives the bytes remaining in this record given a buffer position.
The position is an absolute position in a byte buffer. This assumes that the absolute position in bufferStartingPosition
is being maintained properly by the reader.
pos | the absolute current position in a byte buffer. |
EvioException | if position out of bounds |
Implements evio::IBlockHeader.
|
static |
Clear the bit in the given arg to indicate it is NOT the last record.
i | integer in which to clear the last-record bit |
void evio::RecordHeader::copy | ( | std::shared_ptr< RecordHeader > const & | head | ) |
Copy method.
head | header to copy. |
string evio::RecordHeader::eventTypeToString | ( | ) | const |
Return a meaningful string associated with event type.
|
overridevirtual |
Determines where the start of the first event in this record is located (bytes).
This assumes the start position has been maintained by the object performing the buffer read.
Implements evio::IBlockHeader.
|
static |
Calculates the sixth word of this header which has the version number (6) in the lowest 8 bits and the set in the upper 24 bits.
NOT FOR GENERAL USE!
set | reference to bitset containing all bits to be set |
Referenced by evio::CompactEventBuilder::toFile().
|
static |
Calculates the sixth word of this header which has the version number in the lowest 8 bits.
The arg hasDictionary is set in the 9th bit and isEnd is set in the 10th bit. Four bits of an int (event type) are set in bits 11-14.
version | evio version number |
hasDictionary | does this block include an evio xml dictionary as the first event? |
isEnd | is this the last block of a file or a buffer? |
eventType | 4 bit type of events header is containing |
|
static |
Calculates the sixth word of this header which has the version number (4) in the lowest 8 bits and the set in the upper 24 bits.
The arg isDictionary is set in the 9th bit and isEnd is set in the 10th bit. Four bits of an int (event type) are set in bits 11-14. Four bits of this header type are set in bits 28-31 (defaults to 0 which is an evio record header).
set | reference to bitset containing all bits to be set |
version | evio version number |
hasDictionary | does this block include an evio xml dictionary as the first event? |
isEnd | is this the last block of a file or a buffer? |
eventType | 4 bit type of events header is containing |
headerType | 4 bit type of this header (defaults to 0 which is an evio record header). |
uint32_t evio::RecordHeader::getBitInfoWord | ( | ) | const |
Get the bit info word.
Will initialize if not already done.
Referenced by evio::RecordInput::uncompressRecord().
|
overridevirtual |
Get the position in the buffer (bytes) of this record's last data word.
Implements evio::IBlockHeader.
|
overridevirtual |
Get the starting position in the buffer (bytes) from which this header was read–if that happened.
This is not part of the record header proper. It is a position in a memory buffer of the start of the record It is kept for convenience. It is up to the reader to set it.
Implements evio::IBlockHeader.
|
overridevirtual |
Get the byte order of the file/buffer this header was read from.
Defaults to little endian.
Implements evio::IBlockHeader.
Referenced by evio::Reader::scanBuffer(), and evio::Reader::scanUncompressedBuffer().
uint32_t evio::RecordHeader::getCompressedDataLength | ( | ) | const |
Get the length of the compressed data in bytes.
Referenced by evio::RecordInput::uncompressRecord().
uint32_t evio::RecordHeader::getCompressedDataLengthPadding | ( | ) | const |
Get the padding of the compressed data in bytes.
uint32_t evio::RecordHeader::getCompressedDataLengthWords | ( | ) | const |
Get the length of the compressed data in words (padded).
Referenced by main().
uint32_t evio::RecordHeader::getCompressedRecordLength | ( | ) | const |
Get the padded length in bytes of the entire compressed record.
If the data is not compressed, then this returns 0;
|
overridevirtual |
Get the type of compression used.
0=none, 1=LZ4 fast, 2=LZ4 best, 3=gzip.
Implements evio::IBlockHeader.
Referenced by evio::Reader::scanUncompressedBuffer(), and evio::RecordInput::uncompressRecord().
uint32_t evio::RecordHeader::getDataLength | ( | ) | const |
Get the length of the uncompressed data in bytes.
uint32_t evio::RecordHeader::getDataLengthWords | ( | ) | const |
Get the length of the uncompressed data in words (padded).
Referenced by evio::RecordInput::uncompressRecord().
uint32_t evio::RecordHeader::getEntries | ( | ) | const |
Get the number of events or entries in index.
Referenced by evio::Reader::forceScanFile(), evio::Reader::scanBuffer(), and evio::Reader::scanUncompressedBuffer().
|
overridevirtual |
Get the type of events in record (see values of DataType.
Implements evio::IBlockHeader.
uint32_t evio::RecordHeader::getHeaderLength | ( | ) | const |
Get the length of this header in bytes (NOT including user header or index).
Referenced by evio::Reader::scanBuffer(), evio::Reader::scanUncompressedBuffer(), and evio::RecordInput::uncompressRecord().
const HeaderType & evio::RecordHeader::getHeaderType | ( | ) | const |
Get the type of header this is.
|
overridevirtual |
Get the length of this header in words.
Implements evio::IBlockHeader.
uint32_t evio::RecordHeader::getIndexLength | ( | ) | const |
Get the length of the index array in bytes.
Referenced by evio::Reader::scanFile(), evio::Reader::scanUncompressedBuffer(), and evio::RecordInput::uncompressRecord().
uint32_t evio::RecordHeader::getLength | ( | ) | const |
Get the total length of this record in bytes.
Referenced by evio::Reader::forceScanFile(), evio::Reader::scanBuffer(), evio::Reader::scanUncompressedBuffer(), and evio::RecordInput::uncompressRecord().
uint32_t evio::RecordHeader::getLengthWords | ( | ) | const |
Get the total length of this record in 32 bit words.
|
overridevirtual |
Get the magic number the record)header which should be 0xc0da0100.
Implements evio::IBlockHeader.
|
overridevirtual |
Get the block number for this record) In a file, this is usually sequential.
Implements evio::IBlockHeader.
|
static |
Returns number of bytes needed to pad to 4-byte boundary for the given length.
length | length in bytes. |
size_t evio::RecordHeader::getPosition | ( | ) | const |
Get the position of this record in a file.
uint32_t evio::RecordHeader::getRecordNumber | ( | ) | const |
Get the record number.
Referenced by evio::Reader::forceScanFile(), evio::Reader::scanBuffer(), and evio::Reader::scanUncompressedBuffer().
|
overridevirtual |
Get the size of the record)in 32 bit words.
Implements evio::IBlockHeader.
|
overridevirtual |
Get the source ID number if in CODA online context and data is coming from ROC.
Implements evio::IBlockHeader.
uint32_t evio::RecordHeader::getUncompressedRecordLength | ( | ) | const |
Get the padded length in bytes of the entire uncompressed record.
Referenced by evio::Reader::scanBuffer(), and evio::RecordInput::uncompressRecord().
uint32_t evio::RecordHeader::getUserHeaderLength | ( | ) | const |
Get the length of the user-defined header in bytes.
uint32_t evio::RecordHeader::getUserHeaderLengthWords | ( | ) | const |
Get the length of the user-defined header in words.
Referenced by evio::Reader::scanUncompressedBuffer(), and evio::RecordInput::uncompressRecord().
uint64_t evio::RecordHeader::getUserRegisterFirst | ( | ) | const |
Get the first user-defined 64-bit register.
uint64_t evio::RecordHeader::getUserRegisterSecond | ( | ) | const |
Get the second user-defined 64-bit register.
|
overridevirtual |
Get the Evio format version number.
Implements evio::IBlockHeader.
Referenced by evio::Reader::scanBuffer(), and evio::Reader::scanUncompressedBuffer().
|
static |
Returns length padded to 4-byte boundary for given length in bytes.
length | length in bytes. |
uint32_t evio::RecordHeader::hasDictionary | ( | bool | hasFirst | ) |
Set the bit which says record has a dictionary in the user header.
hasFirst | true if record has a dictionary in the user header. |
Referenced by evio::Writer::createRecord().
|
static |
Does this bitInfo arg indicate the existence of a dictionary in the user header?
bitInfo | bitInfo word. |
|
overridevirtual |
Does this record have a dictionary in the user header?
Implements evio::IBlockHeader.
|
overridevirtual |
Does this header have a first event in the user header?
Implements evio::IBlockHeader.
|
overridevirtual |
Does this header indicate compressed data?
Implements evio::IBlockHeader.
Referenced by evio::Reader::scanBuffer().
|
static |
Quickly check to see if this buffer contains compressed data or not.
The offset must point to the beginning of a valid hipo/evio record in the buffer.
buffer | buffer to read from. |
offset | position of record header to be read. |
EvioException | if buffer contains too little data, or is not in proper format. |
References evio::ByteBuffer::getInt(), evio::ByteBuffer::limit(), evio::ByteBuffer::order(), and SWAP_32.
|
static |
Quickly check to see if this buffer contains compressed data or not.
The offset must point to the beginning of a valid hipo/evio record in the buffer.
buffer | buffer to read from. |
offset | position of record header to be read. |
EvioException | if buffer contains too little data, or is not in proper format. |
bool evio::RecordHeader::isEvioRecord | ( | ) | const |
Is this header an evio record?
|
static |
Does this arg indicate its header is an evio record?
bitInfo | bitInfo word. |
bool evio::RecordHeader::isEvioTrailer | ( | ) | const |
Is this header an evio trailer?
|
static |
Does this arg indicate its header is an evio trailer?
bitInfo | bitInfo word. |
bool evio::RecordHeader::isHipoRecord | ( | ) | const |
Is this header a hipo record?
|
static |
Does this arg indicate its header is a hipo record?
bitInfo | bitInfo word. |
bool evio::RecordHeader::isHipoTrailer | ( | ) | const |
Is this header a hipo trailer?
|
static |
Does this arg indicate its header is a hipo trailer?
bitInfo | bitInfo word. |
|
overridevirtual |
Is this the last record in the file or being sent over the network?
true
if this is the last record in the file or being sent over the network, else false
. Implements evio::IBlockHeader.
uint32_t evio::RecordHeader::isLastRecord | ( | bool | isLast | ) |
Set the bit which says record is last in file/buffer.
isLast | true if record is last in file/buffer. |
Referenced by evio::Reader::scanBuffer().
bool evio::RecordHeader::isLastRecord | ( | ) | const |
Is this the header of the last record?
|
static |
Does this word indicate this is the header of the last record?
bitInfo | bitInfo word. |
int evio::RecordHeader::main | ( | int | argc, |
char ** | argv | ||
) |
Run this class as an executable which tests the writing and reading of a record.
argc | argument count |
argv | argument list |
References getCompressedDataLengthWords(), evio::ByteBuffer::order(), readHeader(), setCompressedDataLength(), setCompressionType(), setDataLength(), setEntries(), setHeaderLength(), setIndexLength(), setLength(), setRecordNumber(), setUserHeaderLength(), setUserRegisterFirst(), setUserRegisterSecond(), toString(), and writeHeader().
|
overridevirtual |
Determines where the start of the next record header in some buffer is located (bytes).
This assumes the start position has been maintained by the object performing the buffer read.
Implements evio::IBlockHeader.
RecordHeader & evio::RecordHeader::operator= | ( | const RecordHeader & | head | ) |
void evio::RecordHeader::readHeader | ( | ByteBuffer & | buffer, |
size_t | offset = 0 |
||
) |
Reads the header information from a byte buffer and validates it by checking the magic word (8th word).
This magic word also determines the byte order.
buffer | buffer to read from. |
offset | position of first word to be read. |
EvioException | if buffer contains too little data, is not in proper format, or version earlier than 6. |
References evio::ByteBuffer::capacity(), evio::ByteBuffer::getInt(), evio::ByteBuffer::getLong(), evio::ByteBuffer::order(), evio::ByteBuffer::printBytes(), and SWAP_32.
Referenced by evio::Reader::forceScanFile(), main(), evio::Reader::scanFile(), evio::Reader::scanUncompressedBuffer(), and evio::RecordInput::uncompressRecord().
void evio::RecordHeader::readHeader | ( | std::shared_ptr< ByteBuffer > & | buffer, |
size_t | offset = 0 |
||
) |
Reads the header information from a byte buffer and validates it by checking the magic word (8th word).
This magic word also determines the byte order.
buffer | buffer to read from. |
offset | position of first word to be read. |
EvioException | if buffer contains too little data, is not in proper format, or version earlier than 6. |
void evio::RecordHeader::readHeader | ( | uint8_t * | src, |
ByteOrder | order | ||
) |
Reads the header information from a byte buffer and validates it by checking the magic word (8th word).
This magic word also determines the byte order.
src | data to read from. |
order | byte order when reading. |
EvioException | if src arg is null, is not in proper format, or version earlier than 6. |
References SWAP_32.
void evio::RecordHeader::reset | ( | ) |
Reset generated data.
uint32_t evio::RecordHeader::setBitInfo | ( | bool | isLastRecord, |
bool | haveDictionary | ||
) |
Set the bit info word for a record header.
Current value of bitInfo is lost.
isLastRecord | true if record is last in stream or file. |
haveDictionary | true if record has dictionary in user header. |
uint32_t evio::RecordHeader::setBitInfoEventType | ( | uint32_t | type | ) |
Set the bit info of a record header for a specified CODA event type.
Must be called AFTER setBitInfo(bool, bool) or setBitInfoWord(uint32_t) in order to have change preserved.
type | event type (0=ROC raw, 1=Physics, 2=Partial Physics, 3=Disentangled, 4=User, 5=Control, 15=Other, else = nothing set). |
void evio::RecordHeader::setBitInfoWord | ( | uint32_t | word | ) |
Set the bit info word and related values.
NOT FOR GENERAL USE!
word | bit info word. |
void evio::RecordHeader::setBitInfoWord | ( | std::bitset< 24 > const & | set | ) |
Set the bit info word and related values.
NOT FOR GENERAL USE!
set | reference to bitset containing all bits to be set |
|
overridevirtual |
Set the starting position in the buffer (bytes) from which this header was read–if that happened.
This is not part of the record header proper. It is a position in a memory buffer of the start of the record It is kept for convenience. It is up to the reader to set it.
bufferStartingPosition | starting position in buffer from which this header was read–if that happened. |
Implements evio::IBlockHeader.
RecordHeader & evio::RecordHeader::setCompressedDataLength | ( | uint32_t | length | ) |
Set the compressed data length in bytes & words and the padding.
length | length of compressed data in bytes. |
Referenced by main(), and evio::RecordInput::uncompressRecord().
RecordHeader & evio::RecordHeader::setCompressionType | ( | Compressor::CompressionType | type | ) |
Set the compression type.
0=none, 1=LZ4 fast, 2=LZ4 best, 3=gzip. No compression for other values.
type | compression type. |
Referenced by main(), and evio::RecordInput::uncompressRecord().
RecordHeader & evio::RecordHeader::setDataLength | ( | uint32_t | length | ) |
Set the uncompressed data length in bytes & words and the padding.
length | length of uncompressed data in bytes. |
Referenced by main().
RecordHeader & evio::RecordHeader::setEntries | ( | uint32_t | n | ) |
Set the number of events or index entries.
No compression for other values.
n | number of events or index entries. |
Referenced by main().
RecordHeader & evio::RecordHeader::setHeaderLength | ( | uint32_t | length | ) |
Set the this header's length in bytes & words.
If length is not a multiple of 4, you're on your own!
length | this header's length in bytes. |
Referenced by main().
RecordHeader & evio::RecordHeader::setHeaderType | ( | HeaderType const & | type | ) |
Set this header's type.
Normally done in constructor. Limited access.
type | type of header. |
References evio::HeaderType::getValue().
RecordHeader & evio::RecordHeader::setIndexLength | ( | uint32_t | length | ) |
Set the length of the index array in bytes.
Length is forced to be a multiple of 4!
length | length of index array in bytes. |
Referenced by main().
RecordHeader & evio::RecordHeader::setLength | ( | uint32_t | length | ) |
Set the record length in bytes & words.
If length is not a multiple of 4, you're on your own!
length | length of record in bytes. |
Referenced by main(), and evio::RecordInput::uncompressRecord().
RecordHeader & evio::RecordHeader::setPosition | ( | size_t | pos | ) |
Set the position of this record in a file.
pos | position of this record in a file. |
RecordHeader & evio::RecordHeader::setRecordNumber | ( | uint32_t | num | ) |
RecordHeader & evio::RecordHeader::setUserHeaderLength | ( | uint32_t | length | ) |
Set the user-defined header's length in bytes & words and the padding.
length | user-defined header's length in bytes. |
Referenced by main().
RecordHeader & evio::RecordHeader::setUserRegisterFirst | ( | uint64_t | reg | ) |
Set the first, 64-bit, user-defined register.
reg | first, 64-bit, user-defined register. |
Referenced by main().
RecordHeader & evio::RecordHeader::setUserRegisterSecond | ( | uint64_t | reg | ) |
Set the second, 64-bit, user-defined register.
reg | second, 64-bit, user-defined register. |
Referenced by main().
|
overridevirtual |
Returns a string representation of this record.
Implements evio::IBlockHeader.
Referenced by main().
|
overridevirtual |
Write myself out into a byte buffer.
This write is relative–i.e., it uses the current position of the buffer.
byteBuffer | the byteBuffer to write to. |
Implements evio::IBlockHeader.
References evio::ByteBuffer::position().
void evio::RecordHeader::writeHeader | ( | ByteBuffer & | buf, |
size_t | off = 0 |
||
) |
Writes this header into the given byte buffer.
Position & limit of given buffer does NOT change.
buf | byte buffer to write header into. |
off | position in buffer to begin writing. |
EvioException | if buffer contains too little room. |
References evio::ByteBuffer::limit(), evio::ByteBuffer::putInt(), and evio::ByteBuffer::putLong().
Referenced by main().
void evio::RecordHeader::writeHeader | ( | std::shared_ptr< ByteBuffer > & | buffer, |
size_t | off = 0 |
||
) |
Writes this header into the given byte buffer.
Position & limit of given buffer does NOT change.
buffer | byte buffer to write header into. |
off | position in buffer to begin writing. |
EvioException | if buffer contains too little room. |
void evio::RecordHeader::writeHeader | ( | uint8_t * | array, |
const ByteOrder & | order | ||
) |
Writes this header at the given pointer.
array | byte array to write header into. |
order | byte order of data to be written. |
EvioException | if array arg is null. |
|
static |
|
static |
|
static |
|
static |
|
static |
Byte offset from beginning of header to bit info word.
Referenced by evio::Writer::close(), evio::Reader::findRecordInfo(), and evio::RecordInput::uncompressRecord().
|
static |
Byte offset from beginning of header to the compression type & compressed data length word.
Referenced by evio::Reader::findRecordInfo(), and evio::RecordInput::uncompressRecord().
|
static |
11-14th bits in bitInfo word in record header for CODA data type, control = 5.
|
static |
11-14th bits in bitInfo word in header for CODA data type, disentangled = 3.
|
static |
11-14th bits in bitInfo word in record header for CODA data type, other = 15.
|
static |
11-14th bits in bitInfo word in header for CODA data type, partial physics = 2.
|
static |
11-14th bits in bitInfo word in header for CODA data type, physics = 1.
|
static |
11-14th bits in bitInfo word in header for CODA data type, ROC raw = 0.
|
static |
11-14th bits in bitInfo word in header for CODA data type, user = 4.
|
static |
8th bit set in bitInfo word in header means contains dictionary.
|
static |
Byte offset from beginning of header to the event index count.
Referenced by evio::Reader::findRecordInfo().
|
static |
Byte offset from beginning of header to the header length.
Referenced by evio::Reader::findRecordInfo().
|
static |
Magic number used to track endianness.
Referenced by evio::CompactEventBuilder::toFile().
|
static |
Number of bytes in a normal sized header.
Referenced by evio::RecordOutput::build(), evio::EventWriter::EventWriter(), evio::Reader::forceScanFile(), evio::RecordOutput::getUncompressedSize(), evio::RecordInput::readRecord(), evio::RecordOutput::roomForEvent(), evio::Reader::scanBuffer(), evio::Reader::scanFile(), evio::Reader::scanUncompressedBuffer(), evio::CompactEventBuilder::toFile(), evio::Writer::Writer(), and evio::WriterMT::WriterMT().
|
static |
Number of 32-bit words in a normal sized header.
Referenced by evio::CompactEventBuilder::toFile().
|
static |
Byte offset from beginning of header to the index array length.
Referenced by evio::Reader::findRecordInfo().
|
static |
9th bit set in bitInfo word in header means is last in stream or file.
|
static |
"Last record" is 11th bit in bitInfo word.
|
staticinherited |
The magic number, should be the value of magicNumber
.
Referenced by evio::Util::findEvioVersion(), evio::EvioReaderV4::parseFirstHeader(), evio::BlockHeaderV2::setMagicNumber(), and evio::BlockHeaderV4::setMagicNumber().
|
static |
Byte offset from beginning of header to the magic number.
|
static |
Byte offset from beginning of header to the record length.
Referenced by evio::Reader::findRecordInfo(), and evio::RecordInput::uncompressRecord().
|
static |
Byte offset from beginning of header to the record number.
|
static |
Byte offset from beginning of header to the user register #1.
|
static |
Byte offset from beginning of header to the user register #2.
|
static |
Byte offset from beginning of header to the uncompressed data length.
Referenced by evio::Reader::addStructure(), evio::Reader::findRecordInfo(), and evio::Reader::removeStructure().
|
static |
Byte offset from beginning of header to the user header length.
Referenced by evio::Reader::findRecordInfo().
|
static |
Mask to get version number from 6th int in header.