[systemd-devel] sdbus-c++, an open source C++ library on top of sd-bus
Stanislav Angelovic
Stanislav.Angelovic at kistler.com
Thu Dec 14 11:09:02 UTC 2017
Hi all,
I would like to let you know that sdbus-c++, our in-house C++ binding for sd-bus library, has been published open-source at https://github.com/Kistler-Group/sdbus-cpp in hope that it will be useful.
Currently, the binding does not cover the entire sd-bus API; it covers the core, most widely used functionality - D-Bus methods, signals, properties. It supports serialization/deserialization of all D-Bus types.
The library offers two levels of its API:
* the basic layer, which is a simple wrapper layer on top of sd-bus, but using native C++ approach (e.g. serialization/deserialization of data from messages, support for STL containers...).
* the convenience layer, building on top of the basic layer, which aims at alleviating users from unnecessary details and enables them to write shorter, safer, and more expressive code. It abstracts away the concept of messages, and utilizes C++ type system to automatically deduce and build all necessary information.
Example of exporting a method:
std::string concatenate(const std::vector<int> numbers, const std::string& separator);
concatenator->registerMethod("concatenate").onInterface(interfaceName).implementedAs(&concatenate);
Example of invoking a method:
concatenator->callMethod("concatenate").onInterface(interfaceName).withArguments(numbers, separator).storeResultsTo(concatenatedString);
sdbus-c++ also ships with stub code generator, which can generate adaptor and proxy stub classes, analogously to the generator in e.g. dbus-c++ library.
The library needs a C++17-capable compiler (std::uncaught_exceptions is used) and sd-bus API of systemd v236 (which will hopefully be released very soon).
Readme file: https://github.com/Kistler-Group/sdbus-cpp/blob/master/README.md
Howto: https://github.com/Kistler-Group/sdbus-cpp/blob/master/doc/using-sdbus-c%2B%2B.md
There is surely a lot that can be added/improved in the library. Ideas, contributions, improvements are welcome :-)
Best regards,
Stanislav.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20171214/501b23b8/attachment.html>
More information about the systemd-devel
mailing list