8#ifndef META_OCEAN_BASE_DATA_TYPE_H
9#define META_OCEAN_BASE_DATA_TYPE_H
25template <
typename T,
unsigned int tElements>
51 static_assert(
sizeof(
Type) ==
sizeof(T) * tElements,
"Invalid data type!");
225 using Type =
unsigned long long;
443 template <
typename T>
444 static inline const char*
name();
462template <
size_t tBytes>
465 static_assert(tBytes == 1 || tBytes == 2 || tBytes == 4 || tBytes == 8,
"Invalid data type!");
501 static_assert(
sizeof(T) == 1 ||
sizeof(T) == 2 ||
sizeof(T) == 4 ||
sizeof(T) == 8,
"Invalid data type!");
516template <
bool tOrderedKeys>
524 template <
typename TKey,
typename TElement>
525 using TMap = std::map<TKey, TElement>;
539 template <
typename TKey,
typename TElement>
540 using TMap = std::unordered_map<TKey, TElement>;
562 inline Float16(
const uint16_t sign,
const uint16_t fraction,
const uint16_t exponent);
574 inline uint16_t
binary()
const;
580 explicit operator float()
const;
635template <
typename T,
unsigned int tElements>
638 for (
unsigned int n = 0u; n < tElements; ++n)
649template <
typename T,
unsigned int tElements>
652 return !(*
this == type);
764 using Type =
unsigned long long;
1388 static const char* value =
"bool";
1395 static const char* value =
"char";
1402 static const char* value =
"signed char";
1409 static const char* value =
"unsigned char";
1416 static const char* value =
"short";
1423 static const char* value =
"unsigned short";
1430 static const char* value =
"int";
1437 static const char* value =
"unsigned int";
1444 static const char* value =
"long";
1451 static const char* value =
"unsigned long";
1458 static const char* value =
"long long";
1465 static const char* value =
"unsigned long long";
1472 static const char* value =
"float";
1479 static const char* value =
"double";
1541 ocean_assert(sign <= 1u);
1542 ocean_assert(fraction <= 1023u);
1543 ocean_assert(exponent <= 31u);
1545 data_.ieee_.fraction_ = fraction;
1546 data_.ieee_.exponent_ = exponent;
1547 data_.ieee_.sign_ = sign;
1557 return data_.binary_;
1572 return !(*
this == second);
1577 constexpr uint16_t sign = 0u;
1578 constexpr uint16_t fraction = 0u;
1579 constexpr uint16_t maxExponent = 31u;
1581 return Float16(sign, fraction, maxExponent);
unsigned int Type
Definition of the absolute difference value type.
Definition DataType.h:890
double Type
Definition of the absolute difference value type.
Definition DataType.h:946
double Type
Definition of the absolute difference value type.
Definition DataType.h:932
unsigned int Type
Definition of the absolute difference value type.
Definition DataType.h:904
unsigned int Type
Definition of the absolute difference value type.
Definition DataType.h:918
This class is a helper class allowing to define the resulting data type for an absolute difference op...
Definition DataType.h:218
unsigned long long Type
Definition of the data type for the absolute difference value.
Definition DataType.h:225
Template class allowing to define an array of data types.
Definition DataType.h:27
int Type
Definition of the signed distance type.
Definition DataType.h:778
int Type
Definition of the signed distance type.
Definition DataType.h:834
int Type
Definition of the signed distance type.
Definition DataType.h:792
int Type
Definition of the signed distance type.
Definition DataType.h:806
int Type
Definition of the signed distance type.
Definition DataType.h:820
long Type
Definition of the signed distance type.
Definition DataType.h:862
long long Type
Definition of the signed distance type.
Definition DataType.h:876
int Type
Definition of the signed distance type.
Definition DataType.h:848
This class is a helper class allowing to define the signed difference data type of a given type.
Definition DataType.h:169
T Type
Definition of the data type for the signed difference value.
Definition DataType.h:176
bool operator==(const Float16 &second) const
Returns whether two 16-bit float values are identical.
Definition DataType.h:1565
uint16_t binary() const
Returns the binary representation of this 16-bit float value.
Definition DataType.h:1555
uint16_t exponent_
The exponent composed of 5 bits.
Definition DataType.h:627
uint16_t sign_
The sign composed of 1 bit.
Definition DataType.h:630
Float16()=default
Default constructor.
bool operator!=(const Float16 &second) const
Returns whether two 16-bit float values are not identical.
Definition DataType.h:1570
union Ocean::Float16::@347134372052162010116346255364224136030344262321 data_
Union allowing to access the binary representation or the IEEE representation.
static Float16 infinity()
Returns +infinity.
Definition DataType.h:1575
uint16_t binary_
The binary representation.
Definition DataType.h:616
uint16_t fraction_
The mantissa composed of 10 bits.
Definition DataType.h:624
Float16 operator-() const
Negates the 16-bit float value.
Definition DataType.h:1560
This class implements a helper class allowing to define the identity data type of a given type.
Definition DataType.h:86
T Type
The data type of 'T'.
Definition DataType.h:90
std::unordered_map< TKey, TElement > TMap
Definition of an unordered map.
Definition DataType.h:540
Helper class allowing to define an ordered or unordered map based on the template parameter 'tOrdered...
Definition DataType.h:518
std::map< TKey, TElement > TMap
Definition of an ordered map.
Definition DataType.h:525
float TypePerformance
Definition of the data type for the next larger data type regarding performance.
Definition DataType.h:1088
double Type
Definition of the data type for the next larger data type.
Definition DataType.h:1083
long long Type
Definition of the data type for the next larger data type.
Definition DataType.h:1045
long long TypePerformance
Definition of the data type for the next larger data type regarding performance.
Definition DataType.h:1050
int TypePerformance
Definition of the data type for the next larger data type regarding performance.
Definition DataType.h:1012
int Type
Definition of the data type for the next larger data type.
Definition DataType.h:1007
short Type
Definition of the data type for the next larger data type.
Definition DataType.h:969
int TypePerformance
Definition of the data type for the next larger data type regarding performance.
Definition DataType.h:974
unsigned int TypePerformance
Definition of the data type for the next larger data type regarding performance.
Definition DataType.h:993
unsigned short Type
Definition of the data type for the next larger data type.
Definition DataType.h:988
unsigned long long TypePerformance
Definition of the data type for the next larger data type regarding performance.
Definition DataType.h:1069
unsigned long long Type
Definition of the data type for the next larger data type.
Definition DataType.h:1064
unsigned int TypePerformance
Definition of the data type for the next larger data type regarding performance.
Definition DataType.h:1031
unsigned int Type
Definition of the data type for the next larger data type.
Definition DataType.h:1026
This class is a helper class allowing to determine the next larger data type for a given data type.
Definition DataType.h:248
T TypePerformance
Definition of the data type for the next larger data type regarding performance.
Definition DataType.h:261
T Type
Definition of the data type for the next larger data type.
Definition DataType.h:255
bool Type
Definition of the data type which is 'bool' in case of 'T' is 'void'.
Definition DataType.h:418
static constexpr bool defaultValue()
Returns a default value for 'T'.
Definition DataType.h:424
This struct implements a helper struct allowing to use a data type instead of void.
Definition DataType.h:389
T Type
Definition of the data type which is 'bool' in case of 'T' is 'void'.
Definition DataType.h:395
static constexpr T defaultValue()
Returns a default value for 'T'.
Definition DataType.h:401
static const bool hasSigned
True, if the data has a corresponding signed data type (or itself is signed).
Definition DataType.h:1112
bool Type
Definition of the signed data type, if existing.
Definition DataType.h:1102
static const bool isSigned
True, if the data type T is an signed data type; False, otherwise.
Definition DataType.h:1107
static const bool isSigned
True, if the data type T is an signed data type; False, otherwise.
Definition DataType.h:1164
static const bool hasSigned
True, if the data has a corresponding signed data type (or itself is signed).
Definition DataType.h:1169
int Type
Definition of the signed data type, if existing.
Definition DataType.h:1159
static const bool hasSigned
True, if the data has a corresponding signed data type (or itself is signed).
Definition DataType.h:1193
long long Type
Definition of the signed data type, if existing.
Definition DataType.h:1183
static const bool isSigned
True, if the data type T is an signed data type; False, otherwise.
Definition DataType.h:1188
static const bool hasSigned
True, if the data has a corresponding signed data type (or itself is signed).
Definition DataType.h:1145
static const bool isSigned
True, if the data type T is an signed data type; False, otherwise.
Definition DataType.h:1140
short Type
Definition of the signed data type, if existing.
Definition DataType.h:1135
This class is a helper class allowing to determine the signed data type for a given data type if exis...
Definition DataType.h:288
static const bool hasSigned
True, if the data has a corresponding signed data type (or itself is signed).
Definition DataType.h:304
T Type
Definition of the signed data type, if existing.
Definition DataType.h:294
static const bool isSigned
True, if the data type T is an signed data type; False, otherwise.
Definition DataType.h:299
unsigned int Type
Definition of the square distance type.
Definition DataType.h:680
unsigned int Type
Definition of the square distance type.
Definition DataType.h:666
unsigned long Type
Definition of the square distance type.
Definition DataType.h:750
unsigned long long Type
Definition of the square distance type.
Definition DataType.h:764
unsigned int Type
Definition of the square distance type.
Definition DataType.h:722
unsigned int Type
Definition of the square distance type.
Definition DataType.h:694
unsigned int Type
Definition of the square distance type.
Definition DataType.h:708
unsigned int Type
Definition of the square distance type.
Definition DataType.h:736
This class is a helper class allowing to define the square difference data type of a given type.
Definition DataType.h:125
T Type
Definition of the data type for the square value.
Definition DataType.h:132
uint8_t Type
Definition of the mapped data type.
Definition DataType.h:1494
uint16_t Type
Definition of the mapped data type.
Definition DataType.h:1508
uint32_t Type
Definition of the mapped data type.
Definition DataType.h:1522
uint64_t Type
Definition of the mapped data type.
Definition DataType.h:1536
This class provides a unique data type for any data type specified by the number of bytes.
Definition DataType.h:464
void Type
Definition of an invalid mapped data type.
Definition DataType.h:472
This class provides a unique data type for any data type.
Definition DataType.h:500
typename TypeMapperBySize< sizeof(T)>::Type Type
Definition of an invalid mapped data type.
Definition DataType.h:508
This class implements a helper class allowing to determine unique names for most of native C++ data t...
Definition DataType.h:435
static const char * name()
Returns a user-friendly name for most of native C++ data types.
static const bool isUnsigned
True, if the data type T is an unsigned data type; False, otherwise.
Definition DataType.h:1365
double Type
Definition of the unsigned data type, if existing.
Definition DataType.h:1360
static const bool hasUnsigned
True, if the data has a corresponding unsigned data type (or itself is unsigned).
Definition DataType.h:1370
float Type
Definition of the unsigned data type, if existing.
Definition DataType.h:1336
static const bool isUnsigned
True, if the data type T is an unsigned data type; False, otherwise.
Definition DataType.h:1341
static const bool hasUnsigned
True, if the data has a corresponding unsigned data type (or itself is unsigned).
Definition DataType.h:1346
static const bool isUnsigned
True, if the data type T is an unsigned data type; False, otherwise.
Definition DataType.h:1269
unsigned int Type
Definition of the unsigned data type, if existing.
Definition DataType.h:1264
static const bool hasUnsigned
True, if the data has a corresponding unsigned data type (or itself is unsigned).
Definition DataType.h:1274
static const bool isUnsigned
True, if the data type T is an unsigned data type; False, otherwise.
Definition DataType.h:1293
static const bool hasUnsigned
True, if the data has a corresponding unsigned data type (or itself is unsigned).
Definition DataType.h:1298
unsigned long Type
Definition of the unsigned data type, if existing.
Definition DataType.h:1288
static const bool hasUnsigned
True, if the data has a corresponding unsigned data type (or itself is unsigned).
Definition DataType.h:1322
static const bool isUnsigned
True, if the data type T is an unsigned data type; False, otherwise.
Definition DataType.h:1317
unsigned long long Type
Definition of the unsigned data type, if existing.
Definition DataType.h:1312
unsigned short Type
Definition of the unsigned data type, if existing.
Definition DataType.h:1240
static const bool hasUnsigned
True, if the data has a corresponding unsigned data type (or itself is unsigned).
Definition DataType.h:1250
static const bool isUnsigned
True, if the data type T is an unsigned data type; False, otherwise.
Definition DataType.h:1245
unsigned char Type
Definition of the unsigned data type, if existing.
Definition DataType.h:1216
static const bool isUnsigned
True, if the data type T is an unsigned data type; False, otherwise.
Definition DataType.h:1221
static const bool hasUnsigned
True, if the data has a corresponding unsigned data type (or itself is unsigned).
Definition DataType.h:1226
This class is a helper class allowing to determine the unsigned data type for a given data type if ex...
Definition DataType.h:333
static const bool hasUnsigned
True, if the data has a corresponding unsigned data type (or itself is unsigned).
Definition DataType.h:349
static const bool isUnsigned
True, if the data type T is an unsigned data type; False, otherwise.
Definition DataType.h:344
T Type
Definition of the unsigned data type, if existing.
Definition DataType.h:339
The namespace covering the entire Ocean framework.
Definition Accessor.h:15
Default definition of a type with tBytes bytes.
Definition DataType.h:32
T values_[tElements]
Data values of the type.
Definition DataType.h:48
bool operator!=(const Type &type) const
Returns whether two objects do not store the same values.
Definition DataType.h:650
bool operator==(const Type &type) const
Returns whether two objects store the same values.
Definition DataType.h:636
double Type
The 64 bit floating point data type if T is 'double'.
Definition DataType.h:1382
This struct is a helper struct providing a floating point data type best matching for a given data ty...
Definition DataType.h:369
float Type
The 32 bit floating point data type for any data type T but 'double'.
Definition DataType.h:373