evio  6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IBlockHeader.h
Go to the documentation of this file.
1 //
2 // Copyright 2020, Jefferson Science Associates, LLC.
3 // Subject to the terms in the LICENSE file found in the top-level directory.
4 //
5 // EPSCI Group
6 // Thomas Jefferson National Accelerator Facility
7 // 12000, Jefferson Ave, Newport News, VA 23606
8 // (757)-269-7100
9 
10 
11 #ifndef EVIO_6_0_IBLOCKHEADER_H
12 #define EVIO_6_0_IBLOCKHEADER_H
13 
14 
15 #include <cstdint>
16 #include <cstring>
17 #include <string>
18 #include <vector>
19 #include <stdexcept>
20 
21 
22 #include "ByteOrder.h"
23 #include "ByteBuffer.h"
24 #include "Compressor.h"
25 
26 
27 namespace evio {
28 
29 
37  class IBlockHeader {
38 
39  public:
40 
42  static const uint32_t MAGIC_NUMBER = 0xc0da0100;
43 
45  static const uint32_t MAGIC_OFFSET = 28;
46 
48  static const uint32_t BIT_INFO_OFFSET = 20;
49 
51  static const uint32_t VERSION_MASK = 0xff;
52 
57  virtual uint32_t getSize() = 0;
58 
64  virtual uint32_t getNumber() = 0;
65 
70  virtual uint32_t getHeaderWords() = 0;
71 
76  virtual uint32_t getSourceId() = 0;
77 
84  virtual bool hasFirstEvent() = 0;
85 
91  virtual uint32_t getEventType() = 0;
92 
97  virtual uint32_t getVersion() = 0;
98 
103  virtual uint32_t getMagicNumber() = 0;
104 
109  virtual ByteOrder & getByteOrder() = 0;
110 
115  virtual size_t getBufferEndingPosition() = 0;
116 
124  virtual size_t getBufferStartingPosition() = 0;
125 
133  virtual void setBufferStartingPosition(size_t pos) = 0;
134 
141  virtual size_t nextBufferStartingPosition() = 0;
142 
152  virtual size_t firstEventStartingPosition() = 0;
153 
163  virtual size_t bytesRemaining(size_t position) = 0;
164 
170  virtual bool hasDictionary() = 0;
171 
178  virtual bool isLastBlock() = 0;
179 
184  virtual bool isCompressed() = 0;
185 
191 
199  virtual size_t write(ByteBuffer & byteBuffer) = 0;
200 
205  virtual std::string toString() = 0;
206  };
207 
208 
209 
210 }
211 
212 #endif //EVIO_6_0_IBLOCKHEADER_H
This class is copied from one of the same name in the Java programming language.
Definition: ByteBuffer.h:42
virtual size_t getBufferStartingPosition()=0
Get the starting position in the buffer (bytes) from which this header was read–if that happened...
Make a common interface for different versions of the BlockHeader arising from different evio version...
Definition: IBlockHeader.h:37
CompressionType
Enum of supported data compression types.
Definition: Compressor.h:65
Numerical values associated with endian byte order.
Definition: ByteOrder.h:53
virtual uint32_t getEventType()=0
Get the type of events in block/record (see values of DataType.
virtual uint32_t getHeaderWords()=0
Get the block (record) header length, in 32 bit words.
virtual std::string toString()=0
Get the string representation of the block (record) header.
virtual size_t bytesRemaining(size_t position)=0
Gives the bytes remaining in this block (record) given a buffer position.
virtual bool hasFirstEvent()=0
Does this block/record contain the &quot;first event&quot; (first event to be written to each file split)...
static const uint32_t VERSION_MASK
Mask to get version number from bitinfo word in header.
Definition: IBlockHeader.h:51
virtual uint32_t getSourceId()=0
Get the source ID number if in CODA online context and data is coming from ROC.
virtual bool isCompressed()=0
Is this the data in this block compressed?
virtual uint32_t getVersion()=0
Get the evio version of the block (record) header.
virtual Compressor::CompressionType getCompressionType()=0
Get the type of data compression used.
virtual void setBufferStartingPosition(size_t pos)=0
Set the starting position in the buffer (bytes) from which this header was read–if that happened...
virtual ByteOrder & getByteOrder()=0
Get the byte order of the data being read.
static const uint32_t BIT_INFO_OFFSET
Byte offset from beginning of header to bit info word.
Definition: IBlockHeader.h:48
virtual uint32_t getSize()=0
Get the size of the block (record) in 32 bit words.
virtual uint32_t getMagicNumber()=0
Get the magic number the block (record) header which should be 0xc0da0100.
static const uint32_t MAGIC_OFFSET
Byte offset from beginning of header to the magic number.
Definition: IBlockHeader.h:45
virtual size_t getBufferEndingPosition()=0
Get the position in the buffer (bytes) of this block&#39;s last data word.
virtual size_t firstEventStartingPosition()=0
Determines where the start of the first event in this block (record) is located (bytes).
virtual bool isLastBlock()=0
Is this the last block in the file or being sent over the network?
virtual size_t write(ByteBuffer &byteBuffer)=0
Write myself out into a byte buffer.
virtual size_t nextBufferStartingPosition()=0
Determines where the start of the next block (record) header in some buffer is located (bytes)...
virtual uint32_t getNumber()=0
Get the block number for this block (record).
virtual bool hasDictionary()=0
Does this block contain an evio dictionary?
static const uint32_t MAGIC_NUMBER
The magic number, should be the value of magicNumber.
Definition: IBlockHeader.h:42