lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
XtcData::Names Class Reference

Xtc of type TypeId::Names: the header, a NameInfo, then an array of Name entries appended by add(). More...

#include <ShapesData.hh>

Inherits XtcData::AutoParentAlloc.

Public Member Functions

 Names (const void *bufEnd, const char *detName, Alg &alg, const char *detType, const char *detId, const NamesId &namesId, unsigned segment=0)
 Build the header (TypeId::Names version 0, src = namesId), fill the NameInfo, and grow this xtc's own extent to cover the NameInfo.
 
NamesId & namesId ()
 Return src reinterpreted as a NamesId reference.
 
uint32_t numArrays ()
 Return NameInfo::numArrays.
 
const char * detName ()
 Return the detName string from the NameInfo.
 
const char * detType ()
 Return the detType string from the NameInfo.
 
const char * detId ()
 Return the detId string from the NameInfo.
 
unsigned segment ()
 Return the segment number from the NameInfo.
 
Alg & alg ()
 Return a reference to the Alg in the NameInfo.
 
Name & get (unsigned index)
 Return the index-th Name stored right after this object (no bounds check).
 
unsigned num ()
 Return the number of Name entries: the bytes between the end of this object and next(), divided by sizeof(Name).
 
void add (Xtc &parent, const void *bufEnd, VarDef &V)
 Append a copy of every Name in V.NameVec, adding sizeof(Name) to this xtc's and parent's extents for each (AutoParentAlloc::alloc()).
 
- Public Member Functions inherited from XtcData::AutoParentAlloc
 AutoParentAlloc (TypeId typeId)
 Construct as Xtc(typeId): damage 0, extent sizeof(Xtc).
 
 AutoParentAlloc (TypeId typeId, const NamesId &namesId)
 Construct as Xtc(typeId, namesId): src is set to namesId, damage 0, extent sizeof(Xtc).
 
void * alloc (uint32_t size, Xtc &parent, const void *bufEnd)
 Add size to parent's extent (parent.alloc()) and to this xtc's extent (Xtc::alloc()), returning the address that was this->next().
 
void * alloc (uint32_t size, Xtc &parent, Xtc &superparent, const void *bufEnd)
 Add size to the extents of superparent, parent and this xtc (in that order), returning the address that was this->next().
 
- Public Member Functions inherited from XtcData::Xtc
 Xtc ()
 Set damage and extent to 0; src gets the Src default (value 0) and contains is left uninitialized.
 
 Xtc (const Xtc &xtc)
 Copy src, damage and contains from xtc, but set extent to sizeof(Xtc) (empty payload).
 
 Xtc (const TypeId &type)
 Header of the given type with default Src (value 0), damage 0 and extent sizeof(Xtc).
 
 Xtc (const TypeId &type, const Src &_src)
 Header with the given type and src, damage 0 and extent sizeof(Xtc).
 
 Xtc (const TypeId &_tag, const Src &_src, unsigned _damage)
 Header with the given type (_tag), src and damage word, and extent sizeof(Xtc).
 
 Xtc (const TypeId &_tag, const Src &_src, const Damage &_damage)
 Header with the given type (_tag), src and damage, and extent sizeof(Xtc).
 
Xtc & operator= (const Xtc &xtc)
 Copy src, damage and contains from xtc and reset extent to sizeof(Xtc).
 
void * operator new (size_t size)
 Allocate size bytes with std::malloc.
 
void * operator new (size_t size, char *p, const void *end)
 Placement new at p.
 
void * operator new (size_t size, Xtc *p, const void *end)
 Placement new into the payload of p: returns p->alloc(size, end), which adds size to p's extent.
 
void * operator new (size_t size, Xtc &p, const void *end)
 Placement new into the payload of p: returns p.alloc(size, end), which adds size to p's extent.
 
void operator delete (void *p)
 Free p with std::free.
 
void operator delete (void *ptr, char *p, const void *end)
 Placement delete matching operator new(size_t, char*, const void*); does nothing.
 
void operator delete (void *ptr, Xtc *p, const void *end)
 Placement delete matching operator new(size_t, Xtc*, const void*); does nothing.
 
void operator delete (void *ptr, Xtc &p, const void *end)
 Placement delete matching operator new(size_t, Xtc&, const void*); does nothing.
 
char * payload () const
 Return a pointer to the first byte after this header.
 
int sizeofPayload () const
 Return extent - sizeof(Xtc) as an int (the comment above notes this limits extent to 31 bits).
 
Xtc * next ()
 Return the address extent bytes after the start of this header, where the next sibling Xtc begins.
 
const Xtc * next () const
 Return the address extent bytes after the start of this header, where the next sibling Xtc begins (const version).
 
void * alloc (size_t size, const void *end)
 Reserve size bytes at next() by adding size to extent and return that address (memory is not initialized).
 

Additional Inherited Members

- Public Attributes inherited from XtcData::Xtc
Src src
 Source word (Src); Names and ShapesData keep their NamesId here.
 
Damage damage
 Damage word.
 
TypeId contains
 TypeId (type and version) of the payload.
 
uint32_t extent
 Size in bytes of this header plus its payload.
 

Detailed Description

Xtc of type TypeId::Names: the header, a NameInfo, then an array of Name entries appended by add().

Its src holds the NamesId.

Constructor & Destructor Documentation

◆ Names()

XtcData::Names::Names ( const void *  bufEnd,
const char *  detName,
Alg &  alg,
const char *  detType,
const char *  detId,
const NamesId &  namesId,
unsigned  segment = 0 
)
inline

Build the header (TypeId::Names version 0, src = namesId), fill the NameInfo, and grow this xtc's own extent to cover the NameInfo.

Aborts if bufEnd is non-null and would be passed, or if detName has a character other than letters, digits or '_'.

Member Function Documentation

◆ add()

void XtcData::Names::add ( Xtc &  parent,
const void *  bufEnd,
VarDef &  V 
)
inline

Append a copy of every Name in V.NameVec, adding sizeof(Name) to this xtc's and parent's extents for each (AutoParentAlloc::alloc()).

Increments numArrays for each added Name with rank > 0.

◆ alg()

Alg & XtcData::Names::alg ( )
inline

Return a reference to the Alg in the NameInfo.

◆ detId()

const char * XtcData::Names::detId ( )
inline

Return the detId string from the NameInfo.

◆ detName()

const char * XtcData::Names::detName ( )
inline

Return the detName string from the NameInfo.

◆ detType()

const char * XtcData::Names::detType ( )
inline

Return the detType string from the NameInfo.

◆ get()

Name & XtcData::Names::get ( unsigned  index)
inline

Return the index-th Name stored right after this object (no bounds check).

◆ namesId()

NamesId & XtcData::Names::namesId ( )
inline

Return src reinterpreted as a NamesId reference.

◆ num()

unsigned XtcData::Names::num ( )
inline

Return the number of Name entries: the bytes between the end of this object and next(), divided by sizeof(Name).

Aborts with a message if that byte count is not a multiple of sizeof(Name).

◆ numArrays()

uint32_t XtcData::Names::numArrays ( )
inline

◆ segment()

unsigned XtcData::Names::segment ( )
inline

Return the segment number from the NameInfo.


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