ChimeraTK-DeviceAccess  03.18.00
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 
5 #include "SupportedUserTypes.h"
6 
7 #include <cassert>
8 
9 namespace 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
ChimeraTK::DataDescriptor::operator!=
bool operator!=(const DataDescriptor &other) const
Definition: DataDescriptor.cpp:136
ChimeraTK::DataDescriptor::setRawDataType
void setRawDataType(const DataType &d)
Set the raw data type.
Definition: DataDescriptor.cpp:116
ChimeraTK::DataDescriptor::transportLayerDataType
DataType transportLayerDataType() const
Get the data type on the transport layer.
Definition: DataDescriptor.cpp:122
ChimeraTK::DataDescriptor::FundamentalType::nodata
@ nodata
SupportedUserTypes.h
ChimeraTK::DataDescriptor::minimumDataType
DataType minimumDataType() const
Get the minimum data type required to represent the described data type in the host CPU.
Definition: DataDescriptor.cpp:142
ChimeraTK::DataDescriptor
Class describing the actual payload data format of a register in an abstract manner.
Definition: DataDescriptor.h:19
ChimeraTK::DataDescriptor::fundamentalType
FundamentalType fundamentalType() const
Get the fundamental data type.
Definition: DataDescriptor.cpp:78
ChimeraTK::DataDescriptor::nFractionalDigits
size_t nFractionalDigits() const
Approximate maximum number of digits after decimal dot (of base 10) needed to represent the value (ex...
Definition: DataDescriptor.cpp:105
ChimeraTK::DataDescriptor::FundamentalType::boolean
@ boolean
ChimeraTK::DataDescriptor::isSigned
bool isSigned() const
Return whether the data is signed or not.
Definition: DataDescriptor.cpp:84
ChimeraTK::DataDescriptor::operator==
bool operator==(const DataDescriptor &other) const
Definition: DataDescriptor.cpp:128
ChimeraTK::DataType::none
@ none
The data type/concept does not exist, e.g. there is no raw transfer (do not confuse with Void)
Definition: SupportedUserTypes.h:606
ChimeraTK::DataDescriptor::FundamentalType::undefined
@ undefined
ChimeraTK::DataDescriptor::FundamentalType::numeric
@ numeric
ChimeraTK::DataType
A class to describe which of the supported data types is used.
Definition: SupportedUserTypes.h:599
ChimeraTK::DataDescriptor::rawDataType
DataType rawDataType() const
Get the raw data type.
Definition: DataDescriptor.cpp:112
ChimeraTK::DataDescriptor::FundamentalType
FundamentalType
Enum for the fundamental data types.
Definition: DataDescriptor.h:25
ChimeraTK::operator<<
std::ostream & operator<<(std::ostream &stream, const DataDescriptor::FundamentalType &fundamentalType)
Definition: DataDescriptor.cpp:195
ChimeraTK::DataDescriptor::isIntegral
bool isIntegral() const
Return whether the data is integral or not (e.g.
Definition: DataDescriptor.cpp:91
ChimeraTK::DataDescriptor::nDigits
size_t nDigits() const
Return the approximate maximum number of digits (of base 10) needed to represent the value (including...
Definition: DataDescriptor.cpp:98
ChimeraTK::DataDescriptor::DataDescriptor
DataDescriptor()
Default constructor sets fundamental type to "undefined".
Definition: DataDescriptor.cpp:72
ChimeraTK
Definition: DummyBackend.h:16
ChimeraTK::DataDescriptor::FundamentalType::string
@ string