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>

List of all members.

Public Types

typedef uint8_t byte_t
 For byte representation.
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 copy constructor.
 Fragment (Fragment &&) noexcept = default
 Move Constructor.
Fragmentoperator= (const Fragment &)
 Default copy-assignment operator.
Fragmentoperator= (Fragment &&) noexcept = default
 Move-assignment operator.
 Fragment (std::size_t n)
 Create a Fragment ready to hold n words (RawDataTypes) of payload, and with all values zeroed.
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.
 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.
void print (std::ostream &os) const
 Print out summary information for this Fragment to the given stream.
std::size_t size () const
 Gets the size of the Fragment, from the Fragment header.
version_t version () const
 Version of the Fragment, from the Fragment header.
type_t type () const
 Type of the Fragment, from the Fragment header.
std::string typeString () const
 Print the type of the Fragment.
sequence_id_t sequenceID () const
 Sequence ID of the Fragment, from the Fragment header.
fragment_id_t fragmentID () const
 Fragment ID of the Fragment, from the Fragment header.
timestamp_t timestamp () const
 Timestamp of the Fragment, from the Fragment header.
void setUserType (type_t utype)
 Sets the type of the Fragment, checking that it is a valid user type.
void setSystemType (type_t stype)
 Sets the type of the Fragment, checking that it is a valid system type.
void setSequenceID (sequence_id_t sequence_id)
 Sets the Sequence ID of the Fragment.
void setFragmentID (fragment_id_t fragment_id)
 Sets the Fragment ID of the Fragment.
void setTimestamp (timestamp_t timestamp)
 Sets the Timestamp of the Fragment.
std::size_t sizeBytes () const
 Size of vals_ vector ( header + (optional) metadata + payload) in bytes.
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.
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.
bool hasMetadata () const
 Test whether this Fragment has metadata.
template<class T >
T * metadata ()
 Return a pointer to the metadata. This throws an exception if the Fragment contains no metadata.
template<class T >
T const * metadata () const
 Return a const pointer to the metadata. This throws an exception if the Fragment contains no metadata.
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.
template<class T >
void updateMetadata (const T &md)
 Updates existing metadata with a new metadata object.
void resize (std::size_t sz)
 Resize the data payload to hold sz RawDataType words.
void resize (std::size_t sz, RawDataType val)
 Resize the data payload to hold sz RawDataType words. Initialize new elements (if any) with val.
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).
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.
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).
iterator dataEnd ()
 Return an iterator to the end of the data payload.
template<typename T >
reinterpret_cast_checked (const RawDataType *in) const
 Wrapper around reinterpret_cast.
template<typename T >
reinterpret_cast_checked (RawDataType *in)
 Wrapper around reinterpret_cast.
byte_tdataBeginBytes ()
 Return Fragment::byte_t* pointing at the beginning of the payload.
byte_tdataEndBytes ()
 Return Fragment::byte_t* pointing at the end of the payload.
iterator headerBegin ()
 Return an iterator to the beginning of the header (should be used for serialization only: use setters for preference).
byte_theaderBeginBytes ()
 Return a Fragment::byte_t pointer pointing to the beginning of the header.
const_iterator dataBegin () const
 Returns a const_iterator to the beginning of the data payload.
const_iterator dataEnd () const
 Returns a const_iterator to the end of the data payload.
const byte_tdataBeginBytes () const
 Return const Fragment::byte_t* pointing at the beginning of the payload.
const byte_tdataEndBytes () const
 Return const Fragment::byte_t* pointing at the end of the payload.
const_iterator headerBegin () const
 Return an const_iterator to the beginning of the header (should be used for serialization only: use setters for preference).
const byte_theaderBeginBytes () const
 Return a const Fragment::byte_t pointer pointing to the beginning of the header.
void clear ()
 Removes all elements from the payload section of the Fragment.
bool empty ()
 Determines if the Fragment contains no data.
void reserve (std::size_t cap)
 Reserves enough memory to hold cap RawDataType words in the Fragment payload.
void swap (Fragment &other) noexcept
 Swaps two Fragment objects.
void swap (QuickVec< RawDataType > &other) noexcept
 Swaps two Fragment data vectors.
RawDataTypedataAddress ()
 Returns a RawDataType pointer to the beginning of the payload.
RawDataTypemetadataAddress ()
 Get the address of the metadata. For internal use only, use metadata() instead.
RawDataTypeheaderAddress ()
 Gets the address of the header.

Static Public Member Functions

static constexpr bool isUserFragmentType (type_t fragmentType)
 Returns whether the given type is in the range of user types.
static constexpr bool isSystemFragmentType (type_t fragmentType)
 Returns whether the given type is in the range of system types.
static std::map< type_t,
std::string > 
MakeSystemTypeMap ()
 Returns a map of the most commonly-used system types.
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".
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".
static FragmentPtr eodFrag (size_t nFragsToExpect)
 Creates an EndOfData Fragment.
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).
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.

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.

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 84 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 99 of file Fragment.hh.


Constructor & Destructor Documentation

artdaq::Fragment::Fragment ( const Fragment  ) 

Default copy constructor.

Todo:
Decide if Copy constructor should be declared =delete
artdaq::Fragment::Fragment ( Fragment &&   )  = default [inline]

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:
n The initial size of the Fragment, in RawDataType words

Definition at line 22 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 
) [inline]

Create a Fragment with the given header values.

Template Parameters:
T Metadata type
Parameters:
payload_size Size of the payload in RawDataType words (Fragment size is header + metadata + payload)
sequence_id Sequence ID of Fragment
fragment_id Fragment ID of Fragment
type Type of Fragment
metadata Metadata object
timestamp Timestamp of Fragment

Definition at line 767 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:
sequenceID Sequence ID of Fragment
fragID Fragment ID of Fragment
type Type of Fragment
timestamp Timestamp of Fragment

Definition at line 39 of file Fragment.cc.


Member Function Documentation

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 1101 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 1047 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 1025 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 567 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 522 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 1055 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 1033 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 580 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 532 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:
sequenceID Sequence ID of new Fragment
fragID Fragment ID of new Fragment
dataPtr Pointer to data to store in Fragment
dataSize Size of data to store in Fragment
timestamp Timestamp of created Fragment
Returns:
FragmentPtr to created Fragment

Definition at line 85 of file Fragment.cc.

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

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:
InputIterator Type of input iterator
Parameters:
sequenceID Sequence ID of new Fragment
fragID Fragment ID of new Fragment
i Beginning of input range
e End of input range
Returns:
FragmentPtr to created Fragment
Todo:
Change function access specifier to restrict access

Definition at line 669 of file Fragment.hh.

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 894 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 355 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 1078 of file Fragment.hh.

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

Creates an EndOfData Fragment.

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

Definition at line 74 of file Fragment.cc.

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 
) [inline, static]

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

Template Parameters:
T Metadata type
Parameters:
payload_size_in_bytes Size of the payload in bytes (Fragment size is header + metadata + payload). Bytes will be rounded to the next factor of RawDataType / sizeof(char)
sequence_id Sequence ID of Fragment
fragment_id Fragment ID of Fragment
type Type of Fragment
metadata Metadata object
timestamp Timestamp of Fragment
Returns:
FragmentPtr to created Fragment

Definition at line 235 of file Fragment.hh.

static FragmentPtr artdaq::Fragment::FragmentBytes ( std::size_t  nbytes  )  [inline, static]

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

Parameters:
nbytes The initial size of the Fragment, in bytes
Returns:
FragmentPtr to created Fragment

Definition at line 200 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 833 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 902 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 1121 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 1062 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 1040 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 596 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 545 of file Fragment.hh.

bool constexpr artdaq::Fragment::isSystemFragmentType ( type_t  fragmentType  )  [inline, static]

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

Parameters:
fragmentType The type to test
Returns:
Whether the given type is in the range of system types

Definition at line 734 of file Fragment.hh.

bool constexpr artdaq::Fragment::isUserFragmentType ( type_t  fragmentType  )  [inline, static]

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

Parameters:
fragmentType The type to test
Returns:
Whether the given type is in the range of user types

Definition at line 724 of file Fragment.hh.

static std::map<type_t, std::string> artdaq::Fragment::MakeSystemTypeMap (  )  [inline, static]

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

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

Definition at line 175 of file Fragment.hh.

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

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

Template Parameters:
T Type of the metadata
Returns:
const Pointer to the metadata
Exceptions:
cet::exception if no metadata is present

Definition at line 923 of file Fragment.hh.

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

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

Template Parameters:
T Type of the metadata
Returns:
Pointer to the metadata
Exceptions:
cet::exception if no metadata is present

Definition at line 909 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::exception if no metadata in Fragment
Todo:
Change function access specifier to restrict access

Definition at line 1109 of file Fragment.hh.

artdaq::Fragment & artdaq::Fragment::operator= ( Fragment &&   )  = default [inline]

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

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

Default copy-assignment operator.

Returns:
Reference to new Fragment
Todo:
Decide if copy-assignment operator should be declared =delete
void artdaq::Fragment::print ( std::ostream &  os  )  const

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

Parameters:
os Stream to print to

Definition at line 65 of file Fragment.cc.

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

Wrapper around reinterpret_cast.

Template Parameters:
T Type of output pointer
Parameters:
in input pointer
Returns:
Pointer cast to type T
Exceptions:
cet::exception if 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 502 of file Fragment.hh.

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

Wrapper around reinterpret_cast.

Template Parameters:
T Type of output pointer
Parameters:
in input pointer
Returns:
Pointer cast to type T
Exceptions:
cet::exception if 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 474 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:
cap The new capacity of the Fragment payload, in RawDataType words.

Definition at line 1086 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:
sz The new size of the payload portion of the Fragment, in RawDataType words
val Value with which to initialize any new elements

Definition at line 982 of file Fragment.hh.

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

Resize the data payload to hold sz RawDataType words.

Parameters:
sz The new size of the payload portion of the Fragment, in RawDataType words

Definition at line 973 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:
szbytes The new size of the payload portion of the Fragment, in bytes
val Value with which to initialize any new elements

Definition at line 998 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:
szbytes The new size of the payload portion of the Fragment, in bytes

Definition at line 990 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 826 of file Fragment.hh.

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

Sets the Fragment ID of the Fragment.

Parameters:
fragment_id The Fragment ID to set

Definition at line 869 of file Fragment.hh.

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

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:
T Type of the metadata
Parameters:
md Metadata to store in Fragment
Exceptions:
cet::exception if metadata already present in Fragment

Definition at line 936 of file Fragment.hh.

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

Sets the Sequence ID of the Fragment.

Parameters:
sequence_id The sequence ID to set

Definition at line 861 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:
stype The System type to set

Definition at line 854 of file Fragment.hh.

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

Sets the Timestamp of the Fragment.

Parameters:
timestamp The Timestamp to set

Definition at line 876 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:
utype The User type to set

Definition at line 847 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 798 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 340 of file Fragment.hh.

void artdaq::Fragment::swap ( QuickVec< RawDataType > &  other  )  [inline]

Swaps two Fragment data vectors.

Parameters:
other The 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 630 of file Fragment.hh.

void artdaq::Fragment::swap ( Fragment other  )  [inline]

Swaps two Fragment objects.

Parameters:
other Fragment to swap with

Definition at line 1094 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 840 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 812 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 819 of file Fragment.hh.

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

Updates existing metadata with a new metadata object.

Template Parameters:
T Type of the metadata
Parameters:
md Metadata to set
Exceptions:
cet::exception if no metadata stored in Fragment
cet::exception if new metadata has different size than existing metadata

Definition at line 953 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 805 of file Fragment.hh.


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

Generated on 19 Feb 2018 for artdaq_core by  doxygen 1.6.1