Syntalos::BaseDataType

Syntalos::BaseDataType

Syntalos::BaseDataType

Base interface for all data types. More…

#include <datatypes.h>

Inherited by Syntalos::ControlCommand, Syntalos::FirmataControl, Syntalos::FirmataData, Syntalos::FloatSignalBlock, Syntalos::Frame, Syntalos::IntSignalBlock, Syntalos::TableRow

Public Types

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

Public Functions

Name
virtual~BaseDataType() =default
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 booltoBytes(ByteVector & output) const =0
Serialize the data to a byte array.
std::stringtypeIdToString(int value)
std::stringtypeIdToString(TypeId value)
TypeIdtypeIdFromString(const std::string & str)

Detailed Description

struct Syntalos::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 ~BaseDataType

virtual ~BaseDataType() =default

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: Syntalos::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: Syntalos::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 bool toBytes(
    ByteVector & output
) const =0

Serialize the data to a byte array.

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

Serialize the data to a byte array for local transmission.

function typeIdToString

static inline std::string typeIdToString(
    int value
)

function typeIdToString

static inline std::string typeIdToString(
    TypeId value
)

function typeIdFromString

static inline TypeId typeIdFromString(
    const std::string & str
)

Updated on 2026-03-16 at 19:16:01 +0000