artdaq_core  v3_05_10
artdaq::Fragment Class Reference

A Fragment contains the data from one piece of the DAQ system for one event The artdaq::Fragment is the main data storage class in artdaq. Each Fragment represents the data from one piece of the readout, for one artdaq event. BoardReaders create Fragments and send them to the EventBuilders, where they are assembled into artdaq::RawEvent objects. More...

#include <artdaq-core/Data/Fragment.hh>

Public Types

typedef uint8_t byte_t
 For byte representation. More...
 
typedef
detail::RawFragmentHeader::version_t 
version_t
 typedef for version_t from RawFragmentHeader
 
typedef
detail::RawFragmentHeader::type_t 
type_t
 typedef for type_t from RawFragmentHeader
 
typedef
detail::RawFragmentHeader::sequence_id_t 
sequence_id_t
 typedef for sequence_id_t from RawFragmentHeader
 
typedef
detail::RawFragmentHeader::fragment_id_t 
fragment_id_t
 typedef for fragment_id_t from RawFragmentHeader
 
typedef
detail::RawFragmentHeader::timestamp_t 
timestamp_t
 typedef for timestamp_t from RawFragmentHeader
 
typedef QuickVec< RawDataType >
::reference 
reference
 Alias reference type from QuickVec<RawDataType>
 
typedef QuickVec< RawDataType >
::iterator 
iterator
 Alias iterator type from QuickVec<RawDataType>
 
typedef QuickVec< RawDataType >
::const_iterator 
const_iterator
 Alias const_iterator type from QuickVec<RawDataType>
 
typedef QuickVec< RawDataType >
::value_type 
value_type
 Alias value_type type from QuickVec<RawDataType>
 
typedef QuickVec< RawDataType >
::difference_type 
difference_type
 Alias difference_type type from QuickVec<RawDataType>
 
typedef QuickVec< RawDataType >
::size_type 
size_type
 Alias size_type type from QuickVec<RawDataType>
 

Public Member Functions

 Fragment ()
 Create a Fragment with all header values zeroed.
 
 Fragment (const Fragment &)=default
 Default copy constructor. More...
 
 Fragment (Fragment &&) noexcept
 Move Constructor. More...
 
Fragmentoperator= (const Fragment &)=default
 Default copy-assignment operator. More...
 
Fragmentoperator= (Fragment &&) noexcept
 Move-assignment operator. More...
 
 Fragment (std::size_t n)
 Create a Fragment ready to hold n words (RawDataTypes) of payload, and with all values zeroed. More...
 
template<class T >
 Fragment (std::size_t payload_size, sequence_id_t sequence_id, fragment_id_t fragment_id, type_t type, const T &metadata, timestamp_t timestamp=Fragment::InvalidTimestamp)
 Create a Fragment with the given header values. More...
 
 Fragment (sequence_id_t sequenceID, fragment_id_t fragID, type_t type=Fragment::DataFragmentType, timestamp_t timestamp=Fragment::InvalidTimestamp)
 Create a fragment with the given event id and fragment id, and with no data payload. More...
 
void print (std::ostream &os) const
 Print out summary information for this Fragment to the given stream. More...
 
std::size_t size () const
 Gets the size of the Fragment, from the Fragment header. More...
 
version_t version () const
 Version of the Fragment, from the Fragment header. More...
 
type_t type () const
 Type of the Fragment, from the Fragment header. More...
 
std::string typeString () const
 Print the type of the Fragment. More...
 
sequence_id_t sequenceID () const
 Sequence ID of the Fragment, from the Fragment header. More...
 
fragment_id_t fragmentID () const
 Fragment ID of the Fragment, from the Fragment header. More...
 
timestamp_t timestamp () const
 Timestamp of the Fragment, from the Fragment header. More...
 
void setUserType (type_t utype)
 Sets the type of the Fragment, checking that it is a valid user type. More...
 
void setSystemType (type_t stype)
 Sets the type of the Fragment, checking that it is a valid system type. More...
 
void setSequenceID (sequence_id_t sequence_id)
 Sets the Sequence ID of the Fragment. More...
 
void setFragmentID (fragment_id_t fragment_id)
 Sets the Fragment ID of the Fragment. More...
 
void setTimestamp (timestamp_t timestamp)
 Sets the Timestamp of the Fragment. More...
 
void touch ()
 Update the access time of the Fragment.
 
struct timespec atime () const
 Get the last access time of the Fragment. More...
 
struct timespec getLatency (bool touch)
 Get the difference between the current time and the last access time of the Fragment. More...
 
std::size_t sizeBytes () const
 Size of vals_ vector ( header + (optional) metadata + payload) in bytes. More...
 
std::size_t dataSize () const
 Return the number of RawDataType words in the data payload. This does not include the number of words in the header or the metadata. More...
 
std::size_t dataSizeBytes () const
 Return the number of bytes in the data payload. This does not include the number of bytes in the header or the metadata. More...
 
bool hasMetadata () const
 Test whether this Fragment has metadata. More...
 
template<class T >
T * metadata ()
 Return a pointer to the metadata. This throws an exception if the Fragment contains no metadata. More...
 
template<class T >
T const * metadata () const
 Return a const pointer to the metadata. This throws an exception if the Fragment contains no metadata. More...
 
template<class T >
void setMetadata (const T &md)
 Set the metadata in the Fragment to the contents of the specified structure. This throws an exception if the Fragment already contains metadata. More...
 
template<class T >
void updateMetadata (const T &md)
 Updates existing metadata with a new metadata object. More...
 
void resize (std::size_t sz)
 Resize the data payload to hold sz RawDataType words. More...
 
void resize (std::size_t sz, RawDataType val)
 Resize the data payload to hold sz RawDataType words. Initialize new elements (if any) with val. More...
 
void resizeBytes (std::size_t szbytes)
 Resize the data payload to hold szbytes bytes (padded by the 8-byte RawDataTypes, so, e.g., requesting 14 bytes will actually get you 16) More...
 
void resizeBytesWithCushion (std::size_t szbytes, double growthFactor=1.3)
 Resize the data payload to hold szbytes bytes (padded by the 8-byte RawDataTypes, so, e.g., requesting 14 bytes will actually get you 16) and request additional capacity in the underlying storage (to help avoid extra reallocations) More...
 
void resizeBytes (std::size_t szbytes, byte_t val)
 Resize the data payload to hold sz bytes (padded by the 8-byte RawDataTypes, so, e.g., requesting 14 bytes will actually get you 16). Initialize new elements (if any) with val. More...
 
void autoResize ()
 Resize the fragment to hold the number of words indicated by the header.
 
iterator dataBegin ()
 Return an iterator to the beginning of the data payload (after header and metadata) More...
 
iterator dataEnd ()
 Return an iterator to the end of the data payload. More...
 
template<typename T >
reinterpret_cast_checked (const RawDataType *in) const
 Wrapper around reinterpret_cast. More...
 
template<typename T >
reinterpret_cast_checked (RawDataType *in)
 Wrapper around reinterpret_cast. More...
 
byte_tdataBeginBytes ()
 Return Fragment::byte_t* pointing at the beginning of the payload. More...
 
byte_tdataEndBytes ()
 Return Fragment::byte_t* pointing at the end of the payload. More...
 
iterator headerBegin ()
 Return an iterator to the beginning of the header (should be used for serialization only: use setters for preference). More...
 
byte_theaderBeginBytes ()
 Return a Fragment::byte_t pointer pointing to the beginning of the header. More...
 
const_iterator dataBegin () const
 Returns a const_iterator to the beginning of the data payload. More...
 
const_iterator dataEnd () const
 Returns a const_iterator to the end of the data payload. More...
 
const byte_tdataBeginBytes () const
 Return const Fragment::byte_t* pointing at the beginning of the payload. More...
 
const byte_tdataEndBytes () const
 Return const Fragment::byte_t* pointing at the end of the payload. More...
 
const_iterator headerBegin () const
 Return an const_iterator to the beginning of the header (should be used for serialization only: use setters for preference). More...
 
const byte_theaderBeginBytes () const
 Return a const Fragment::byte_t pointer pointing to the beginning of the header. More...
 
size_t headerSizeWords () const
 Get the size of this Fragment's header, in RawDataType words. More...
 
size_t headerSizeBytes () const
 Get the size of this Fragment's header, in bytes. More...
 
void clear ()
 Removes all elements from the payload section of the Fragment.
 
bool empty ()
 Determines if the Fragment contains no data. More...
 
void reserve (std::size_t cap)
 Reserves enough memory to hold cap RawDataType words in the Fragment payload. More...
 
void swap (Fragment &other) noexcept
 Swaps two Fragment objects. More...
 
void swap (QuickVec< RawDataType > &other) noexcept
 Swaps two Fragment data vectors. More...
 
RawDataTypedataAddress ()
 Returns a RawDataType pointer to the beginning of the payload. More...
 
RawDataTypemetadataAddress ()
 Get the address of the metadata. For internal use only, use metadata() instead. More...
 
RawDataTypeheaderAddress ()
 Gets the address of the header. More...
 

Static Public Member Functions

static constexpr bool isUserFragmentType (type_t fragmentType)
 Returns whether the given type is in the range of user types. More...
 
static constexpr bool isSystemFragmentType (type_t fragmentType)
 Returns whether the given type is in the range of system types. More...
 
static std::map< type_t,
std::string > 
MakeSystemTypeMap ()
 Returns a map of the most commonly-used system types. More...
 
static FragmentPtr FragmentBytes (std::size_t nbytes)
 Create a Fragment using a static factory function rather than a constructor to allow for the function name "FragmentBytes". More...
 
template<class T >
static FragmentPtr FragmentBytes (std::size_t payload_size_in_bytes, sequence_id_t sequence_id, fragment_id_t fragment_id, type_t type, const T &metadata, timestamp_t timestamp=Fragment::InvalidTimestamp)
 Create a Fragment with the given header values. Uses static factory function instead of constructor to allow for the function name "FragmentBytes". More...
 
static FragmentPtr eodFrag (size_t nFragsToExpect)
 Creates an EndOfData Fragment. More...
 
template<class InputIterator >
static FragmentPtr dataFrag (sequence_id_t sequenceID, fragment_id_t fragID, InputIterator i, InputIterator e)
 Creates a Fragment, copying data from given location. 12-Apr-2013, KAB - this method is deprecated, please do not use (internal use only) More...
 
static FragmentPtr dataFrag (sequence_id_t sequenceID, fragment_id_t fragID, RawDataType const *dataPtr, size_t dataSize, timestamp_t timestamp=Fragment::InvalidTimestamp)
 Crates a Fragment, copying data from given location. More...
 

Static Public Attributes

static constexpr version_t InvalidVersion = detail::RawFragmentHeader::InvalidVersion
 Copy InvalidVersion from RawFragmentHeader.
 
static constexpr sequence_id_t InvalidSequenceID = detail::RawFragmentHeader::InvalidSequenceID
 Copy InvalidSequenceID from RawFragmentHeader.
 
static constexpr fragment_id_t InvalidFragmentID = detail::RawFragmentHeader::InvalidFragmentID
 Copy InvalidFragmentID from RawFragmentHeader.
 
static constexpr timestamp_t InvalidTimestamp = detail::RawFragmentHeader::InvalidTimestamp
 Copy InvalidTimestamp from RawFragmentHeader.
 
static constexpr type_t InvalidFragmentType = detail::RawFragmentHeader::InvalidFragmentType
 Copy InvalidFragmentType from RawFragmentHeader.
 
static constexpr type_t EndOfDataFragmentType = detail::RawFragmentHeader::EndOfDataFragmentType
 Copy EndOfDataFragmentType from RawFragmentHeader.
 
static constexpr type_t DataFragmentType = detail::RawFragmentHeader::DataFragmentType
 Copy DataFragmentType from RawFragmentHeader.
 
static constexpr type_t InitFragmentType = detail::RawFragmentHeader::InitFragmentType
 Copy InitFragmentType from RawFragmentHeader.
 
static constexpr type_t EndOfRunFragmentType = detail::RawFragmentHeader::EndOfRunFragmentType
 Copy EndOfRunFragmentType from RawFragmentHeader.
 
static constexpr type_t EndOfSubrunFragmentType = detail::RawFragmentHeader::EndOfSubrunFragmentType
 Copy EndOfSubrunFragmentType from RawFragmentHeader.
 
static constexpr type_t ShutdownFragmentType = detail::RawFragmentHeader::ShutdownFragmentType
 Copy ShutdownFragmentType from RawFragmentHeader.
 
static constexpr type_t FirstUserFragmentType = detail::RawFragmentHeader::FIRST_USER_TYPE
 Copy FIRST_USER_TYPE from RawFragmentHeader.
 
static constexpr type_t EmptyFragmentType = detail::RawFragmentHeader::EmptyFragmentType
 Copy EmptyFragmentType from RawFragmentHeader.
 
static constexpr type_t ContainerFragmentType = detail::RawFragmentHeader::ContainerFragmentType
 Copy ContainerFragmentType from RawFragmentHeader.
 
static constexpr type_t ErrorFragmentType = detail::RawFragmentHeader::ErrorFragmentType
 Copy ErrorFragmentType from RawFragmentHeader.
 

Detailed Description

A Fragment contains the data from one piece of the DAQ system for one event The artdaq::Fragment is the main data storage class in artdaq. Each Fragment represents the data from one piece of the readout, for one artdaq event. BoardReaders create Fragments and send them to the EventBuilders, where they are assembled into artdaq::RawEvent objects.

Definition at line 85 of file Fragment.hh.

Member Typedef Documentation

typedef uint8_t artdaq::Fragment::byte_t

For byte representation.

JCF, 3/25/14 Add interface functions which allow users to work with the underlying data (a vector of RawDataTypes) in byte representation

Definition at line 100 of file Fragment.hh.

Constructor & Destructor Documentation

artdaq::Fragment::Fragment ( const Fragment )
default

Default copy constructor.

Todo:
Decide if Copy constructor should be declared =delete
artdaq::Fragment::Fragment ( Fragment &&  )
inlinedefaultnoexcept

Move Constructor.

Separate declaration and definition of Move Constructor: http://stackoverflow.com/questions/33939687 This should generate an exception if artdaq::Fragment is not move-constructible

artdaq::Fragment::Fragment ( std::size_t  n)
explicit

Create a Fragment ready to hold n words (RawDataTypes) of payload, and with all values zeroed.

Parameters
nThe initial size of the Fragment, in RawDataType words

Definition at line 23 of file Fragment.cc.

template<class T >
artdaq::Fragment::Fragment ( std::size_t  payload_size,
sequence_id_t  sequence_id,
fragment_id_t  fragment_id,
type_t  type,
const T &  metadata,
timestamp_t  timestamp = Fragment::InvalidTimestamp 
)

Create a Fragment with the given header values.

Template Parameters
TMetadata type
Parameters
payload_sizeSize of the payload in RawDataType words (Fragment size is header + metadata + payload)
sequence_idSequence ID of Fragment
fragment_idFragment ID of Fragment
typeType of Fragment
metadataMetadata object
timestampTimestamp of Fragment

Definition at line 803 of file Fragment.hh.

artdaq::Fragment::Fragment ( sequence_id_t  sequenceID,
fragment_id_t  fragID,
type_t  type = Fragment::DataFragmentType,
timestamp_t  timestamp = Fragment::InvalidTimestamp 
)

Create a fragment with the given event id and fragment id, and with no data payload.

Parameters
sequenceIDSequence ID of Fragment
fragIDFragment ID of Fragment
typeType of Fragment
timestampTimestamp of Fragment

Definition at line 42 of file Fragment.cc.

Member Function Documentation

struct timespec artdaq::Fragment::atime ( ) const

Get the last access time of the Fragment.

Returns
struct timespec with last access time of the Fragment

Definition at line 913 of file Fragment.hh.

artdaq::RawDataType * artdaq::Fragment::dataAddress ( )
inline

Returns a RawDataType pointer to the beginning of the payload.

Returns
A RawDataType pointer to the beginning of the payload

Definition at line 1130 of file Fragment.hh.

artdaq::Fragment::iterator artdaq::Fragment::dataBegin ( )
inline

Return an iterator to the beginning of the data payload (after header and metadata)

Returns
iterator to the beginning of the data payload

Definition at line 1065 of file Fragment.hh.

artdaq::Fragment::const_iterator artdaq::Fragment::dataBegin ( ) const
inline

Returns a const_iterator to the beginning of the data payload.

Returns
A const_iterator to the beginning of the data payload

Definition at line 1084 of file Fragment.hh.

byte_t* artdaq::Fragment::dataBeginBytes ( )
inline

Return Fragment::byte_t* pointing at the beginning of the payload.

Returns
byte_t pointer to beginning of data payload

JCF, 3/25/14 – one nice thing about returning a pointer rather than an iterator is that we don't need to take the address of the dereferenced iterator (e.g., via &*dataBegin() ) to get ahold of the memory

Definition at line 551 of file Fragment.hh.

const byte_t* artdaq::Fragment::dataBeginBytes ( ) const
inline

Return const Fragment::byte_t* pointing at the beginning of the payload.

Returns
const byte_t pointer to beginning of data payload

JCF, 3/25/14 – one nice thing about returning a pointer rather than an iterator is that we don't need to take the address of the dereferenced iterator (e.g., via &*dataEnd() ) to get ahold of the memory

Definition at line 596 of file Fragment.hh.

artdaq::Fragment::iterator artdaq::Fragment::dataEnd ( )
inline

Return an iterator to the end of the data payload.

Returns
iterator to the end of the data payload

Definition at line 1072 of file Fragment.hh.

artdaq::Fragment::const_iterator artdaq::Fragment::dataEnd ( ) const
inline

Returns a const_iterator to the end of the data payload.

Returns
A const_iterator to the end of the data payload

Definition at line 1091 of file Fragment.hh.

byte_t* artdaq::Fragment::dataEndBytes ( )
inline

Return Fragment::byte_t* pointing at the end of the payload.

Returns
byte_t pointer to end of data payload

JCF, 3/25/14 – one nice thing about returning a pointer rather than an iterator is that we don't need to take the address of the dereferenced iterator (e.g., via &*dataEnd() ) to get ahold of the memory

Definition at line 561 of file Fragment.hh.

const byte_t* artdaq::Fragment::dataEndBytes ( ) const
inline

Return const Fragment::byte_t* pointing at the end of the payload.

Returns
const byte_t pointer to end of data payload

JCF, 3/25/14 – one nice thing about returning a pointer rather than an iterator is that we don't need to take the address of the dereferenced iterator (e.g., via &*dataEnd() ) to get ahold of the memory

Definition at line 609 of file Fragment.hh.

template<class InputIterator >
static FragmentPtr artdaq::Fragment::dataFrag ( sequence_id_t  sequenceID,
fragment_id_t  fragID,
InputIterator  i,
InputIterator  e 
)
inlinestatic

Creates a Fragment, copying data from given location. 12-Apr-2013, KAB - this method is deprecated, please do not use (internal use only)

Template Parameters
InputIteratorType of input iterator
Parameters
sequenceIDSequence ID of new Fragment
fragIDFragment ID of new Fragment
iBeginning of input range
eEnd of input range
Returns
FragmentPtr to created Fragment
Todo:
Change function access specifier to restrict access

Definition at line 711 of file Fragment.hh.

artdaq::FragmentPtr artdaq::Fragment::dataFrag ( sequence_id_t  sequenceID,
fragment_id_t  fragID,
RawDataType const *  dataPtr,
size_t  dataSize,
timestamp_t  timestamp = Fragment::InvalidTimestamp 
)
static

Crates a Fragment, copying data from given location.

Parameters
sequenceIDSequence ID of new Fragment
fragIDFragment ID of new Fragment
dataPtrPointer to data to store in Fragment
dataSizeSize of data to store in Fragment
timestampTimestamp of created Fragment
Returns
FragmentPtr to created Fragment

Definition at line 88 of file Fragment.cc.

std::size_t artdaq::Fragment::dataSize ( ) const
inline

Return the number of RawDataType words in the data payload. This does not include the number of words in the header or the metadata.

Returns
Number of RawDataType words in the payload section of the Fragment

Definition at line 934 of file Fragment.hh.

std::size_t artdaq::Fragment::dataSizeBytes ( ) const
inline

Return the number of bytes in the data payload. This does not include the number of bytes in the header or the metadata.

Returns

Definition at line 374 of file Fragment.hh.

bool artdaq::Fragment::empty ( )
inline

Determines if the Fragment contains no data.

Returns
Whether the Fragment's payload is empty

Definition at line 1110 of file Fragment.hh.

artdaq::FragmentPtr artdaq::Fragment::eodFrag ( size_t  nFragsToExpect)
static

Creates an EndOfData Fragment.

Parameters
nFragsToExpectThe number of Fragments the receiver should have at the end of data-taking
Returns
Pointer to created EndOfData Fragment

Definition at line 77 of file Fragment.cc.

static FragmentPtr artdaq::Fragment::FragmentBytes ( std::size_t  nbytes)
inlinestatic

Create a Fragment using a static factory function rather than a constructor to allow for the function name "FragmentBytes".

Parameters
nbytesThe initial size of the Fragment, in bytes
Returns
FragmentPtr to created Fragment

Definition at line 202 of file Fragment.hh.

template<class T >
static FragmentPtr artdaq::Fragment::FragmentBytes ( std::size_t  payload_size_in_bytes,
sequence_id_t  sequence_id,
fragment_id_t  fragment_id,
type_t  type,
const T &  metadata,
timestamp_t  timestamp = Fragment::InvalidTimestamp 
)
inlinestatic

Create a Fragment with the given header values. Uses static factory function instead of constructor to allow for the function name "FragmentBytes".

Template Parameters
TMetadata type
Parameters
payload_size_in_bytesSize of the payload in bytes (Fragment size is header + metadata + payload). Bytes will be rounded to the next factor of RawDataType / sizeof(char)
sequence_idSequence ID of Fragment
fragment_idFragment ID of Fragment
typeType of Fragment
metadataMetadata object
timestampTimestamp of Fragment
Returns
FragmentPtr to created Fragment

Definition at line 237 of file Fragment.hh.

artdaq::Fragment::fragment_id_t artdaq::Fragment::fragmentID ( ) const
inline

Fragment ID of the Fragment, from the Fragment header.

Returns
Fragment ID of the Fragment

Definition at line 866 of file Fragment.hh.

struct timespec artdaq::Fragment::getLatency ( bool  touch)

Get the difference between the current time and the last access time of the Fragment.

Parameters
touchWhether to also perform a touch operation
Returns
struct timespec representing the difference between current time and the last access time

Definition at line 918 of file Fragment.hh.

bool artdaq::Fragment::hasMetadata ( ) const
inline

Test whether this Fragment has metadata.

Returns
If a metadata object has been set

Definition at line 941 of file Fragment.hh.

artdaq::RawDataType * artdaq::Fragment::headerAddress ( )
inline

Gets the address of the header.

Returns
Pointer to the header's location within the vals_ vector

Definition at line 1148 of file Fragment.hh.

artdaq::Fragment::iterator artdaq::Fragment::headerBegin ( )
inline

Return an iterator to the beginning of the header (should be used for serialization only: use setters for preference).

Returns
an iterator to the beginning of the header

Definition at line 1078 of file Fragment.hh.

artdaq::Fragment::const_iterator artdaq::Fragment::headerBegin ( ) const
inline

Return an const_iterator to the beginning of the header (should be used for serialization only: use setters for preference).

Returns
an const_iterator to the beginning of the header

Definition at line 1097 of file Fragment.hh.

byte_t* artdaq::Fragment::headerBeginBytes ( )
inline

Return a Fragment::byte_t pointer pointing to the beginning of the header.

Returns
byte_t pointer to the beginning of the header

Definition at line 574 of file Fragment.hh.

const byte_t* artdaq::Fragment::headerBeginBytes ( ) const
inline

Return a const Fragment::byte_t pointer pointing to the beginning of the header.

Returns
const byte_t pointer to the beginning of the header

Definition at line 625 of file Fragment.hh.

size_t artdaq::Fragment::headerSizeBytes ( ) const
inline

Get the size of this Fragment's header, in bytes.

Returns
The on-disk or in-memory size of the Fragment header, in bytes

Definition at line 640 of file Fragment.hh.

size_t artdaq::Fragment::headerSizeWords ( ) const
inline

Get the size of this Fragment's header, in RawDataType words.

Returns
The on-disk or in-memory size of the Fragment header, in RawDataType words

Definition at line 1154 of file Fragment.hh.

bool constexpr artdaq::Fragment::isSystemFragmentType ( type_t  fragmentType)
inlinestatic

Returns whether the given type is in the range of system types.

Parameters
fragmentTypeThe type to test
Returns
Whether the given type is in the range of system types

Definition at line 770 of file Fragment.hh.

bool constexpr artdaq::Fragment::isUserFragmentType ( type_t  fragmentType)
inlinestatic

Returns whether the given type is in the range of user types.

Parameters
fragmentTypeThe type to test
Returns
Whether the given type is in the range of user types

Definition at line 763 of file Fragment.hh.

static std::map<type_t, std::string> artdaq::Fragment::MakeSystemTypeMap ( )
inlinestatic

Returns a map of the most commonly-used system types.

Returns
A std::map of the most commonly-used system types

Definition at line 177 of file Fragment.hh.

template<class T >
T * artdaq::Fragment::metadata ( )

Return a pointer to the metadata. This throws an exception if the Fragment contains no metadata.

Template Parameters
TType of the metadata
Returns
Pointer to the metadata
Exceptions
cet::exceptionif no metadata is present

Definition at line 947 of file Fragment.hh.

template<class T >
T const * artdaq::Fragment::metadata ( ) const

Return a const pointer to the metadata. This throws an exception if the Fragment contains no metadata.

Template Parameters
TType of the metadata
Returns
const Pointer to the metadata
Exceptions
cet::exceptionif no metadata is present

Definition at line 960 of file Fragment.hh.

artdaq::RawDataType * artdaq::Fragment::metadataAddress ( )
inline

Get the address of the metadata. For internal use only, use metadata() instead.

Returns
Pointer to the metadata's location within the vals_ vector
Exceptions
cet::exceptionif no metadata in Fragment
Todo:
Change function access specifier to restrict access

Definition at line 1137 of file Fragment.hh.

Fragment& artdaq::Fragment::operator= ( const Fragment )
default

Default copy-assignment operator.

Returns
Reference to new Fragment
Todo:
Decide if copy-assignment operator should be declared =delete
artdaq::Fragment & artdaq::Fragment::operator= ( Fragment &&  )
inlinedefaultnoexcept

Move-assignment operator.

Returns
Reference to Fragment

Separate declaration and definition of Move Constructor: http://stackoverflow.com/questions/33939687 This should generate an exception if artdaq::Fragment is not move-constructible

void artdaq::Fragment::print ( std::ostream &  os) const

Print out summary information for this Fragment to the given stream.

Parameters
osStream to print to

Definition at line 68 of file Fragment.cc.

template<typename T >
T artdaq::Fragment::reinterpret_cast_checked ( const RawDataType in) const
inline

Wrapper around reinterpret_cast.

Template Parameters
TType of output pointer
Parameters
ininput pointer
Returns
Pointer cast to type T
Exceptions
cet::exceptionif new pointer does not point to same address as old pointer

JCF, 1/21/15 There's actually not an ironclad guarantee in the C++ standard that the pointer reinterpret_cast<> returns has the same address as the pointer that was casted. It IS tested in the artdaq-core test suite, but since any uncaught, unexpected behavior from reinterpret_cast could be disastrous, I've wrapped it in this function and added a check just to be completely safe.

Please note that for this const-version, you'll need the const- qualifier to the pointer you pass as a parameter (i.e., reinterpret_cast_checked<const PtrType*>, not reinterpret_cast_checked<PtrType*>)

Definition at line 503 of file Fragment.hh.

template<typename T >
T artdaq::Fragment::reinterpret_cast_checked ( RawDataType in)
inline

Wrapper around reinterpret_cast.

Template Parameters
TType of output pointer
Parameters
ininput pointer
Returns
Pointer cast to type T
Exceptions
cet::exceptionif new pointer does not point to same address as old pointer

JCF, 1/21/15 There's actually not an ironclad guarantee in the C++ standard that the pointer reinterpret_cast<> returns has the same address as the pointer that was casted. It IS tested in the artdaq-core test suite, but since any uncaught, unexpected behavior from reinterpret_cast could be disastrous, I've wrapped it in this function and added a check just to be completely safe.

Definition at line 531 of file Fragment.hh.

void artdaq::Fragment::reserve ( std::size_t  cap)
inline

Reserves enough memory to hold cap RawDataType words in the Fragment payload.

Parameters
capThe new capacity of the Fragment payload, in RawDataType words.

Definition at line 1117 of file Fragment.hh.

void artdaq::Fragment::resize ( std::size_t  sz)
inline

Resize the data payload to hold sz RawDataType words.

Parameters
szThe new size of the payload portion of the Fragment, in RawDataType words

Definition at line 1007 of file Fragment.hh.

void artdaq::Fragment::resize ( std::size_t  sz,
RawDataType  val 
)
inline

Resize the data payload to hold sz RawDataType words. Initialize new elements (if any) with val.

Parameters
szThe new size of the payload portion of the Fragment, in RawDataType words
valValue with which to initialize any new elements

Definition at line 1015 of file Fragment.hh.

void artdaq::Fragment::resizeBytes ( std::size_t  szbytes)
inline

Resize the data payload to hold szbytes bytes (padded by the 8-byte RawDataTypes, so, e.g., requesting 14 bytes will actually get you 16)

Parameters
szbytesThe new size of the payload portion of the Fragment, in bytes

Definition at line 1024 of file Fragment.hh.

void artdaq::Fragment::resizeBytes ( std::size_t  szbytes,
byte_t  val 
)
inline

Resize the data payload to hold sz bytes (padded by the 8-byte RawDataTypes, so, e.g., requesting 14 bytes will actually get you 16). Initialize new elements (if any) with val.

Parameters
szbytesThe new size of the payload portion of the Fragment, in bytes
valValue with which to initialize any new elements

Definition at line 1041 of file Fragment.hh.

void artdaq::Fragment::resizeBytesWithCushion ( std::size_t  szbytes,
double  growthFactor = 1.3 
)
inline

Resize the data payload to hold szbytes bytes (padded by the 8-byte RawDataTypes, so, e.g., requesting 14 bytes will actually get you 16) and request additional capacity in the underlying storage (to help avoid extra reallocations)

Parameters
szbytesThe new size of the payload portion of the Fragment, in bytes
growthFactorThe requested growth factor in the capacity of storage

Definition at line 1031 of file Fragment.hh.

artdaq::Fragment::sequence_id_t artdaq::Fragment::sequenceID ( ) const
inline

Sequence ID of the Fragment, from the Fragment header.

Returns
Sequence ID of the Fragment

Definition at line 860 of file Fragment.hh.

void artdaq::Fragment::setFragmentID ( fragment_id_t  fragment_id)
inline

Sets the Fragment ID of the Fragment.

Parameters
fragment_idThe Fragment ID to set

Definition at line 897 of file Fragment.hh.

template<class T >
void artdaq::Fragment::setMetadata ( const T &  md)

Set the metadata in the Fragment to the contents of the specified structure. This throws an exception if the Fragment already contains metadata.

Template Parameters
TType of the metadata
Parameters
mdMetadata to store in Fragment
Exceptions
cet::exceptionif metadata already present in Fragment

Definition at line 971 of file Fragment.hh.

void artdaq::Fragment::setSequenceID ( sequence_id_t  sequence_id)
inline

Sets the Sequence ID of the Fragment.

Parameters
sequence_idThe sequence ID to set

Definition at line 890 of file Fragment.hh.

void artdaq::Fragment::setSystemType ( type_t  stype)
inline

Sets the type of the Fragment, checking that it is a valid system type.

Parameters
stypeThe System type to set

Definition at line 884 of file Fragment.hh.

void artdaq::Fragment::setTimestamp ( timestamp_t  timestamp)
inline

Sets the Timestamp of the Fragment.

Parameters
timestampThe Timestamp to set

Definition at line 903 of file Fragment.hh.

void artdaq::Fragment::setUserType ( type_t  utype)
inline

Sets the type of the Fragment, checking that it is a valid user type.

Parameters
utypeThe User type to set

Definition at line 878 of file Fragment.hh.

std::size_t artdaq::Fragment::size ( ) const
inline

Gets the size of the Fragment, from the Fragment header.

Returns
Number of words in the Fragment. Includes header, metadata, and payload

Definition at line 835 of file Fragment.hh.

std::size_t artdaq::Fragment::sizeBytes ( ) const
inline

Size of vals_ vector ( header + (optional) metadata + payload) in bytes.

Returns
The size of the Fragment in bytes, including header, metadata, and payload

Definition at line 360 of file Fragment.hh.

void artdaq::Fragment::swap ( Fragment other)
inlinenoexcept

Swaps two Fragment objects.

Parameters
otherFragment to swap with

Definition at line 1124 of file Fragment.hh.

void artdaq::Fragment::swap ( QuickVec< RawDataType > &  other)
inlinenoexcept

Swaps two Fragment data vectors.

Parameters
otherThe data vector to swap with

Since all Fragment header information is stored in the data vector, this is equivalent to swapping two Fragment objects

Definition at line 671 of file Fragment.hh.

artdaq::Fragment::timestamp_t artdaq::Fragment::timestamp ( ) const
inline

Timestamp of the Fragment, from the Fragment header.

Returns
Timestamp of the Fragment

Definition at line 872 of file Fragment.hh.

artdaq::Fragment::type_t artdaq::Fragment::type ( ) const
inline

Type of the Fragment, from the Fragment header.

Returns
Type of the Fragment

Definition at line 848 of file Fragment.hh.

std::string artdaq::Fragment::typeString ( ) const
inline

Print the type of the Fragment.

Returns
String representation of the Fragment type. For system types, the name will be included in parentheses

Definition at line 854 of file Fragment.hh.

template<class T >
void artdaq::Fragment::updateMetadata ( const T &  md)

Updates existing metadata with a new metadata object.

Template Parameters
TType of the metadata
Parameters
mdMetadata to set
Exceptions
cet::exceptionif no metadata stored in Fragment
cet::exceptionif new metadata has different size than existing metadata

Definition at line 987 of file Fragment.hh.

artdaq::Fragment::version_t artdaq::Fragment::version ( ) const
inline

Version of the Fragment, from the Fragment header.

Returns
Version of the Fragment

Definition at line 841 of file Fragment.hh.


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