| IOLink 1.11.0

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
iolink::DataType Class Reference

Stores information about a data type. More...

`#include <iolink/DataType.h>`

## Public Member Functions
| DataType () noexcept
| Default constructor, creating an opaque type.
| DataType (uint64_t value) noexcept
| Build a DataType from an id.
| DataType (DataTypeId value) noexcept
| Build a DataType from a DataTypeId.
| DataType (PrimitiveTypeId primitiveType, size_t dimension, size_t bitDepth, DataTypeInterpretation interpretation) noexcept
| Build a DataType from its properties.
| DataType (PrimitiveTypeId primitiveType, size_t dimension, size_t bitDepth) noexcept
| Build a DataType from its properties.
bool | isNumeric () const
| Checks if the type is a mathematical one.
bool | isScalar () const
| Checks if the type is a scalar numeric value.
bool | isVector () const
| Checks if the type is a vector of numeric values.
bool | isConvertibleTo (DataType other) const
| Checks if this type is trivially convertible to another.
uint64_t | id () const noexcept
| Return unique id representing this datatype.
size_t | bitDepth () const noexcept
| Return the bit depth of this type.
size_t | elementCount () const noexcept
| Return the number of sub-values included in this type.
PrimitiveTypeId | primitiveType () const noexcept
| Return the primitive type of the current type.
DataTypeInterpretation | interpretation () const noexcept
| The DataType interpretation.
size_t | bitCount () const
| Get the number of bits required to store the type.
size_t | byteCount () const
| Get the number of bits required to store the type.
std::string | toString () const
| Return a readable version of the DataType.
bool | operator== (DataType other) const
bool | operator!= (DataType other) const

## Static Public Member Functions
static DataType | extractScalarType (DataType dtype)
| Return scalar type in case of multi dimensionnal DataType.
static Vector2d | standardRange (DataType dtype)
| Return conventional range for given DataType.

## Detailed Description

Stores information about a data type.

DataType is associated with an ID, with wich the type can be uniquely identified. Although this ID is composed of multiple fields:

- ScalarType: base type of each component.
- BitDepth: bit depth for each component.
- Dimension: the number of components.
- Interpretation: What the DataType represents in particular.

See user guide for more explainations.

These fields can have different meaning bases on the scalar type or the flags. For example the bitDepth field indicate the precision for integer and floating point types, and the size of a coding point in an unicode string.

Examples
  CheckerBoard.cpp, CheckerBoardFast.cpp, DiskImageView.cpp, colorWheel.cpp, copyImageView.cpp, customImageView.cpp, gradientFloatImage.cpp, gradientFloatToInt.cpp, grayscaleSphere.cpp, and volumeFromStack.cpp.

## Constructor & Destructor Documentation

## ◆ DataType()

iolink::DataType::DataType | ( |  | ) |
| noexcept

Default constructor, creating an opaque type.

See also
  DataTypeId::UNKNOWN

## Member Function Documentation

## ◆ bitDepth()

size_t iolink::DataType::bitDepth | ( |  | ) | const
| inline noexcept

Return the bit depth of this type.

(i.e. UINT8 => 8 bit depth, VEC3_UINT16 => 16 bit depth)

## ◆ byteCount()

size_t iolink::DataType::byteCount | ( |  | ) | const
| inline

Get the number of bits required to store the type.

If the number of bits required to store the type is not aligned to a byte, the number of byte will be rounded up. For example, a 12 bits integer type will have a byte count of 2.

## ◆ elementCount()

size_t iolink::DataType::elementCount | ( |  | ) | const
| inline noexcept

Return the number of sub-values included in this type.

For example:

- UINT8 => dimension 1
- VEC3_UINT8 => dimension 3 because it contains three UINT8

## ◆ extractScalarType()

static DataType iolink::DataType::extractScalarType | ( | DataType | dtype | ) |
| static

Return scalar type in case of multi dimensionnal DataType.

If the type is already scalar, it return itself.

## ◆ id()

uint64_t iolink::DataType::id | ( |  | ) | const
| noexcept

Return unique id representing this datatype.

Can be used inside a switch/case statement.

## ◆ interpretation()

DataTypeInterpretation iolink::DataType::interpretation | ( |  | ) | const
| inline noexcept

The DataType interpretation.

See also
  DataTypeInterpretation

## ◆ isConvertibleTo()

bool iolink::DataType::isConvertibleTo | ( | DataType | other | ) | const

Checks if this type is trivially convertible to another.

See also
  DataConverter

## ◆ primitiveType()

PrimitiveTypeId iolink::DataType::primitiveType | ( |  | ) | const
| inline noexcept

Return the primitive type of the current type.

for example: UINT8 => UNSIGNED_INTEGER

## ◆ standardRange()

static Vector2d iolink::DataType::standardRange | ( | DataType | dtype | ) |
| static

Return conventional range for given DataType.

By convention, range for INTEGER types are classical min and max representable values.

Range for FLOATING_POINT type is [0, 1]

As returned range is DOUBLE precison, returned value is imprecise for INT64 and UINT64 type.

Exceptions

  Error | If no range can be computed for this type.

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

- iolink/public/include/iolink/DataType.h