![]() |
CopperSpice DBUS
1.7.4
|
D-Bus has an extensible type system based on a few primitives and composition of the primitives in arrays and structures. CsDBus implements the interface to that type system through the QDBusArgument class, allowing user programs to send and receive practically every C++ type over the bus.
The primitive types are supported natively by QDBusArgument and need no special customization to be sent or received. They are listed below, along with the C++ class they relate to.
CopperSpice Type | D-Bus equivalent Type |
---|---|
uchar | BYTE |
bool | BOOLEAN |
short | INT16 |
ushort | UINT16 |
int | INT32 |
uint | UINT32 |
qlonglong | INT64 |
qulonglong | UINT64 |
double | DOUBLE |
QString | STRING |
QDBusVariant | VARIANT |
QDBusObjectPath | OBJECT_PATH |
QDBusSignature | SIGNATURE |
Aside from the primitive types, QDBusArgument also supports two non-primitive types natively, due to their widespread use in CopperSpice applications: QStringList and QByteArray.
D-Bus specifies three types of aggregations of primitive types that allow one to create compound types. They are ARRAY
, STRUCT
and maps/dictionaries.
Arrays are sets of zero or more elements of the same type, while structures are a set of a fixed number of elements, each of any type. Maps or dictionaries are implemented as arrays of a pair of elements, so there can be zero or more elements in one map.
In order to use your own type with CsDBus the data type must be declared as a CopperSpice meta type using the CS_DECLARE_METATYPE() macro and registered with the qDBusRegisterMetaType(). The streaming operators operator>>() and operator<<() will automatically be found by the registration system.
CsDBus provides template specializations for arrays and maps for use with the CopperSpice container classes, such as QMap and QList, so it is not necessary to write the streaming operator functions for those. For other types, and specially for types implementing structures, the operators have to be explicitly implemented.
Refer to the QDBusArgument documentation for examples of structures, arrays, and maps.
All of the CsDBus types (primitives and user-defined alike) can be used to send and receive messages of all types over the bus.