ChimeraTK-DeviceAccess
03.18.00
|
Class describing the actual payload data format of a register in an abstract manner. More...
#include <DataDescriptor.h>
Public Types | |
enum | FundamentalType { FundamentalType::numeric, FundamentalType::string, FundamentalType::boolean, FundamentalType::nodata, FundamentalType::undefined } |
Enum for the fundamental data types. More... | |
Public Member Functions | |
DataDescriptor (FundamentalType fundamentalType_, bool isIntegral_=false, bool isSigned_=false, size_t nDigits_=0, size_t nFractionalDigits_=0, DataType rawDataType_=DataType::none, DataType transportLayerDataType_=DataType::none) | |
Constructor setting all members. More... | |
DataDescriptor (DataType type) | |
Construct from DataType object - the DataDescriptor will then describe the passed DataType (with no raw type). More... | |
DataDescriptor () | |
Default constructor sets fundamental type to "undefined". More... | |
FundamentalType | fundamentalType () const |
Get the fundamental data type. More... | |
bool | isSigned () const |
Return whether the data is signed or not. More... | |
bool | isIntegral () const |
Return whether the data is integral or not (e.g. More... | |
size_t | nDigits () const |
Return the approximate maximum number of digits (of base 10) needed to represent the value (including a decimal dot, if not an integral data* type, and the sign). More... | |
size_t | nFractionalDigits () const |
Approximate maximum number of digits after decimal dot (of base 10) needed to represent the value (excluding the decimal dot itself). More... | |
DataType | rawDataType () const |
Get the raw data type. More... | |
void | setRawDataType (const DataType &d) |
Set the raw data type. More... | |
DataType | transportLayerDataType () const |
Get the data type on the transport layer. More... | |
DataType | minimumDataType () const |
Get the minimum data type required to represent the described data type in the host CPU. More... | |
bool | operator== (const DataDescriptor &other) const |
bool | operator!= (const DataDescriptor &other) const |
Class describing the actual payload data format of a register in an abstract manner.
It gives information about the underlying data type without fully describing it, to prevent a loss of abstraction on the application level. The returned information always refers to the data type and thus is completely independent of the current value of the register.
Definition at line 19 of file DataDescriptor.h.
|
strong |
Enum for the fundamental data types.
This is only used inside the DataDescriptor class but defined outside to prevent too long fully qualified names.
Enumerator | |
---|---|
numeric | |
string | |
boolean | |
nodata | |
undefined |
Definition at line 25 of file DataDescriptor.h.
|
explicit |
Constructor setting all members.
Definition at line 9 of file DataDescriptor.cpp.
|
explicit |
Construct from DataType object - the DataDescriptor will then describe the passed DataType (with no raw type).
Definition at line 16 of file DataDescriptor.cpp.
ChimeraTK::DataDescriptor::DataDescriptor | ( | ) |
Default constructor sets fundamental type to "undefined".
Definition at line 72 of file DataDescriptor.cpp.
DataDescriptor::FundamentalType ChimeraTK::DataDescriptor::fundamentalType | ( | ) | const |
Get the fundamental data type.
Definition at line 78 of file DataDescriptor.cpp.
bool ChimeraTK::DataDescriptor::isIntegral | ( | ) | const |
Return whether the data is integral or not (e.g.
int vs. float). May only be called for numeric data types.
Definition at line 91 of file DataDescriptor.cpp.
bool ChimeraTK::DataDescriptor::isSigned | ( | ) | const |
Return whether the data is signed or not.
May only be called for numeric data types.
Definition at line 84 of file DataDescriptor.cpp.
DataType ChimeraTK::DataDescriptor::minimumDataType | ( | ) | const |
Get the minimum data type required to represent the described data type in the host CPU.
Definition at line 142 of file DataDescriptor.cpp.
size_t ChimeraTK::DataDescriptor::nDigits | ( | ) | const |
Return the approximate maximum number of digits (of base 10) needed to represent the value (including a decimal dot, if not an integral data* type, and the sign).
May only be called for numeric data types.
This number shall only be used for displaying purposes, e.g. to decide how much space for displaying the register value should be reserved. Beware that for some data types this might become a really large number (e.g. 300), which indicates that you need to choose a different representation than just a plain decimal number.
Definition at line 98 of file DataDescriptor.cpp.
size_t ChimeraTK::DataDescriptor::nFractionalDigits | ( | ) | const |
Approximate maximum number of digits after decimal dot (of base 10) needed to represent the value (excluding the decimal dot itself).
May only be called for non-integral numeric data types.
Just like in case of nDigits(), this number should only be used for displaying purposes. There is no guarantee that the full precision of the number can be displayed with the given number of digits. Again beware that this number might be rather large (e.g. 300).
Definition at line 105 of file DataDescriptor.cpp.
bool ChimeraTK::DataDescriptor::operator!= | ( | const DataDescriptor & | other | ) | const |
bool ChimeraTK::DataDescriptor::operator== | ( | const DataDescriptor & | other | ) | const |
DataType ChimeraTK::DataDescriptor::rawDataType | ( | ) | const |
Get the raw data type.
This is the data conversion from 'cooked' to the raw data type on the device. This conversion does not change the shape of the data but descibes the data type of a single data point.
Most backends will have type none, i.e. no raw data conversion available. At the moment only the NumericalAddressedBackend has int32_t raw transfer with raw/cooked conversion. Can be extended if needed, but this partily breaks abstraction because it exposes details of the (transport) layer below. It should be avoided if possible.
Definition at line 112 of file DataDescriptor.cpp.
void ChimeraTK::DataDescriptor::setRawDataType | ( | const DataType & | d | ) |
Set the raw data type.
This is useful e.g. when a decorated register should no longer allow raw access, in which case you should set DataType::none
Definition at line 116 of file DataDescriptor.cpp.
DataType ChimeraTK::DataDescriptor::transportLayerDataType | ( | ) | const |
Get the data type on the transport layer.
This is always a 1D array of the specific data type. This raw transfer might contain data for more than one register.
Examples:
Notice: Currently all implementations return 'none'. From the interface there is no way to access the transport layer data (yet). The function is put here for conceputal completeness.
Definition at line 122 of file DataDescriptor.cpp.