BaseDataType

BaseDataType

BaseDataType

Base interface for all data types. More…

#include <datatypes.h>

Inherited by ControlCommand< T >, FirmataControl, FirmataData, FloatSignalBlock, Frame, IntSignalBlock, TableRow

Public Types

Name
enumTypeId { Unknown, ControlCommand, TableRow, Frame, FirmataControl, FirmataData, IntSignalBlock, FloatSignalBlock, Last}
The TypeId enum.

Public Functions

Name
QStringtypeIdToString(TypeId value)
QStringtypeIdToString(int value)
TypeIdtypeIdFromString(const QString & str)
virtual TypeIdtypeId() const =0
virtual ssize_tmemorySize() const
Calculate the size of the data in memory.
virtual boolwriteToMemory(void * memory, ssize_t size =-1) const
Write the data to a memory block.
virtual QByteArraytoBytes() const =0
Serialize the data to a byte array.

Detailed Description

struct BaseDataType;

Base interface for all data types.

This structure defines basic interfaces that data types need to possess.

Public Types Documentation

enum TypeId

EnumeratorValueDescription
Unknown
ControlCommand
TableRow
Frame
FirmataControl
FirmataData
IntSignalBlock
FloatSignalBlock
Last

The TypeId enum.

Describes the type of data that is being transferred, and provides the needed type reflection in a very efficient way to allow for type checks in hot code paths.

Public Functions Documentation

function typeIdToString

static inline QString typeIdToString(
    TypeId value
)

function typeIdToString

static inline QString typeIdToString(
    int value
)

function typeIdFromString

static inline TypeId typeIdFromString(
    const QString & str
)

function typeId

virtual TypeId typeId() const =0

Unique ID for the respective data type.

function memorySize

inline virtual ssize_t memorySize() const

Calculate the size of the data in memory.

Reimplemented by: Frame::memorySize

Quickly calculate the maximum size this data occupies in memory. This will be used to allocate appropriate shared memory blocks in advance. Return -1 if the size is unknown.

function writeToMemory

inline virtual bool writeToMemory(
    void * memory,
    ssize_t size =-1
) const

Write the data to a memory block.

Reimplemented by: Frame::writeToMemory

Write the data to a memory block. The required size of the block is given by the memorySize() method, but a larger size can be passed if needed.

Return true if the data was written successfully.

function toBytes

virtual QByteArray toBytes() const =0

Serialize the data to a byte array.

Reimplemented by: ControlCommand::toBytes, TableRow::toBytes, FirmataControl::toBytes, FirmataData::toBytes, IntSignalBlock::toBytes, FloatSignalBlock::toBytes, Frame::toBytes

Serialize the data to a byte array for local transmission.


Updated on 2024-09-05 at 17:39:59 +0000