ChimeraTK-DeviceAccess 03.25.00
Loading...
Searching...
No Matches
DataDescriptor.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3#pragma once
4
6
7#include <cassert>
8
9namespace ChimeraTK {
10
11 /********************************************************************************************************************/
12
20 public:
26
30 explicit DataDescriptor(FundamentalType fundamentalType_, bool isIntegral_ = false, bool isSigned_ = false,
31 size_t nDigits_ = 0, size_t nFractionalDigits_ = 0, DataType rawDataType_ = DataType::none,
32 DataType transportLayerDataType_ = DataType::none);
33
37 explicit DataDescriptor(DataType type);
38
43
45 [[nodiscard]] FundamentalType fundamentalType() const;
46
48 [[nodiscard]] bool isSigned() const;
49
51 [[nodiscard]] bool isIntegral() const;
52
61 [[nodiscard]] size_t nDigits() const;
62
71 [[nodiscard]] size_t nFractionalDigits() const;
72
90 [[nodiscard]] DataType rawDataType() const;
91
96 void setRawDataType(const DataType& d);
97
110 [[nodiscard]] DataType transportLayerDataType() const;
111
115 [[nodiscard]] DataType minimumDataType() const;
116
117 bool operator==(const DataDescriptor& other) const;
118 bool operator!=(const DataDescriptor& other) const;
119
120 private:
122 FundamentalType _fundamentalType;
123
125 DataType _rawDataType;
126
128 DataType _transportLayerDataType;
129
131 bool _isIntegral;
132
134 bool _isSigned;
135
140 size_t _nDigits;
141
146 size_t _nFractionalDigits;
147 };
148
149 /********************************************************************************************************************/
150
151 std::ostream& operator<<(std::ostream& stream, const DataDescriptor::FundamentalType& fundamentalType);
152
153 /********************************************************************************************************************/
154
155} // namespace ChimeraTK
Class describing the actual payload data format of a register in an abstract manner.
size_t nFractionalDigits() const
Approximate maximum number of digits after decimal dot (of base 10) needed to represent the value (ex...
FundamentalType fundamentalType() const
Get the fundamental data type.
bool isIntegral() const
Return whether the data is integral or not (e.g.
DataType transportLayerDataType() const
Get the data type on the transport layer.
DataDescriptor()
Default constructor sets fundamental type to "undefined".
DataType minimumDataType() const
Get the minimum data type required to represent the described data type in the host CPU.
void setRawDataType(const DataType &d)
Set the raw data type.
bool operator!=(const DataDescriptor &other) const
bool operator==(const DataDescriptor &other) const
size_t nDigits() const
Return the approximate maximum number of digits (of base 10) needed to represent the value (including...
DataType rawDataType() const
Get the raw data type.
bool isSigned() const
Return whether the data is signed or not.
FundamentalType
Enum for the fundamental data types.
A class to describe which of the supported data types is used.
@ none
The data type/concept does not exist, e.g. there is no raw transfer (do not confuse with Void)
std::ostream & operator<<(std::ostream &stream, const DataDescriptor::FundamentalType &fundamentalType)