forked from Kistler-Group/sdbus-cpp
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.
55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
|
|
/*
|
|
* This file was automatically generated by sdbus-c++-xml2cpp; DO NOT EDIT!
|
|
*/
|
|
|
|
#ifndef __sdbuscpp__examplemanager_planet1_server_glue_h__adaptor__H__
|
|
#define __sdbuscpp__examplemanager_planet1_server_glue_h__adaptor__H__
|
|
|
|
#include <sdbus-c++/sdbus-c++.h>
|
|
#include <string>
|
|
#include <tuple>
|
|
|
|
namespace org {
|
|
namespace sdbuscpp {
|
|
namespace ExampleManager {
|
|
|
|
class Planet1_adaptor
|
|
{
|
|
public:
|
|
static constexpr const char* INTERFACE_NAME = "org.sdbuscpp.ExampleManager.Planet1";
|
|
|
|
protected:
|
|
Planet1_adaptor(sdbus::IObject& object)
|
|
: m_object(object)
|
|
{
|
|
}
|
|
|
|
Planet1_adaptor(const Planet1_adaptor&) = delete;
|
|
Planet1_adaptor& operator=(const Planet1_adaptor&) = delete;
|
|
Planet1_adaptor(Planet1_adaptor&&) = delete;
|
|
Planet1_adaptor& operator=(Planet1_adaptor&&) = delete;
|
|
|
|
~Planet1_adaptor() = default;
|
|
|
|
void registerAdaptor()
|
|
{
|
|
m_object.addVTable( sdbus::registerMethod("GetPopulation").withOutputParamNames("population").implementedAs([this](){ return this->GetPopulation(); })
|
|
, sdbus::registerProperty("Name").withGetter([this](){ return this->Name(); })
|
|
).forInterface(INTERFACE_NAME);
|
|
}
|
|
|
|
private:
|
|
virtual uint64_t GetPopulation() = 0;
|
|
|
|
private:
|
|
virtual std::string Name() = 0;
|
|
|
|
private:
|
|
sdbus::IObject& m_object;
|
|
};
|
|
|
|
}}} // namespaces
|
|
|
|
#endif
|