gdata
Loading...
Searching...
No Matches
GFrameDataCollection Class Reference

Owns one frame header and the list of payloads accumulated for that frame. More...

#include <gFrameDataCollection.h>

Public Member Functions

 GFrameDataCollection (GFrameHeader *header, std::shared_ptr< GLogger > logger)
 Construct a frame data collection.
 
 ~GFrameDataCollection ()
 Destructor.
 
void addIntegralPayload (std::vector< int > payload) const
 Add one integral payload to this frame.
 
void addEvent (int evn)
 Placeholder for adding event-level information into the frame.
 
bool shouldWriteFrame () const
 Placeholder decision hook indicating whether this frame should be emitted.
 
const GFrameHeadergetHeader () const
 Returns the owned frame header.
 
const std::vector< GIntegralPayload * > * getIntegralPayload () const
 Returns the stored payload pointers.
 
long int getFrameID () const
 Convenience getter for the frame ID.
 

Detailed Description

Definition at line 48 of file gFrameDataCollection.h.

Constructor & Destructor Documentation

◆ GFrameDataCollection()

GFrameDataCollection::GFrameDataCollection ( GFrameHeader * header,
std::shared_ptr< GLogger > logger )
inline

Ownership:

  • header is adopted by this object and deleted in the destructor

Internal storage:

  • the payload pointer vector is allocated on the heap for historical reasons
Parameters
headerFrame header pointer. Ownership is transferred to this object.
loggerLogger instance used for diagnostics.

Definition at line 64 of file gFrameDataCollection.h.

◆ ~GFrameDataCollection()

GFrameDataCollection::~GFrameDataCollection ( )
inline

Deletes in the following order:

  • the owned frame header
  • all owned payload pointers
  • the payload vector container
Warning
Any pointers previously returned by getHeader() or getIntegralPayload() become invalid after destruction.

Definition at line 84 of file gFrameDataCollection.h.

Member Function Documentation

◆ addEvent()

void GFrameDataCollection::addEvent ( int evn)

Intended future usage:

  • accept an event number or event object
  • integrate it into this frame's payload list by collecting channels hit during the frame window
Parameters
evnEvent number.

◆ addIntegralPayload()

void GFrameDataCollection::addIntegralPayload ( std::vector< int > payload) const
inline

The payload is passed as a vector to support a generic packed interface, typically used when data come from external buffers or electronics emulators.

Expected layout, size must be exactly 5:

  • payload[0] = crate
  • payload[1] = slot
  • payload[2] = channel
  • payload[3] = charge
  • payload[4] = time

On success:

On failure:

Parameters
payloadPacked payload vector with exactly five integer entries.

Definition at line 115 of file gFrameDataCollection.h.

◆ getFrameID()

long int GFrameDataCollection::getFrameID ( ) const
inline

Equivalent to calling getFrameID() on the owned header.

Returns
Frame ID as stored in the header.

Definition at line 193 of file gFrameDataCollection.h.

◆ getHeader()

const GFrameHeader * GFrameDataCollection::getHeader ( ) const
inline

The returned pointer remains valid as long as this GFrameDataCollection exists. The header is owned by this object and must not be deleted by the caller.

Returns
Pointer to the frame header owned by this object.

Definition at line 170 of file gFrameDataCollection.h.

◆ getIntegralPayload()

const std::vector< GIntegralPayload * > * GFrameDataCollection::getIntegralPayload ( ) const
inline

The returned pointers:

  • are owned by this object
  • remain valid only as long as the collection exists
  • must not be deleted by the caller
Returns
Pointer to the internal payload vector.

Definition at line 183 of file gFrameDataCollection.h.

◆ shouldWriteFrame()

bool GFrameDataCollection::shouldWriteFrame ( ) const

Intended future usage:

  • decide whether enough data has accumulated
  • decide whether the frame time window has elapsed
  • trigger writing this frame to an output stream
Returns
true if the frame should be written.

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