This introduces strong types for `std::string`-based D-Bus types. This facilitates safer, less error-prone and more expressive API.
What previously was `auto proxy = createProxy("org.sdbuscpp.concatenator", "/org/sdbuscpp/concatenator");` is now written like `auto proxy = createProxy(ServiceName{"org.sdbuscpp.concatenator"}, ObjectPath{"/org/sdbuscpp/concatenator"});`.
These types are:
* `ObjectPath` type for the object path (the type has been around already but now is also used consistently in sdbus-c++ API for object path strings),
* `InterfaceName` type for D-Bus interface names,
* `BusName` (and its aliases `ServiceName` and `ConnectionName`) type for bus/service/connection names,
* `MemberName` (and its aliases `MethodName`, `SignalName` and `PropertyName`) type for D-Bus method, signal and property names,
* `Signature` type for the D-Bus signature (the type has been around already but now is also used consistently in sdbus-c++ API for signature strings),
* `Error::Name` type for D-Bus error names.
59 lines
2.0 KiB
C++
59 lines
2.0 KiB
C++
|
|
/*
|
|
* This file was automatically generated by sdbus-c++-xml2cpp; DO NOT EDIT!
|
|
*/
|
|
|
|
#ifndef __sdbuscpp__perftests_adaptor_h__adaptor__H__
|
|
#define __sdbuscpp__perftests_adaptor_h__adaptor__H__
|
|
|
|
#include <sdbus-c++/sdbus-c++.h>
|
|
#include <string>
|
|
#include <tuple>
|
|
|
|
namespace org {
|
|
namespace sdbuscpp {
|
|
|
|
class perftests_adaptor
|
|
{
|
|
public:
|
|
static inline const sdbus::InterfaceName INTERFACE_NAME{"org.sdbuscpp.perftests"};
|
|
|
|
protected:
|
|
perftests_adaptor(sdbus::IObject& object)
|
|
: object_(&object)
|
|
{
|
|
}
|
|
|
|
perftests_adaptor(const perftests_adaptor&) = delete;
|
|
perftests_adaptor& operator=(const perftests_adaptor&) = delete;
|
|
perftests_adaptor(perftests_adaptor&&) = default;
|
|
perftests_adaptor& operator=(perftests_adaptor&&) = default;
|
|
|
|
~perftests_adaptor() = default;
|
|
|
|
void registerAdaptor()
|
|
{
|
|
object_->addVTable( sdbus::registerMethod("sendDataSignals").withInputParamNames("numberOfSignals", "signalMsgSize").implementedAs([this](const uint32_t& numberOfSignals, const uint32_t& signalMsgSize){ return this->sendDataSignals(numberOfSignals, signalMsgSize); })
|
|
, sdbus::registerMethod("concatenateTwoStrings").withInputParamNames("string1", "string2").withOutputParamNames("result").implementedAs([this](const std::string& string1, const std::string& string2){ return this->concatenateTwoStrings(string1, string2); })
|
|
, sdbus::registerSignal("dataSignal").withParameters<std::string>("data")
|
|
).forInterface(INTERFACE_NAME);
|
|
}
|
|
|
|
public:
|
|
void emitDataSignal(const std::string& data)
|
|
{
|
|
object_->emitSignal("dataSignal").onInterface(INTERFACE_NAME).withArguments(data);
|
|
}
|
|
|
|
private:
|
|
virtual void sendDataSignals(const uint32_t& numberOfSignals, const uint32_t& signalMsgSize) = 0;
|
|
virtual std::string concatenateTwoStrings(const std::string& string1, const std::string& string2) = 0;
|
|
|
|
private:
|
|
sdbus::IObject* object_;
|
|
};
|
|
|
|
}} // namespaces
|
|
|
|
#endif
|