forked from Kistler-Group/sdbus-cpp
Add protected non-virtual destructor in generated classes
This commit is contained in:
@ -525,7 +525,7 @@ After running this through the stubs generator, we get the stub code that is des
|
|||||||
|
|
||||||
### concatenator-server-glue.h
|
### concatenator-server-glue.h
|
||||||
|
|
||||||
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 inheriting from 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.
|
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.
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
/*
|
/*
|
||||||
@ -555,6 +555,8 @@ protected:
|
|||||||
object_.registerSignal("concatenated").onInterface(INTERFACE_NAME).withParameters<std::string>();
|
object_.registerSignal("concatenated").onInterface(INTERFACE_NAME).withParameters<std::string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~Concatenator_adaptor() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void emitConcatenated(const std::string& concatenatedString)
|
void emitConcatenated(const std::string& concatenatedString)
|
||||||
{
|
{
|
||||||
@ -604,6 +606,8 @@ protected:
|
|||||||
proxy_.uponSignal("concatenated").onInterface(INTERFACE_NAME).call([this](const std::string& concatenatedString){ this->onConcatenated(concatenatedString); });
|
proxy_.uponSignal("concatenated").onInterface(INTERFACE_NAME).call([this](const std::string& concatenatedString){ this->onConcatenated(concatenatedString); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~Concatenator_proxy() = default;
|
||||||
|
|
||||||
virtual void onConcatenated(const std::string& concatenatedString) = 0;
|
virtual void onConcatenated(const std::string& concatenatedString) = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -1062,12 +1066,14 @@ public:
|
|||||||
object_.registerProperty("status").onInterface(INTERFACE_NAME).withGetter([this](){ return this->status(); }).withSetter([this](const uint32_t& value){ this->status(value); });
|
object_.registerProperty("status").onInterface(INTERFACE_NAME).withGetter([this](){ return this->status(); }).withSetter([this](const uint32_t& value){ this->status(value); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~PropertyProvider_adaptor() = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// property getter
|
// property getter
|
||||||
virtual uint32_t status() = 0;
|
virtual uint32_t status() = 0;
|
||||||
// property setter
|
// property setter
|
||||||
virtual void status(const uint32_t& value) = 0;
|
virtual void status(const uint32_t& value) = 0;
|
||||||
|
|
||||||
/*...*/
|
/*...*/
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@ -1079,7 +1085,7 @@ The proxy:
|
|||||||
class PropertyProvider_proxy
|
class PropertyProvider_proxy
|
||||||
{
|
{
|
||||||
/*...*/
|
/*...*/
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// getting the property value
|
// getting the property value
|
||||||
uint32_t status()
|
uint32_t status()
|
||||||
@ -1092,7 +1098,7 @@ public:
|
|||||||
{
|
{
|
||||||
object_.setProperty("status").onInterface(INTERFACE_NAME).toValue(value);
|
object_.setProperty("status").onInterface(INTERFACE_NAME).toValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*...*/
|
/*...*/
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
@ -46,6 +46,8 @@ namespace sdbus {
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~Peer_proxy() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void Ping()
|
void Ping()
|
||||||
{
|
{
|
||||||
@ -74,6 +76,8 @@ namespace sdbus {
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~Introspectable_proxy() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::string Introspect()
|
std::string Introspect()
|
||||||
{
|
{
|
||||||
@ -106,6 +110,8 @@ namespace sdbus {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~Properties_proxy() = default;
|
||||||
|
|
||||||
virtual void onPropertiesChanged( const std::string& interfaceName
|
virtual void onPropertiesChanged( const std::string& interfaceName
|
||||||
, const std::map<std::string, sdbus::Variant>& changedProperties
|
, const std::map<std::string, sdbus::Variant>& changedProperties
|
||||||
, const std::vector<std::string>& invalidatedProperties ) = 0;
|
, const std::vector<std::string>& invalidatedProperties ) = 0;
|
||||||
@ -160,6 +166,8 @@ namespace sdbus {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~ObjectManager_proxy() = default;
|
||||||
|
|
||||||
virtual void onInterfacesAdded( const sdbus::ObjectPath& objectPath
|
virtual void onInterfacesAdded( const sdbus::ObjectPath& objectPath
|
||||||
, const std::map<std::string, std::map<std::string, sdbus::Variant>>& interfacesAndProperties) = 0;
|
, const std::map<std::string, std::map<std::string, sdbus::Variant>>& interfacesAndProperties) = 0;
|
||||||
virtual void onInterfacesRemoved( const sdbus::ObjectPath& objectPath
|
virtual void onInterfacesRemoved( const sdbus::ObjectPath& objectPath
|
||||||
@ -192,6 +200,8 @@ namespace sdbus {
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~Properties_adaptor() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void emitPropertiesChangedSignal(const std::string& interfaceName, const std::vector<std::string>& properties)
|
void emitPropertiesChangedSignal(const std::string& interfaceName, const std::vector<std::string>& properties)
|
||||||
{
|
{
|
||||||
@ -219,6 +229,8 @@ namespace sdbus {
|
|||||||
object_.addObjectManager();
|
object_.addObjectManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~ObjectManager_adaptor() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void emitInterfacesAddedSignal()
|
void emitInterfacesAddedSignal()
|
||||||
{
|
{
|
||||||
|
@ -52,7 +52,6 @@ using ComplexType = std::map<
|
|||||||
|
|
||||||
class testing_adaptor
|
class testing_adaptor
|
||||||
{
|
{
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
testing_adaptor(sdbus::IObject& object) :
|
testing_adaptor(sdbus::IObject& object) :
|
||||||
object_(object)
|
object_(object)
|
||||||
@ -115,9 +114,10 @@ protected:
|
|||||||
object_.registerProperty("action").onInterface(INTERFACE_NAME).withGetter([this](){ return this->action(); }).withSetter([this](const uint32_t& value){ this->action(value); }).withUpdateBehavior(sdbus::Flags::EMITS_INVALIDATION_SIGNAL);
|
object_.registerProperty("action").onInterface(INTERFACE_NAME).withGetter([this](){ return this->action(); }).withSetter([this](const uint32_t& value){ this->action(value); }).withUpdateBehavior(sdbus::Flags::EMITS_INVALIDATION_SIGNAL);
|
||||||
//object_.registerProperty("blocking").onInterface(INTERFACE_NAME)./*withGetter([this](){ return this->blocking(); }).*/withSetter([this](const bool& value){ this->blocking(value); });
|
//object_.registerProperty("blocking").onInterface(INTERFACE_NAME)./*withGetter([this](){ return this->blocking(); }).*/withSetter([this](const bool& value){ this->blocking(value); });
|
||||||
object_.registerProperty("blocking").onInterface(INTERFACE_NAME).withGetter([this](){ return this->blocking(); }).withSetter([this](const bool& value){ this->blocking(value); });
|
object_.registerProperty("blocking").onInterface(INTERFACE_NAME).withGetter([this](){ return this->blocking(); }).withSetter([this](const bool& value){ this->blocking(value); });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~testing_adaptor() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void emitSimpleSignal()
|
void emitSimpleSignal()
|
||||||
{
|
{
|
||||||
|
@ -45,6 +45,8 @@ protected:
|
|||||||
{ this->onSignalWithoutRegistration(s); });
|
{ this->onSignalWithoutRegistration(s); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~testing_proxy() = default;
|
||||||
|
|
||||||
virtual void onSimpleSignal() = 0;
|
virtual void onSimpleSignal() = 0;
|
||||||
virtual void onSignalWithMap(const std::map<int32_t, std::string>& map) = 0;
|
virtual void onSignalWithMap(const std::map<int32_t, std::string>& map) = 0;
|
||||||
virtual void onSignalWithVariant(const sdbus::Variant& v) = 0;
|
virtual void onSignalWithVariant(const sdbus::Variant& v) = 0;
|
||||||
|
@ -27,6 +27,8 @@ protected:
|
|||||||
object_.registerSignal("dataSignal").onInterface(INTERFACE_NAME).withParameters<std::string>();
|
object_.registerSignal("dataSignal").onInterface(INTERFACE_NAME).withParameters<std::string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~perftests_adaptor() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void emitDataSignal(const std::string& data)
|
void emitDataSignal(const std::string& data)
|
||||||
{
|
{
|
||||||
|
@ -25,6 +25,8 @@ protected:
|
|||||||
proxy_.uponSignal("dataSignal").onInterface(INTERFACE_NAME).call([this](const std::string& data){ this->onDataSignal(data); });
|
proxy_.uponSignal("dataSignal").onInterface(INTERFACE_NAME).call([this](const std::string& data){ this->onDataSignal(data); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~perftests_proxy() = default;
|
||||||
|
|
||||||
virtual void onDataSignal(const std::string& data) = 0;
|
virtual void onDataSignal(const std::string& data) = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -27,6 +27,8 @@ protected:
|
|||||||
object_.registerMethod("getCurrentTemperature").onInterface(INTERFACE_NAME).implementedAs([this](){ return this->getCurrentTemperature(); });
|
object_.registerMethod("getCurrentTemperature").onInterface(INTERFACE_NAME).implementedAs([this](){ return this->getCurrentTemperature(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~thermometer_adaptor() = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual uint32_t getCurrentTemperature() = 0;
|
virtual uint32_t getCurrentTemperature() = 0;
|
||||||
|
|
||||||
|
@ -26,6 +26,8 @@ protected:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~thermometer_proxy() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
uint32_t getCurrentTemperature()
|
uint32_t getCurrentTemperature()
|
||||||
{
|
{
|
||||||
|
@ -27,6 +27,8 @@ protected:
|
|||||||
object_.registerSignal("concatenatedSignal").onInterface(INTERFACE_NAME).withParameters<std::string>();
|
object_.registerSignal("concatenatedSignal").onInterface(INTERFACE_NAME).withParameters<std::string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~concatenator_adaptor() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void emitConcatenatedSignal(const std::string& concatenatedString)
|
void emitConcatenatedSignal(const std::string& concatenatedString)
|
||||||
{
|
{
|
||||||
|
@ -26,6 +26,8 @@ protected:
|
|||||||
proxy_.uponSignal("concatenatedSignal").onInterface(INTERFACE_NAME).call([this](const std::string& concatenatedString){ this->onConcatenatedSignal(concatenatedString); });
|
proxy_.uponSignal("concatenatedSignal").onInterface(INTERFACE_NAME).call([this](const std::string& concatenatedString){ this->onConcatenatedSignal(concatenatedString); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~concatenator_proxy() = default;
|
||||||
|
|
||||||
virtual void onConcatenatedSignal(const std::string& concatenatedString) = 0;
|
virtual void onConcatenatedSignal(const std::string& concatenatedString) = 0;
|
||||||
|
|
||||||
virtual void onConcatenateReply(const std::string& result, const sdbus::Error* error) = 0;
|
virtual void onConcatenateReply(const std::string& result, const sdbus::Error* error) = 0;
|
||||||
|
@ -27,6 +27,8 @@ protected:
|
|||||||
object_.registerMethod("getCurrentTemperature").onInterface(INTERFACE_NAME).implementedAs([this](){ return this->getCurrentTemperature(); });
|
object_.registerMethod("getCurrentTemperature").onInterface(INTERFACE_NAME).implementedAs([this](){ return this->getCurrentTemperature(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~thermometer_adaptor() = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual uint32_t getCurrentTemperature() = 0;
|
virtual uint32_t getCurrentTemperature() = 0;
|
||||||
|
|
||||||
@ -55,6 +57,8 @@ protected:
|
|||||||
object_.registerMethod("destroyDelegateObject").onInterface(INTERFACE_NAME).implementedAs([this](sdbus::Result<>&& result, sdbus::ObjectPath delegate){ this->destroyDelegateObject(std::move(result), std::move(delegate)); }).withNoReply();
|
object_.registerMethod("destroyDelegateObject").onInterface(INTERFACE_NAME).implementedAs([this](sdbus::Result<>&& result, sdbus::ObjectPath delegate){ this->destroyDelegateObject(std::move(result), std::move(delegate)); }).withNoReply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~factory_adaptor() = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void createDelegateObject(sdbus::Result<sdbus::ObjectPath>&& result) = 0;
|
virtual void createDelegateObject(sdbus::Result<sdbus::ObjectPath>&& result) = 0;
|
||||||
virtual void destroyDelegateObject(sdbus::Result<>&& result, sdbus::ObjectPath delegate) = 0;
|
virtual void destroyDelegateObject(sdbus::Result<>&& result, sdbus::ObjectPath delegate) = 0;
|
||||||
|
@ -26,6 +26,8 @@ protected:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~thermometer_proxy() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
uint32_t getCurrentTemperature()
|
uint32_t getCurrentTemperature()
|
||||||
{
|
{
|
||||||
@ -57,6 +59,8 @@ protected:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~factory_proxy() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
sdbus::ObjectPath createDelegateObject()
|
sdbus::ObjectPath createDelegateObject()
|
||||||
{
|
{
|
||||||
|
@ -130,6 +130,8 @@ std::string AdaptorGenerator::processInterface(Node& interface) const
|
|||||||
<< propertyRegistration
|
<< propertyRegistration
|
||||||
<< tab << "}" << endl << endl;
|
<< tab << "}" << endl << endl;
|
||||||
|
|
||||||
|
body << tab << "~" << className << "() = default;" << endl << endl;
|
||||||
|
|
||||||
if (!signalMethods.empty())
|
if (!signalMethods.empty())
|
||||||
{
|
{
|
||||||
body << "public:" << endl << signalMethods;
|
body << "public:" << endl << signalMethods;
|
||||||
|
@ -95,6 +95,9 @@ std::string ProxyGenerator::processInterface(Node& interface) const
|
|||||||
body << tab << "{" << endl
|
body << tab << "{" << endl
|
||||||
<< registration
|
<< registration
|
||||||
<< tab << "}" << endl << endl;
|
<< tab << "}" << endl << endl;
|
||||||
|
|
||||||
|
body << tab << "~" << className << "() = default;" << endl << endl;
|
||||||
|
|
||||||
if (!declaration.empty())
|
if (!declaration.empty())
|
||||||
body << declaration << endl;
|
body << declaration << endl;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user