Belle II Software  release-08-01-10
DataArray Class Reference

Helper class for getting data words from a finesse buffer Keeps checksum counter for each extracted data word and calculates tcp checksum on request. More...

#include <TOPUnpackerModule.h>

Public Member Functions

 DataArray (const int *data, int size, bool swap=false)
 Constructor. More...
 
int getWord ()
 Returns consecutive data word Updates internal checksum counter for each extracted word. More...
 
int peekWord ()
 Returns next data word without incrementing the memory pointer and without modifying the checksum counter. More...
 
int getLastWord ()
 Returns last data word. More...
 
unsigned int getIndex () const
 Returns index of last returned data word. More...
 
int getRemainingWords () const
 Returns number of remaining words in the buffer. More...
 
void resetChecksum ()
 Resets internal checksum counter. More...
 
unsigned int foldChecksum ()
 Performs folding of carry bits into checksum until only 16 LSBs are populated. More...
 
bool validateChecksum ()
 Validates current checksum counter status. More...
 

Private Member Functions

int swap32 (int x)
 Swap bytes of a 32-bit integer.
 

Private Attributes

int m_size = 0
 buffer size
 
const int * m_data = 0
 buffer data
 
int m_i = 0
 index
 
bool m_swap = false
 if true, swap bytes
 
unsigned int m_checksumCounter
 check sum counter
 

Detailed Description

Helper class for getting data words from a finesse buffer Keeps checksum counter for each extracted data word and calculates tcp checksum on request.

Definition at line 38 of file TOPUnpackerModule.h.

Constructor & Destructor Documentation

◆ DataArray()

DataArray ( const int *  data,
int  size,
bool  swap = false 
)
inline

Constructor.

Parameters
datapointer to finesse buffer (pointer must be valid)
sizebuffer size
swapif set to true, swap bytes

Definition at line 48 of file TOPUnpackerModule.h.

49  {
50  m_data = data;
51  m_size = size;
52  m_i = -1;
53  m_swap = swap;
55  }
const int * m_data
buffer data
bool m_swap
if true, swap bytes
unsigned int m_checksumCounter
check sum counter

Member Function Documentation

◆ foldChecksum()

unsigned int foldChecksum ( )
inline

Performs folding of carry bits into checksum until only 16 LSBs are populated.

Returns
reduced checksum counter

Definition at line 122 of file TOPUnpackerModule.h.

◆ getIndex()

unsigned int getIndex ( ) const
inline

Returns index of last returned data word.

Returns
index

Definition at line 104 of file TOPUnpackerModule.h.

◆ getLastWord()

int getLastWord ( )
inline

Returns last data word.

Returns
last data word

Definition at line 93 of file TOPUnpackerModule.h.

◆ getRemainingWords()

int getRemainingWords ( ) const
inline

Returns number of remaining words in the buffer.

Returns
number of remaining words

Definition at line 110 of file TOPUnpackerModule.h.

◆ getWord()

int getWord ( )
inline

Returns consecutive data word Updates internal checksum counter for each extracted word.

Verify checksum using DataArray::validateChecksum()

Returns
data word

Definition at line 63 of file TOPUnpackerModule.h.

◆ peekWord()

int peekWord ( )
inline

Returns next data word without incrementing the memory pointer and without modifying the checksum counter.

Returns
data word

Definition at line 79 of file TOPUnpackerModule.h.

◆ resetChecksum()

void resetChecksum ( )
inline

Resets internal checksum counter.

Call at the beginning of each new block that is checksummed.

Definition at line 116 of file TOPUnpackerModule.h.

◆ validateChecksum()

bool validateChecksum ( )
inline

Validates current checksum counter status.

Call at the end of each block that is checksummed.

Returns
checksum status, true if checksum is correct.

Definition at line 136 of file TOPUnpackerModule.h.


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