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

Writer that appends a ShapesData with an empty Data child; the caller writes the payload at data() and then records its length with set_data_length(). More...

#include <DescData.hh>

Inherits XtcData::DescData.

Public Member Functions

 DescribedData (Xtc &parent, const void *bufEnd, NameIndex &nameindex, NamesId &namesId)
 Append to parent a ShapesData (src namesId) and a Data child inside it, growing the extents of parent and the ShapesData.
 
 DescribedData (Xtc &parent, const void *bufEnd, NamesLookup &NamesLookup, NamesId &namesId)
 Same as the NameIndex constructor, using NamesLookup[namesId] as the NameIndex (a missing key is inserted empty and names() then throws).
 
void * data ()
 Return a pointer to the start of the Data child's payload.
 
void set_data_length (unsigned size)
 Add size bytes to the extents of the Data child, the ShapesData and parent (AutoParentAlloc::alloc()).
 
void set_array_shape (unsigned index, const unsigned shape[MaxRank])
 Store shape as the next Shape entry for array field index.
 
- Public Member Functions inherited from XtcData::DescData
 DescData (ShapesData &shapesdata, NameIndex &nameindex)
 Compute the field offsets for reading an existing shapesdata.
 
DescData & operator= (const DescData &o)
 Copy offsets and counts from o.
 
 ~DescData ()
 Destructor; does nothing.
 
template<typename T >
Array< T > get_array (unsigned index)
 Return an Array<T> view of field index: data at the field's offset in the Data payload, shape from shape(name), rank from the Name.
 
template<class T >
T get_value (const char *name)
 Look up name in the NameIndex's nameMap and return get_value<T>(index).
 
template<class T >
T get_value (unsigned index)
 Return a copy of the T stored at field index's offset in the Data payload.
 
template<class T >
T & get_lvalue (unsigned index)
 Return a reference to the T at field index's offset in the Data payload.
 
uint32_t * shape (Name &name)
 Return the dimension array of the Shape at index shapeMap()[name.name()] in the Shapes child.
 
NameIndex & nameindex ()
 Return the NameIndex reference.
 
ShapesData & shapesdata ()
 Return the ShapesData reference.
 
void shapesdata (ShapesData &o)
 Assign o into the referenced ShapesData (Xtc::operator=, which copies src, damage and contains and resets extent to sizeof(Xtc)); the reference is not rebound.
 

Additional Inherited Members

- Static Public Member Functions inherited from XtcData::DescData
static void incorrectType (const char *file, unsigned line, Name &name)
 Print file, line, and the type and name of name, then call abort().
 
static void checkType (uint8_t val, Name &name)
 Abort (incorrectType()) unless name.type() is UINT8; val only selects the overload.
 
static void checkType (uint16_t val, Name &name)
 Abort (incorrectType()) unless name.type() is UINT16; val only selects the overload.
 
static void checkType (uint32_t val, Name &name)
 Abort (incorrectType()) unless name.type() is UINT32, ENUMVAL or ENUMDICT; val only selects the overload.
 
static void checkType (uint64_t val, Name &name)
 Abort (incorrectType()) unless name.type() is UINT64; val only selects the overload.
 
static void checkType (int8_t val, Name &name)
 Abort (incorrectType()) unless name.type() is INT8; val only selects the overload.
 
static void checkType (int16_t val, Name &name)
 Abort (incorrectType()) unless name.type() is INT16; val only selects the overload.
 
static void checkType (int32_t val, Name &name)
 Abort (incorrectType()) unless name.type() is INT32, ENUMVAL or ENUMDICT; val only selects the overload.
 
static void checkType (int64_t val, Name &name)
 Abort (incorrectType()) unless name.type() is INT64; val only selects the overload.
 
static void checkType (float val, Name &name)
 Abort (incorrectType()) unless name.type() is FLOAT; val only selects the overload.
 
static void checkType (double val, Name &name)
 Abort (incorrectType()) unless name.type() is DOUBLE; val only selects the overload.
 
static void checkType (char val, Name &name)
 Abort (incorrectType()) unless name.type() is CHARSTR; val only selects the overload.
 
- Protected Member Functions inherited from XtcData::DescData
 DescData (NameIndex &nameindex, Xtc &parent, const void *bufEnd, NamesId &namesId)
 
 DescData (NameIndex &nameindex, Xtc &parent, const void *bufEnd, VarDef &V, NamesId &namesId)
 
void set_array_shape (unsigned index, unsigned shapeIndex, const unsigned shape[MaxRank])
 
- Protected Attributes inherited from XtcData::DescData
std::vector< unsigned > _offset
 
ShapesData & _shapesdata
 
unsigned _numentries
 
NameIndex & _nameindex
 
unsigned _numarrays
 

Detailed Description

Writer that appends a ShapesData with an empty Data child; the caller writes the payload at data() and then records its length with set_data_length().

Array shapes are added with set_array_shape().

Constructor & Destructor Documentation

◆ DescribedData() [1/2]

XtcData::DescribedData::DescribedData ( Xtc &  parent,
const void *  bufEnd,
NameIndex &  nameindex,
NamesId &  namesId 
)
inline

Append to parent a ShapesData (src namesId) and a Data child inside it, growing the extents of parent and the ShapesData.

Throws (from NameIndex::names()) if nameindex holds no Names.

◆ DescribedData() [2/2]

XtcData::DescribedData::DescribedData ( Xtc &  parent,
const void *  bufEnd,
NamesLookup &  NamesLookup,
NamesId &  namesId 
)
inline

Same as the NameIndex constructor, using NamesLookup[namesId] as the NameIndex (a missing key is inserted empty and names() then throws).

Member Function Documentation

◆ data()

void * XtcData::DescribedData::data ( )
inline

Return a pointer to the start of the Data child's payload.

◆ set_array_shape()

void XtcData::DescribedData::set_array_shape ( unsigned  index,
const unsigned  shape[MaxRank] 
)
inline

Store shape as the next Shape entry for array field index.

On the first call it first appends a Shapes child with room for shapeMap().size() Shape entries. Aborts if field index is a scalar (rank 0).

◆ set_data_length()

void XtcData::DescribedData::set_data_length ( unsigned  size)
inline

Add size bytes to the extents of the Data child, the ShapesData and parent (AutoParentAlloc::alloc()).

The source comment says this is done once the data has arrived.


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