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

Reader for a ShapesData: combines it with the NameIndex of its Names to compute the byte offset of each field in the Data payload. More...

#include <DescData.hh>

Inherited by XtcData::CreateData, and XtcData::DescribedData.

Public Member Functions

 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.
 

Static Public Member Functions

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

 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

std::vector< unsigned > _offset
 
ShapesData & _shapesdata
 
unsigned _numentries
 
NameIndex & _nameindex
 
unsigned _numarrays
 

Detailed Description

Reader for a ShapesData: combines it with the NameIndex of its Names to compute the byte offset of each field in the Data payload.

Field offsets are cumulative: a scalar takes Name::get_element_size() bytes and an array takes Shape::size() of the next Shape entry.

Constructor & Destructor Documentation

◆ DescData() [1/3]

XtcData::DescData::DescData ( ShapesData &  shapesdata,
NameIndex &  nameindex 
)
inline

Compute the field offsets for reading an existing shapesdata.

Array fields use the Shapes entries in order (0, 1, ...). Throws (from NameIndex::names()) if nameindex holds no Names.

◆ ~DescData()

XtcData::DescData::~DescData ( )
inline

Destructor; does nothing.

◆ DescData() [2/3]

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

◆ DescData() [3/3]

XtcData::DescData::DescData ( NameIndex &  nameindex,
Xtc &  parent,
const void *  bufEnd,
VarDef &  V,
NamesId &  namesId 
)
inlineprotected

Member Function Documentation

◆ checkType() [1/11]

static void XtcData::DescData::checkType ( char  val,
Name &  name 
)
inlinestatic

Abort (incorrectType()) unless name.type() is CHARSTR; val only selects the overload.

◆ checkType() [2/11]

static void XtcData::DescData::checkType ( double  val,
Name &  name 
)
inlinestatic

Abort (incorrectType()) unless name.type() is DOUBLE; val only selects the overload.

◆ checkType() [3/11]

static void XtcData::DescData::checkType ( float  val,
Name &  name 
)
inlinestatic

Abort (incorrectType()) unless name.type() is FLOAT; val only selects the overload.

◆ checkType() [4/11]

static void XtcData::DescData::checkType ( int16_t  val,
Name &  name 
)
inlinestatic

Abort (incorrectType()) unless name.type() is INT16; val only selects the overload.

◆ checkType() [5/11]

static void XtcData::DescData::checkType ( int32_t  val,
Name &  name 
)
inlinestatic

Abort (incorrectType()) unless name.type() is INT32, ENUMVAL or ENUMDICT; val only selects the overload.

◆ checkType() [6/11]

static void XtcData::DescData::checkType ( int64_t  val,
Name &  name 
)
inlinestatic

Abort (incorrectType()) unless name.type() is INT64; val only selects the overload.

◆ checkType() [7/11]

static void XtcData::DescData::checkType ( int8_t  val,
Name &  name 
)
inlinestatic

Abort (incorrectType()) unless name.type() is INT8; val only selects the overload.

◆ checkType() [8/11]

static void XtcData::DescData::checkType ( uint16_t  val,
Name &  name 
)
inlinestatic

Abort (incorrectType()) unless name.type() is UINT16; val only selects the overload.

◆ checkType() [9/11]

static void XtcData::DescData::checkType ( uint32_t  val,
Name &  name 
)
inlinestatic

Abort (incorrectType()) unless name.type() is UINT32, ENUMVAL or ENUMDICT; val only selects the overload.

◆ checkType() [10/11]

static void XtcData::DescData::checkType ( uint64_t  val,
Name &  name 
)
inlinestatic

Abort (incorrectType()) unless name.type() is UINT64; val only selects the overload.

◆ checkType() [11/11]

static void XtcData::DescData::checkType ( uint8_t  val,
Name &  name 
)
inlinestatic

Abort (incorrectType()) unless name.type() is UINT8; val only selects the overload.

◆ get_array()

template<typename T >
Array< T > XtcData::DescData::get_array ( unsigned  index)
inline

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.

T is not checked against the field's DataType.

◆ get_lvalue()

template<class T >
T & XtcData::DescData::get_lvalue ( unsigned  index)
inline

Return a reference to the T at field index's offset in the Data payload.

Aborts with a message if index > the number of entries; the type is not checked.

◆ get_value() [1/2]

template<class T >
T XtcData::DescData::get_value ( const char *  name)
inline

Look up name in the NameIndex's nameMap and return get_value<T>(index).

Prints a message and aborts if the name is not found.

◆ get_value() [2/2]

template<class T >
T XtcData::DescData::get_value ( unsigned  index)
inline

Return a copy of the T stored at field index's offset in the Data payload.

Aborts with a message if index > the number of entries (index equal to it is not rejected), or via checkType() if T does not match the field's DataType.

◆ incorrectType()

static void XtcData::DescData::incorrectType ( const char *  file,
unsigned  line,
Name &  name 
)
inlinestatic

Print file, line, and the type and name of name, then call abort().

◆ nameindex()

NameIndex & XtcData::DescData::nameindex ( )
inline

Return the NameIndex reference.

◆ operator=()

DescData & XtcData::DescData::operator= ( const DescData &  o)
inline

Copy offsets and counts from o.

The ShapesData and NameIndex members are references, so o's objects are assigned into the referenced ones (Xtc::operator= resets that ShapesData's extent to sizeof(Xtc)) instead of rebinding.

Returns
*this.

◆ set_array_shape()

void XtcData::DescData::set_array_shape ( unsigned  index,
unsigned  shapeIndex,
const unsigned  shape[MaxRank] 
)
inlineprotected

◆ shape()

uint32_t * XtcData::DescData::shape ( Name &  name)
inline

Return the dimension array of the Shape at index shapeMap()[name.name()] in the Shapes child.

A name missing from shapeMap is inserted with index 0 by std::map::operator[].

◆ shapesdata() [1/2]

ShapesData & XtcData::DescData::shapesdata ( )
inline

Return the ShapesData reference.

◆ shapesdata() [2/2]

void XtcData::DescData::shapesdata ( ShapesData &  o)
inline

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.

Member Data Documentation

◆ _nameindex

NameIndex& XtcData::DescData::_nameindex
protected

◆ _numarrays

unsigned XtcData::DescData::_numarrays
protected

◆ _numentries

unsigned XtcData::DescData::_numentries
protected

◆ _offset

std::vector<unsigned> XtcData::DescData::_offset
protected

◆ _shapesdata

ShapesData& XtcData::DescData::_shapesdata
protected

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