diff --git a/docs/using-sdbus-c++.md b/docs/using-sdbus-c++.md index 7a3528d..b9b6a31 100644 --- a/docs/using-sdbus-c++.md +++ b/docs/using-sdbus-c++.md @@ -525,7 +525,7 @@ After running this through the stubs generator, we get the stub code that is des ### 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 /* @@ -555,6 +555,8 @@ protected: object_.registerSignal("concatenated").onInterface(INTERFACE_NAME).withParameters(); } + ~Concatenator_adaptor() = default; + public: 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); }); } + ~Concatenator_proxy() = default; + virtual void onConcatenated(const std::string& concatenatedString) = 0; 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); }); } + ~PropertyProvider_adaptor() = default; + private: // property getter virtual uint32_t status() = 0; // property setter virtual void status(const uint32_t& value) = 0; - + /*...*/ }; #endif @@ -1079,7 +1085,7 @@ The proxy: class PropertyProvider_proxy { /*...*/ - + public: // getting the property value uint32_t status() @@ -1092,7 +1098,7 @@ public: { object_.setProperty("status").onInterface(INTERFACE_NAME).toValue(value); } - + /*...*/ }; ``` diff --git a/include/sdbus-c++/StandardInterfaces.h b/include/sdbus-c++/StandardInterfaces.h index ca68dc2..4ed7f58 100644 --- a/include/sdbus-c++/StandardInterfaces.h +++ b/include/sdbus-c++/StandardInterfaces.h @@ -46,6 +46,8 @@ namespace sdbus { { } + ~Peer_proxy() = default; + public: void Ping() { @@ -74,6 +76,8 @@ namespace sdbus { { } + ~Introspectable_proxy() = default; + public: std::string Introspect() { @@ -106,6 +110,8 @@ namespace sdbus { }); } + ~Properties_proxy() = default; + virtual void onPropertiesChanged( const std::string& interfaceName , const std::map& changedProperties , const std::vector& invalidatedProperties ) = 0; @@ -160,6 +166,8 @@ namespace sdbus { }); } + ~ObjectManager_proxy() = default; + virtual void onInterfacesAdded( const sdbus::ObjectPath& objectPath , const std::map>& interfacesAndProperties) = 0; virtual void onInterfacesRemoved( const sdbus::ObjectPath& objectPath @@ -192,6 +200,8 @@ namespace sdbus { { } + ~Properties_adaptor() = default; + public: void emitPropertiesChangedSignal(const std::string& interfaceName, const std::vector& properties) { @@ -219,6 +229,8 @@ namespace sdbus { object_.addObjectManager(); } + ~ObjectManager_adaptor() = default; + public: void emitInterfacesAddedSignal() { diff --git a/tests/integrationtests/adaptor-glue.h b/tests/integrationtests/adaptor-glue.h index b882c3b..107ab27 100644 --- a/tests/integrationtests/adaptor-glue.h +++ b/tests/integrationtests/adaptor-glue.h @@ -52,7 +52,6 @@ using ComplexType = std::map< class testing_adaptor { - protected: testing_adaptor(sdbus::IObject& 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("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: void emitSimpleSignal() { diff --git a/tests/integrationtests/proxy-glue.h b/tests/integrationtests/proxy-glue.h index e2e4bcb..f5af414 100644 --- a/tests/integrationtests/proxy-glue.h +++ b/tests/integrationtests/proxy-glue.h @@ -45,6 +45,8 @@ protected: { this->onSignalWithoutRegistration(s); }); } + ~testing_proxy() = default; + virtual void onSimpleSignal() = 0; virtual void onSignalWithMap(const std::map& map) = 0; virtual void onSignalWithVariant(const sdbus::Variant& v) = 0; diff --git a/tests/perftests/perftests-adaptor.h b/tests/perftests/perftests-adaptor.h index f6d6b41..db2f0df 100644 --- a/tests/perftests/perftests-adaptor.h +++ b/tests/perftests/perftests-adaptor.h @@ -27,6 +27,8 @@ protected: object_.registerSignal("dataSignal").onInterface(INTERFACE_NAME).withParameters(); } + ~perftests_adaptor() = default; + public: void emitDataSignal(const std::string& data) { diff --git a/tests/perftests/perftests-proxy.h b/tests/perftests/perftests-proxy.h index 906657f..cabbdca 100644 --- a/tests/perftests/perftests-proxy.h +++ b/tests/perftests/perftests-proxy.h @@ -25,6 +25,8 @@ protected: 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; public: diff --git a/tests/stresstests/celsius-thermometer-adaptor.h b/tests/stresstests/celsius-thermometer-adaptor.h index c84f7f5..6ef3df4 100644 --- a/tests/stresstests/celsius-thermometer-adaptor.h +++ b/tests/stresstests/celsius-thermometer-adaptor.h @@ -27,6 +27,8 @@ protected: object_.registerMethod("getCurrentTemperature").onInterface(INTERFACE_NAME).implementedAs([this](){ return this->getCurrentTemperature(); }); } + ~thermometer_adaptor() = default; + private: virtual uint32_t getCurrentTemperature() = 0; diff --git a/tests/stresstests/celsius-thermometer-proxy.h b/tests/stresstests/celsius-thermometer-proxy.h index 4b5d090..c21751e 100644 --- a/tests/stresstests/celsius-thermometer-proxy.h +++ b/tests/stresstests/celsius-thermometer-proxy.h @@ -26,6 +26,8 @@ protected: { } + ~thermometer_proxy() = default; + public: uint32_t getCurrentTemperature() { diff --git a/tests/stresstests/concatenator-adaptor.h b/tests/stresstests/concatenator-adaptor.h index 8f4d987..31c38f7 100644 --- a/tests/stresstests/concatenator-adaptor.h +++ b/tests/stresstests/concatenator-adaptor.h @@ -27,6 +27,8 @@ protected: object_.registerSignal("concatenatedSignal").onInterface(INTERFACE_NAME).withParameters(); } + ~concatenator_adaptor() = default; + public: void emitConcatenatedSignal(const std::string& concatenatedString) { diff --git a/tests/stresstests/concatenator-proxy.h b/tests/stresstests/concatenator-proxy.h index 423254c..08e79ac 100644 --- a/tests/stresstests/concatenator-proxy.h +++ b/tests/stresstests/concatenator-proxy.h @@ -26,6 +26,8 @@ protected: 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 onConcatenateReply(const std::string& result, const sdbus::Error* error) = 0; diff --git a/tests/stresstests/fahrenheit-thermometer-adaptor.h b/tests/stresstests/fahrenheit-thermometer-adaptor.h index 36c7cfd..4af48d8 100644 --- a/tests/stresstests/fahrenheit-thermometer-adaptor.h +++ b/tests/stresstests/fahrenheit-thermometer-adaptor.h @@ -27,6 +27,8 @@ protected: object_.registerMethod("getCurrentTemperature").onInterface(INTERFACE_NAME).implementedAs([this](){ return this->getCurrentTemperature(); }); } + ~thermometer_adaptor() = default; + private: 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(); } + ~factory_adaptor() = default; + private: virtual void createDelegateObject(sdbus::Result&& result) = 0; virtual void destroyDelegateObject(sdbus::Result<>&& result, sdbus::ObjectPath delegate) = 0; diff --git a/tests/stresstests/fahrenheit-thermometer-proxy.h b/tests/stresstests/fahrenheit-thermometer-proxy.h index ce2a8a8..b2cb8d9 100644 --- a/tests/stresstests/fahrenheit-thermometer-proxy.h +++ b/tests/stresstests/fahrenheit-thermometer-proxy.h @@ -26,6 +26,8 @@ protected: { } + ~thermometer_proxy() = default; + public: uint32_t getCurrentTemperature() { @@ -57,6 +59,8 @@ protected: { } + ~factory_proxy() = default; + public: sdbus::ObjectPath createDelegateObject() { diff --git a/tools/xml2cpp-codegen/AdaptorGenerator.cpp b/tools/xml2cpp-codegen/AdaptorGenerator.cpp index 4c9001e..906d571 100644 --- a/tools/xml2cpp-codegen/AdaptorGenerator.cpp +++ b/tools/xml2cpp-codegen/AdaptorGenerator.cpp @@ -130,6 +130,8 @@ std::string AdaptorGenerator::processInterface(Node& interface) const << propertyRegistration << tab << "}" << endl << endl; + body << tab << "~" << className << "() = default;" << endl << endl; + if (!signalMethods.empty()) { body << "public:" << endl << signalMethods; diff --git a/tools/xml2cpp-codegen/ProxyGenerator.cpp b/tools/xml2cpp-codegen/ProxyGenerator.cpp index c2f4f58..8a57185 100644 --- a/tools/xml2cpp-codegen/ProxyGenerator.cpp +++ b/tools/xml2cpp-codegen/ProxyGenerator.cpp @@ -95,6 +95,9 @@ std::string ProxyGenerator::processInterface(Node& interface) const body << tab << "{" << endl << registration << tab << "}" << endl << endl; + + body << tab << "~" << className << "() = default;" << endl << endl; + if (!declaration.empty()) body << declaration << endl;