BaseDataType
BaseDataType
Base interface for all data types. More…
#include <datatypes.h>
Inherited by ControlCommand, FirmataControl, FirmataData, FloatSignalBlock, Frame, IntSignalBlock, TableRow
Public Types
| Name | |
|---|---|
| enum | TypeId { Unknown, ControlCommand, TableRow, Frame, FirmataControl, FirmataData, IntSignalBlock, FloatSignalBlock, Last} The TypeId enum. |
Public Functions
| Name | |
|---|---|
| QString | typeIdToString(TypeId value) |
| QString | typeIdToString(int value) |
| TypeId | typeIdFromString(const QString & str) |
| virtual TypeId | typeId() const =0 |
| virtual ssize_t | memorySize() const Calculate the size of the data in memory. |
| virtual bool | writeToMemory(void * memory, ssize_t size =-1) const Write the data to a memory block. |
| virtual QByteArray | toBytes() 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
| Enumerator | Value | Description |
|---|---|---|
| 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 =0Unique ID for the respective data type.
function memorySize
inline virtual ssize_t memorySize() constCalculate 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
) constWrite 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 =0Serialize 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 2025-08-14 at 02:33:43 +0000