Migrating code to the 2.0 version of dbus-cxx should be pretty straightforward. The library must now be built with the libsigc++ version 3.0. This also means that you need a compiler that supports C++17.
This now means that argument lists of an arbitrary length can be used, instead of the previous hard limit of 7.
Most typedefs have also been removed, and you use std::shared_ptr
directly to handle smart pointers.
The syntax for declaring methods has now also changed slightly: instead of having the first template parameter be the return value, the types now correspond to method signatures. This is for compatability with libsigc++ version 3.0.
You must also explicitly define what thread methods need to be called from to ensure proper multithreading.
Given the following code with version 1:
This code now becomes:
You can use the auto-upgrade.sh script to help automate this
For consistency with data types that can be sent over the DBus, types such as float
and char
have been removed. float
was removed as only IEEE-754 doubles may be sent over the bus; likewise, char
is not a type that can be sent over, it is a uint8_t
, or single byte.
The previous DBus::Variant<>
templated class has been removed and replaced with a version that is not templated.
DBus structs map to std::tuple
. Previously, there was no type for struct
.
DBus-cxx is no longer a binding to libdbus
, it is now a complete implementation. This was done partially to make it possible to store arrays(std::vector
) and dictionaries (std::map
) inside of DBus::Variant
.
This also should allow for the fixing of known multithreading issues in libdbus
.
A number of libsigc++ signals have been removed, as it was never defined what thread they would be emitted from, and they were not useful. For example, it was possible to change the name of interfaces and methods at run-time; this ability has been removed and the associated signals for the change were removed as well.
A number of methods were removed from the DBus::Connection
class, as they just mapped directly to libdbus
functionality that has not been re-implemented. If needed, methods can be brought back for needed use-cases.
When exporting objects, you must now be explicit about which thread to call the methods on this object from. This also necessitates a change to how the DBus::Dispatcher
class works.
As of version 2, it is intended that the API will be stable(or at least backwards- compatible), and that the library itself will be ABI compatible.
std::tuple
for a DBus struct should eliminate the need for custom typescall_async
method to all DBus::MethodProxy
s to make it easier to call methods in an async manner.std::shared_ptr
references.operator<<
for many classes and enums to make debugging easierpthread
objects to use std::mutex
, std::thread
, std::unique_lock
as appropriate.std::shared_ptr
sThe following features have been removed. Generally, these features were removed because they are not believed to be widely used. If there is demand, they may be reimplmented in a new version