mirror of
https://github.com/Kistler-Group/sdbus-cpp.git
synced 2025-06-25 01:21:34 +02:00
fix: disable move in generated adaptor and proxy classes (#435)
Moving adaptor or proxy instances changes their `this` pointer. But `this` is captured by value in closures used by those instances, and this remains unchanged on move, leading to accessing an invalid instance when a lambda expression executes. Supporting move semantics would require unsubscribing/unregistering vtable, handlers, etc. and re-subscribing and re-registering all that, which is too complicated and may have side effects. Hence it has been decided that these classes are not moveable. One may use an indirection with e.g. `std::unique_ptr` to get move semantics.
This commit is contained in:
@ -694,7 +694,7 @@ After running this through the code generator, we get the generated code that is
|
||||
|
||||
For each interface in the XML IDL file the generator creates one class that represents it. The class is de facto an interface which shall be implemented by the class inheriting it. The class' constructor takes care of registering all methods, signals and properties. For each D-Bus method there is a pure virtual member function. These pure virtual functions must be implemented in the child class. For each signal, there is a public function member that emits this signal.
|
||||
|
||||
Generated adaptor classes support move semantics. They are moveable but not copyable.
|
||||
Generated adaptor classes are not copyable and not moveable by design. One can create them on the heap and manage them in e.g. a `std::unique_ptr` if move semantics is needed (for example, when they are stored in a container).
|
||||
|
||||
```cpp
|
||||
/*
|
||||
@ -718,30 +718,30 @@ public:
|
||||
|
||||
protected:
|
||||
Concatenator_adaptor(sdbus::IObject& object)
|
||||
: object_(&object)
|
||||
: m_object(object)
|
||||
{
|
||||
object_->registerMethod("concatenate").onInterface(INTERFACE_NAME).withInputParamNames("numbers", "separator").withOutputParamNames("concatenatedString").implementedAs([this](const std::vector<int32_t>& numbers, const std::string& separator){ return this->concatenate(numbers, separator); });
|
||||
object_->registerSignal("concatenated").onInterface(INTERFACE_NAME).withParameters<std::string>("concatenatedString");
|
||||
m_object.registerMethod("concatenate").onInterface(INTERFACE_NAME).withInputParamNames("numbers", "separator").withOutputParamNames("concatenatedString").implementedAs([this](const std::vector<int32_t>& numbers, const std::string& separator){ return this->concatenate(numbers, separator); });
|
||||
m_object.registerSignal("concatenated").onInterface(INTERFACE_NAME).withParameters<std::string>("concatenatedString");
|
||||
}
|
||||
|
||||
Concatenator_adaptor(const Concatenator_adaptor&) = delete;
|
||||
Concatenator_adaptor& operator=(const Concatenator_adaptor&) = delete;
|
||||
Concatenator_adaptor(Concatenator_adaptor&&) = default;
|
||||
Concatenator_adaptor& operator=(Concatenator_adaptor&&) = default;
|
||||
Concatenator_adaptor(Concatenator_adaptor&&) = delete;
|
||||
Concatenator_adaptor& operator=(Concatenator_adaptor&&) = delete;
|
||||
|
||||
~Concatenator_adaptor() = default;
|
||||
|
||||
public:
|
||||
void emitConcatenated(const std::string& concatenatedString)
|
||||
{
|
||||
object_->emitSignal("concatenated").onInterface(INTERFACE_NAME).withArguments(concatenatedString);
|
||||
m_object.emitSignal("concatenated").onInterface(INTERFACE_NAME).withArguments(concatenatedString);
|
||||
}
|
||||
|
||||
private:
|
||||
virtual std::string concatenate(const std::vector<int32_t>& numbers, const std::string& separator) = 0;
|
||||
|
||||
private:
|
||||
sdbus::IObject* object_;
|
||||
sdbus::IObject& m_object;
|
||||
};
|
||||
|
||||
}} // namespaces
|
||||
@ -753,7 +753,7 @@ private:
|
||||
|
||||
Analogously to the adaptor classes described above, there is one proxy class generated for one interface in the XML IDL file. The class is de facto a proxy to the concrete single interface of a remote object. For each D-Bus signal there is a pure virtual member function whose body must be provided in a child class. For each method, there is a public function member that calls the method remotely.
|
||||
|
||||
Generated proxy classes support move semantics. They are moveable but not copyable.
|
||||
Generated proxy classes are not copyable and not moveable by design. One can create them on the heap and manage them in e.g. a `std::unique_ptr` if move semantics is needed (for example, when they are stored in a container).
|
||||
|
||||
```cpp
|
||||
/*
|
||||
@ -777,15 +777,15 @@ public:
|
||||
|
||||
protected:
|
||||
Concatenator_proxy(sdbus::IProxy& proxy)
|
||||
: proxy_(&proxy)
|
||||
: m_proxy(proxy)
|
||||
{
|
||||
proxy_->uponSignal("concatenated").onInterface(INTERFACE_NAME).call([this](const std::string& concatenatedString){ this->onConcatenated(concatenatedString); });
|
||||
m_proxy.uponSignal("concatenated").onInterface(INTERFACE_NAME).call([this](const std::string& concatenatedString){ this->onConcatenated(concatenatedString); });
|
||||
}
|
||||
|
||||
Concatenator_proxy(const Concatenator_proxy&) = delete;
|
||||
Concatenator_proxy& operator=(const Concatenator_proxy&) = delete;
|
||||
Concatenator_proxy(Concatenator_proxy&&) = default;
|
||||
Concatenator_proxy& operator=(Concatenator_proxy&&) = default;
|
||||
Concatenator_proxy(Concatenator_proxy&&) = delete;
|
||||
Concatenator_proxy& operator=(Concatenator_proxy&&) = delete;
|
||||
|
||||
~Concatenator_proxy() = default;
|
||||
|
||||
@ -795,12 +795,12 @@ public:
|
||||
std::string concatenate(const std::vector<int32_t>& numbers, const std::string& separator)
|
||||
{
|
||||
std::string result;
|
||||
proxy_->callMethod("concatenate").onInterface(INTERFACE_NAME).withArguments(numbers, separator).storeResultsTo(result);
|
||||
m_proxy.callMethod("concatenate").onInterface(INTERFACE_NAME).withArguments(numbers, separator).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IProxy* proxy_;
|
||||
sdbus::IProxy& m_proxy;
|
||||
};
|
||||
|
||||
}} // namespaces
|
||||
@ -1405,9 +1405,9 @@ class PropertyProvider_adaptor
|
||||
|
||||
public:
|
||||
PropertyProvider_adaptor(sdbus::IObject& object)
|
||||
: object_(&object)
|
||||
: m_object(object)
|
||||
{
|
||||
object_->registerProperty("status").onInterface(INTERFACE_NAME).withGetter([this](){ return this->status(); }).withSetter([this](const uint32_t& value){ this->status(value); });
|
||||
m_object.registerProperty("status").onInterface(INTERFACE_NAME).withGetter([this](){ return this->status(); }).withSetter([this](const uint32_t& value){ this->status(value); });
|
||||
}
|
||||
|
||||
~PropertyProvider_adaptor() = default;
|
||||
@ -1434,13 +1434,13 @@ public:
|
||||
// getting the property value
|
||||
uint32_t status()
|
||||
{
|
||||
return object_->getProperty("status").onInterface(INTERFACE_NAME);
|
||||
return m_object.getProperty("status").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
// setting the property value
|
||||
void status(const uint32_t& value)
|
||||
{
|
||||
object_->setProperty("status").onInterface(INTERFACE_NAME).toValue(value);
|
||||
m_object.setProperty("status").onInterface(INTERFACE_NAME).toValue(value);
|
||||
}
|
||||
|
||||
/*...*/
|
||||
@ -1487,13 +1487,13 @@ public:
|
||||
// getting the property value
|
||||
sdbus::PendingAsyncCall status()
|
||||
{
|
||||
return object_->getPropertyAsync("status").onInterface(INTERFACE_NAME).uponReplyInvoke([this](std::optional<sdbus::Error> error, const sdbus::Variant& value){ this->onStatusPropertyGetReply(value.get<uint32_t>(), std::move(error)); });
|
||||
return m_object.getPropertyAsync("status").onInterface(INTERFACE_NAME).uponReplyInvoke([this](std::optional<sdbus::Error> error, const sdbus::Variant& value){ this->onStatusPropertyGetReply(value.get<uint32_t>(), std::move(error)); });
|
||||
}
|
||||
|
||||
// setting the property value
|
||||
void status(const uint32_t& value)
|
||||
{
|
||||
object_->setProperty("status").onInterface(INTERFACE_NAME).toValue(value);
|
||||
m_object.setProperty("status").onInterface(INTERFACE_NAME).toValue(value);
|
||||
}
|
||||
|
||||
/*...*/
|
||||
@ -1786,7 +1786,8 @@ sdbus-c++ v2 is a major release that comes with a number of breaking API/ABI/beh
|
||||
* Callbacks taking `const sdbus::Error* error` were changed to take `std::optional<sdbus::Error>`, which better expresses the intent and meaning.
|
||||
* `getInterfaceName()`, `getMemberName()`, `getSender()`, `getPath()` and `getDestination()` methods of `Message` class now return `const char*` instead of `std::string`, for efficiency reasons.
|
||||
* `peekType()` method of `Message` class now returns a pair of `char` (type signature) and `const char*` (contents signature), for expressiveness and efficiency reasons.
|
||||
* D-Bus signatures when using high-level API are now assembled at compile time. There are breaking changes inside `signature_of` type traits and `Message` serialization/deserialization methods. This only interests you if you extend sdbus-c++ type system with your own types. See the updated tutorial on extending sdbus-c++ type system.
|
||||
* D-Bus signatures when using high-level API are now assembled at compile time. There are breaking changes inside `signature_of` type traits and `Message` serialization/deserialization methods. This only interests you if you extend sdbus-c++ type system with your own types. See the updated tutorial on extending sdbus-c++ type system.
|
||||
* Generated adaptor and proxy classes are not moveable anymore.
|
||||
* Types and methods marked deprecated in sdbus-c++ v1 were removed completely.
|
||||
* CMake options got `SDBUSCPP_` prefix for better usability and minimal risk of conflicts in downstream CMake projects. `SDBUSCPP_INSTALL` CMake option was added.
|
||||
* CMake components got `sdbus-c++-` prefix.
|
||||
|
@ -21,14 +21,14 @@ public:
|
||||
|
||||
protected:
|
||||
Planet1_proxy(sdbus::IProxy& proxy)
|
||||
: proxy_(&proxy)
|
||||
: m_proxy(proxy)
|
||||
{
|
||||
}
|
||||
|
||||
Planet1_proxy(const Planet1_proxy&) = delete;
|
||||
Planet1_proxy& operator=(const Planet1_proxy&) = delete;
|
||||
Planet1_proxy(Planet1_proxy&&) = default;
|
||||
Planet1_proxy& operator=(Planet1_proxy&&) = default;
|
||||
Planet1_proxy(Planet1_proxy&&) = delete;
|
||||
Planet1_proxy& operator=(Planet1_proxy&&) = delete;
|
||||
|
||||
~Planet1_proxy() = default;
|
||||
|
||||
@ -40,18 +40,18 @@ public:
|
||||
uint64_t GetPopulation()
|
||||
{
|
||||
uint64_t result;
|
||||
proxy_->callMethod("GetPopulation").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
m_proxy.callMethod("GetPopulation").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public:
|
||||
std::string Name()
|
||||
{
|
||||
return proxy_->getProperty("Name").onInterface(INTERFACE_NAME).get<std::string>();
|
||||
return m_proxy.getProperty("Name").onInterface(INTERFACE_NAME).get<std::string>();
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IProxy* proxy_;
|
||||
sdbus::IProxy& m_proxy;
|
||||
};
|
||||
|
||||
}}} // namespaces
|
||||
|
@ -21,20 +21,20 @@ public:
|
||||
|
||||
protected:
|
||||
Planet1_adaptor(sdbus::IObject& object)
|
||||
: object_(&object)
|
||||
: m_object(object)
|
||||
{
|
||||
}
|
||||
|
||||
Planet1_adaptor(const Planet1_adaptor&) = delete;
|
||||
Planet1_adaptor& operator=(const Planet1_adaptor&) = delete;
|
||||
Planet1_adaptor(Planet1_adaptor&&) = default;
|
||||
Planet1_adaptor& operator=(Planet1_adaptor&&) = default;
|
||||
Planet1_adaptor(Planet1_adaptor&&) = delete;
|
||||
Planet1_adaptor& operator=(Planet1_adaptor&&) = delete;
|
||||
|
||||
~Planet1_adaptor() = default;
|
||||
|
||||
void registerAdaptor()
|
||||
{
|
||||
object_->addVTable( sdbus::registerMethod("GetPopulation").withOutputParamNames("population").implementedAs([this](){ return this->GetPopulation(); })
|
||||
m_object.addVTable( sdbus::registerMethod("GetPopulation").withOutputParamNames("population").implementedAs([this](){ return this->GetPopulation(); })
|
||||
, sdbus::registerProperty("Name").withGetter([this](){ return this->Name(); })
|
||||
).forInterface(INTERFACE_NAME);
|
||||
}
|
||||
@ -46,7 +46,7 @@ private:
|
||||
virtual std::string Name() = 0;
|
||||
|
||||
private:
|
||||
sdbus::IObject* object_;
|
||||
sdbus::IObject& m_object;
|
||||
};
|
||||
|
||||
}}} // namespaces
|
||||
|
@ -142,8 +142,8 @@ namespace sdbus {
|
||||
|
||||
AdaptorInterfaces(const AdaptorInterfaces&) = delete;
|
||||
AdaptorInterfaces& operator=(const AdaptorInterfaces&) = delete;
|
||||
AdaptorInterfaces(AdaptorInterfaces&&) = default;
|
||||
AdaptorInterfaces& operator=(AdaptorInterfaces&&) = default;
|
||||
AdaptorInterfaces(AdaptorInterfaces&&) = delete;
|
||||
AdaptorInterfaces& operator=(AdaptorInterfaces&&) = delete;
|
||||
~AdaptorInterfaces() = default;
|
||||
};
|
||||
|
||||
|
@ -207,8 +207,8 @@ namespace sdbus {
|
||||
|
||||
ProxyInterfaces(const ProxyInterfaces&) = delete;
|
||||
ProxyInterfaces& operator=(const ProxyInterfaces&) = delete;
|
||||
ProxyInterfaces(ProxyInterfaces&&) = default;
|
||||
ProxyInterfaces& operator=(ProxyInterfaces&&) = default;
|
||||
ProxyInterfaces(ProxyInterfaces&&) = delete;
|
||||
ProxyInterfaces& operator=(ProxyInterfaces&&) = delete;
|
||||
~ProxyInterfaces() = default;
|
||||
};
|
||||
|
||||
|
@ -44,14 +44,14 @@ namespace sdbus {
|
||||
|
||||
protected:
|
||||
Peer_proxy(sdbus::IProxy& proxy)
|
||||
: proxy_(&proxy)
|
||||
: m_proxy(proxy)
|
||||
{
|
||||
}
|
||||
|
||||
Peer_proxy(const Peer_proxy&) = delete;
|
||||
Peer_proxy& operator=(const Peer_proxy&) = delete;
|
||||
Peer_proxy(Peer_proxy&&) = default;
|
||||
Peer_proxy& operator=(Peer_proxy&&) = default;
|
||||
Peer_proxy(Peer_proxy&&) = delete;
|
||||
Peer_proxy& operator=(Peer_proxy&&) = delete;
|
||||
|
||||
~Peer_proxy() = default;
|
||||
|
||||
@ -62,18 +62,18 @@ namespace sdbus {
|
||||
public:
|
||||
void Ping()
|
||||
{
|
||||
proxy_->callMethod("Ping").onInterface(INTERFACE_NAME);
|
||||
m_proxy.callMethod("Ping").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
std::string GetMachineId()
|
||||
{
|
||||
std::string machineUUID;
|
||||
proxy_->callMethod("GetMachineId").onInterface(INTERFACE_NAME).storeResultsTo(machineUUID);
|
||||
m_proxy.callMethod("GetMachineId").onInterface(INTERFACE_NAME).storeResultsTo(machineUUID);
|
||||
return machineUUID;
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IProxy* proxy_;
|
||||
sdbus::IProxy& m_proxy;
|
||||
};
|
||||
|
||||
// Proxy for introspection
|
||||
@ -83,14 +83,14 @@ namespace sdbus {
|
||||
|
||||
protected:
|
||||
Introspectable_proxy(sdbus::IProxy& proxy)
|
||||
: proxy_(&proxy)
|
||||
: m_proxy(proxy)
|
||||
{
|
||||
}
|
||||
|
||||
Introspectable_proxy(const Introspectable_proxy&) = delete;
|
||||
Introspectable_proxy& operator=(const Introspectable_proxy&) = delete;
|
||||
Introspectable_proxy(Introspectable_proxy&&) = default;
|
||||
Introspectable_proxy& operator=(Introspectable_proxy&&) = default;
|
||||
Introspectable_proxy(Introspectable_proxy&&) = delete;
|
||||
Introspectable_proxy& operator=(Introspectable_proxy&&) = delete;
|
||||
|
||||
~Introspectable_proxy() = default;
|
||||
|
||||
@ -102,12 +102,12 @@ namespace sdbus {
|
||||
std::string Introspect()
|
||||
{
|
||||
std::string xml;
|
||||
proxy_->callMethod("Introspect").onInterface(INTERFACE_NAME).storeResultsTo(xml);
|
||||
m_proxy.callMethod("Introspect").onInterface(INTERFACE_NAME).storeResultsTo(xml);
|
||||
return xml;
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IProxy* proxy_;
|
||||
sdbus::IProxy& m_proxy;
|
||||
};
|
||||
|
||||
// Proxy for properties
|
||||
@ -117,21 +117,21 @@ namespace sdbus {
|
||||
|
||||
protected:
|
||||
Properties_proxy(sdbus::IProxy& proxy)
|
||||
: proxy_(&proxy)
|
||||
: m_proxy(proxy)
|
||||
{
|
||||
}
|
||||
|
||||
Properties_proxy(const Properties_proxy&) = delete;
|
||||
Properties_proxy& operator=(const Properties_proxy&) = delete;
|
||||
Properties_proxy(Properties_proxy&&) = default;
|
||||
Properties_proxy& operator=(Properties_proxy&&) = default;
|
||||
Properties_proxy(Properties_proxy&&) = delete;
|
||||
Properties_proxy& operator=(Properties_proxy&&) = delete;
|
||||
|
||||
~Properties_proxy() = default;
|
||||
|
||||
void registerProxy()
|
||||
{
|
||||
proxy_
|
||||
->uponSignal("PropertiesChanged")
|
||||
m_proxy
|
||||
.uponSignal("PropertiesChanged")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.call([this]( const InterfaceName& interfaceName
|
||||
, const std::map<PropertyName, sdbus::Variant>& changedProperties
|
||||
@ -148,148 +148,148 @@ namespace sdbus {
|
||||
public:
|
||||
sdbus::Variant Get(const InterfaceName& interfaceName, const PropertyName& propertyName)
|
||||
{
|
||||
return proxy_->getProperty(propertyName).onInterface(interfaceName);
|
||||
return m_proxy.getProperty(propertyName).onInterface(interfaceName);
|
||||
}
|
||||
|
||||
sdbus::Variant Get(std::string_view interfaceName, std::string_view propertyName)
|
||||
{
|
||||
return proxy_->getProperty(propertyName).onInterface(interfaceName);
|
||||
return m_proxy.getProperty(propertyName).onInterface(interfaceName);
|
||||
}
|
||||
|
||||
template <typename _Function>
|
||||
PendingAsyncCall GetAsync(const InterfaceName& interfaceName, const PropertyName& propertyName, _Function&& callback)
|
||||
{
|
||||
return proxy_->getPropertyAsync(propertyName).onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback));
|
||||
return m_proxy.getPropertyAsync(propertyName).onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback));
|
||||
}
|
||||
|
||||
template <typename _Function>
|
||||
[[nodiscard]] Slot GetAsync(const InterfaceName& interfaceName, const PropertyName& propertyName, _Function&& callback, return_slot_t)
|
||||
{
|
||||
return proxy_->getPropertyAsync(propertyName).onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback), return_slot);
|
||||
return m_proxy.getPropertyAsync(propertyName).onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback), return_slot);
|
||||
}
|
||||
|
||||
template <typename _Function>
|
||||
PendingAsyncCall GetAsync(std::string_view interfaceName, std::string_view propertyName, _Function&& callback)
|
||||
{
|
||||
return proxy_->getPropertyAsync(propertyName).onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback));
|
||||
return m_proxy.getPropertyAsync(propertyName).onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback));
|
||||
}
|
||||
|
||||
template <typename _Function>
|
||||
[[nodiscard]] Slot GetAsync(std::string_view interfaceName, std::string_view propertyName, _Function&& callback, return_slot_t)
|
||||
{
|
||||
return proxy_->getPropertyAsync(propertyName).onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback), return_slot);
|
||||
return m_proxy.getPropertyAsync(propertyName).onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback), return_slot);
|
||||
}
|
||||
|
||||
std::future<sdbus::Variant> GetAsync(const InterfaceName& interfaceName, const PropertyName& propertyName, with_future_t)
|
||||
{
|
||||
return proxy_->getPropertyAsync(propertyName).onInterface(interfaceName).getResultAsFuture();
|
||||
return m_proxy.getPropertyAsync(propertyName).onInterface(interfaceName).getResultAsFuture();
|
||||
}
|
||||
|
||||
std::future<sdbus::Variant> GetAsync(std::string_view interfaceName, std::string_view propertyName, with_future_t)
|
||||
{
|
||||
return proxy_->getPropertyAsync(propertyName).onInterface(interfaceName).getResultAsFuture();
|
||||
return m_proxy.getPropertyAsync(propertyName).onInterface(interfaceName).getResultAsFuture();
|
||||
}
|
||||
|
||||
void Set(const InterfaceName& interfaceName, const PropertyName& propertyName, const sdbus::Variant& value)
|
||||
{
|
||||
proxy_->setProperty(propertyName).onInterface(interfaceName).toValue(value);
|
||||
m_proxy.setProperty(propertyName).onInterface(interfaceName).toValue(value);
|
||||
}
|
||||
|
||||
void Set(std::string_view interfaceName, const std::string_view propertyName, const sdbus::Variant& value)
|
||||
{
|
||||
proxy_->setProperty(propertyName).onInterface(interfaceName).toValue(value);
|
||||
m_proxy.setProperty(propertyName).onInterface(interfaceName).toValue(value);
|
||||
}
|
||||
|
||||
void Set(const InterfaceName& interfaceName, const PropertyName& propertyName, const sdbus::Variant& value, dont_expect_reply_t)
|
||||
{
|
||||
proxy_->setProperty(propertyName).onInterface(interfaceName).toValue(value, dont_expect_reply);
|
||||
m_proxy.setProperty(propertyName).onInterface(interfaceName).toValue(value, dont_expect_reply);
|
||||
}
|
||||
|
||||
void Set(std::string_view interfaceName, const std::string_view propertyName, const sdbus::Variant& value, dont_expect_reply_t)
|
||||
{
|
||||
proxy_->setProperty(propertyName).onInterface(interfaceName).toValue(value, dont_expect_reply);
|
||||
m_proxy.setProperty(propertyName).onInterface(interfaceName).toValue(value, dont_expect_reply);
|
||||
}
|
||||
|
||||
template <typename _Function>
|
||||
PendingAsyncCall SetAsync(const InterfaceName& interfaceName, const PropertyName& propertyName, const sdbus::Variant& value, _Function&& callback)
|
||||
{
|
||||
return proxy_->setPropertyAsync(propertyName).onInterface(interfaceName).toValue(value).uponReplyInvoke(std::forward<_Function>(callback));
|
||||
return m_proxy.setPropertyAsync(propertyName).onInterface(interfaceName).toValue(value).uponReplyInvoke(std::forward<_Function>(callback));
|
||||
}
|
||||
|
||||
template <typename _Function>
|
||||
PendingAsyncCall SetAsync(const InterfaceName& interfaceName, const PropertyName& propertyName, const sdbus::Variant& value, _Function&& callback, return_slot_t)
|
||||
{
|
||||
return proxy_->setPropertyAsync(propertyName).onInterface(interfaceName).toValue(value).uponReplyInvoke(std::forward<_Function>(callback), return_slot);
|
||||
return m_proxy.setPropertyAsync(propertyName).onInterface(interfaceName).toValue(value).uponReplyInvoke(std::forward<_Function>(callback), return_slot);
|
||||
}
|
||||
|
||||
template <typename _Function>
|
||||
PendingAsyncCall SetAsync(std::string_view interfaceName, std::string_view propertyName, const sdbus::Variant& value, _Function&& callback)
|
||||
{
|
||||
return proxy_->setPropertyAsync(propertyName).onInterface(interfaceName).toValue(value).uponReplyInvoke(std::forward<_Function>(callback));
|
||||
return m_proxy.setPropertyAsync(propertyName).onInterface(interfaceName).toValue(value).uponReplyInvoke(std::forward<_Function>(callback));
|
||||
}
|
||||
|
||||
template <typename _Function>
|
||||
PendingAsyncCall SetAsync(std::string_view interfaceName, std::string_view propertyName, const sdbus::Variant& value, _Function&& callback, return_slot_t)
|
||||
{
|
||||
return proxy_->setPropertyAsync(propertyName).onInterface(interfaceName).toValue(value).uponReplyInvoke(std::forward<_Function>(callback), return_slot);
|
||||
return m_proxy.setPropertyAsync(propertyName).onInterface(interfaceName).toValue(value).uponReplyInvoke(std::forward<_Function>(callback), return_slot);
|
||||
}
|
||||
|
||||
std::future<void> SetAsync(const InterfaceName& interfaceName, const PropertyName& propertyName, const sdbus::Variant& value, with_future_t)
|
||||
{
|
||||
return proxy_->setPropertyAsync(propertyName).onInterface(interfaceName).toValue(value).getResultAsFuture();
|
||||
return m_proxy.setPropertyAsync(propertyName).onInterface(interfaceName).toValue(value).getResultAsFuture();
|
||||
}
|
||||
|
||||
std::future<void> SetAsync(std::string_view interfaceName, std::string_view propertyName, const sdbus::Variant& value, with_future_t)
|
||||
{
|
||||
return proxy_->setPropertyAsync(propertyName).onInterface(interfaceName).toValue(value).getResultAsFuture();
|
||||
return m_proxy.setPropertyAsync(propertyName).onInterface(interfaceName).toValue(value).getResultAsFuture();
|
||||
}
|
||||
|
||||
std::map<PropertyName, sdbus::Variant> GetAll(const InterfaceName& interfaceName)
|
||||
{
|
||||
return proxy_->getAllProperties().onInterface(interfaceName);
|
||||
return m_proxy.getAllProperties().onInterface(interfaceName);
|
||||
}
|
||||
|
||||
std::map<PropertyName, sdbus::Variant> GetAll(std::string_view interfaceName)
|
||||
{
|
||||
return proxy_->getAllProperties().onInterface(interfaceName);
|
||||
return m_proxy.getAllProperties().onInterface(interfaceName);
|
||||
}
|
||||
|
||||
template <typename _Function>
|
||||
PendingAsyncCall GetAllAsync(const InterfaceName& interfaceName, _Function&& callback)
|
||||
{
|
||||
return proxy_->getAllPropertiesAsync().onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback));
|
||||
return m_proxy.getAllPropertiesAsync().onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback));
|
||||
}
|
||||
|
||||
template <typename _Function>
|
||||
PendingAsyncCall GetAllAsync(const InterfaceName& interfaceName, _Function&& callback, return_slot_t)
|
||||
{
|
||||
return proxy_->getAllPropertiesAsync().onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback), return_slot);
|
||||
return m_proxy.getAllPropertiesAsync().onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback), return_slot);
|
||||
}
|
||||
|
||||
template <typename _Function>
|
||||
PendingAsyncCall GetAllAsync(std::string_view interfaceName, _Function&& callback)
|
||||
{
|
||||
return proxy_->getAllPropertiesAsync().onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback));
|
||||
return m_proxy.getAllPropertiesAsync().onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback));
|
||||
}
|
||||
|
||||
template <typename _Function>
|
||||
PendingAsyncCall GetAllAsync(std::string_view interfaceName, _Function&& callback, return_slot_t)
|
||||
{
|
||||
return proxy_->getAllPropertiesAsync().onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback), return_slot);
|
||||
return m_proxy.getAllPropertiesAsync().onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback), return_slot);
|
||||
}
|
||||
|
||||
std::future<std::map<PropertyName, sdbus::Variant>> GetAllAsync(const InterfaceName& interfaceName, with_future_t)
|
||||
{
|
||||
return proxy_->getAllPropertiesAsync().onInterface(interfaceName).getResultAsFuture();
|
||||
return m_proxy.getAllPropertiesAsync().onInterface(interfaceName).getResultAsFuture();
|
||||
}
|
||||
|
||||
std::future<std::map<PropertyName, sdbus::Variant>> GetAllAsync(std::string_view interfaceName, with_future_t)
|
||||
{
|
||||
return proxy_->getAllPropertiesAsync().onInterface(interfaceName).getResultAsFuture();
|
||||
return m_proxy.getAllPropertiesAsync().onInterface(interfaceName).getResultAsFuture();
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IProxy* proxy_;
|
||||
sdbus::IProxy& m_proxy;
|
||||
};
|
||||
|
||||
// Proxy for object manager
|
||||
@ -299,21 +299,21 @@ namespace sdbus {
|
||||
|
||||
protected:
|
||||
ObjectManager_proxy(sdbus::IProxy& proxy)
|
||||
: proxy_(&proxy)
|
||||
: m_proxy(proxy)
|
||||
{
|
||||
}
|
||||
|
||||
ObjectManager_proxy(const ObjectManager_proxy&) = delete;
|
||||
ObjectManager_proxy& operator=(const ObjectManager_proxy&) = delete;
|
||||
ObjectManager_proxy(ObjectManager_proxy&&) = default;
|
||||
ObjectManager_proxy& operator=(ObjectManager_proxy&&) = default;
|
||||
ObjectManager_proxy(ObjectManager_proxy&&) = delete;
|
||||
ObjectManager_proxy& operator=(ObjectManager_proxy&&) = delete;
|
||||
|
||||
~ObjectManager_proxy() = default;
|
||||
|
||||
void registerProxy()
|
||||
{
|
||||
proxy_
|
||||
->uponSignal("InterfacesAdded")
|
||||
m_proxy
|
||||
.uponSignal("InterfacesAdded")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.call([this]( const sdbus::ObjectPath& objectPath
|
||||
, const std::map<sdbus::InterfaceName, std::map<PropertyName, sdbus::Variant>>& interfacesAndProperties )
|
||||
@ -321,7 +321,8 @@ namespace sdbus {
|
||||
this->onInterfacesAdded(objectPath, interfacesAndProperties);
|
||||
});
|
||||
|
||||
proxy_->uponSignal("InterfacesRemoved")
|
||||
m_proxy
|
||||
.uponSignal("InterfacesRemoved")
|
||||
.onInterface(INTERFACE_NAME)
|
||||
.call([this]( const sdbus::ObjectPath& objectPath
|
||||
, const std::vector<sdbus::InterfaceName>& interfaces )
|
||||
@ -339,12 +340,12 @@ namespace sdbus {
|
||||
std::map<sdbus::ObjectPath, std::map<sdbus::InterfaceName, std::map<PropertyName, sdbus::Variant>>> GetManagedObjects()
|
||||
{
|
||||
std::map<sdbus::ObjectPath, std::map<sdbus::InterfaceName, std::map<PropertyName, sdbus::Variant>>> objectsInterfacesAndProperties;
|
||||
proxy_->callMethod("GetManagedObjects").onInterface(INTERFACE_NAME).storeResultsTo(objectsInterfacesAndProperties);
|
||||
m_proxy.callMethod("GetManagedObjects").onInterface(INTERFACE_NAME).storeResultsTo(objectsInterfacesAndProperties);
|
||||
return objectsInterfacesAndProperties;
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IProxy* proxy_;
|
||||
sdbus::IProxy& m_proxy;
|
||||
};
|
||||
|
||||
// Adaptors for the above-listed standard D-Bus interfaces are not necessary because the functionality
|
||||
@ -357,14 +358,14 @@ namespace sdbus {
|
||||
static inline const char* INTERFACE_NAME = "org.freedesktop.DBus.Properties";
|
||||
|
||||
protected:
|
||||
Properties_adaptor(sdbus::IObject& object) : object_(&object)
|
||||
Properties_adaptor(sdbus::IObject& object) : m_object(object)
|
||||
{
|
||||
}
|
||||
|
||||
Properties_adaptor(const Properties_adaptor&) = delete;
|
||||
Properties_adaptor& operator=(const Properties_adaptor&) = delete;
|
||||
Properties_adaptor(Properties_adaptor&&) = default;
|
||||
Properties_adaptor& operator=(Properties_adaptor&&) = default;
|
||||
Properties_adaptor(Properties_adaptor&&) = delete;
|
||||
Properties_adaptor& operator=(Properties_adaptor&&) = delete;
|
||||
|
||||
~Properties_adaptor() = default;
|
||||
|
||||
@ -375,26 +376,26 @@ namespace sdbus {
|
||||
public:
|
||||
void emitPropertiesChangedSignal(const InterfaceName& interfaceName, const std::vector<PropertyName>& properties)
|
||||
{
|
||||
object_->emitPropertiesChangedSignal(interfaceName, properties);
|
||||
m_object.emitPropertiesChangedSignal(interfaceName, properties);
|
||||
}
|
||||
|
||||
void emitPropertiesChangedSignal(const char* interfaceName, const std::vector<PropertyName>& properties)
|
||||
{
|
||||
object_->emitPropertiesChangedSignal(interfaceName, properties);
|
||||
m_object.emitPropertiesChangedSignal(interfaceName, properties);
|
||||
}
|
||||
|
||||
void emitPropertiesChangedSignal(const InterfaceName& interfaceName)
|
||||
{
|
||||
object_->emitPropertiesChangedSignal(interfaceName);
|
||||
m_object.emitPropertiesChangedSignal(interfaceName);
|
||||
}
|
||||
|
||||
void emitPropertiesChangedSignal(const char* interfaceName)
|
||||
{
|
||||
object_->emitPropertiesChangedSignal(interfaceName);
|
||||
m_object.emitPropertiesChangedSignal(interfaceName);
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IObject* object_;
|
||||
sdbus::IObject& m_object;
|
||||
};
|
||||
|
||||
/*!
|
||||
@ -412,24 +413,24 @@ namespace sdbus {
|
||||
static inline const char* INTERFACE_NAME = "org.freedesktop.DBus.ObjectManager";
|
||||
|
||||
protected:
|
||||
explicit ObjectManager_adaptor(sdbus::IObject& object) : object_(&object)
|
||||
explicit ObjectManager_adaptor(sdbus::IObject& object) : m_object(object)
|
||||
{
|
||||
}
|
||||
|
||||
ObjectManager_adaptor(const ObjectManager_adaptor&) = delete;
|
||||
ObjectManager_adaptor& operator=(const ObjectManager_adaptor&) = delete;
|
||||
ObjectManager_adaptor(ObjectManager_adaptor&&) = default;
|
||||
ObjectManager_adaptor& operator=(ObjectManager_adaptor&&) = default;
|
||||
ObjectManager_adaptor(ObjectManager_adaptor&&) = delete;
|
||||
ObjectManager_adaptor& operator=(ObjectManager_adaptor&&) = delete;
|
||||
|
||||
~ObjectManager_adaptor() = default;
|
||||
|
||||
void registerAdaptor()
|
||||
{
|
||||
object_->addObjectManager();
|
||||
m_object.addObjectManager();
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IObject* object_;
|
||||
sdbus::IObject& m_object;
|
||||
};
|
||||
|
||||
/*!
|
||||
@ -447,14 +448,14 @@ namespace sdbus {
|
||||
{
|
||||
protected:
|
||||
explicit ManagedObject_adaptor(sdbus::IObject& object)
|
||||
: object_(&object)
|
||||
: m_object(object)
|
||||
{
|
||||
}
|
||||
|
||||
ManagedObject_adaptor(const ManagedObject_adaptor&) = delete;
|
||||
ManagedObject_adaptor& operator=(const ManagedObject_adaptor&) = delete;
|
||||
ManagedObject_adaptor(ManagedObject_adaptor&&) = default;
|
||||
ManagedObject_adaptor& operator=(ManagedObject_adaptor&&) = default;
|
||||
ManagedObject_adaptor(ManagedObject_adaptor&&) = delete;
|
||||
ManagedObject_adaptor& operator=(ManagedObject_adaptor&&) = delete;
|
||||
|
||||
~ManagedObject_adaptor() = default;
|
||||
|
||||
@ -470,7 +471,7 @@ namespace sdbus {
|
||||
*/
|
||||
void emitInterfacesAddedSignal()
|
||||
{
|
||||
object_->emitInterfacesAddedSignal();
|
||||
m_object.emitInterfacesAddedSignal();
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -480,7 +481,7 @@ namespace sdbus {
|
||||
*/
|
||||
void emitInterfacesAddedSignal(const std::vector<sdbus::InterfaceName>& interfaces)
|
||||
{
|
||||
object_->emitInterfacesAddedSignal(interfaces);
|
||||
m_object.emitInterfacesAddedSignal(interfaces);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -490,7 +491,7 @@ namespace sdbus {
|
||||
*/
|
||||
void emitInterfacesRemovedSignal()
|
||||
{
|
||||
object_->emitInterfacesRemovedSignal();
|
||||
m_object.emitInterfacesRemovedSignal();
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -500,11 +501,11 @@ namespace sdbus {
|
||||
*/
|
||||
void emitInterfacesRemovedSignal(const std::vector<InterfaceName>& interfaces)
|
||||
{
|
||||
object_->emitInterfacesRemovedSignal(interfaces);
|
||||
m_object.emitInterfacesRemovedSignal(interfaces);
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IObject* object_;
|
||||
sdbus::IObject& m_object;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -63,16 +63,16 @@ TEST(AdaptorAndProxy, CanBeConstructedSuccesfully)
|
||||
connection->releaseName(SERVICE_NAME);
|
||||
}
|
||||
|
||||
TEST(AProxy, SupportsMoveSemantics)
|
||||
TEST(AProxy, DoesNotSupportMoveSemantics)
|
||||
{
|
||||
static_assert(std::is_move_constructible_v<DummyTestProxy>);
|
||||
static_assert(std::is_move_assignable_v<DummyTestProxy>);
|
||||
static_assert(!std::is_move_constructible_v<DummyTestProxy>);
|
||||
static_assert(!std::is_move_assignable_v<DummyTestProxy>);
|
||||
}
|
||||
|
||||
TEST(AnAdaptor, SupportsMoveSemantics)
|
||||
TEST(AnAdaptor, DoesNotSupportMoveSemantics)
|
||||
{
|
||||
static_assert(std::is_move_constructible_v<DummyTestAdaptor>);
|
||||
static_assert(std::is_move_assignable_v<DummyTestAdaptor>);
|
||||
static_assert(!std::is_move_constructible_v<DummyTestAdaptor>);
|
||||
static_assert(!std::is_move_assignable_v<DummyTestAdaptor>);
|
||||
}
|
||||
|
||||
TYPED_TEST(AConnection, WillCallCallbackHandlerForIncomingMessageMatchingMatchRule)
|
||||
|
@ -20,20 +20,20 @@ public:
|
||||
|
||||
protected:
|
||||
integrationtests_adaptor(sdbus::IObject& object)
|
||||
: object_(&object)
|
||||
: m_object(object)
|
||||
{
|
||||
}
|
||||
|
||||
integrationtests_adaptor(const integrationtests_adaptor&) = delete;
|
||||
integrationtests_adaptor& operator=(const integrationtests_adaptor&) = delete;
|
||||
integrationtests_adaptor(integrationtests_adaptor&&) = default;
|
||||
integrationtests_adaptor& operator=(integrationtests_adaptor&&) = default;
|
||||
integrationtests_adaptor(integrationtests_adaptor&&) = delete;
|
||||
integrationtests_adaptor& operator=(integrationtests_adaptor&&) = delete;
|
||||
|
||||
~integrationtests_adaptor() = default;
|
||||
|
||||
void registerAdaptor()
|
||||
{
|
||||
object_->addVTable( sdbus::setInterfaceFlags().markAsDeprecated().withPropertyUpdateBehavior(sdbus::Flags::EMITS_NO_SIGNAL)
|
||||
m_object.addVTable( sdbus::setInterfaceFlags().markAsDeprecated().withPropertyUpdateBehavior(sdbus::Flags::EMITS_NO_SIGNAL)
|
||||
, sdbus::registerMethod("noArgNoReturn").implementedAs([this](){ return this->noArgNoReturn(); })
|
||||
, sdbus::registerMethod("getInt").withOutputParamNames("anInt").implementedAs([this](){ return this->getInt(); })
|
||||
, sdbus::registerMethod("getTuple").withOutputParamNames("arg0", "arg1").implementedAs([this](){ return this->getTuple(); })
|
||||
@ -67,17 +67,17 @@ protected:
|
||||
public:
|
||||
void emitSimpleSignal()
|
||||
{
|
||||
object_->emitSignal("simpleSignal").onInterface(INTERFACE_NAME);
|
||||
m_object.emitSignal("simpleSignal").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
void emitSignalWithMap(const std::map<int32_t, std::string>& aMap)
|
||||
{
|
||||
object_->emitSignal("signalWithMap").onInterface(INTERFACE_NAME).withArguments(aMap);
|
||||
m_object.emitSignal("signalWithMap").onInterface(INTERFACE_NAME).withArguments(aMap);
|
||||
}
|
||||
|
||||
void emitSignalWithVariant(const sdbus::Variant& aVariant)
|
||||
{
|
||||
object_->emitSignal("signalWithVariant").onInterface(INTERFACE_NAME).withArguments(aVariant);
|
||||
m_object.emitSignal("signalWithVariant").onInterface(INTERFACE_NAME).withArguments(aVariant);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -111,7 +111,7 @@ private:
|
||||
virtual std::string state() = 0;
|
||||
|
||||
private:
|
||||
sdbus::IObject* object_;
|
||||
sdbus::IObject& m_object;
|
||||
};
|
||||
|
||||
}} // namespaces
|
||||
|
@ -20,22 +20,22 @@ public:
|
||||
|
||||
protected:
|
||||
integrationtests_proxy(sdbus::IProxy& proxy)
|
||||
: proxy_(&proxy)
|
||||
: m_proxy(proxy)
|
||||
{
|
||||
}
|
||||
|
||||
integrationtests_proxy(const integrationtests_proxy&) = delete;
|
||||
integrationtests_proxy& operator=(const integrationtests_proxy&) = delete;
|
||||
integrationtests_proxy(integrationtests_proxy&&) = default;
|
||||
integrationtests_proxy& operator=(integrationtests_proxy&&) = default;
|
||||
integrationtests_proxy(integrationtests_proxy&&) = delete;
|
||||
integrationtests_proxy& operator=(integrationtests_proxy&&) = delete;
|
||||
|
||||
~integrationtests_proxy() = default;
|
||||
|
||||
void registerProxy()
|
||||
{
|
||||
simpleSignalSlot_ = proxy_->uponSignal("simpleSignal").onInterface(INTERFACE_NAME).call([this](){ this->onSimpleSignal(); }, sdbus::return_slot);
|
||||
proxy_->uponSignal("signalWithMap").onInterface(INTERFACE_NAME).call([this](const std::map<int32_t, std::string>& aMap){ this->onSignalWithMap(aMap); });
|
||||
proxy_->uponSignal("signalWithVariant").onInterface(INTERFACE_NAME).call([this](const sdbus::Variant& aVariant){ this->onSignalWithVariant(aVariant); });
|
||||
simpleSignalSlot_ = m_proxy.uponSignal("simpleSignal").onInterface(INTERFACE_NAME).call([this](){ this->onSimpleSignal(); }, sdbus::return_slot);
|
||||
m_proxy.uponSignal("signalWithMap").onInterface(INTERFACE_NAME).call([this](const std::map<int32_t, std::string>& aMap){ this->onSignalWithMap(aMap); });
|
||||
m_proxy.uponSignal("signalWithVariant").onInterface(INTERFACE_NAME).call([this](const sdbus::Variant& aVariant){ this->onSignalWithVariant(aVariant); });
|
||||
}
|
||||
|
||||
virtual void onSimpleSignal() = 0;
|
||||
@ -45,144 +45,144 @@ protected:
|
||||
public:
|
||||
void noArgNoReturn()
|
||||
{
|
||||
proxy_->callMethod("noArgNoReturn").onInterface(INTERFACE_NAME);
|
||||
m_proxy.callMethod("noArgNoReturn").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
int32_t getInt()
|
||||
{
|
||||
int32_t result;
|
||||
proxy_->callMethod("getInt").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
m_proxy.callMethod("getInt").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::tuple<uint32_t, std::string> getTuple()
|
||||
{
|
||||
std::tuple<uint32_t, std::string> result;
|
||||
proxy_->callMethod("getTuple").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
m_proxy.callMethod("getTuple").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
double multiply(const int64_t& a, const double& b)
|
||||
{
|
||||
double result;
|
||||
proxy_->callMethod("multiply").onInterface(INTERFACE_NAME).withArguments(a, b).storeResultsTo(result);
|
||||
m_proxy.callMethod("multiply").onInterface(INTERFACE_NAME).withArguments(a, b).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void multiplyWithNoReply(const int64_t& a, const double& b)
|
||||
{
|
||||
proxy_->callMethod("multiplyWithNoReply").onInterface(INTERFACE_NAME).withArguments(a, b).dontExpectReply();
|
||||
m_proxy.callMethod("multiplyWithNoReply").onInterface(INTERFACE_NAME).withArguments(a, b).dontExpectReply();
|
||||
}
|
||||
|
||||
std::vector<int16_t> getInts16FromStruct(const sdbus::Struct<uint8_t, int16_t, double, std::string, std::vector<int16_t>>& arg0)
|
||||
{
|
||||
std::vector<int16_t> result;
|
||||
proxy_->callMethod("getInts16FromStruct").onInterface(INTERFACE_NAME).withArguments(arg0).storeResultsTo(result);
|
||||
m_proxy.callMethod("getInts16FromStruct").onInterface(INTERFACE_NAME).withArguments(arg0).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
sdbus::Variant processVariant(const sdbus::Variant& variant)
|
||||
{
|
||||
sdbus::Variant result;
|
||||
proxy_->callMethod("processVariant").onInterface(INTERFACE_NAME).withArguments(variant).storeResultsTo(result);
|
||||
m_proxy.callMethod("processVariant").onInterface(INTERFACE_NAME).withArguments(variant).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::variant<int32_t, double, std::string> processVariant(const std::variant<int32_t, double, std::string>& variant)
|
||||
{
|
||||
std::variant<int32_t, double, std::string> result;
|
||||
proxy_->callMethod("processVariant").onInterface(INTERFACE_NAME).withArguments(variant).storeResultsTo(result);
|
||||
m_proxy.callMethod("processVariant").onInterface(INTERFACE_NAME).withArguments(variant).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::map<int32_t, sdbus::Variant> getMapOfVariants(const std::vector<int32_t>& x, const sdbus::Struct<sdbus::Variant, sdbus::Variant>& y)
|
||||
{
|
||||
std::map<int32_t, sdbus::Variant> result;
|
||||
proxy_->callMethod("getMapOfVariants").onInterface(INTERFACE_NAME).withArguments(x, y).storeResultsTo(result);
|
||||
m_proxy.callMethod("getMapOfVariants").onInterface(INTERFACE_NAME).withArguments(x, y).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
sdbus::Struct<std::string, sdbus::Struct<std::map<int32_t, int32_t>>> getStructInStruct()
|
||||
{
|
||||
sdbus::Struct<std::string, sdbus::Struct<std::map<int32_t, int32_t>>> result;
|
||||
proxy_->callMethod("getStructInStruct").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
m_proxy.callMethod("getStructInStruct").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t sumStructItems(const sdbus::Struct<uint8_t, uint16_t>& arg0, const sdbus::Struct<int32_t, int64_t>& arg1)
|
||||
{
|
||||
int32_t result;
|
||||
proxy_->callMethod("sumStructItems").onInterface(INTERFACE_NAME).withArguments(arg0, arg1).storeResultsTo(result);
|
||||
m_proxy.callMethod("sumStructItems").onInterface(INTERFACE_NAME).withArguments(arg0, arg1).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t sumArrayItems(const std::vector<uint16_t>& arg0, const std::array<uint64_t, 3>& arg1)
|
||||
{
|
||||
uint32_t result;
|
||||
proxy_->callMethod("sumArrayItems").onInterface(INTERFACE_NAME).withArguments(arg0, arg1).storeResultsTo(result);
|
||||
m_proxy.callMethod("sumArrayItems").onInterface(INTERFACE_NAME).withArguments(arg0, arg1).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t doOperation(const uint32_t& arg0)
|
||||
{
|
||||
uint32_t result;
|
||||
proxy_->callMethod("doOperation").onInterface(INTERFACE_NAME).withArguments(arg0).storeResultsTo(result);
|
||||
m_proxy.callMethod("doOperation").onInterface(INTERFACE_NAME).withArguments(arg0).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t doOperationAsync(const uint32_t& arg0)
|
||||
{
|
||||
uint32_t result;
|
||||
proxy_->callMethod("doOperationAsync").onInterface(INTERFACE_NAME).withArguments(arg0).storeResultsTo(result);
|
||||
m_proxy.callMethod("doOperationAsync").onInterface(INTERFACE_NAME).withArguments(arg0).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
sdbus::Signature getSignature()
|
||||
{
|
||||
sdbus::Signature result;
|
||||
proxy_->callMethod("getSignature").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
m_proxy.callMethod("getSignature").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
sdbus::ObjectPath getObjPath()
|
||||
{
|
||||
sdbus::ObjectPath result;
|
||||
proxy_->callMethod("getObjPath").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
m_proxy.callMethod("getObjPath").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
sdbus::UnixFd getUnixFd()
|
||||
{
|
||||
sdbus::UnixFd result;
|
||||
proxy_->callMethod("getUnixFd").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
m_proxy.callMethod("getUnixFd").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::map<uint64_t, sdbus::Struct<std::map<uint8_t, std::vector<sdbus::Struct<sdbus::ObjectPath, bool, sdbus::Variant, std::unordered_map<int32_t, std::string>>>>, sdbus::Signature, std::string>> getComplex()
|
||||
{
|
||||
std::map<uint64_t, sdbus::Struct<std::map<uint8_t, std::vector<sdbus::Struct<sdbus::ObjectPath, bool, sdbus::Variant, std::unordered_map<int32_t, std::string>>>>, sdbus::Signature, std::string>> result;
|
||||
proxy_->callMethod("getComplex").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
m_proxy.callMethod("getComplex").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void throwError()
|
||||
{
|
||||
proxy_->callMethod("throwError").onInterface(INTERFACE_NAME);
|
||||
m_proxy.callMethod("throwError").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
void throwErrorWithNoReply()
|
||||
{
|
||||
proxy_->callMethod("throwErrorWithNoReply").onInterface(INTERFACE_NAME).dontExpectReply();
|
||||
m_proxy.callMethod("throwErrorWithNoReply").onInterface(INTERFACE_NAME).dontExpectReply();
|
||||
}
|
||||
|
||||
void doPrivilegedStuff()
|
||||
{
|
||||
proxy_->callMethod("doPrivilegedStuff").onInterface(INTERFACE_NAME);
|
||||
m_proxy.callMethod("doPrivilegedStuff").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
void emitTwoSimpleSignals()
|
||||
{
|
||||
proxy_->callMethod("emitTwoSimpleSignals").onInterface(INTERFACE_NAME);
|
||||
m_proxy.callMethod("emitTwoSimpleSignals").onInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
void unregisterSimpleSignalHandler()
|
||||
@ -192,37 +192,37 @@ public:
|
||||
|
||||
void reRegisterSimpleSignalHandler()
|
||||
{
|
||||
simpleSignalSlot_ = proxy_->uponSignal("simpleSignal").onInterface(INTERFACE_NAME).call([this](){ this->onSimpleSignal(); }, sdbus::return_slot);
|
||||
simpleSignalSlot_ = m_proxy.uponSignal("simpleSignal").onInterface(INTERFACE_NAME).call([this](){ this->onSimpleSignal(); }, sdbus::return_slot);
|
||||
}
|
||||
|
||||
public:
|
||||
uint32_t action()
|
||||
{
|
||||
return proxy_->getProperty("action").onInterface(INTERFACE_NAME).get<uint32_t>();
|
||||
return m_proxy.getProperty("action").onInterface(INTERFACE_NAME).get<uint32_t>();
|
||||
}
|
||||
|
||||
void action(const uint32_t& value)
|
||||
{
|
||||
proxy_->setProperty("action").onInterface(INTERFACE_NAME).toValue(value);
|
||||
m_proxy.setProperty("action").onInterface(INTERFACE_NAME).toValue(value);
|
||||
}
|
||||
|
||||
bool blocking()
|
||||
{
|
||||
return proxy_->getProperty("blocking").onInterface(INTERFACE_NAME).get<bool>();
|
||||
return m_proxy.getProperty("blocking").onInterface(INTERFACE_NAME).get<bool>();
|
||||
}
|
||||
|
||||
void blocking(const bool& value)
|
||||
{
|
||||
proxy_->setProperty("blocking").onInterface(INTERFACE_NAME).toValue(value);
|
||||
m_proxy.setProperty("blocking").onInterface(INTERFACE_NAME).toValue(value);
|
||||
}
|
||||
|
||||
std::string state()
|
||||
{
|
||||
return proxy_->getProperty("state").onInterface(INTERFACE_NAME).get<std::string>();
|
||||
return m_proxy.getProperty("state").onInterface(INTERFACE_NAME).get<std::string>();
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IProxy* proxy_;
|
||||
sdbus::IProxy& m_proxy;
|
||||
sdbus::Slot simpleSignalSlot_;
|
||||
};
|
||||
|
||||
|
@ -20,20 +20,20 @@ public:
|
||||
|
||||
protected:
|
||||
perftests_adaptor(sdbus::IObject& object)
|
||||
: object_(&object)
|
||||
: m_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(perftests_adaptor&&) = delete;
|
||||
perftests_adaptor& operator=(perftests_adaptor&&) = delete;
|
||||
|
||||
~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); })
|
||||
m_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);
|
||||
@ -42,7 +42,7 @@ protected:
|
||||
public:
|
||||
void emitDataSignal(const std::string& data)
|
||||
{
|
||||
object_->emitSignal("dataSignal").onInterface(INTERFACE_NAME).withArguments(data);
|
||||
m_object.emitSignal("dataSignal").onInterface(INTERFACE_NAME).withArguments(data);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -50,7 +50,7 @@ private:
|
||||
virtual std::string concatenateTwoStrings(const std::string& string1, const std::string& string2) = 0;
|
||||
|
||||
private:
|
||||
sdbus::IObject* object_;
|
||||
sdbus::IObject& m_object;
|
||||
};
|
||||
|
||||
}} // namespaces
|
||||
|
@ -20,20 +20,20 @@ public:
|
||||
|
||||
protected:
|
||||
perftests_proxy(sdbus::IProxy& proxy)
|
||||
: proxy_(&proxy)
|
||||
: m_proxy(proxy)
|
||||
{
|
||||
}
|
||||
|
||||
perftests_proxy(const perftests_proxy&) = delete;
|
||||
perftests_proxy& operator=(const perftests_proxy&) = delete;
|
||||
perftests_proxy(perftests_proxy&&) = default;
|
||||
perftests_proxy& operator=(perftests_proxy&&) = default;
|
||||
perftests_proxy(perftests_proxy&&) = delete;
|
||||
perftests_proxy& operator=(perftests_proxy&&) = delete;
|
||||
|
||||
~perftests_proxy() = default;
|
||||
|
||||
void registerProxy()
|
||||
{
|
||||
proxy_->uponSignal("dataSignal").onInterface(INTERFACE_NAME).call([this](const std::string& data){ this->onDataSignal(data); });
|
||||
m_proxy.uponSignal("dataSignal").onInterface(INTERFACE_NAME).call([this](const std::string& data){ this->onDataSignal(data); });
|
||||
}
|
||||
|
||||
virtual void onDataSignal(const std::string& data) = 0;
|
||||
@ -41,18 +41,18 @@ protected:
|
||||
public:
|
||||
void sendDataSignals(const uint32_t& numberOfSignals, const uint32_t& signalMsgSize)
|
||||
{
|
||||
proxy_->callMethod("sendDataSignals").onInterface(INTERFACE_NAME).withArguments(numberOfSignals, signalMsgSize);
|
||||
m_proxy.callMethod("sendDataSignals").onInterface(INTERFACE_NAME).withArguments(numberOfSignals, signalMsgSize);
|
||||
}
|
||||
|
||||
std::string concatenateTwoStrings(const std::string& string1, const std::string& string2)
|
||||
{
|
||||
std::string result;
|
||||
proxy_->callMethod("concatenateTwoStrings").onInterface(INTERFACE_NAME).withArguments(string1, string2).storeResultsTo(result);
|
||||
m_proxy.callMethod("concatenateTwoStrings").onInterface(INTERFACE_NAME).withArguments(string1, string2).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IProxy* proxy_;
|
||||
sdbus::IProxy& m_proxy;
|
||||
};
|
||||
|
||||
}} // namespaces
|
||||
|
@ -22,27 +22,27 @@ public:
|
||||
|
||||
protected:
|
||||
thermometer_adaptor(sdbus::IObject& object)
|
||||
: object_(&object)
|
||||
: m_object(object)
|
||||
{
|
||||
}
|
||||
|
||||
thermometer_adaptor(const thermometer_adaptor&) = delete;
|
||||
thermometer_adaptor& operator=(const thermometer_adaptor&) = delete;
|
||||
thermometer_adaptor(thermometer_adaptor&&) = default;
|
||||
thermometer_adaptor& operator=(thermometer_adaptor&&) = default;
|
||||
thermometer_adaptor(thermometer_adaptor&&) = delete;
|
||||
thermometer_adaptor& operator=(thermometer_adaptor&&) = delete;
|
||||
|
||||
~thermometer_adaptor() = default;
|
||||
|
||||
void registerAdaptor()
|
||||
{
|
||||
object_->addVTable(sdbus::registerMethod("getCurrentTemperature").withOutputParamNames("result").implementedAs([this](){ return this->getCurrentTemperature(); })).forInterface(INTERFACE_NAME);
|
||||
m_object.addVTable(sdbus::registerMethod("getCurrentTemperature").withOutputParamNames("result").implementedAs([this](){ return this->getCurrentTemperature(); })).forInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
private:
|
||||
virtual uint32_t getCurrentTemperature() = 0;
|
||||
|
||||
private:
|
||||
sdbus::IObject* object_;
|
||||
sdbus::IObject& m_object;
|
||||
};
|
||||
|
||||
}}}} // namespaces
|
||||
|
@ -22,14 +22,14 @@ public:
|
||||
|
||||
protected:
|
||||
thermometer_proxy(sdbus::IProxy& proxy)
|
||||
: proxy_(&proxy)
|
||||
: m_proxy(proxy)
|
||||
{
|
||||
}
|
||||
|
||||
thermometer_proxy(const thermometer_proxy&) = delete;
|
||||
thermometer_proxy& operator=(const thermometer_proxy&) = delete;
|
||||
thermometer_proxy(thermometer_proxy&&) = default;
|
||||
thermometer_proxy& operator=(thermometer_proxy&&) = default;
|
||||
thermometer_proxy(thermometer_proxy&&) = delete;
|
||||
thermometer_proxy& operator=(thermometer_proxy&&) = delete;
|
||||
|
||||
~thermometer_proxy() = default;
|
||||
|
||||
@ -41,12 +41,12 @@ public:
|
||||
uint32_t getCurrentTemperature()
|
||||
{
|
||||
uint32_t result;
|
||||
proxy_->callMethod("getCurrentTemperature").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
m_proxy.callMethod("getCurrentTemperature").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IProxy* proxy_;
|
||||
sdbus::IProxy& m_proxy;
|
||||
};
|
||||
|
||||
}}}} // namespaces
|
||||
|
@ -21,20 +21,20 @@ public:
|
||||
|
||||
protected:
|
||||
concatenator_adaptor(sdbus::IObject& object)
|
||||
: object_(&object)
|
||||
: m_object(object)
|
||||
{
|
||||
}
|
||||
|
||||
concatenator_adaptor(const concatenator_adaptor&) = delete;
|
||||
concatenator_adaptor& operator=(const concatenator_adaptor&) = delete;
|
||||
concatenator_adaptor(concatenator_adaptor&&) = default;
|
||||
concatenator_adaptor& operator=(concatenator_adaptor&&) = default;
|
||||
concatenator_adaptor(concatenator_adaptor&&) = delete;
|
||||
concatenator_adaptor& operator=(concatenator_adaptor&&) = delete;
|
||||
|
||||
~concatenator_adaptor() = default;
|
||||
|
||||
void registerAdaptor()
|
||||
{
|
||||
object_->addVTable( sdbus::registerMethod("concatenate").withInputParamNames("params").withOutputParamNames("result").implementedAs([this](sdbus::Result<std::string>&& result, std::map<std::string, sdbus::Variant> params){ this->concatenate(std::move(result), std::move(params)); })
|
||||
m_object.addVTable( sdbus::registerMethod("concatenate").withInputParamNames("params").withOutputParamNames("result").implementedAs([this](sdbus::Result<std::string>&& result, std::map<std::string, sdbus::Variant> params){ this->concatenate(std::move(result), std::move(params)); })
|
||||
, sdbus::registerSignal("concatenatedSignal").withParameters<std::string>("concatenatedString")
|
||||
).forInterface(INTERFACE_NAME);
|
||||
}
|
||||
@ -42,14 +42,14 @@ protected:
|
||||
public:
|
||||
void emitConcatenatedSignal(const std::string& concatenatedString)
|
||||
{
|
||||
object_->emitSignal("concatenatedSignal").onInterface(INTERFACE_NAME).withArguments(concatenatedString);
|
||||
m_object.emitSignal("concatenatedSignal").onInterface(INTERFACE_NAME).withArguments(concatenatedString);
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void concatenate(sdbus::Result<std::string>&& result, std::map<std::string, sdbus::Variant> params) = 0;
|
||||
|
||||
private:
|
||||
sdbus::IObject* object_;
|
||||
sdbus::IObject& m_object;
|
||||
};
|
||||
|
||||
}}} // namespaces
|
||||
|
@ -21,20 +21,20 @@ public:
|
||||
|
||||
protected:
|
||||
concatenator_proxy(sdbus::IProxy& proxy)
|
||||
: proxy_(&proxy)
|
||||
: m_proxy(proxy)
|
||||
{
|
||||
}
|
||||
|
||||
concatenator_proxy(const concatenator_proxy&) = delete;
|
||||
concatenator_proxy& operator=(const concatenator_proxy&) = delete;
|
||||
concatenator_proxy(concatenator_proxy&&) = default;
|
||||
concatenator_proxy& operator=(concatenator_proxy&&) = default;
|
||||
concatenator_proxy(concatenator_proxy&&) = delete;
|
||||
concatenator_proxy& operator=(concatenator_proxy&&) = delete;
|
||||
|
||||
~concatenator_proxy() = default;
|
||||
|
||||
void registerProxy()
|
||||
{
|
||||
proxy_->uponSignal("concatenatedSignal").onInterface(INTERFACE_NAME).call([this](const std::string& concatenatedString){ this->onConcatenatedSignal(concatenatedString); });
|
||||
m_proxy.uponSignal("concatenatedSignal").onInterface(INTERFACE_NAME).call([this](const std::string& concatenatedString){ this->onConcatenatedSignal(concatenatedString); });
|
||||
}
|
||||
|
||||
virtual void onConcatenatedSignal(const std::string& concatenatedString) = 0;
|
||||
@ -44,11 +44,11 @@ protected:
|
||||
public:
|
||||
sdbus::PendingAsyncCall concatenate(const std::map<std::string, sdbus::Variant>& params)
|
||||
{
|
||||
return proxy_->callMethodAsync("concatenate").onInterface(INTERFACE_NAME).withArguments(params).uponReplyInvoke([this](std::optional<sdbus::Error> error, const std::string& result){ this->onConcatenateReply(result, std::move(error)); });
|
||||
return m_proxy.callMethodAsync("concatenate").onInterface(INTERFACE_NAME).withArguments(params).uponReplyInvoke([this](std::optional<sdbus::Error> error, const std::string& result){ this->onConcatenateReply(result, std::move(error)); });
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IProxy* proxy_;
|
||||
sdbus::IProxy& m_proxy;
|
||||
};
|
||||
|
||||
}}} // namespaces
|
||||
|
@ -22,27 +22,27 @@ public:
|
||||
|
||||
protected:
|
||||
thermometer_adaptor(sdbus::IObject& object)
|
||||
: object_(&object)
|
||||
: m_object(object)
|
||||
{
|
||||
}
|
||||
|
||||
thermometer_adaptor(const thermometer_adaptor&) = delete;
|
||||
thermometer_adaptor& operator=(const thermometer_adaptor&) = delete;
|
||||
thermometer_adaptor(thermometer_adaptor&&) = default;
|
||||
thermometer_adaptor& operator=(thermometer_adaptor&&) = default;
|
||||
thermometer_adaptor(thermometer_adaptor&&) = delete;
|
||||
thermometer_adaptor& operator=(thermometer_adaptor&&) = delete;
|
||||
|
||||
~thermometer_adaptor() = default;
|
||||
|
||||
void registerAdaptor()
|
||||
{
|
||||
object_->addVTable(sdbus::registerMethod("getCurrentTemperature").withOutputParamNames("result").implementedAs([this](){ return this->getCurrentTemperature(); })).forInterface(INTERFACE_NAME);
|
||||
m_object.addVTable(sdbus::registerMethod("getCurrentTemperature").withOutputParamNames("result").implementedAs([this](){ return this->getCurrentTemperature(); })).forInterface(INTERFACE_NAME);
|
||||
}
|
||||
|
||||
private:
|
||||
virtual uint32_t getCurrentTemperature() = 0;
|
||||
|
||||
private:
|
||||
sdbus::IObject* object_;
|
||||
sdbus::IObject& m_object;
|
||||
};
|
||||
|
||||
}}}} // namespaces
|
||||
@ -60,20 +60,20 @@ public:
|
||||
|
||||
protected:
|
||||
factory_adaptor(sdbus::IObject& object)
|
||||
: object_(&object)
|
||||
: m_object(object)
|
||||
{
|
||||
}
|
||||
|
||||
factory_adaptor(const factory_adaptor&) = delete;
|
||||
factory_adaptor& operator=(const factory_adaptor&) = delete;
|
||||
factory_adaptor(factory_adaptor&&) = default;
|
||||
factory_adaptor& operator=(factory_adaptor&&) = default;
|
||||
factory_adaptor(factory_adaptor&&) = delete;
|
||||
factory_adaptor& operator=(factory_adaptor&&) = delete;
|
||||
|
||||
~factory_adaptor() = default;
|
||||
|
||||
void registerAdaptor()
|
||||
{
|
||||
object_->addVTable( sdbus::registerMethod("createDelegateObject").withOutputParamNames("delegate").implementedAs([this](sdbus::Result<sdbus::ObjectPath>&& result){ this->createDelegateObject(std::move(result)); })
|
||||
m_object.addVTable( sdbus::registerMethod("createDelegateObject").withOutputParamNames("delegate").implementedAs([this](sdbus::Result<sdbus::ObjectPath>&& result){ this->createDelegateObject(std::move(result)); })
|
||||
, sdbus::registerMethod("destroyDelegateObject").withInputParamNames("delegate").implementedAs([this](sdbus::Result<>&& result, sdbus::ObjectPath delegate){ this->destroyDelegateObject(std::move(result), std::move(delegate)); }).withNoReply()
|
||||
).forInterface(INTERFACE_NAME);
|
||||
}
|
||||
@ -83,7 +83,7 @@ private:
|
||||
virtual void destroyDelegateObject(sdbus::Result<>&& result, sdbus::ObjectPath delegate) = 0;
|
||||
|
||||
private:
|
||||
sdbus::IObject* object_;
|
||||
sdbus::IObject& m_object;
|
||||
};
|
||||
|
||||
}}}}} // namespaces
|
||||
|
@ -22,14 +22,14 @@ public:
|
||||
|
||||
protected:
|
||||
thermometer_proxy(sdbus::IProxy& proxy)
|
||||
: proxy_(&proxy)
|
||||
: m_proxy(proxy)
|
||||
{
|
||||
}
|
||||
|
||||
thermometer_proxy(const thermometer_proxy&) = delete;
|
||||
thermometer_proxy& operator=(const thermometer_proxy&) = delete;
|
||||
thermometer_proxy(thermometer_proxy&&) = default;
|
||||
thermometer_proxy& operator=(thermometer_proxy&&) = default;
|
||||
thermometer_proxy(thermometer_proxy&&) = delete;
|
||||
thermometer_proxy& operator=(thermometer_proxy&&) = delete;
|
||||
|
||||
~thermometer_proxy() = default;
|
||||
|
||||
@ -41,12 +41,12 @@ public:
|
||||
uint32_t getCurrentTemperature()
|
||||
{
|
||||
uint32_t result;
|
||||
proxy_->callMethod("getCurrentTemperature").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
m_proxy.callMethod("getCurrentTemperature").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IProxy* proxy_;
|
||||
sdbus::IProxy& m_proxy;
|
||||
};
|
||||
|
||||
}}}} // namespaces
|
||||
@ -64,14 +64,14 @@ public:
|
||||
|
||||
protected:
|
||||
factory_proxy(sdbus::IProxy& proxy)
|
||||
: proxy_(&proxy)
|
||||
: m_proxy(proxy)
|
||||
{
|
||||
}
|
||||
|
||||
factory_proxy(const factory_proxy&) = delete;
|
||||
factory_proxy& operator=(const factory_proxy&) = delete;
|
||||
factory_proxy(factory_proxy&&) = default;
|
||||
factory_proxy& operator=(factory_proxy&&) = default;
|
||||
factory_proxy(factory_proxy&&) = delete;
|
||||
factory_proxy& operator=(factory_proxy&&) = delete;
|
||||
|
||||
~factory_proxy() = default;
|
||||
|
||||
@ -83,17 +83,17 @@ public:
|
||||
sdbus::ObjectPath createDelegateObject()
|
||||
{
|
||||
sdbus::ObjectPath result;
|
||||
proxy_->callMethod("createDelegateObject").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
m_proxy.callMethod("createDelegateObject").onInterface(INTERFACE_NAME).storeResultsTo(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void destroyDelegateObject(const sdbus::ObjectPath& delegate)
|
||||
{
|
||||
proxy_->callMethod("destroyDelegateObject").onInterface(INTERFACE_NAME).withArguments(delegate).dontExpectReply();
|
||||
m_proxy.callMethod("destroyDelegateObject").onInterface(INTERFACE_NAME).withArguments(delegate).dontExpectReply();
|
||||
}
|
||||
|
||||
private:
|
||||
sdbus::IProxy* proxy_;
|
||||
sdbus::IProxy& m_proxy;
|
||||
};
|
||||
|
||||
}}}}} // namespaces
|
||||
|
@ -85,15 +85,15 @@ std::string AdaptorGenerator::processInterface(Node& interface) const
|
||||
<< tab << "static constexpr const char* INTERFACE_NAME = \"" << ifaceName << "\";" << endl << endl
|
||||
<< "protected:" << endl
|
||||
<< tab << className << "(sdbus::IObject& object)" << endl
|
||||
<< tab << tab << ": object_(&object)" << endl
|
||||
<< tab << tab << ": m_object(object)" << endl
|
||||
<< tab << "{" << endl
|
||||
<< tab << "}" << endl << endl;
|
||||
|
||||
// Rule of Five
|
||||
body << tab << className << "(const " << className << "&) = delete;" << endl;
|
||||
body << tab << className << "& operator=(const " << className << "&) = delete;" << endl;
|
||||
body << tab << className << "(" << className << "&&) = default;" << endl;
|
||||
body << tab << className << "& operator=(" << className << "&&) = default;" << endl << endl;
|
||||
body << tab << className << "(" << className << "&&) = delete;" << endl;
|
||||
body << tab << className << "& operator=(" << className << "&&) = delete;" << endl << endl;
|
||||
|
||||
body << tab << "~" << className << "() = default;" << endl << endl;
|
||||
|
||||
@ -160,7 +160,7 @@ std::string AdaptorGenerator::processInterface(Node& interface) const
|
||||
}
|
||||
|
||||
body << "private:" << endl
|
||||
<< tab << "sdbus::IObject* object_;" << endl
|
||||
<< tab << "sdbus::IObject& m_object;" << endl
|
||||
<< "};" << endl << endl
|
||||
<< std::string(namespacesCount, '}') << " // namespaces" << endl << endl;
|
||||
|
||||
@ -303,7 +303,7 @@ std::tuple<std::vector<std::string>, std::string> AdaptorGenerator::processSigna
|
||||
|
||||
signalMethodSS << tab << "void emit" << nameWithCapFirstLetter << "(" << argTypeStr << ")" << endl
|
||||
<< tab << "{" << endl
|
||||
<< tab << tab << "object_->emitSignal(\"" << name << "\")"
|
||||
<< tab << tab << "m_object.emitSignal(\"" << name << "\")"
|
||||
".onInterface(INTERFACE_NAME)";
|
||||
|
||||
if (!argStr.empty())
|
||||
@ -402,11 +402,11 @@ std::string AdaptorGenerator::createVTableRegistration(const std::string& annota
|
||||
std::ostringstream registrationSS;
|
||||
if (allRegistrations.size() == 1)
|
||||
{
|
||||
registrationSS << tab << tab << "object_->addVTable(" << allRegistrations[0] << ").forInterface(INTERFACE_NAME);";
|
||||
registrationSS << tab << tab << "m_object.addVTable(" << allRegistrations[0] << ").forInterface(INTERFACE_NAME);";
|
||||
}
|
||||
else
|
||||
{
|
||||
registrationSS << tab << tab << "object_->addVTable( " << allRegistrations[0] << endl;
|
||||
registrationSS << tab << tab << "m_object.addVTable( " << allRegistrations[0] << endl;
|
||||
for (size_t i = 1; i < allRegistrations.size(); ++i)
|
||||
registrationSS << tab << tab << " , " << allRegistrations[i] << endl;
|
||||
registrationSS << tab << tab << " ).forInterface(INTERFACE_NAME);";
|
||||
|
@ -84,15 +84,15 @@ std::string ProxyGenerator::processInterface(Node& interface) const
|
||||
<< tab << "static constexpr const char* INTERFACE_NAME = \"" << ifaceName << "\";" << endl << endl
|
||||
<< "protected:" << endl
|
||||
<< tab << className << "(sdbus::IProxy& proxy)" << endl
|
||||
<< tab << tab << ": proxy_(&proxy)" << endl
|
||||
<< tab << tab << ": m_proxy(proxy)" << endl
|
||||
<< tab << "{" << endl
|
||||
<< tab << "}" << endl << endl;
|
||||
|
||||
// Rule of Five
|
||||
body << tab << className << "(const " << className << "&) = delete;" << endl;
|
||||
body << tab << className << "& operator=(const " << className << "&) = delete;" << endl;
|
||||
body << tab << className << "(" << className << "&&) = default;" << endl;
|
||||
body << tab << className << "& operator=(" << className << "&&) = default;" << endl << endl;
|
||||
body << tab << className << "(" << className << "&&) = delete;" << endl;
|
||||
body << tab << className << "& operator=(" << className << "&&) = delete;" << endl << endl;
|
||||
|
||||
body << tab << "~" << className << "() = default;" << endl << endl;
|
||||
|
||||
@ -136,7 +136,7 @@ std::string ProxyGenerator::processInterface(Node& interface) const
|
||||
}
|
||||
|
||||
body << "private:" << endl
|
||||
<< tab << "sdbus::IProxy* proxy_;" << endl
|
||||
<< tab << "sdbus::IProxy& m_proxy;" << endl
|
||||
<< "};" << endl << endl
|
||||
<< std::string(namespacesCount, '}') << " // namespaces" << endl << endl;
|
||||
|
||||
@ -226,7 +226,7 @@ std::tuple<std::string, std::string> ProxyGenerator::processMethods(const Nodes&
|
||||
}
|
||||
|
||||
definitionSS << tab << tab << (async && !dontExpectReply ? "return " : "")
|
||||
<< "proxy_->callMethod" << (async ? "Async" : "") << "(\"" << name << "\").onInterface(INTERFACE_NAME)";
|
||||
<< "m_proxy.callMethod" << (async ? "Async" : "") << "(\"" << name << "\").onInterface(INTERFACE_NAME)";
|
||||
|
||||
if (!timeoutValue.empty())
|
||||
{
|
||||
@ -289,8 +289,8 @@ std::tuple<std::string, std::string> ProxyGenerator::processSignals(const Nodes&
|
||||
std::string argStr, argTypeStr;
|
||||
std::tie(argStr, argTypeStr, std::ignore, std::ignore) = argsToNamesAndTypes(args);
|
||||
|
||||
registrationSS << tab << tab << "proxy_"
|
||||
"->uponSignal(\"" << name << "\")"
|
||||
registrationSS << tab << tab << "m_proxy"
|
||||
".uponSignal(\"" << name << "\")"
|
||||
".onInterface(INTERFACE_NAME)"
|
||||
".call([this](" << argTypeStr << ")"
|
||||
"{ this->on" << nameBigFirst << "(" << argStr << "); });" << endl;
|
||||
@ -346,9 +346,13 @@ std::tuple<std::string, std::string> ProxyGenerator::processProperties(const Nod
|
||||
|
||||
propertySS << tab << realRetType << " " << propertyNameSafe << "()" << endl
|
||||
<< tab << "{" << endl;
|
||||
propertySS << tab << tab << "return proxy_->getProperty" << (asyncGet ? "Async" : "") << "(\"" << propertyName << "\")"
|
||||
propertySS << tab << tab << "return m_proxy.getProperty" << (asyncGet ? "Async" : "") << "(\"" << propertyName << "\")"
|
||||
".onInterface(INTERFACE_NAME)";
|
||||
if (asyncGet)
|
||||
if (!asyncGet)
|
||||
{
|
||||
propertySS << ".get<" << realRetType << ">()";
|
||||
}
|
||||
else
|
||||
{
|
||||
auto nameBigFirst = propertyName;
|
||||
nameBigFirst[0] = islower(nameBigFirst[0]) ? nameBigFirst[0] + 'A' - 'a' : nameBigFirst[0];
|
||||
@ -375,7 +379,7 @@ std::tuple<std::string, std::string> ProxyGenerator::processProperties(const Nod
|
||||
|
||||
propertySS << tab << realRetType << " " << propertyNameSafe << "(" << propertyTypeArg << ")" << endl
|
||||
<< tab << "{" << endl;
|
||||
propertySS << tab << tab << (asyncSet ? "return " : "") << "proxy_->setProperty" << (asyncSet ? "Async" : "")
|
||||
propertySS << tab << tab << (asyncSet ? "return " : "") << "m_proxy.setProperty" << (asyncSet ? "Async" : "")
|
||||
<< "(\"" << propertyName << "\")"
|
||||
".onInterface(INTERFACE_NAME)"
|
||||
".toValue(" << propertyArg << ")";
|
||||
|
Reference in New Issue
Block a user