diff options
Diffstat (limited to 'src/test/commonapi')
32 files changed, 2713 insertions, 188 deletions
diff --git a/src/test/commonapi/tests/ExtendedInterfaceDBusStubAdapter.cpp b/src/test/commonapi/tests/ExtendedInterfaceDBusStubAdapter.cpp index 59cf9cd..bbfa2b8 100644 --- a/src/test/commonapi/tests/ExtendedInterfaceDBusStubAdapter.cpp +++ b/src/test/commonapi/tests/ExtendedInterfaceDBusStubAdapter.cpp @@ -68,9 +68,10 @@ CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< > ExtendedInterfaceDBusStubAdapterInternal::setTestPredefinedTypeAttributeAttributeStubDispatcher( &ExtendedInterfaceStub::getTestPredefinedTypeAttributeAttribute, &ExtendedInterfaceStubRemoteEvent::onRemoteSetTestPredefinedTypeAttributeAttribute, - &ExtendedInterfaceStubRemoteEvent::onRemoteTestPredefinedTypeAttributeAttributeChanged, - &ExtendedInterfaceStubAdapter::fireTestPredefinedTypeAttributeAttributeChanged, - "u"); + &ExtendedInterfaceStubRemoteEvent::onRemoteTestPredefinedTypeAttributeAttributeChanged + ,&ExtendedInterfaceStubAdapter::fireTestPredefinedTypeAttributeAttributeChanged + ,"u" + ); CommonAPI::DBus::DBusGetAttributeStubDispatcher< ExtendedInterfaceStub, DerivedTypeCollection::TestStructExtended @@ -81,9 +82,10 @@ CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< > ExtendedInterfaceDBusStubAdapterInternal::setTestDerivedStructAttributeAttributeStubDispatcher( &ExtendedInterfaceStub::getTestDerivedStructAttributeAttribute, &ExtendedInterfaceStubRemoteEvent::onRemoteSetTestDerivedStructAttributeAttribute, - &ExtendedInterfaceStubRemoteEvent::onRemoteTestDerivedStructAttributeAttributeChanged, - &ExtendedInterfaceStubAdapter::fireTestDerivedStructAttributeAttributeChanged, - "(sqi)"); + &ExtendedInterfaceStubRemoteEvent::onRemoteTestDerivedStructAttributeAttributeChanged + ,&ExtendedInterfaceStubAdapter::fireTestDerivedStructAttributeAttributeChanged + ,"(sqi)" + ); CommonAPI::DBus::DBusGetAttributeStubDispatcher< ExtendedInterfaceStub, DerivedTypeCollection::TestArrayUInt64 @@ -94,9 +96,10 @@ CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< > ExtendedInterfaceDBusStubAdapterInternal::setTestDerivedArrayAttributeAttributeStubDispatcher( &ExtendedInterfaceStub::getTestDerivedArrayAttributeAttribute, &ExtendedInterfaceStubRemoteEvent::onRemoteSetTestDerivedArrayAttributeAttribute, - &ExtendedInterfaceStubRemoteEvent::onRemoteTestDerivedArrayAttributeAttributeChanged, - &ExtendedInterfaceStubAdapter::fireTestDerivedArrayAttributeAttributeChanged, - "at"); + &ExtendedInterfaceStubRemoteEvent::onRemoteTestDerivedArrayAttributeAttributeChanged + ,&ExtendedInterfaceStubAdapter::fireTestDerivedArrayAttributeAttributeChanged + ,"at" + ); #endif CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< @@ -188,6 +191,9 @@ const ExtendedInterfaceDBusStubAdapterHelper::StubDispatcherTable& ExtendedInter return stubDispatcherTable_; } +const CommonAPI::DBus::StubAttributeTable& ExtendedInterfaceDBusStubAdapterInternal::getStubAttributeTable() { + return stubAttributeTable_; +} ExtendedInterfaceDBusStubAdapterInternal::ExtendedInterfaceDBusStubAdapterInternal( const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, @@ -250,7 +256,8 @@ ExtendedInterfaceDBusStubAdapterInternal::ExtendedInterfaceDBusStubAdapterIntern , { { "unsubscribeFromTestBroadcastWithOutArgsSelective", "" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::unsubscribeTestBroadcastWithOutArgsSelectiveStubDispatcher } #endif - }) { + }), + stubAttributeTable_() { #ifdef WIN32 stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::getExtendedInterfaceInterfaceVersionStubDispatcher }); @@ -264,8 +271,16 @@ ExtendedInterfaceDBusStubAdapterInternal::ExtendedInterfaceDBusStubAdapterIntern } else { stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::getExtendedInterfaceInterfaceVersionStubDispatcher }); } + + auto parentAttributeTable = TestInterfaceDBusStubAdapterInternal::getStubAttributeTable(); + stubAttributeTable_.insert(parentAttributeTable.begin(), parentAttributeTable.end()); + #endif } +const bool ExtendedInterfaceDBusStubAdapterInternal::hasFreedesktopProperties() { + return false; +} + } // namespace tests } // namespace commonapi diff --git a/src/test/commonapi/tests/ExtendedInterfaceDBusStubAdapter.h b/src/test/commonapi/tests/ExtendedInterfaceDBusStubAdapter.h index 3d2f23e..5c43471 100644 --- a/src/test/commonapi/tests/ExtendedInterfaceDBusStubAdapter.h +++ b/src/test/commonapi/tests/ExtendedInterfaceDBusStubAdapter.h @@ -42,10 +42,13 @@ class ExtendedInterfaceDBusStubAdapterInternal: public virtual ExtendedInterface ~ExtendedInterfaceDBusStubAdapterInternal(); + virtual const bool hasFreedesktopProperties(); + const ExtendedInterfaceDBusStubAdapterHelper::StubDispatcherTable& getStubDispatcherTable(); + const CommonAPI::DBus::StubAttributeTable& getStubAttributeTable(); void deactivateManagedInstances(); @@ -77,6 +80,10 @@ class ExtendedInterfaceDBusStubAdapterInternal: public virtual ExtendedInterface return ExtendedInterfaceDBusStubAdapterHelper::onInterfaceDBusMessage(dbusMessage); } + virtual bool onInterfaceDBusFreedesktopPropertiesMessage(const CommonAPI::DBus::DBusMessage& dbusMessage) { + return ExtendedInterfaceDBusStubAdapterHelper::onInterfaceDBusFreedesktopPropertiesMessage(dbusMessage); + } + static CommonAPI::DBus::DBusGetAttributeStubDispatcher< ExtendedInterfaceStub, CommonAPI::Version @@ -196,9 +203,10 @@ static CommonAPI::DBus::DBusMethodWithReplyAdapterDispatcher< protected: virtual const char* getMethodsDBusIntrospectionXmlData() const; - - private: + + private: ExtendedInterfaceDBusStubAdapterHelper::StubDispatcherTable stubDispatcherTable_; + CommonAPI::DBus::StubAttributeTable stubAttributeTable_; }; class ExtendedInterfaceDBusStubAdapter: public ExtendedInterfaceDBusStubAdapterInternal, public std::enable_shared_from_this<ExtendedInterfaceDBusStubAdapter> { diff --git a/src/test/commonapi/tests/TestFreedesktopDerivedInterface.h b/src/test/commonapi/tests/TestFreedesktopDerivedInterface.h new file mode 100644 index 0000000..ea40d73 --- /dev/null +++ b/src/test/commonapi/tests/TestFreedesktopDerivedInterface.h @@ -0,0 +1,60 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.5.qualifier. +* Used org.franca.core 0.8.10.201309262002. +* +* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +* If a copy of the MPL was not distributed with this file, You can obtain one at +* http://mozilla.org/MPL/2.0/. +*/ +#ifndef COMMONAPI_TESTS_Test_Freedesktop_Derived_Interface_H_ +#define COMMONAPI_TESTS_Test_Freedesktop_Derived_Interface_H_ + + + +#include <commonapi/tests/TestFreedesktopInterface.h> + +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#define COMMONAPI_INTERNAL_COMPILATION +#endif + +#include <CommonAPI/types.h> + +#undef COMMONAPI_INTERNAL_COMPILATION + +namespace commonapi { +namespace tests { + +class TestFreedesktopDerivedInterface: public TestFreedesktopInterface { + public: + virtual ~TestFreedesktopDerivedInterface() { } + + static inline const char* getInterfaceId(); + static inline CommonAPI::Version getInterfaceVersion(); +}; + +const char* TestFreedesktopDerivedInterface::getInterfaceId() { + static const char* interfaceId = "commonapi.tests.TestFreedesktopDerivedInterface"; + return interfaceId; +} + +CommonAPI::Version TestFreedesktopDerivedInterface::getInterfaceVersion() { + return CommonAPI::Version(1, 0); +} + + +} // namespace tests +} // namespace commonapi + +namespace CommonAPI { + +} + + +namespace std { + //hashes for types + + //hashes for error types +} + +#endif // COMMONAPI_TESTS_Test_Freedesktop_Derived_Interface_H_ diff --git a/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceDBusProxy.cpp b/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceDBusProxy.cpp new file mode 100644 index 0000000..d8b2602 --- /dev/null +++ b/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceDBusProxy.cpp @@ -0,0 +1,63 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.5.qualifier. +* Used org.franca.core 0.8.10.201309262002. +* +* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +* If a copy of the MPL was not distributed with this file, You can obtain one at +* http://mozilla.org/MPL/2.0/. +*/ +#include "TestFreedesktopDerivedInterfaceDBusProxy.h" + +namespace commonapi { +namespace tests { + +std::shared_ptr<CommonAPI::DBus::DBusProxy> createTestFreedesktopDerivedInterfaceDBusProxy( + const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, + const std::string& commonApiAddress, + const std::string& interfaceName, + const std::string& busName, + const std::string& objectPath, + const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection>& dbusProxyConnection) { + return std::make_shared<TestFreedesktopDerivedInterfaceDBusProxy>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection); +} + +INITIALIZER(registerTestFreedesktopDerivedInterfaceDBusProxy) { + CommonAPI::DBus::DBusFactory::registerProxyFactoryMethod(TestFreedesktopDerivedInterface::getInterfaceId(), + &createTestFreedesktopDerivedInterfaceDBusProxy); +} + +TestFreedesktopDerivedInterfaceDBusProxy::TestFreedesktopDerivedInterfaceDBusProxy( + const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, + const std::string& commonApiAddress, + const std::string& interfaceName, + const std::string& busName, + const std::string& objectPath, + const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection>& dbusProxyconnection): + CommonAPI::DBus::DBusProxy(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyconnection) + , TestFreedesktopInterfaceDBusProxy( + factory, + commonApiAddress, + interfaceName, + busName, + objectPath, + dbusProxyconnection) +,testAttributedFromDerivedInterface_(*this, interfaceName.c_str(), "TestAttributedFromDerivedInterface") + { + } + +TestFreedesktopDerivedInterfaceDBusProxy::TestAttributedFromDerivedInterfaceAttribute& TestFreedesktopDerivedInterfaceDBusProxy::getTestAttributedFromDerivedInterfaceAttribute() { + return testAttributedFromDerivedInterface_; +} + + + + + +void TestFreedesktopDerivedInterfaceDBusProxy::getOwnVersion(uint16_t& ownVersionMajor, uint16_t& ownVersionMinor) const { + ownVersionMajor = 1; + ownVersionMinor = 0; +} + +} // namespace tests +} // namespace commonapi diff --git a/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceDBusProxy.h b/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceDBusProxy.h new file mode 100644 index 0000000..260e3ce --- /dev/null +++ b/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceDBusProxy.h @@ -0,0 +1,61 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.5.qualifier. +* Used org.franca.core 0.8.10.201309262002. +* +* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +* If a copy of the MPL was not distributed with this file, You can obtain one at +* http://mozilla.org/MPL/2.0/. +*/ +#ifndef COMMONAPI_TESTS_Test_Freedesktop_Derived_Interface_DBUS_PROXY_H_ +#define COMMONAPI_TESTS_Test_Freedesktop_Derived_Interface_DBUS_PROXY_H_ + +#include <commonapi/tests/TestFreedesktopDerivedInterfaceProxyBase.h> +#include <commonapi/tests/TestFreedesktopInterfaceDBusProxy.h> + +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#define COMMONAPI_INTERNAL_COMPILATION +#endif + +#include <CommonAPI/DBus/DBusFactory.h> +#include <CommonAPI/DBus/DBusProxy.h> +#include <CommonAPI/DBus/DBusAttribute.h> + +#undef COMMONAPI_INTERNAL_COMPILATION + +#include <string> + +namespace commonapi { +namespace tests { + +class TestFreedesktopDerivedInterfaceDBusProxy: virtual public TestFreedesktopDerivedInterfaceProxyBase, virtual public TestFreedesktopInterfaceDBusProxy { + public: + TestFreedesktopDerivedInterfaceDBusProxy( + const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, + const std::string& commonApiAddress, + const std::string& interfaceName, + const std::string& busName, + const std::string& objectPath, + const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection>& dbusProxyconnection); + + virtual ~TestFreedesktopDerivedInterfaceDBusProxy() { } + + virtual TestAttributedFromDerivedInterfaceAttribute& getTestAttributedFromDerivedInterfaceAttribute(); + + + + + virtual void getOwnVersion(uint16_t& ownVersionMajor, uint16_t& ownVersionMinor) const; + + private: + CommonAPI::DBus::DBusFreedesktopObservableAttribute<CommonAPI::DBus::DBusFreedesktopAttribute<TestAttributedFromDerivedInterfaceAttribute>> testAttributedFromDerivedInterface_; + + +}; + + + +} // namespace tests +} // namespace commonapi + +#endif // COMMONAPI_TESTS_Test_Freedesktop_Derived_Interface_DBUS_PROXY_H_ diff --git a/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceDBusStubAdapter.cpp b/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceDBusStubAdapter.cpp new file mode 100644 index 0000000..71ac6fe --- /dev/null +++ b/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceDBusStubAdapter.cpp @@ -0,0 +1,245 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.5.qualifier. +* Used org.franca.core 0.8.10.201309262002. +* +* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +* If a copy of the MPL was not distributed with this file, You can obtain one at +* http://mozilla.org/MPL/2.0/. +*/ +#include "TestFreedesktopDerivedInterfaceDBusStubAdapter.h" +#include <commonapi/tests/TestFreedesktopDerivedInterface.h> + +namespace commonapi { +namespace tests { + +std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> createTestFreedesktopDerivedInterfaceDBusStubAdapter( + const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, + const std::string& commonApiAddress, + const std::string& interfaceName, + const std::string& busName, + const std::string& objectPath, + const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection>& dbusProxyConnection, + const std::shared_ptr<CommonAPI::StubBase>& stubBase) { + return std::make_shared<TestFreedesktopDerivedInterfaceDBusStubAdapter>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection, stubBase); +} + +INITIALIZER(registerTestFreedesktopDerivedInterfaceDBusStubAdapter) { + CommonAPI::DBus::DBusFactory::registerAdapterFactoryMethod(TestFreedesktopDerivedInterface::getInterfaceId(), + &createTestFreedesktopDerivedInterfaceDBusStubAdapter); +} + + + +TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::~TestFreedesktopDerivedInterfaceDBusStubAdapterInternal() { + deactivateManagedInstances(); + TestFreedesktopDerivedInterfaceDBusStubAdapterHelper::deinit(); +} + +void TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::deactivateManagedInstances() { + +} + +const char* TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::getMethodsDBusIntrospectionXmlData() const { + static const std::string introspectionData = + std::string(TestFreedesktopInterfaceDBusStubAdapterInternal::getMethodsDBusIntrospectionXmlData()) + + "<property name=\"TestAttributedFromDerivedInterface\" type=\"u\" access=\"readwrite\" />\n" + + ; + return introspectionData.c_str(); +} + +CommonAPI::DBus::DBusGetAttributeStubDispatcher< + TestFreedesktopDerivedInterfaceStub, + CommonAPI::Version + > TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::getTestFreedesktopDerivedInterfaceInterfaceVersionStubDispatcher(&TestFreedesktopDerivedInterfaceStub::getInterfaceVersion, "uu"); + +CommonAPI::DBus::DBusGetFreedesktopAttributeStubDispatcher< + TestFreedesktopDerivedInterfaceStub, + uint32_t + > TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::getTestAttributedFromDerivedInterfaceAttributeStubDispatcher(&TestFreedesktopDerivedInterfaceStub::getTestAttributedFromDerivedInterfaceAttribute); +CommonAPI::DBus::DBusSetFreedesktopObservableAttributeStubDispatcher< + TestFreedesktopDerivedInterfaceStub, + uint32_t + > TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::setTestAttributedFromDerivedInterfaceAttributeStubDispatcher( + &TestFreedesktopDerivedInterfaceStub::getTestAttributedFromDerivedInterfaceAttribute, + &TestFreedesktopDerivedInterfaceStubRemoteEvent::onRemoteSetTestAttributedFromDerivedInterfaceAttribute, + &TestFreedesktopDerivedInterfaceStubRemoteEvent::onRemoteTestAttributedFromDerivedInterfaceAttributeChanged + ,&TestFreedesktopDerivedInterfaceStubAdapter::fireTestAttributedFromDerivedInterfaceAttributeChanged + ); + +#ifdef WIN32 +CommonAPI::DBus::DBusGetFreedesktopAttributeStubDispatcher< + TestFreedesktopDerivedInterfaceStub, + uint32_t + > TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::getTestPredefinedTypeAttributeAttributeStubDispatcher(&TestFreedesktopDerivedInterfaceStub::getTestPredefinedTypeAttributeAttribute); +CommonAPI::DBus::DBusSetFreedesktopObservableAttributeStubDispatcher< + TestFreedesktopDerivedInterfaceStub, + uint32_t + > TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::setTestPredefinedTypeAttributeAttributeStubDispatcher( + &TestFreedesktopDerivedInterfaceStub::getTestPredefinedTypeAttributeAttribute, + &TestFreedesktopDerivedInterfaceStubRemoteEvent::onRemoteSetTestPredefinedTypeAttributeAttribute, + &TestFreedesktopDerivedInterfaceStubRemoteEvent::onRemoteTestPredefinedTypeAttributeAttributeChanged + ,&TestFreedesktopDerivedInterfaceStubAdapter::fireTestPredefinedTypeAttributeAttributeChanged + ); +CommonAPI::DBus::DBusGetFreedesktopAttributeStubDispatcher< + TestFreedesktopDerivedInterfaceStub, + uint32_t + > TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::getTestReadonlyAttributeAttributeStubDispatcher(&TestFreedesktopDerivedInterfaceStub::getTestReadonlyAttributeAttribute); +CommonAPI::DBus::DBusGetFreedesktopAttributeStubDispatcher< + TestFreedesktopDerivedInterfaceStub, + DerivedTypeCollection::TestStructExtended + > TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::getTestDerivedStructAttributeAttributeStubDispatcher(&TestFreedesktopDerivedInterfaceStub::getTestDerivedStructAttributeAttribute); +CommonAPI::DBus::DBusSetFreedesktopObservableAttributeStubDispatcher< + TestFreedesktopDerivedInterfaceStub, + DerivedTypeCollection::TestStructExtended + > TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::setTestDerivedStructAttributeAttributeStubDispatcher( + &TestFreedesktopDerivedInterfaceStub::getTestDerivedStructAttributeAttribute, + &TestFreedesktopDerivedInterfaceStubRemoteEvent::onRemoteSetTestDerivedStructAttributeAttribute, + &TestFreedesktopDerivedInterfaceStubRemoteEvent::onRemoteTestDerivedStructAttributeAttributeChanged + ,&TestFreedesktopDerivedInterfaceStubAdapter::fireTestDerivedStructAttributeAttributeChanged + ); +CommonAPI::DBus::DBusGetFreedesktopAttributeStubDispatcher< + TestFreedesktopDerivedInterfaceStub, + DerivedTypeCollection::TestArrayUInt64 + > TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::getTestDerivedArrayAttributeAttributeStubDispatcher(&TestFreedesktopDerivedInterfaceStub::getTestDerivedArrayAttributeAttribute); +CommonAPI::DBus::DBusSetFreedesktopObservableAttributeStubDispatcher< + TestFreedesktopDerivedInterfaceStub, + DerivedTypeCollection::TestArrayUInt64 + > TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::setTestDerivedArrayAttributeAttributeStubDispatcher( + &TestFreedesktopDerivedInterfaceStub::getTestDerivedArrayAttributeAttribute, + &TestFreedesktopDerivedInterfaceStubRemoteEvent::onRemoteSetTestDerivedArrayAttributeAttribute, + &TestFreedesktopDerivedInterfaceStubRemoteEvent::onRemoteTestDerivedArrayAttributeAttributeChanged + ,&TestFreedesktopDerivedInterfaceStubAdapter::fireTestDerivedArrayAttributeAttributeChanged + ); +#endif + + +#ifdef WIN32 +#endif + +void TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::fireTestAttributedFromDerivedInterfaceAttributeChanged(const uint32_t& value) { + CommonAPI::DBus::DBusStubFreedesktopPropertiesSignalHelper<CommonAPI::DBus::DBusSerializableArguments<uint32_t>> + ::sendPropertiesChangedSignal( + *this, + "TestAttributedFromDerivedInterface", + value + ); +} + + +#ifdef WIN32 +#endif + +const TestFreedesktopDerivedInterfaceDBusStubAdapterHelper::StubDispatcherTable& TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::getStubDispatcherTable() { + return stubDispatcherTable_; +} + +const CommonAPI::DBus::StubAttributeTable& TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::getStubAttributeTable() { + return stubAttributeTable_; +} + +TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::TestFreedesktopDerivedInterfaceDBusStubAdapterInternal( + const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, + const std::string& commonApiAddress, + const std::string& dbusInterfaceName, + const std::string& dbusBusName, + const std::string& dbusObjectPath, + const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection>& dbusConnection, + const std::shared_ptr<CommonAPI::StubBase>& stub): + CommonAPI::DBus::DBusStubAdapter( + factory, + commonApiAddress, + dbusInterfaceName, + dbusBusName, + dbusObjectPath, + dbusConnection, + false), + TestFreedesktopDerivedInterfaceDBusStubAdapterHelper( + factory, + commonApiAddress, + dbusInterfaceName, + dbusBusName, + dbusObjectPath, + dbusConnection, + std::dynamic_pointer_cast<TestFreedesktopDerivedInterfaceStub>(stub), + false), + TestFreedesktopInterfaceDBusStubAdapterInternal( + factory, + commonApiAddress, + dbusInterfaceName, + dbusBusName, + dbusObjectPath, + dbusConnection, + stub), + stubDispatcherTable_({ + #ifdef WIN32 + #endif + }), + stubAttributeTable_({ + { + "TestAttributedFromDerivedInterface", + { + &commonapi::tests::TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::getTestAttributedFromDerivedInterfaceAttributeStubDispatcher, + &commonapi::tests::TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::setTestAttributedFromDerivedInterfaceAttributeStubDispatcher + } + } + #ifdef WIN32 + , + { + "TestPredefinedTypeAttribute", + { + &commonapi::tests::TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::getTestPredefinedTypeAttributeAttributeStubDispatcher, + &commonapi::tests::TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::setTestPredefinedTypeAttributeAttributeStubDispatcher + } + }, + { + "TestReadonlyAttribute", + { + &commonapi::tests::TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::getTestReadonlyAttributeAttributeStubDispatcher, + NULL + } + }, + { + "TestDerivedStructAttribute", + { + &commonapi::tests::TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::getTestDerivedStructAttributeAttributeStubDispatcher, + &commonapi::tests::TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::setTestDerivedStructAttributeAttributeStubDispatcher + } + }, + { + "TestDerivedArrayAttribute", + { + &commonapi::tests::TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::getTestDerivedArrayAttributeAttributeStubDispatcher, + &commonapi::tests::TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::setTestDerivedArrayAttributeAttributeStubDispatcher + } + } + #endif + } + ) { + + #ifdef WIN32 + stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::getTestFreedesktopDerivedInterfaceInterfaceVersionStubDispatcher }); + #else + auto parentDispatcherTable = TestFreedesktopInterfaceDBusStubAdapterInternal::getStubDispatcherTable(); + stubDispatcherTable_.insert(parentDispatcherTable.begin(), parentDispatcherTable.end()); + + auto interfaceVersionGetter = stubDispatcherTable_.find({ "getInterfaceVersion", "" }); + if(interfaceVersionGetter != stubDispatcherTable_.end()) { + interfaceVersionGetter->second = &commonapi::tests::TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::getTestFreedesktopDerivedInterfaceInterfaceVersionStubDispatcher; + } else { + stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::getTestFreedesktopDerivedInterfaceInterfaceVersionStubDispatcher }); + } + + auto parentAttributeTable = TestFreedesktopInterfaceDBusStubAdapterInternal::getStubAttributeTable(); + stubAttributeTable_.insert(parentAttributeTable.begin(), parentAttributeTable.end()); + + #endif +} + +const bool TestFreedesktopDerivedInterfaceDBusStubAdapterInternal::hasFreedesktopProperties() { + return true; +} + +} // namespace tests +} // namespace commonapi diff --git a/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceDBusStubAdapter.h b/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceDBusStubAdapter.h new file mode 100644 index 0000000..c22afff --- /dev/null +++ b/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceDBusStubAdapter.h @@ -0,0 +1,180 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.5.qualifier. +* Used org.franca.core 0.8.10.201309262002. +* +* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +* If a copy of the MPL was not distributed with this file, You can obtain one at +* http://mozilla.org/MPL/2.0/. +*/ +#ifndef COMMONAPI_TESTS_Test_Freedesktop_Derived_Interface_DBUS_STUB_ADAPTER_H_ +#define COMMONAPI_TESTS_Test_Freedesktop_Derived_Interface_DBUS_STUB_ADAPTER_H_ + +#include <commonapi/tests/TestFreedesktopDerivedInterfaceStub.h> +#include <commonapi/tests/TestFreedesktopInterfaceDBusStubAdapter.h> + +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#define COMMONAPI_INTERNAL_COMPILATION +#endif + +#include <CommonAPI/DBus/DBusStubAdapterHelper.h> +#include <CommonAPI/DBus/DBusStubAdapter.h> +#include <CommonAPI/DBus/DBusFactory.h> +#include <CommonAPI/DBus/DBusServicePublisher.h> + +#undef COMMONAPI_INTERNAL_COMPILATION + +namespace commonapi { +namespace tests { + +typedef CommonAPI::DBus::DBusStubAdapterHelper<TestFreedesktopDerivedInterfaceStub> TestFreedesktopDerivedInterfaceDBusStubAdapterHelper; + +class TestFreedesktopDerivedInterfaceDBusStubAdapterInternal: public virtual TestFreedesktopDerivedInterfaceStubAdapter, public TestFreedesktopDerivedInterfaceDBusStubAdapterHelper, public TestFreedesktopInterfaceDBusStubAdapterInternal { + public: + TestFreedesktopDerivedInterfaceDBusStubAdapterInternal( + const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, + const std::string& commonApiAddress, + const std::string& dbusInterfaceName, + const std::string& dbusBusName, + const std::string& dbusObjectPath, + const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection>& dbusConnection, + const std::shared_ptr<CommonAPI::StubBase>& stub); + + ~TestFreedesktopDerivedInterfaceDBusStubAdapterInternal(); + + virtual const bool hasFreedesktopProperties(); + + void fireTestAttributedFromDerivedInterfaceAttributeChanged(const uint32_t& value); + + + + const TestFreedesktopDerivedInterfaceDBusStubAdapterHelper::StubDispatcherTable& getStubDispatcherTable(); + const CommonAPI::DBus::StubAttributeTable& getStubAttributeTable(); + + void deactivateManagedInstances(); + + virtual const std::string getAddress() const { + return DBusStubAdapter::getAddress(); + } + + virtual const std::string& getDomain() const { + return DBusStubAdapter::getDomain(); + } + + virtual const std::string& getServiceId() const { + return DBusStubAdapter::getServiceId(); + } + + virtual const std::string& getInstanceId() const { + return DBusStubAdapter::getInstanceId(); + } + + virtual void init(std::shared_ptr<DBusStubAdapter> instance) { + return TestFreedesktopDerivedInterfaceDBusStubAdapterHelper::init(instance); + } + + virtual void deinit() { + return TestFreedesktopDerivedInterfaceDBusStubAdapterHelper::deinit(); + } + + virtual bool onInterfaceDBusMessage(const CommonAPI::DBus::DBusMessage& dbusMessage) { + return TestFreedesktopDerivedInterfaceDBusStubAdapterHelper::onInterfaceDBusMessage(dbusMessage); + } + + virtual bool onInterfaceDBusFreedesktopPropertiesMessage(const CommonAPI::DBus::DBusMessage& dbusMessage) { + return TestFreedesktopDerivedInterfaceDBusStubAdapterHelper::onInterfaceDBusFreedesktopPropertiesMessage(dbusMessage); + } + +static CommonAPI::DBus::DBusGetAttributeStubDispatcher< + TestFreedesktopDerivedInterfaceStub, + CommonAPI::Version + > getTestFreedesktopDerivedInterfaceInterfaceVersionStubDispatcher; + +static CommonAPI::DBus::DBusGetFreedesktopAttributeStubDispatcher< + TestFreedesktopDerivedInterfaceStub, + uint32_t + > getTestAttributedFromDerivedInterfaceAttributeStubDispatcher; +static CommonAPI::DBus::DBusSetFreedesktopObservableAttributeStubDispatcher< + TestFreedesktopDerivedInterfaceStub, + uint32_t + > setTestAttributedFromDerivedInterfaceAttributeStubDispatcher; + +#ifdef WIN32 +static CommonAPI::DBus::DBusGetFreedesktopAttributeStubDispatcher< + TestFreedesktopDerivedInterfaceStub, + uint32_t + > getTestPredefinedTypeAttributeAttributeStubDispatcher; +static CommonAPI::DBus::DBusSetFreedesktopObservableAttributeStubDispatcher< + TestFreedesktopDerivedInterfaceStub, + uint32_t + > setTestPredefinedTypeAttributeAttributeStubDispatcher; +static CommonAPI::DBus::DBusGetFreedesktopAttributeStubDispatcher< + TestFreedesktopDerivedInterfaceStub, + uint32_t + > getTestReadonlyAttributeAttributeStubDispatcher; +static CommonAPI::DBus::DBusGetFreedesktopAttributeStubDispatcher< + TestFreedesktopDerivedInterfaceStub, + DerivedTypeCollection::TestStructExtended + > getTestDerivedStructAttributeAttributeStubDispatcher; +static CommonAPI::DBus::DBusSetFreedesktopObservableAttributeStubDispatcher< + TestFreedesktopDerivedInterfaceStub, + DerivedTypeCollection::TestStructExtended + > setTestDerivedStructAttributeAttributeStubDispatcher; +static CommonAPI::DBus::DBusGetFreedesktopAttributeStubDispatcher< + TestFreedesktopDerivedInterfaceStub, + DerivedTypeCollection::TestArrayUInt64 + > getTestDerivedArrayAttributeAttributeStubDispatcher; +static CommonAPI::DBus::DBusSetFreedesktopObservableAttributeStubDispatcher< + TestFreedesktopDerivedInterfaceStub, + DerivedTypeCollection::TestArrayUInt64 + > setTestDerivedArrayAttributeAttributeStubDispatcher; +#endif + + +#ifdef WIN32 +#endif + + +#ifdef WIN32 +#endif + + protected: + virtual const char* getMethodsDBusIntrospectionXmlData() const; + + private: + TestFreedesktopDerivedInterfaceDBusStubAdapterHelper::StubDispatcherTable stubDispatcherTable_; + CommonAPI::DBus::StubAttributeTable stubAttributeTable_; +}; + +class TestFreedesktopDerivedInterfaceDBusStubAdapter: public TestFreedesktopDerivedInterfaceDBusStubAdapterInternal, public std::enable_shared_from_this<TestFreedesktopDerivedInterfaceDBusStubAdapter> { +public: + TestFreedesktopDerivedInterfaceDBusStubAdapter( + const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, + const std::string& commonApiAddress, + const std::string& dbusInterfaceName, + const std::string& dbusBusName, + const std::string& dbusObjectPath, + const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection>& dbusConnection, + const std::shared_ptr<CommonAPI::StubBase>& stub) : + CommonAPI::DBus::DBusStubAdapter( + factory, + commonApiAddress, + dbusInterfaceName, + dbusBusName, + dbusObjectPath, + dbusConnection, + false), + TestFreedesktopDerivedInterfaceDBusStubAdapterInternal( + factory, + commonApiAddress, + dbusInterfaceName, + dbusBusName, + dbusObjectPath, + dbusConnection, + stub) { } +}; + +} // namespace tests +} // namespace commonapi + +#endif // COMMONAPI_TESTS_Test_Freedesktop_Derived_Interface_DBUS_STUB_ADAPTER_H_ diff --git a/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceProxy.h b/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceProxy.h new file mode 100644 index 0000000..c449582 --- /dev/null +++ b/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceProxy.h @@ -0,0 +1,199 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.5.qualifier. +* Used org.franca.core 0.8.10.201309262002. +* +* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +* If a copy of the MPL was not distributed with this file, You can obtain one at +* http://mozilla.org/MPL/2.0/. +*/ +#ifndef COMMONAPI_TESTS_Test_Freedesktop_Derived_Interface_PROXY_H_ +#define COMMONAPI_TESTS_Test_Freedesktop_Derived_Interface_PROXY_H_ + +#include "TestFreedesktopDerivedInterfaceProxyBase.h" + +#include "TestFreedesktopInterfaceProxy.h" + +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#define COMMONAPI_INTERNAL_COMPILATION +#endif + +#include <CommonAPI/AttributeExtension.h> +#include <CommonAPI/Factory.h> + +#undef COMMONAPI_INTERNAL_COMPILATION + +namespace commonapi { +namespace tests { + +template <typename ... _AttributeExtensions> +class TestFreedesktopDerivedInterfaceProxy: virtual public TestFreedesktopDerivedInterface, virtual public TestFreedesktopDerivedInterfaceProxyBase +, virtual public TestFreedesktopInterfaceProxy<_AttributeExtensions...> +, public _AttributeExtensions... { +public: + TestFreedesktopDerivedInterfaceProxy(std::shared_ptr<CommonAPI::Proxy> delegate); + ~TestFreedesktopDerivedInterfaceProxy(); + + typedef TestFreedesktopDerivedInterface InterfaceType; + + inline static const char* getInterfaceId() { + return(TestFreedesktopDerivedInterface::getInterfaceId()); + } + + /** + * Returns the wrapper class that provides access to the attribute TestAttributedFromDerivedInterface. + */ + virtual TestAttributedFromDerivedInterfaceAttribute& getTestAttributedFromDerivedInterfaceAttribute() { + return delegate_->getTestAttributedFromDerivedInterfaceAttribute(); + } + + + + + /** + * Returns the CommonAPI address of the remote partner this proxy communicates with. + */ + virtual std::string getAddress() const; + + /** + * Returns the domain of the remote partner this proxy communicates with. + */ + virtual const std::string& getDomain() const; + + /** + * Returns the service ID of the remote partner this proxy communicates with. + */ + virtual const std::string& getServiceId() const; + + /** + * Returns the instance ID of the remote partner this proxy communicates with. + */ + virtual const std::string& getInstanceId() const; + + /** + * Returns true if the remote partner for this proxy is currently known to be available. + */ + virtual bool isAvailable() const; + + /** + * Returns true if the remote partner for this proxy is available. + */ + virtual bool isAvailableBlocking() const; + + /** + * Returns the wrapper class that is used to (de-)register for notifications about + * the availability of the remote partner of this proxy. + */ + virtual CommonAPI::ProxyStatusEvent& getProxyStatusEvent(); + + /** + * Returns the wrapper class that is used to access version information of the remote + * partner of this proxy. + */ + virtual CommonAPI::InterfaceVersionAttribute& getInterfaceVersionAttribute(); + + private: + std::shared_ptr<TestFreedesktopDerivedInterfaceProxyBase> delegate_; +}; + +#ifdef WIN32 + typedef TestFreedesktopDerivedInterfaceProxy<CommonAPI::WINDummyAttributeExtension<CommonAPI::WINDummyAttribute>> TestFreedesktopDerivedInterfaceProxyDefault; +#else + typedef TestFreedesktopDerivedInterfaceProxy<> TestFreedesktopDerivedInterfaceProxyDefault; +#endif + +namespace TestFreedesktopDerivedInterfaceExtensions { + template <template <typename > class _ExtensionType> + class TestAttributedFromDerivedInterfaceAttributeExtension { + public: + typedef _ExtensionType<TestFreedesktopDerivedInterfaceProxyBase::TestAttributedFromDerivedInterfaceAttribute> extension_type; + + static_assert(std::is_base_of<typename CommonAPI::AttributeExtension<TestFreedesktopDerivedInterfaceProxyBase::TestAttributedFromDerivedInterfaceAttribute>, extension_type>::value, + "Not CommonAPI Attribute Extension!"); + #ifdef WIN32 + TestAttributedFromDerivedInterfaceAttributeExtension() {} + #endif + + TestAttributedFromDerivedInterfaceAttributeExtension(TestFreedesktopDerivedInterfaceProxyBase& proxy): attributeExtension_(proxy.getTestAttributedFromDerivedInterfaceAttribute()) { + } + + inline extension_type& getTestAttributedFromDerivedInterfaceAttributeExtension() { + return attributeExtension_; + } + + private: + extension_type attributeExtension_; + }; + +} // namespace TestFreedesktopDerivedInterfaceExtensions + +// +// TestFreedesktopDerivedInterfaceProxy Implementation +// +template <typename ... _AttributeExtensions> +TestFreedesktopDerivedInterfaceProxy<_AttributeExtensions...>::TestFreedesktopDerivedInterfaceProxy(std::shared_ptr<CommonAPI::Proxy> delegate): + TestFreedesktopInterfaceProxy<_AttributeExtensions...>(delegate), + _AttributeExtensions(*(std::dynamic_pointer_cast<TestFreedesktopDerivedInterfaceProxyBase>(delegate)))..., + delegate_(std::dynamic_pointer_cast<TestFreedesktopDerivedInterfaceProxyBase>(delegate)) { +} + +template <typename ... _AttributeExtensions> +TestFreedesktopDerivedInterfaceProxy<_AttributeExtensions...>::~TestFreedesktopDerivedInterfaceProxy() { +} + + +template <typename ... _AttributeExtensions> +std::string TestFreedesktopDerivedInterfaceProxy<_AttributeExtensions...>::getAddress() const { + return delegate_->getAddress(); +} + +template <typename ... _AttributeExtensions> +const std::string& TestFreedesktopDerivedInterfaceProxy<_AttributeExtensions...>::getDomain() const { + return delegate_->getDomain(); +} + +template <typename ... _AttributeExtensions> +const std::string& TestFreedesktopDerivedInterfaceProxy<_AttributeExtensions...>::getServiceId() const { + return delegate_->getServiceId(); +} + +template <typename ... _AttributeExtensions> +const std::string& TestFreedesktopDerivedInterfaceProxy<_AttributeExtensions...>::getInstanceId() const { + return delegate_->getInstanceId(); +} + +template <typename ... _AttributeExtensions> +bool TestFreedesktopDerivedInterfaceProxy<_AttributeExtensions...>::isAvailable() const { + return delegate_->isAvailable(); +} + +template <typename ... _AttributeExtensions> +bool TestFreedesktopDerivedInterfaceProxy<_AttributeExtensions...>::isAvailableBlocking() const { + return delegate_->isAvailableBlocking(); +} + +template <typename ... _AttributeExtensions> +CommonAPI::ProxyStatusEvent& TestFreedesktopDerivedInterfaceProxy<_AttributeExtensions...>::getProxyStatusEvent() { + return delegate_->getProxyStatusEvent(); +} + +template <typename ... _AttributeExtensions> +CommonAPI::InterfaceVersionAttribute& TestFreedesktopDerivedInterfaceProxy<_AttributeExtensions...>::getInterfaceVersionAttribute() { + return delegate_->getInterfaceVersionAttribute(); +} + + +} // namespace tests +} // namespace commonapi + +namespace CommonAPI { +template<template<typename > class _AttributeExtension> +struct DefaultAttributeProxyFactoryHelper<commonapi::tests::TestFreedesktopDerivedInterfaceProxy, + _AttributeExtension> { + typedef typename commonapi::tests::TestFreedesktopDerivedInterfaceProxy< + commonapi::tests::TestFreedesktopDerivedInterfaceExtensions::TestAttributedFromDerivedInterfaceAttributeExtension<_AttributeExtension> + > class_t; +}; +} + +#endif // COMMONAPI_TESTS_Test_Freedesktop_Derived_Interface_PROXY_H_ diff --git a/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceProxyBase.h b/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceProxyBase.h new file mode 100644 index 0000000..97a3c0f --- /dev/null +++ b/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceProxyBase.h @@ -0,0 +1,44 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.5.qualifier. +* Used org.franca.core 0.8.10.201309262002. +* +* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +* If a copy of the MPL was not distributed with this file, You can obtain one at +* http://mozilla.org/MPL/2.0/. +*/ +#ifndef COMMONAPI_TESTS_Test_Freedesktop_Derived_Interface_PROXY_BASE_H_ +#define COMMONAPI_TESTS_Test_Freedesktop_Derived_Interface_PROXY_BASE_H_ + +#include "TestFreedesktopDerivedInterface.h" +#include "TestFreedesktopInterfaceProxyBase.h" + + + +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#define COMMONAPI_INTERNAL_COMPILATION +#endif + + +#include <CommonAPI/Attribute.h> +#include <CommonAPI/Proxy.h> + +#undef COMMONAPI_INTERNAL_COMPILATION + +namespace commonapi { +namespace tests { + +class TestFreedesktopDerivedInterfaceProxyBase: virtual public TestFreedesktopInterfaceProxyBase { + public: + typedef CommonAPI::ObservableAttribute<uint32_t> TestAttributedFromDerivedInterfaceAttribute; + + + virtual TestAttributedFromDerivedInterfaceAttribute& getTestAttributedFromDerivedInterfaceAttribute() = 0; + + +}; + +} // namespace tests +} // namespace commonapi + +#endif // COMMONAPI_TESTS_Test_Freedesktop_Derived_Interface_PROXY_BASE_H_ diff --git a/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceStub.h b/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceStub.h new file mode 100644 index 0000000..c81a7d2 --- /dev/null +++ b/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceStub.h @@ -0,0 +1,102 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.5.qualifier. +* Used org.franca.core 0.8.10.201309262002. +* +* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +* If a copy of the MPL was not distributed with this file, You can obtain one at +* http://mozilla.org/MPL/2.0/. +*/ +#ifndef COMMONAPI_TESTS_Test_Freedesktop_Derived_Interface_STUB_H_ +#define COMMONAPI_TESTS_Test_Freedesktop_Derived_Interface_STUB_H_ + + + +#include <commonapi/tests/TestFreedesktopInterfaceStub.h> + +#include "TestFreedesktopDerivedInterface.h" + +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#define COMMONAPI_INTERNAL_COMPILATION +#endif + + +#include <CommonAPI/Stub.h> + +#undef COMMONAPI_INTERNAL_COMPILATION + +namespace commonapi { +namespace tests { + +/** + * Receives messages from remote and handles all dispatching of deserialized calls + * to a stub for the service TestFreedesktopDerivedInterface. Also provides means to send broadcasts + * and attribute-changed-notifications of observable attributes as defined by this service. + * An application developer should not need to bother with this class. + */ +class TestFreedesktopDerivedInterfaceStubAdapter: virtual public CommonAPI::StubAdapter, public TestFreedesktopDerivedInterface, public virtual TestFreedesktopInterfaceStubAdapter { + public: + ///Notifies all remote listeners about a change of value of the attribute TestAttributedFromDerivedInterface. + virtual void fireTestAttributedFromDerivedInterfaceAttributeChanged(const uint32_t& TestAttributedFromDerivedInterface) = 0; + + + + virtual void deactivateManagedInstances() = 0; +protected: + /** + * Defines properties for storing the ClientIds of clients / proxies that have + * subscribed to the selective broadcasts + */ +}; + + +/** + * Defines the necessary callbacks to handle remote set events related to the attributes + * defined in the IDL description for TestFreedesktopDerivedInterface. + * For each attribute two callbacks are defined: + * - a verification callback that allows to verify the requested value and to prevent setting + * e.g. an invalid value ("onRemoteSet<AttributeName>"). + * - an action callback to do local work after the attribute value has been changed + * ("onRemote<AttributeName>Changed"). + * + * This class and the one below are the ones an application developer needs to have + * a look at if he wants to implement a service. + */ +class TestFreedesktopDerivedInterfaceStubRemoteEvent: public virtual TestFreedesktopInterfaceStubRemoteEvent { + public: + virtual ~TestFreedesktopDerivedInterfaceStubRemoteEvent() { } + + /// Verification callback for remote set requests on the attribute TestAttributedFromDerivedInterface + virtual bool onRemoteSetTestAttributedFromDerivedInterfaceAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId, uint32_t TestAttributedFromDerivedInterface) = 0; + /// Action callback for remote set requests on the attribute TestAttributedFromDerivedInterface + virtual void onRemoteTestAttributedFromDerivedInterfaceAttributeChanged() = 0; + +}; + + +/** + * Defines the interface that must be implemented by any class that should provide + * the service TestFreedesktopDerivedInterface to remote clients. + * This class and the one above are the ones an application developer needs to have + * a look at if he wants to implement a service. + */ +class TestFreedesktopDerivedInterfaceStub: public virtual CommonAPI::Stub<TestFreedesktopDerivedInterfaceStubAdapter, TestFreedesktopDerivedInterfaceStubRemoteEvent>, public virtual TestFreedesktopInterfaceStub { +public: + virtual ~TestFreedesktopDerivedInterfaceStub() { } + virtual const CommonAPI::Version& getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId) = 0; + + /// Provides getter access to the attribute TestAttributedFromDerivedInterface + virtual const uint32_t& getTestAttributedFromDerivedInterfaceAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId) = 0; + + + using CommonAPI::Stub<TestFreedesktopDerivedInterfaceStubAdapter, TestFreedesktopDerivedInterfaceStubRemoteEvent>::initStubAdapter; + typedef CommonAPI::Stub<TestFreedesktopDerivedInterfaceStubAdapter, TestFreedesktopDerivedInterfaceStubRemoteEvent>::StubAdapterType StubAdapterType; + typedef CommonAPI::Stub<TestFreedesktopDerivedInterfaceStubAdapter, TestFreedesktopDerivedInterfaceStubRemoteEvent>::RemoteEventHandlerType RemoteEventHandlerType; + typedef TestFreedesktopDerivedInterfaceStubRemoteEvent RemoteEventType; + typedef TestFreedesktopDerivedInterface StubInterface; +}; + +} // namespace tests +} // namespace commonapi + +#endif // COMMONAPI_TESTS_Test_Freedesktop_Derived_Interface_STUB_H_ diff --git a/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceStubDefault.cpp b/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceStubDefault.cpp new file mode 100644 index 0000000..44ef5a0 --- /dev/null +++ b/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceStubDefault.cpp @@ -0,0 +1,88 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.5.qualifier. +* Used org.franca.core 0.8.10.201309262002. +* +* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +* If a copy of the MPL was not distributed with this file, You can obtain one at +* http://mozilla.org/MPL/2.0/. +*/ +#include <commonapi/tests/TestFreedesktopDerivedInterfaceStubDefault.h> + +namespace commonapi { +namespace tests { + +TestFreedesktopDerivedInterfaceStubDefault::TestFreedesktopDerivedInterfaceStubDefault(): + remoteEventHandler_(this), + interfaceVersion_(TestFreedesktopDerivedInterface::getInterfaceVersion()) { +} + +const CommonAPI::Version& TestFreedesktopDerivedInterfaceStubDefault::getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId) { + return interfaceVersion_; +} + +TestFreedesktopDerivedInterfaceStubRemoteEvent* TestFreedesktopDerivedInterfaceStubDefault::initStubAdapter(const std::shared_ptr<TestFreedesktopDerivedInterfaceStubAdapter>& stubAdapter) { + TestFreedesktopInterfaceStubDefault::initStubAdapter(stubAdapter); + CommonAPI::Stub<TestFreedesktopDerivedInterfaceStubAdapter, TestFreedesktopDerivedInterfaceStubRemoteEvent>::stubAdapter_ = stubAdapter; + return &remoteEventHandler_; +} + +const uint32_t& TestFreedesktopDerivedInterfaceStubDefault::getTestAttributedFromDerivedInterfaceAttribute() { + return testAttributedFromDerivedInterfaceAttributeValue_; +} + +const uint32_t& TestFreedesktopDerivedInterfaceStubDefault::getTestAttributedFromDerivedInterfaceAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId) { + return getTestAttributedFromDerivedInterfaceAttribute(); +} + +void TestFreedesktopDerivedInterfaceStubDefault::setTestAttributedFromDerivedInterfaceAttribute(uint32_t value) { + const bool valueChanged = trySetTestAttributedFromDerivedInterfaceAttribute(std::move(value)); + if (valueChanged) { + CommonAPI::Stub<TestFreedesktopDerivedInterfaceStubAdapter, TestFreedesktopDerivedInterfaceStubRemoteEvent>::stubAdapter_->fireTestAttributedFromDerivedInterfaceAttributeChanged(testAttributedFromDerivedInterfaceAttributeValue_); + } +} + +bool TestFreedesktopDerivedInterfaceStubDefault::trySetTestAttributedFromDerivedInterfaceAttribute(uint32_t value) { + if (!validateTestAttributedFromDerivedInterfaceAttributeRequestedValue(value)) + return false; + + const bool valueChanged = (testAttributedFromDerivedInterfaceAttributeValue_ != value); + testAttributedFromDerivedInterfaceAttributeValue_ = std::move(value); + return valueChanged; +} + +bool TestFreedesktopDerivedInterfaceStubDefault::validateTestAttributedFromDerivedInterfaceAttributeRequestedValue(const uint32_t& value) { + return true; +} + +void TestFreedesktopDerivedInterfaceStubDefault::setTestAttributedFromDerivedInterfaceAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId, uint32_t value) { + setTestAttributedFromDerivedInterfaceAttribute(value); +} + +void TestFreedesktopDerivedInterfaceStubDefault::onRemoteTestAttributedFromDerivedInterfaceAttributeChanged() { + // No operation in default +} + +void TestFreedesktopDerivedInterfaceStubDefault::RemoteEventHandler::onRemoteTestAttributedFromDerivedInterfaceAttributeChanged() { + defaultStub_->onRemoteTestAttributedFromDerivedInterfaceAttributeChanged(); +} + +bool TestFreedesktopDerivedInterfaceStubDefault::RemoteEventHandler::onRemoteSetTestAttributedFromDerivedInterfaceAttribute(uint32_t value) { + return defaultStub_->trySetTestAttributedFromDerivedInterfaceAttribute(std::move(value)); +} + +bool TestFreedesktopDerivedInterfaceStubDefault::RemoteEventHandler::onRemoteSetTestAttributedFromDerivedInterfaceAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId, uint32_t value) { + return onRemoteSetTestAttributedFromDerivedInterfaceAttribute(value); +} + + + + + +TestFreedesktopDerivedInterfaceStubDefault::RemoteEventHandler::RemoteEventHandler(TestFreedesktopDerivedInterfaceStubDefault* defaultStub): + TestFreedesktopInterfaceStubDefault::RemoteEventHandler(defaultStub), + defaultStub_(defaultStub) { +} + +} // namespace tests +} // namespace commonapi diff --git a/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceStubDefault.h b/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceStubDefault.h new file mode 100644 index 0000000..22f88d5 --- /dev/null +++ b/src/test/commonapi/tests/TestFreedesktopDerivedInterfaceStubDefault.h @@ -0,0 +1,74 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.5.qualifier. +* Used org.franca.core 0.8.10.201309262002. +* +* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +* If a copy of the MPL was not distributed with this file, You can obtain one at +* http://mozilla.org/MPL/2.0/. +*/ +#ifndef COMMONAPI_TESTS_Test_Freedesktop_Derived_Interface_STUB_DEFAULT_H_ +#define COMMONAPI_TESTS_Test_Freedesktop_Derived_Interface_STUB_DEFAULT_H_ + +#include <commonapi/tests/TestFreedesktopInterfaceStubDefault.h> + +#include <commonapi/tests/TestFreedesktopDerivedInterfaceStub.h> +#include <sstream> + +namespace commonapi { +namespace tests { + +/** + * Provides a default implementation for TestFreedesktopDerivedInterfaceStubRemoteEvent and + * TestFreedesktopDerivedInterfaceStub. Method callbacks have an empty implementation, + * remote set calls on attributes will always change the value of the attribute + * to the one received. + * + * Override this stub if you only want to provide a subset of the functionality + * that would be defined for this service, and/or if you do not need any non-default + * behaviour. + */ +class TestFreedesktopDerivedInterfaceStubDefault : public virtual TestFreedesktopDerivedInterfaceStub, public virtual TestFreedesktopInterfaceStubDefault { +public: + TestFreedesktopDerivedInterfaceStubDefault(); + + TestFreedesktopDerivedInterfaceStubRemoteEvent* initStubAdapter(const std::shared_ptr<TestFreedesktopDerivedInterfaceStubAdapter>& stubAdapter); + + const CommonAPI::Version& getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId); + + virtual const uint32_t& getTestAttributedFromDerivedInterfaceAttribute(); + virtual const uint32_t& getTestAttributedFromDerivedInterfaceAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId); + virtual void setTestAttributedFromDerivedInterfaceAttribute(uint32_t value); + virtual void setTestAttributedFromDerivedInterfaceAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId, uint32_t value); + + + + +protected: + virtual bool trySetTestAttributedFromDerivedInterfaceAttribute(uint32_t value); + virtual bool validateTestAttributedFromDerivedInterfaceAttributeRequestedValue(const uint32_t& value); + virtual void onRemoteTestAttributedFromDerivedInterfaceAttributeChanged(); + class RemoteEventHandler: public virtual TestFreedesktopDerivedInterfaceStubRemoteEvent, public virtual TestFreedesktopInterfaceStubDefault::RemoteEventHandler { + public: + RemoteEventHandler(TestFreedesktopDerivedInterfaceStubDefault* defaultStub); + + virtual bool onRemoteSetTestAttributedFromDerivedInterfaceAttribute(uint32_t value); + virtual bool onRemoteSetTestAttributedFromDerivedInterfaceAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId, uint32_t value); + virtual void onRemoteTestAttributedFromDerivedInterfaceAttributeChanged(); + + + private: + TestFreedesktopDerivedInterfaceStubDefault* defaultStub_; + }; +private: + TestFreedesktopDerivedInterfaceStubDefault::RemoteEventHandler remoteEventHandler_; + + uint32_t testAttributedFromDerivedInterfaceAttributeValue_; + + CommonAPI::Version interfaceVersion_; +}; + +} // namespace tests +} // namespace commonapi + +#endif // COMMONAPI_TESTS_Test_Freedesktop_Derived_Interface_STUB_DEFAULT_H_ diff --git a/src/test/commonapi/tests/TestFreedesktopInterface.h b/src/test/commonapi/tests/TestFreedesktopInterface.h new file mode 100644 index 0000000..7b97b15 --- /dev/null +++ b/src/test/commonapi/tests/TestFreedesktopInterface.h @@ -0,0 +1,59 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.5.qualifier. +* Used org.franca.core 0.8.10.201309262002. +* +* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +* If a copy of the MPL was not distributed with this file, You can obtain one at +* http://mozilla.org/MPL/2.0/. +*/ +#ifndef COMMONAPI_TESTS_Test_Freedesktop_Interface_H_ +#define COMMONAPI_TESTS_Test_Freedesktop_Interface_H_ + + + + +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#define COMMONAPI_INTERNAL_COMPILATION +#endif + +#include <CommonAPI/types.h> + +#undef COMMONAPI_INTERNAL_COMPILATION + +namespace commonapi { +namespace tests { + +class TestFreedesktopInterface { + public: + virtual ~TestFreedesktopInterface() { } + + static inline const char* getInterfaceId(); + static inline CommonAPI::Version getInterfaceVersion(); +}; + +const char* TestFreedesktopInterface::getInterfaceId() { + static const char* interfaceId = "commonapi.tests.TestFreedesktopInterface"; + return interfaceId; +} + +CommonAPI::Version TestFreedesktopInterface::getInterfaceVersion() { + return CommonAPI::Version(1, 0); +} + + +} // namespace tests +} // namespace commonapi + +namespace CommonAPI { + +} + + +namespace std { + //hashes for types + + //hashes for error types +} + +#endif // COMMONAPI_TESTS_Test_Freedesktop_Interface_H_ diff --git a/src/test/commonapi/tests/TestFreedesktopInterfaceDBusProxy.cpp b/src/test/commonapi/tests/TestFreedesktopInterfaceDBusProxy.cpp new file mode 100644 index 0000000..ad98cec --- /dev/null +++ b/src/test/commonapi/tests/TestFreedesktopInterfaceDBusProxy.cpp @@ -0,0 +1,68 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.5.qualifier. +* Used org.franca.core 0.8.10.201309262002. +* +* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +* If a copy of the MPL was not distributed with this file, You can obtain one at +* http://mozilla.org/MPL/2.0/. +*/ +#include "TestFreedesktopInterfaceDBusProxy.h" + +namespace commonapi { +namespace tests { + +std::shared_ptr<CommonAPI::DBus::DBusProxy> createTestFreedesktopInterfaceDBusProxy( + const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, + const std::string& commonApiAddress, + const std::string& interfaceName, + const std::string& busName, + const std::string& objectPath, + const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection>& dbusProxyConnection) { + return std::make_shared<TestFreedesktopInterfaceDBusProxy>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection); +} + +INITIALIZER(registerTestFreedesktopInterfaceDBusProxy) { + CommonAPI::DBus::DBusFactory::registerProxyFactoryMethod(TestFreedesktopInterface::getInterfaceId(), + &createTestFreedesktopInterfaceDBusProxy); +} + +TestFreedesktopInterfaceDBusProxy::TestFreedesktopInterfaceDBusProxy( + const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, + const std::string& commonApiAddress, + const std::string& interfaceName, + const std::string& busName, + const std::string& objectPath, + const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection>& dbusProxyconnection): + CommonAPI::DBus::DBusProxy(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyconnection) +,testPredefinedTypeAttribute_(*this, interfaceName.c_str(), "TestPredefinedTypeAttribute"), +testReadonlyAttribute_(*this, interfaceName.c_str(), "TestReadonlyAttribute"), +testDerivedStructAttribute_(*this, interfaceName.c_str(), "TestDerivedStructAttribute"), +testDerivedArrayAttribute_(*this, interfaceName.c_str(), "TestDerivedArrayAttribute") + { + } + +TestFreedesktopInterfaceDBusProxy::TestPredefinedTypeAttributeAttribute& TestFreedesktopInterfaceDBusProxy::getTestPredefinedTypeAttributeAttribute() { + return testPredefinedTypeAttribute_; +} +TestFreedesktopInterfaceDBusProxy::TestReadonlyAttributeAttribute& TestFreedesktopInterfaceDBusProxy::getTestReadonlyAttributeAttribute() { + return testReadonlyAttribute_; +} +TestFreedesktopInterfaceDBusProxy::TestDerivedStructAttributeAttribute& TestFreedesktopInterfaceDBusProxy::getTestDerivedStructAttributeAttribute() { + return testDerivedStructAttribute_; +} +TestFreedesktopInterfaceDBusProxy::TestDerivedArrayAttributeAttribute& TestFreedesktopInterfaceDBusProxy::getTestDerivedArrayAttributeAttribute() { + return testDerivedArrayAttribute_; +} + + + + + +void TestFreedesktopInterfaceDBusProxy::getOwnVersion(uint16_t& ownVersionMajor, uint16_t& ownVersionMinor) const { + ownVersionMajor = 1; + ownVersionMinor = 0; +} + +} // namespace tests +} // namespace commonapi diff --git a/src/test/commonapi/tests/TestFreedesktopInterfaceDBusProxy.h b/src/test/commonapi/tests/TestFreedesktopInterfaceDBusProxy.h new file mode 100644 index 0000000..869fa29 --- /dev/null +++ b/src/test/commonapi/tests/TestFreedesktopInterfaceDBusProxy.h @@ -0,0 +1,66 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.5.qualifier. +* Used org.franca.core 0.8.10.201309262002. +* +* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +* If a copy of the MPL was not distributed with this file, You can obtain one at +* http://mozilla.org/MPL/2.0/. +*/ +#ifndef COMMONAPI_TESTS_Test_Freedesktop_Interface_DBUS_PROXY_H_ +#define COMMONAPI_TESTS_Test_Freedesktop_Interface_DBUS_PROXY_H_ + +#include <commonapi/tests/TestFreedesktopInterfaceProxyBase.h> + +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#define COMMONAPI_INTERNAL_COMPILATION +#endif + +#include <CommonAPI/DBus/DBusFactory.h> +#include <CommonAPI/DBus/DBusProxy.h> +#include <CommonAPI/DBus/DBusAttribute.h> + +#undef COMMONAPI_INTERNAL_COMPILATION + +#include <string> + +namespace commonapi { +namespace tests { + +class TestFreedesktopInterfaceDBusProxy: virtual public TestFreedesktopInterfaceProxyBase, virtual public CommonAPI::DBus::DBusProxy { + public: + TestFreedesktopInterfaceDBusProxy( + const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, + const std::string& commonApiAddress, + const std::string& interfaceName, + const std::string& busName, + const std::string& objectPath, + const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection>& dbusProxyconnection); + + virtual ~TestFreedesktopInterfaceDBusProxy() { } + + virtual TestPredefinedTypeAttributeAttribute& getTestPredefinedTypeAttributeAttribute(); + virtual TestReadonlyAttributeAttribute& getTestReadonlyAttributeAttribute(); + virtual TestDerivedStructAttributeAttribute& getTestDerivedStructAttributeAttribute(); + virtual TestDerivedArrayAttributeAttribute& getTestDerivedArrayAttributeAttribute(); + + + + + virtual void getOwnVersion(uint16_t& ownVersionMajor, uint16_t& ownVersionMinor) const; + + private: + CommonAPI::DBus::DBusFreedesktopObservableAttribute<CommonAPI::DBus::DBusFreedesktopAttribute<TestPredefinedTypeAttributeAttribute>> testPredefinedTypeAttribute_; + CommonAPI::DBus::DBusFreedesktopObservableAttribute<CommonAPI::DBus::DBusFreedesktopReadonlyAttribute<TestReadonlyAttributeAttribute>> testReadonlyAttribute_; + CommonAPI::DBus::DBusFreedesktopObservableAttribute<CommonAPI::DBus::DBusFreedesktopAttribute<TestDerivedStructAttributeAttribute>> testDerivedStructAttribute_; + CommonAPI::DBus::DBusFreedesktopObservableAttribute<CommonAPI::DBus::DBusFreedesktopAttribute<TestDerivedArrayAttributeAttribute>> testDerivedArrayAttribute_; + + +}; + + + +} // namespace tests +} // namespace commonapi + +#endif // COMMONAPI_TESTS_Test_Freedesktop_Interface_DBUS_PROXY_H_ diff --git a/src/test/commonapi/tests/TestFreedesktopInterfaceDBusStubAdapter.cpp b/src/test/commonapi/tests/TestFreedesktopInterfaceDBusStubAdapter.cpp new file mode 100644 index 0000000..22317d2 --- /dev/null +++ b/src/test/commonapi/tests/TestFreedesktopInterfaceDBusStubAdapter.cpp @@ -0,0 +1,219 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.5.qualifier. +* Used org.franca.core 0.8.10.201309262002. +* +* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +* If a copy of the MPL was not distributed with this file, You can obtain one at +* http://mozilla.org/MPL/2.0/. +*/ +#include "TestFreedesktopInterfaceDBusStubAdapter.h" +#include <commonapi/tests/TestFreedesktopInterface.h> + +namespace commonapi { +namespace tests { + +std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> createTestFreedesktopInterfaceDBusStubAdapter( + const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, + const std::string& commonApiAddress, + const std::string& interfaceName, + const std::string& busName, + const std::string& objectPath, + const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection>& dbusProxyConnection, + const std::shared_ptr<CommonAPI::StubBase>& stubBase) { + return std::make_shared<TestFreedesktopInterfaceDBusStubAdapter>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection, stubBase); +} + +INITIALIZER(registerTestFreedesktopInterfaceDBusStubAdapter) { + CommonAPI::DBus::DBusFactory::registerAdapterFactoryMethod(TestFreedesktopInterface::getInterfaceId(), + &createTestFreedesktopInterfaceDBusStubAdapter); +} + + + +TestFreedesktopInterfaceDBusStubAdapterInternal::~TestFreedesktopInterfaceDBusStubAdapterInternal() { + deactivateManagedInstances(); + TestFreedesktopInterfaceDBusStubAdapterHelper::deinit(); +} + +void TestFreedesktopInterfaceDBusStubAdapterInternal::deactivateManagedInstances() { + +} + +const char* TestFreedesktopInterfaceDBusStubAdapterInternal::getMethodsDBusIntrospectionXmlData() const { + static const std::string introspectionData = + "<method name=\"getInterfaceVersion\">\n" + "<arg name=\"value\" type=\"uu\" direction=\"out\" />" + "</method>\n" + "<property name=\"TestPredefinedTypeAttribute\" type=\"u\" access=\"readwrite\" />\n" + "<property name=\"TestReadonlyAttribute\" type=\"u\" access=\"read\" />\n" + "<property name=\"TestDerivedStructAttribute\" type=\"(sqi)\" access=\"readwrite\" />\n" + "<property name=\"TestDerivedArrayAttribute\" type=\"at\" access=\"readwrite\" />\n" + + ; + return introspectionData.c_str(); +} + +CommonAPI::DBus::DBusGetAttributeStubDispatcher< + TestFreedesktopInterfaceStub, + CommonAPI::Version + > TestFreedesktopInterfaceDBusStubAdapterInternal::getTestFreedesktopInterfaceInterfaceVersionStubDispatcher(&TestFreedesktopInterfaceStub::getInterfaceVersion, "uu"); + +CommonAPI::DBus::DBusGetFreedesktopAttributeStubDispatcher< + TestFreedesktopInterfaceStub, + uint32_t + > TestFreedesktopInterfaceDBusStubAdapterInternal::getTestPredefinedTypeAttributeAttributeStubDispatcher(&TestFreedesktopInterfaceStub::getTestPredefinedTypeAttributeAttribute); +CommonAPI::DBus::DBusSetFreedesktopObservableAttributeStubDispatcher< + TestFreedesktopInterfaceStub, + uint32_t + > TestFreedesktopInterfaceDBusStubAdapterInternal::setTestPredefinedTypeAttributeAttributeStubDispatcher( + &TestFreedesktopInterfaceStub::getTestPredefinedTypeAttributeAttribute, + &TestFreedesktopInterfaceStubRemoteEvent::onRemoteSetTestPredefinedTypeAttributeAttribute, + &TestFreedesktopInterfaceStubRemoteEvent::onRemoteTestPredefinedTypeAttributeAttributeChanged + ,&TestFreedesktopInterfaceStubAdapter::fireTestPredefinedTypeAttributeAttributeChanged + ); +CommonAPI::DBus::DBusGetFreedesktopAttributeStubDispatcher< + TestFreedesktopInterfaceStub, + uint32_t + > TestFreedesktopInterfaceDBusStubAdapterInternal::getTestReadonlyAttributeAttributeStubDispatcher(&TestFreedesktopInterfaceStub::getTestReadonlyAttributeAttribute); +CommonAPI::DBus::DBusGetFreedesktopAttributeStubDispatcher< + TestFreedesktopInterfaceStub, + DerivedTypeCollection::TestStructExtended + > TestFreedesktopInterfaceDBusStubAdapterInternal::getTestDerivedStructAttributeAttributeStubDispatcher(&TestFreedesktopInterfaceStub::getTestDerivedStructAttributeAttribute); +CommonAPI::DBus::DBusSetFreedesktopObservableAttributeStubDispatcher< + TestFreedesktopInterfaceStub, + DerivedTypeCollection::TestStructExtended + > TestFreedesktopInterfaceDBusStubAdapterInternal::setTestDerivedStructAttributeAttributeStubDispatcher( + &TestFreedesktopInterfaceStub::getTestDerivedStructAttributeAttribute, + &TestFreedesktopInterfaceStubRemoteEvent::onRemoteSetTestDerivedStructAttributeAttribute, + &TestFreedesktopInterfaceStubRemoteEvent::onRemoteTestDerivedStructAttributeAttributeChanged + ,&TestFreedesktopInterfaceStubAdapter::fireTestDerivedStructAttributeAttributeChanged + ); +CommonAPI::DBus::DBusGetFreedesktopAttributeStubDispatcher< + TestFreedesktopInterfaceStub, + DerivedTypeCollection::TestArrayUInt64 + > TestFreedesktopInterfaceDBusStubAdapterInternal::getTestDerivedArrayAttributeAttributeStubDispatcher(&TestFreedesktopInterfaceStub::getTestDerivedArrayAttributeAttribute); +CommonAPI::DBus::DBusSetFreedesktopObservableAttributeStubDispatcher< + TestFreedesktopInterfaceStub, + DerivedTypeCollection::TestArrayUInt64 + > TestFreedesktopInterfaceDBusStubAdapterInternal::setTestDerivedArrayAttributeAttributeStubDispatcher( + &TestFreedesktopInterfaceStub::getTestDerivedArrayAttributeAttribute, + &TestFreedesktopInterfaceStubRemoteEvent::onRemoteSetTestDerivedArrayAttributeAttribute, + &TestFreedesktopInterfaceStubRemoteEvent::onRemoteTestDerivedArrayAttributeAttributeChanged + ,&TestFreedesktopInterfaceStubAdapter::fireTestDerivedArrayAttributeAttributeChanged + ); + + + + +void TestFreedesktopInterfaceDBusStubAdapterInternal::fireTestPredefinedTypeAttributeAttributeChanged(const uint32_t& value) { + CommonAPI::DBus::DBusStubFreedesktopPropertiesSignalHelper<CommonAPI::DBus::DBusSerializableArguments<uint32_t>> + ::sendPropertiesChangedSignal( + *this, + "TestPredefinedTypeAttribute", + value + ); +} +void TestFreedesktopInterfaceDBusStubAdapterInternal::fireTestReadonlyAttributeAttributeChanged(const uint32_t& value) { + CommonAPI::DBus::DBusStubFreedesktopPropertiesSignalHelper<CommonAPI::DBus::DBusSerializableArguments<uint32_t>> + ::sendPropertiesChangedSignal( + *this, + "TestReadonlyAttribute", + value + ); +} +void TestFreedesktopInterfaceDBusStubAdapterInternal::fireTestDerivedStructAttributeAttributeChanged(const DerivedTypeCollection::TestStructExtended& value) { + CommonAPI::DBus::DBusStubFreedesktopPropertiesSignalHelper<CommonAPI::DBus::DBusSerializableArguments<DerivedTypeCollection::TestStructExtended>> + ::sendPropertiesChangedSignal( + *this, + "TestDerivedStructAttribute", + value + ); +} +void TestFreedesktopInterfaceDBusStubAdapterInternal::fireTestDerivedArrayAttributeAttributeChanged(const DerivedTypeCollection::TestArrayUInt64& value) { + CommonAPI::DBus::DBusStubFreedesktopPropertiesSignalHelper<CommonAPI::DBus::DBusSerializableArguments<DerivedTypeCollection::TestArrayUInt64>> + ::sendPropertiesChangedSignal( + *this, + "TestDerivedArrayAttribute", + value + ); +} + + + +const TestFreedesktopInterfaceDBusStubAdapterHelper::StubDispatcherTable& TestFreedesktopInterfaceDBusStubAdapterInternal::getStubDispatcherTable() { + return stubDispatcherTable_; +} + +const CommonAPI::DBus::StubAttributeTable& TestFreedesktopInterfaceDBusStubAdapterInternal::getStubAttributeTable() { + return stubAttributeTable_; +} + +TestFreedesktopInterfaceDBusStubAdapterInternal::TestFreedesktopInterfaceDBusStubAdapterInternal( + const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, + const std::string& commonApiAddress, + const std::string& dbusInterfaceName, + const std::string& dbusBusName, + const std::string& dbusObjectPath, + const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection>& dbusConnection, + const std::shared_ptr<CommonAPI::StubBase>& stub): + CommonAPI::DBus::DBusStubAdapter( + factory, + commonApiAddress, + dbusInterfaceName, + dbusBusName, + dbusObjectPath, + dbusConnection, + false), + TestFreedesktopInterfaceDBusStubAdapterHelper( + factory, + commonApiAddress, + dbusInterfaceName, + dbusBusName, + dbusObjectPath, + dbusConnection, + std::dynamic_pointer_cast<TestFreedesktopInterfaceStub>(stub), + false), + stubDispatcherTable_({ + }), + stubAttributeTable_({ + { + "TestPredefinedTypeAttribute", + { + &commonapi::tests::TestFreedesktopInterfaceDBusStubAdapterInternal::getTestPredefinedTypeAttributeAttributeStubDispatcher, + &commonapi::tests::TestFreedesktopInterfaceDBusStubAdapterInternal::setTestPredefinedTypeAttributeAttributeStubDispatcher + } + }, + { + "TestReadonlyAttribute", + { + &commonapi::tests::TestFreedesktopInterfaceDBusStubAdapterInternal::getTestReadonlyAttributeAttributeStubDispatcher, + NULL + } + }, + { + "TestDerivedStructAttribute", + { + &commonapi::tests::TestFreedesktopInterfaceDBusStubAdapterInternal::getTestDerivedStructAttributeAttributeStubDispatcher, + &commonapi::tests::TestFreedesktopInterfaceDBusStubAdapterInternal::setTestDerivedStructAttributeAttributeStubDispatcher + } + }, + { + "TestDerivedArrayAttribute", + { + &commonapi::tests::TestFreedesktopInterfaceDBusStubAdapterInternal::getTestDerivedArrayAttributeAttributeStubDispatcher, + &commonapi::tests::TestFreedesktopInterfaceDBusStubAdapterInternal::setTestDerivedArrayAttributeAttributeStubDispatcher + } + } + } + ) { + + stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::TestFreedesktopInterfaceDBusStubAdapterInternal::getTestFreedesktopInterfaceInterfaceVersionStubDispatcher }); +} + +const bool TestFreedesktopInterfaceDBusStubAdapterInternal::hasFreedesktopProperties() { + return true; +} + +} // namespace tests +} // namespace commonapi diff --git a/src/test/commonapi/tests/TestFreedesktopInterfaceDBusStubAdapter.h b/src/test/commonapi/tests/TestFreedesktopInterfaceDBusStubAdapter.h new file mode 100644 index 0000000..23c94bb --- /dev/null +++ b/src/test/commonapi/tests/TestFreedesktopInterfaceDBusStubAdapter.h @@ -0,0 +1,137 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.5.qualifier. +* Used org.franca.core 0.8.10.201309262002. +* +* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +* If a copy of the MPL was not distributed with this file, You can obtain one at +* http://mozilla.org/MPL/2.0/. +*/ +#ifndef COMMONAPI_TESTS_Test_Freedesktop_Interface_DBUS_STUB_ADAPTER_H_ +#define COMMONAPI_TESTS_Test_Freedesktop_Interface_DBUS_STUB_ADAPTER_H_ + +#include <commonapi/tests/TestFreedesktopInterfaceStub.h> + +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#define COMMONAPI_INTERNAL_COMPILATION +#endif + +#include <CommonAPI/DBus/DBusStubAdapterHelper.h> +#include <CommonAPI/DBus/DBusStubAdapter.h> +#include <CommonAPI/DBus/DBusFactory.h> +#include <CommonAPI/DBus/DBusServicePublisher.h> + +#undef COMMONAPI_INTERNAL_COMPILATION + +namespace commonapi { +namespace tests { + +typedef CommonAPI::DBus::DBusStubAdapterHelper<TestFreedesktopInterfaceStub> TestFreedesktopInterfaceDBusStubAdapterHelper; + +class TestFreedesktopInterfaceDBusStubAdapterInternal: public virtual TestFreedesktopInterfaceStubAdapter, public TestFreedesktopInterfaceDBusStubAdapterHelper { + public: + TestFreedesktopInterfaceDBusStubAdapterInternal( + const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, + const std::string& commonApiAddress, + const std::string& dbusInterfaceName, + const std::string& dbusBusName, + const std::string& dbusObjectPath, + const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection>& dbusConnection, + const std::shared_ptr<CommonAPI::StubBase>& stub); + + ~TestFreedesktopInterfaceDBusStubAdapterInternal(); + + virtual const bool hasFreedesktopProperties(); + + void fireTestPredefinedTypeAttributeAttributeChanged(const uint32_t& value); + void fireTestReadonlyAttributeAttributeChanged(const uint32_t& value); + void fireTestDerivedStructAttributeAttributeChanged(const DerivedTypeCollection::TestStructExtended& value); + void fireTestDerivedArrayAttributeAttributeChanged(const DerivedTypeCollection::TestArrayUInt64& value); + + + + const TestFreedesktopInterfaceDBusStubAdapterHelper::StubDispatcherTable& getStubDispatcherTable(); + const CommonAPI::DBus::StubAttributeTable& getStubAttributeTable(); + + void deactivateManagedInstances(); + + +static CommonAPI::DBus::DBusGetAttributeStubDispatcher< + TestFreedesktopInterfaceStub, + CommonAPI::Version + > getTestFreedesktopInterfaceInterfaceVersionStubDispatcher; + +static CommonAPI::DBus::DBusGetFreedesktopAttributeStubDispatcher< + TestFreedesktopInterfaceStub, + uint32_t + > getTestPredefinedTypeAttributeAttributeStubDispatcher; +static CommonAPI::DBus::DBusSetFreedesktopObservableAttributeStubDispatcher< + TestFreedesktopInterfaceStub, + uint32_t + > setTestPredefinedTypeAttributeAttributeStubDispatcher; +static CommonAPI::DBus::DBusGetFreedesktopAttributeStubDispatcher< + TestFreedesktopInterfaceStub, + uint32_t + > getTestReadonlyAttributeAttributeStubDispatcher; +static CommonAPI::DBus::DBusGetFreedesktopAttributeStubDispatcher< + TestFreedesktopInterfaceStub, + DerivedTypeCollection::TestStructExtended + > getTestDerivedStructAttributeAttributeStubDispatcher; +static CommonAPI::DBus::DBusSetFreedesktopObservableAttributeStubDispatcher< + TestFreedesktopInterfaceStub, + DerivedTypeCollection::TestStructExtended + > setTestDerivedStructAttributeAttributeStubDispatcher; +static CommonAPI::DBus::DBusGetFreedesktopAttributeStubDispatcher< + TestFreedesktopInterfaceStub, + DerivedTypeCollection::TestArrayUInt64 + > getTestDerivedArrayAttributeAttributeStubDispatcher; +static CommonAPI::DBus::DBusSetFreedesktopObservableAttributeStubDispatcher< + TestFreedesktopInterfaceStub, + DerivedTypeCollection::TestArrayUInt64 + > setTestDerivedArrayAttributeAttributeStubDispatcher; + + + + + + + protected: + virtual const char* getMethodsDBusIntrospectionXmlData() const; + + private: + TestFreedesktopInterfaceDBusStubAdapterHelper::StubDispatcherTable stubDispatcherTable_; + CommonAPI::DBus::StubAttributeTable stubAttributeTable_; +}; + +class TestFreedesktopInterfaceDBusStubAdapter: public TestFreedesktopInterfaceDBusStubAdapterInternal, public std::enable_shared_from_this<TestFreedesktopInterfaceDBusStubAdapter> { +public: + TestFreedesktopInterfaceDBusStubAdapter( + const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, + const std::string& commonApiAddress, + const std::string& dbusInterfaceName, + const std::string& dbusBusName, + const std::string& dbusObjectPath, + const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection>& dbusConnection, + const std::shared_ptr<CommonAPI::StubBase>& stub) : + CommonAPI::DBus::DBusStubAdapter( + factory, + commonApiAddress, + dbusInterfaceName, + dbusBusName, + dbusObjectPath, + dbusConnection, + false), + TestFreedesktopInterfaceDBusStubAdapterInternal( + factory, + commonApiAddress, + dbusInterfaceName, + dbusBusName, + dbusObjectPath, + dbusConnection, + stub) { } +}; + +} // namespace tests +} // namespace commonapi + +#endif // COMMONAPI_TESTS_Test_Freedesktop_Interface_DBUS_STUB_ADAPTER_H_ diff --git a/src/test/commonapi/tests/TestFreedesktopInterfaceProxy.h b/src/test/commonapi/tests/TestFreedesktopInterfaceProxy.h new file mode 100644 index 0000000..0b4ce8d --- /dev/null +++ b/src/test/commonapi/tests/TestFreedesktopInterfaceProxy.h @@ -0,0 +1,280 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.5.qualifier. +* Used org.franca.core 0.8.10.201309262002. +* +* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +* If a copy of the MPL was not distributed with this file, You can obtain one at +* http://mozilla.org/MPL/2.0/. +*/ +#ifndef COMMONAPI_TESTS_Test_Freedesktop_Interface_PROXY_H_ +#define COMMONAPI_TESTS_Test_Freedesktop_Interface_PROXY_H_ + +#include "TestFreedesktopInterfaceProxyBase.h" + + +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#define COMMONAPI_INTERNAL_COMPILATION +#endif + +#include <CommonAPI/AttributeExtension.h> +#include <CommonAPI/Factory.h> + +#undef COMMONAPI_INTERNAL_COMPILATION + +namespace commonapi { +namespace tests { + +template <typename ... _AttributeExtensions> +class TestFreedesktopInterfaceProxy: virtual public TestFreedesktopInterface, virtual public TestFreedesktopInterfaceProxyBase +, public _AttributeExtensions... { +public: + TestFreedesktopInterfaceProxy(std::shared_ptr<CommonAPI::Proxy> delegate); + ~TestFreedesktopInterfaceProxy(); + + typedef TestFreedesktopInterface InterfaceType; + + + /** + * Returns the wrapper class that provides access to the attribute TestPredefinedTypeAttribute. + */ + virtual TestPredefinedTypeAttributeAttribute& getTestPredefinedTypeAttributeAttribute() { + return delegate_->getTestPredefinedTypeAttributeAttribute(); + } + /** + * Returns the wrapper class that provides access to the attribute TestReadonlyAttribute. + */ + virtual TestReadonlyAttributeAttribute& getTestReadonlyAttributeAttribute() { + return delegate_->getTestReadonlyAttributeAttribute(); + } + /** + * Returns the wrapper class that provides access to the attribute TestDerivedStructAttribute. + */ + virtual TestDerivedStructAttributeAttribute& getTestDerivedStructAttributeAttribute() { + return delegate_->getTestDerivedStructAttributeAttribute(); + } + /** + * Returns the wrapper class that provides access to the attribute TestDerivedArrayAttribute. + */ + virtual TestDerivedArrayAttributeAttribute& getTestDerivedArrayAttributeAttribute() { + return delegate_->getTestDerivedArrayAttributeAttribute(); + } + + + + + /** + * Returns the CommonAPI address of the remote partner this proxy communicates with. + */ + virtual std::string getAddress() const; + + /** + * Returns the domain of the remote partner this proxy communicates with. + */ + virtual const std::string& getDomain() const; + + /** + * Returns the service ID of the remote partner this proxy communicates with. + */ + virtual const std::string& getServiceId() const; + + /** + * Returns the instance ID of the remote partner this proxy communicates with. + */ + virtual const std::string& getInstanceId() const; + + /** + * Returns true if the remote partner for this proxy is currently known to be available. + */ + virtual bool isAvailable() const; + + /** + * Returns true if the remote partner for this proxy is available. + */ + virtual bool isAvailableBlocking() const; + + /** + * Returns the wrapper class that is used to (de-)register for notifications about + * the availability of the remote partner of this proxy. + */ + virtual CommonAPI::ProxyStatusEvent& getProxyStatusEvent(); + + /** + * Returns the wrapper class that is used to access version information of the remote + * partner of this proxy. + */ + virtual CommonAPI::InterfaceVersionAttribute& getInterfaceVersionAttribute(); + + private: + std::shared_ptr<TestFreedesktopInterfaceProxyBase> delegate_; +}; + +#ifdef WIN32 + typedef TestFreedesktopInterfaceProxy<CommonAPI::WINDummyAttributeExtension<CommonAPI::WINDummyAttribute>> TestFreedesktopInterfaceProxyDefault; +#else + typedef TestFreedesktopInterfaceProxy<> TestFreedesktopInterfaceProxyDefault; +#endif + +namespace TestFreedesktopInterfaceExtensions { + template <template <typename > class _ExtensionType> + class TestPredefinedTypeAttributeAttributeExtension { + public: + typedef _ExtensionType<TestFreedesktopInterfaceProxyBase::TestPredefinedTypeAttributeAttribute> extension_type; + + static_assert(std::is_base_of<typename CommonAPI::AttributeExtension<TestFreedesktopInterfaceProxyBase::TestPredefinedTypeAttributeAttribute>, extension_type>::value, + "Not CommonAPI Attribute Extension!"); + #ifdef WIN32 + TestPredefinedTypeAttributeAttributeExtension() {} + #endif + + TestPredefinedTypeAttributeAttributeExtension(TestFreedesktopInterfaceProxyBase& proxy): attributeExtension_(proxy.getTestPredefinedTypeAttributeAttribute()) { + } + + inline extension_type& getTestPredefinedTypeAttributeAttributeExtension() { + return attributeExtension_; + } + + private: + extension_type attributeExtension_; + }; + + template <template <typename > class _ExtensionType> + class TestReadonlyAttributeAttributeExtension { + public: + typedef _ExtensionType<TestFreedesktopInterfaceProxyBase::TestReadonlyAttributeAttribute> extension_type; + + static_assert(std::is_base_of<typename CommonAPI::AttributeExtension<TestFreedesktopInterfaceProxyBase::TestReadonlyAttributeAttribute>, extension_type>::value, + "Not CommonAPI Attribute Extension!"); + #ifdef WIN32 + TestReadonlyAttributeAttributeExtension() {} + #endif + + TestReadonlyAttributeAttributeExtension(TestFreedesktopInterfaceProxyBase& proxy): attributeExtension_(proxy.getTestReadonlyAttributeAttribute()) { + } + + inline extension_type& getTestReadonlyAttributeAttributeExtension() { + return attributeExtension_; + } + + private: + extension_type attributeExtension_; + }; + + template <template <typename > class _ExtensionType> + class TestDerivedStructAttributeAttributeExtension { + public: + typedef _ExtensionType<TestFreedesktopInterfaceProxyBase::TestDerivedStructAttributeAttribute> extension_type; + + static_assert(std::is_base_of<typename CommonAPI::AttributeExtension<TestFreedesktopInterfaceProxyBase::TestDerivedStructAttributeAttribute>, extension_type>::value, + "Not CommonAPI Attribute Extension!"); + #ifdef WIN32 + TestDerivedStructAttributeAttributeExtension() {} + #endif + + TestDerivedStructAttributeAttributeExtension(TestFreedesktopInterfaceProxyBase& proxy): attributeExtension_(proxy.getTestDerivedStructAttributeAttribute()) { + } + + inline extension_type& getTestDerivedStructAttributeAttributeExtension() { + return attributeExtension_; + } + + private: + extension_type attributeExtension_; + }; + + template <template <typename > class _ExtensionType> + class TestDerivedArrayAttributeAttributeExtension { + public: + typedef _ExtensionType<TestFreedesktopInterfaceProxyBase::TestDerivedArrayAttributeAttribute> extension_type; + + static_assert(std::is_base_of<typename CommonAPI::AttributeExtension<TestFreedesktopInterfaceProxyBase::TestDerivedArrayAttributeAttribute>, extension_type>::value, + "Not CommonAPI Attribute Extension!"); + #ifdef WIN32 + TestDerivedArrayAttributeAttributeExtension() {} + #endif + + TestDerivedArrayAttributeAttributeExtension(TestFreedesktopInterfaceProxyBase& proxy): attributeExtension_(proxy.getTestDerivedArrayAttributeAttribute()) { + } + + inline extension_type& getTestDerivedArrayAttributeAttributeExtension() { + return attributeExtension_; + } + + private: + extension_type attributeExtension_; + }; + +} // namespace TestFreedesktopInterfaceExtensions + +// +// TestFreedesktopInterfaceProxy Implementation +// +template <typename ... _AttributeExtensions> +TestFreedesktopInterfaceProxy<_AttributeExtensions...>::TestFreedesktopInterfaceProxy(std::shared_ptr<CommonAPI::Proxy> delegate): + _AttributeExtensions(*(std::dynamic_pointer_cast<TestFreedesktopInterfaceProxyBase>(delegate)))..., + delegate_(std::dynamic_pointer_cast<TestFreedesktopInterfaceProxyBase>(delegate)) { +} + +template <typename ... _AttributeExtensions> +TestFreedesktopInterfaceProxy<_AttributeExtensions...>::~TestFreedesktopInterfaceProxy() { +} + + +template <typename ... _AttributeExtensions> +std::string TestFreedesktopInterfaceProxy<_AttributeExtensions...>::getAddress() const { + return delegate_->getAddress(); +} + +template <typename ... _AttributeExtensions> +const std::string& TestFreedesktopInterfaceProxy<_AttributeExtensions...>::getDomain() const { + return delegate_->getDomain(); +} + +template <typename ... _AttributeExtensions> +const std::string& TestFreedesktopInterfaceProxy<_AttributeExtensions...>::getServiceId() const { + return delegate_->getServiceId(); +} + +template <typename ... _AttributeExtensions> +const std::string& TestFreedesktopInterfaceProxy<_AttributeExtensions...>::getInstanceId() const { + return delegate_->getInstanceId(); +} + +template <typename ... _AttributeExtensions> +bool TestFreedesktopInterfaceProxy<_AttributeExtensions...>::isAvailable() const { + return delegate_->isAvailable(); +} + +template <typename ... _AttributeExtensions> +bool TestFreedesktopInterfaceProxy<_AttributeExtensions...>::isAvailableBlocking() const { + return delegate_->isAvailableBlocking(); +} + +template <typename ... _AttributeExtensions> +CommonAPI::ProxyStatusEvent& TestFreedesktopInterfaceProxy<_AttributeExtensions...>::getProxyStatusEvent() { + return delegate_->getProxyStatusEvent(); +} + +template <typename ... _AttributeExtensions> +CommonAPI::InterfaceVersionAttribute& TestFreedesktopInterfaceProxy<_AttributeExtensions...>::getInterfaceVersionAttribute() { + return delegate_->getInterfaceVersionAttribute(); +} + + +} // namespace tests +} // namespace commonapi + +namespace CommonAPI { +template<template<typename > class _AttributeExtension> +struct DefaultAttributeProxyFactoryHelper<commonapi::tests::TestFreedesktopInterfaceProxy, + _AttributeExtension> { + typedef typename commonapi::tests::TestFreedesktopInterfaceProxy< + commonapi::tests::TestFreedesktopInterfaceExtensions::TestPredefinedTypeAttributeAttributeExtension<_AttributeExtension>, + commonapi::tests::TestFreedesktopInterfaceExtensions::TestReadonlyAttributeAttributeExtension<_AttributeExtension>, + commonapi::tests::TestFreedesktopInterfaceExtensions::TestDerivedStructAttributeAttributeExtension<_AttributeExtension>, + commonapi::tests::TestFreedesktopInterfaceExtensions::TestDerivedArrayAttributeAttributeExtension<_AttributeExtension> + > class_t; +}; +} + +#endif // COMMONAPI_TESTS_Test_Freedesktop_Interface_PROXY_H_ diff --git a/src/test/commonapi/tests/TestFreedesktopInterfaceProxyBase.h b/src/test/commonapi/tests/TestFreedesktopInterfaceProxyBase.h new file mode 100644 index 0000000..417a157 --- /dev/null +++ b/src/test/commonapi/tests/TestFreedesktopInterfaceProxyBase.h @@ -0,0 +1,52 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.5.qualifier. +* Used org.franca.core 0.8.10.201309262002. +* +* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +* If a copy of the MPL was not distributed with this file, You can obtain one at +* http://mozilla.org/MPL/2.0/. +*/ +#ifndef COMMONAPI_TESTS_Test_Freedesktop_Interface_PROXY_BASE_H_ +#define COMMONAPI_TESTS_Test_Freedesktop_Interface_PROXY_BASE_H_ + +#include "TestFreedesktopInterface.h" + + +#include <commonapi/tests/DerivedTypeCollection.h> + +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#define COMMONAPI_INTERNAL_COMPILATION +#endif + +#include <cstdint> +#include <vector> + +#include <CommonAPI/Attribute.h> +#include <CommonAPI/Proxy.h> + +#undef COMMONAPI_INTERNAL_COMPILATION + +namespace commonapi { +namespace tests { + +class TestFreedesktopInterfaceProxyBase: virtual public CommonAPI::Proxy { + public: + typedef CommonAPI::ObservableAttribute<uint32_t> TestPredefinedTypeAttributeAttribute; + typedef CommonAPI::ObservableReadonlyAttribute<uint32_t> TestReadonlyAttributeAttribute; + typedef CommonAPI::ObservableAttribute<DerivedTypeCollection::TestStructExtended> TestDerivedStructAttributeAttribute; + typedef CommonAPI::ObservableAttribute<DerivedTypeCollection::TestArrayUInt64> TestDerivedArrayAttributeAttribute; + + + virtual TestPredefinedTypeAttributeAttribute& getTestPredefinedTypeAttributeAttribute() = 0; + virtual TestReadonlyAttributeAttribute& getTestReadonlyAttributeAttribute() = 0; + virtual TestDerivedStructAttributeAttribute& getTestDerivedStructAttributeAttribute() = 0; + virtual TestDerivedArrayAttributeAttribute& getTestDerivedArrayAttributeAttribute() = 0; + + +}; + +} // namespace tests +} // namespace commonapi + +#endif // COMMONAPI_TESTS_Test_Freedesktop_Interface_PROXY_BASE_H_ diff --git a/src/test/commonapi/tests/TestFreedesktopInterfaceStub.h b/src/test/commonapi/tests/TestFreedesktopInterfaceStub.h new file mode 100644 index 0000000..623c012 --- /dev/null +++ b/src/test/commonapi/tests/TestFreedesktopInterfaceStub.h @@ -0,0 +1,127 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.5.qualifier. +* Used org.franca.core 0.8.10.201309262002. +* +* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +* If a copy of the MPL was not distributed with this file, You can obtain one at +* http://mozilla.org/MPL/2.0/. +*/ +#ifndef COMMONAPI_TESTS_Test_Freedesktop_Interface_STUB_H_ +#define COMMONAPI_TESTS_Test_Freedesktop_Interface_STUB_H_ + + + +#include <commonapi/tests/DerivedTypeCollection.h> + +#include "TestFreedesktopInterface.h" + +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#define COMMONAPI_INTERNAL_COMPILATION +#endif + +#include <cstdint> +#include <vector> + +#include <CommonAPI/Stub.h> + +#undef COMMONAPI_INTERNAL_COMPILATION + +namespace commonapi { +namespace tests { + +/** + * Receives messages from remote and handles all dispatching of deserialized calls + * to a stub for the service TestFreedesktopInterface. Also provides means to send broadcasts + * and attribute-changed-notifications of observable attributes as defined by this service. + * An application developer should not need to bother with this class. + */ +class TestFreedesktopInterfaceStubAdapter: virtual public CommonAPI::StubAdapter, public TestFreedesktopInterface { + public: + ///Notifies all remote listeners about a change of value of the attribute TestPredefinedTypeAttribute. + virtual void fireTestPredefinedTypeAttributeAttributeChanged(const uint32_t& TestPredefinedTypeAttribute) = 0; + ///Notifies all remote listeners about a change of value of the attribute TestReadonlyAttribute. + virtual void fireTestReadonlyAttributeAttributeChanged(const uint32_t& TestReadonlyAttribute) = 0; + ///Notifies all remote listeners about a change of value of the attribute TestDerivedStructAttribute. + virtual void fireTestDerivedStructAttributeAttributeChanged(const DerivedTypeCollection::TestStructExtended& TestDerivedStructAttribute) = 0; + ///Notifies all remote listeners about a change of value of the attribute TestDerivedArrayAttribute. + virtual void fireTestDerivedArrayAttributeAttributeChanged(const DerivedTypeCollection::TestArrayUInt64& TestDerivedArrayAttribute) = 0; + + + + virtual void deactivateManagedInstances() = 0; +protected: + /** + * Defines properties for storing the ClientIds of clients / proxies that have + * subscribed to the selective broadcasts + */ +}; + + +/** + * Defines the necessary callbacks to handle remote set events related to the attributes + * defined in the IDL description for TestFreedesktopInterface. + * For each attribute two callbacks are defined: + * - a verification callback that allows to verify the requested value and to prevent setting + * e.g. an invalid value ("onRemoteSet<AttributeName>"). + * - an action callback to do local work after the attribute value has been changed + * ("onRemote<AttributeName>Changed"). + * + * This class and the one below are the ones an application developer needs to have + * a look at if he wants to implement a service. + */ +class TestFreedesktopInterfaceStubRemoteEvent { + public: + virtual ~TestFreedesktopInterfaceStubRemoteEvent() { } + + /// Verification callback for remote set requests on the attribute TestPredefinedTypeAttribute + virtual bool onRemoteSetTestPredefinedTypeAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId, uint32_t TestPredefinedTypeAttribute) = 0; + /// Action callback for remote set requests on the attribute TestPredefinedTypeAttribute + virtual void onRemoteTestPredefinedTypeAttributeAttributeChanged() = 0; + + + /// Verification callback for remote set requests on the attribute TestDerivedStructAttribute + virtual bool onRemoteSetTestDerivedStructAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::TestStructExtended TestDerivedStructAttribute) = 0; + /// Action callback for remote set requests on the attribute TestDerivedStructAttribute + virtual void onRemoteTestDerivedStructAttributeAttributeChanged() = 0; + + /// Verification callback for remote set requests on the attribute TestDerivedArrayAttribute + virtual bool onRemoteSetTestDerivedArrayAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::TestArrayUInt64 TestDerivedArrayAttribute) = 0; + /// Action callback for remote set requests on the attribute TestDerivedArrayAttribute + virtual void onRemoteTestDerivedArrayAttributeAttributeChanged() = 0; + +}; + + +/** + * Defines the interface that must be implemented by any class that should provide + * the service TestFreedesktopInterface to remote clients. + * This class and the one above are the ones an application developer needs to have + * a look at if he wants to implement a service. + */ +class TestFreedesktopInterfaceStub: public virtual CommonAPI::Stub<TestFreedesktopInterfaceStubAdapter, TestFreedesktopInterfaceStubRemoteEvent> { +public: + virtual ~TestFreedesktopInterfaceStub() { } + virtual const CommonAPI::Version& getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId) = 0; + + /// Provides getter access to the attribute TestPredefinedTypeAttribute + virtual const uint32_t& getTestPredefinedTypeAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId) = 0; + /// Provides getter access to the attribute TestReadonlyAttribute + virtual const uint32_t& getTestReadonlyAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId) = 0; + /// Provides getter access to the attribute TestDerivedStructAttribute + virtual const DerivedTypeCollection::TestStructExtended& getTestDerivedStructAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId) = 0; + /// Provides getter access to the attribute TestDerivedArrayAttribute + virtual const DerivedTypeCollection::TestArrayUInt64& getTestDerivedArrayAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId) = 0; + + + using CommonAPI::Stub<TestFreedesktopInterfaceStubAdapter, TestFreedesktopInterfaceStubRemoteEvent>::initStubAdapter; + typedef CommonAPI::Stub<TestFreedesktopInterfaceStubAdapter, TestFreedesktopInterfaceStubRemoteEvent>::StubAdapterType StubAdapterType; + typedef CommonAPI::Stub<TestFreedesktopInterfaceStubAdapter, TestFreedesktopInterfaceStubRemoteEvent>::RemoteEventHandlerType RemoteEventHandlerType; + typedef TestFreedesktopInterfaceStubRemoteEvent RemoteEventType; + typedef TestFreedesktopInterface StubInterface; +}; + +} // namespace tests +} // namespace commonapi + +#endif // COMMONAPI_TESTS_Test_Freedesktop_Interface_STUB_H_ diff --git a/src/test/commonapi/tests/TestFreedesktopInterfaceStubDefault.cpp b/src/test/commonapi/tests/TestFreedesktopInterfaceStubDefault.cpp new file mode 100644 index 0000000..3de15da --- /dev/null +++ b/src/test/commonapi/tests/TestFreedesktopInterfaceStubDefault.cpp @@ -0,0 +1,211 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.5.qualifier. +* Used org.franca.core 0.8.10.201309262002. +* +* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +* If a copy of the MPL was not distributed with this file, You can obtain one at +* http://mozilla.org/MPL/2.0/. +*/ +#include <commonapi/tests/TestFreedesktopInterfaceStubDefault.h> + +namespace commonapi { +namespace tests { + +TestFreedesktopInterfaceStubDefault::TestFreedesktopInterfaceStubDefault(): + remoteEventHandler_(this), + interfaceVersion_(TestFreedesktopInterface::getInterfaceVersion()) { +} + +const CommonAPI::Version& TestFreedesktopInterfaceStubDefault::getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId) { + return interfaceVersion_; +} + +TestFreedesktopInterfaceStubRemoteEvent* TestFreedesktopInterfaceStubDefault::initStubAdapter(const std::shared_ptr<TestFreedesktopInterfaceStubAdapter>& stubAdapter) { + CommonAPI::Stub<TestFreedesktopInterfaceStubAdapter, TestFreedesktopInterfaceStubRemoteEvent>::stubAdapter_ = stubAdapter; + return &remoteEventHandler_; +} + +const uint32_t& TestFreedesktopInterfaceStubDefault::getTestPredefinedTypeAttributeAttribute() { + return testPredefinedTypeAttributeAttributeValue_; +} + +const uint32_t& TestFreedesktopInterfaceStubDefault::getTestPredefinedTypeAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId) { + return getTestPredefinedTypeAttributeAttribute(); +} + +void TestFreedesktopInterfaceStubDefault::setTestPredefinedTypeAttributeAttribute(uint32_t value) { + const bool valueChanged = trySetTestPredefinedTypeAttributeAttribute(std::move(value)); + if (valueChanged) { + stubAdapter_->fireTestPredefinedTypeAttributeAttributeChanged(testPredefinedTypeAttributeAttributeValue_); + } +} + +bool TestFreedesktopInterfaceStubDefault::trySetTestPredefinedTypeAttributeAttribute(uint32_t value) { + if (!validateTestPredefinedTypeAttributeAttributeRequestedValue(value)) + return false; + + const bool valueChanged = (testPredefinedTypeAttributeAttributeValue_ != value); + testPredefinedTypeAttributeAttributeValue_ = std::move(value); + return valueChanged; +} + +bool TestFreedesktopInterfaceStubDefault::validateTestPredefinedTypeAttributeAttributeRequestedValue(const uint32_t& value) { + return true; +} + +void TestFreedesktopInterfaceStubDefault::setTestPredefinedTypeAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId, uint32_t value) { + setTestPredefinedTypeAttributeAttribute(value); +} + +void TestFreedesktopInterfaceStubDefault::onRemoteTestPredefinedTypeAttributeAttributeChanged() { + // No operation in default +} + +void TestFreedesktopInterfaceStubDefault::RemoteEventHandler::onRemoteTestPredefinedTypeAttributeAttributeChanged() { + defaultStub_->onRemoteTestPredefinedTypeAttributeAttributeChanged(); +} + +bool TestFreedesktopInterfaceStubDefault::RemoteEventHandler::onRemoteSetTestPredefinedTypeAttributeAttribute(uint32_t value) { + return defaultStub_->trySetTestPredefinedTypeAttributeAttribute(std::move(value)); +} + +bool TestFreedesktopInterfaceStubDefault::RemoteEventHandler::onRemoteSetTestPredefinedTypeAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId, uint32_t value) { + return onRemoteSetTestPredefinedTypeAttributeAttribute(value); +} + +const uint32_t& TestFreedesktopInterfaceStubDefault::getTestReadonlyAttributeAttribute() { + return testReadonlyAttributeAttributeValue_; +} + +const uint32_t& TestFreedesktopInterfaceStubDefault::getTestReadonlyAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId) { + return getTestReadonlyAttributeAttribute(); +} + +void TestFreedesktopInterfaceStubDefault::setTestReadonlyAttributeAttribute(uint32_t value) { + const bool valueChanged = trySetTestReadonlyAttributeAttribute(std::move(value)); + if (valueChanged) { + stubAdapter_->fireTestReadonlyAttributeAttributeChanged(testReadonlyAttributeAttributeValue_); + } +} + +bool TestFreedesktopInterfaceStubDefault::trySetTestReadonlyAttributeAttribute(uint32_t value) { + if (!validateTestReadonlyAttributeAttributeRequestedValue(value)) + return false; + + const bool valueChanged = (testReadonlyAttributeAttributeValue_ != value); + testReadonlyAttributeAttributeValue_ = std::move(value); + return valueChanged; +} + +bool TestFreedesktopInterfaceStubDefault::validateTestReadonlyAttributeAttributeRequestedValue(const uint32_t& value) { + return true; +} + + +const DerivedTypeCollection::TestStructExtended& TestFreedesktopInterfaceStubDefault::getTestDerivedStructAttributeAttribute() { + return testDerivedStructAttributeAttributeValue_; +} + +const DerivedTypeCollection::TestStructExtended& TestFreedesktopInterfaceStubDefault::getTestDerivedStructAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId) { + return getTestDerivedStructAttributeAttribute(); +} + +void TestFreedesktopInterfaceStubDefault::setTestDerivedStructAttributeAttribute(DerivedTypeCollection::TestStructExtended value) { + const bool valueChanged = trySetTestDerivedStructAttributeAttribute(std::move(value)); + if (valueChanged) { + stubAdapter_->fireTestDerivedStructAttributeAttributeChanged(testDerivedStructAttributeAttributeValue_); + } +} + +bool TestFreedesktopInterfaceStubDefault::trySetTestDerivedStructAttributeAttribute(DerivedTypeCollection::TestStructExtended value) { + if (!validateTestDerivedStructAttributeAttributeRequestedValue(value)) + return false; + + const bool valueChanged = (testDerivedStructAttributeAttributeValue_ != value); + testDerivedStructAttributeAttributeValue_ = std::move(value); + return valueChanged; +} + +bool TestFreedesktopInterfaceStubDefault::validateTestDerivedStructAttributeAttributeRequestedValue(const DerivedTypeCollection::TestStructExtended& value) { + return true; +} + +void TestFreedesktopInterfaceStubDefault::setTestDerivedStructAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::TestStructExtended value) { + setTestDerivedStructAttributeAttribute(value); +} + +void TestFreedesktopInterfaceStubDefault::onRemoteTestDerivedStructAttributeAttributeChanged() { + // No operation in default +} + +void TestFreedesktopInterfaceStubDefault::RemoteEventHandler::onRemoteTestDerivedStructAttributeAttributeChanged() { + defaultStub_->onRemoteTestDerivedStructAttributeAttributeChanged(); +} + +bool TestFreedesktopInterfaceStubDefault::RemoteEventHandler::onRemoteSetTestDerivedStructAttributeAttribute(DerivedTypeCollection::TestStructExtended value) { + return defaultStub_->trySetTestDerivedStructAttributeAttribute(std::move(value)); +} + +bool TestFreedesktopInterfaceStubDefault::RemoteEventHandler::onRemoteSetTestDerivedStructAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::TestStructExtended value) { + return onRemoteSetTestDerivedStructAttributeAttribute(value); +} + +const DerivedTypeCollection::TestArrayUInt64& TestFreedesktopInterfaceStubDefault::getTestDerivedArrayAttributeAttribute() { + return testDerivedArrayAttributeAttributeValue_; +} + +const DerivedTypeCollection::TestArrayUInt64& TestFreedesktopInterfaceStubDefault::getTestDerivedArrayAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId) { + return getTestDerivedArrayAttributeAttribute(); +} + +void TestFreedesktopInterfaceStubDefault::setTestDerivedArrayAttributeAttribute(DerivedTypeCollection::TestArrayUInt64 value) { + const bool valueChanged = trySetTestDerivedArrayAttributeAttribute(std::move(value)); + if (valueChanged) { + stubAdapter_->fireTestDerivedArrayAttributeAttributeChanged(testDerivedArrayAttributeAttributeValue_); + } +} + +bool TestFreedesktopInterfaceStubDefault::trySetTestDerivedArrayAttributeAttribute(DerivedTypeCollection::TestArrayUInt64 value) { + if (!validateTestDerivedArrayAttributeAttributeRequestedValue(value)) + return false; + + const bool valueChanged = (testDerivedArrayAttributeAttributeValue_ != value); + testDerivedArrayAttributeAttributeValue_ = std::move(value); + return valueChanged; +} + +bool TestFreedesktopInterfaceStubDefault::validateTestDerivedArrayAttributeAttributeRequestedValue(const DerivedTypeCollection::TestArrayUInt64& value) { + return true; +} + +void TestFreedesktopInterfaceStubDefault::setTestDerivedArrayAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::TestArrayUInt64 value) { + setTestDerivedArrayAttributeAttribute(value); +} + +void TestFreedesktopInterfaceStubDefault::onRemoteTestDerivedArrayAttributeAttributeChanged() { + // No operation in default +} + +void TestFreedesktopInterfaceStubDefault::RemoteEventHandler::onRemoteTestDerivedArrayAttributeAttributeChanged() { + defaultStub_->onRemoteTestDerivedArrayAttributeAttributeChanged(); +} + +bool TestFreedesktopInterfaceStubDefault::RemoteEventHandler::onRemoteSetTestDerivedArrayAttributeAttribute(DerivedTypeCollection::TestArrayUInt64 value) { + return defaultStub_->trySetTestDerivedArrayAttributeAttribute(std::move(value)); +} + +bool TestFreedesktopInterfaceStubDefault::RemoteEventHandler::onRemoteSetTestDerivedArrayAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::TestArrayUInt64 value) { + return onRemoteSetTestDerivedArrayAttributeAttribute(value); +} + + + + + +TestFreedesktopInterfaceStubDefault::RemoteEventHandler::RemoteEventHandler(TestFreedesktopInterfaceStubDefault* defaultStub): + defaultStub_(defaultStub) { +} + +} // namespace tests +} // namespace commonapi diff --git a/src/test/commonapi/tests/TestFreedesktopInterfaceStubDefault.h b/src/test/commonapi/tests/TestFreedesktopInterfaceStubDefault.h new file mode 100644 index 0000000..597e176 --- /dev/null +++ b/src/test/commonapi/tests/TestFreedesktopInterfaceStubDefault.h @@ -0,0 +1,104 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.5.qualifier. +* Used org.franca.core 0.8.10.201309262002. +* +* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +* If a copy of the MPL was not distributed with this file, You can obtain one at +* http://mozilla.org/MPL/2.0/. +*/ +#ifndef COMMONAPI_TESTS_Test_Freedesktop_Interface_STUB_DEFAULT_H_ +#define COMMONAPI_TESTS_Test_Freedesktop_Interface_STUB_DEFAULT_H_ + + +#include <commonapi/tests/TestFreedesktopInterfaceStub.h> +#include <sstream> + +namespace commonapi { +namespace tests { + +/** + * Provides a default implementation for TestFreedesktopInterfaceStubRemoteEvent and + * TestFreedesktopInterfaceStub. Method callbacks have an empty implementation, + * remote set calls on attributes will always change the value of the attribute + * to the one received. + * + * Override this stub if you only want to provide a subset of the functionality + * that would be defined for this service, and/or if you do not need any non-default + * behaviour. + */ +class TestFreedesktopInterfaceStubDefault : public virtual TestFreedesktopInterfaceStub { +public: + TestFreedesktopInterfaceStubDefault(); + + TestFreedesktopInterfaceStubRemoteEvent* initStubAdapter(const std::shared_ptr<TestFreedesktopInterfaceStubAdapter>& stubAdapter); + + const CommonAPI::Version& getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId); + + virtual const uint32_t& getTestPredefinedTypeAttributeAttribute(); + virtual const uint32_t& getTestPredefinedTypeAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId); + virtual void setTestPredefinedTypeAttributeAttribute(uint32_t value); + virtual void setTestPredefinedTypeAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId, uint32_t value); + virtual const uint32_t& getTestReadonlyAttributeAttribute(); + virtual const uint32_t& getTestReadonlyAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId); + virtual void setTestReadonlyAttributeAttribute(uint32_t value); + virtual const DerivedTypeCollection::TestStructExtended& getTestDerivedStructAttributeAttribute(); + virtual const DerivedTypeCollection::TestStructExtended& getTestDerivedStructAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId); + virtual void setTestDerivedStructAttributeAttribute(DerivedTypeCollection::TestStructExtended value); + virtual void setTestDerivedStructAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::TestStructExtended value); + virtual const DerivedTypeCollection::TestArrayUInt64& getTestDerivedArrayAttributeAttribute(); + virtual const DerivedTypeCollection::TestArrayUInt64& getTestDerivedArrayAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId); + virtual void setTestDerivedArrayAttributeAttribute(DerivedTypeCollection::TestArrayUInt64 value); + virtual void setTestDerivedArrayAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::TestArrayUInt64 value); + + + + +protected: + virtual bool trySetTestPredefinedTypeAttributeAttribute(uint32_t value); + virtual bool validateTestPredefinedTypeAttributeAttributeRequestedValue(const uint32_t& value); + virtual void onRemoteTestPredefinedTypeAttributeAttributeChanged(); + virtual bool trySetTestReadonlyAttributeAttribute(uint32_t value); + virtual bool validateTestReadonlyAttributeAttributeRequestedValue(const uint32_t& value); + virtual bool trySetTestDerivedStructAttributeAttribute(DerivedTypeCollection::TestStructExtended value); + virtual bool validateTestDerivedStructAttributeAttributeRequestedValue(const DerivedTypeCollection::TestStructExtended& value); + virtual void onRemoteTestDerivedStructAttributeAttributeChanged(); + virtual bool trySetTestDerivedArrayAttributeAttribute(DerivedTypeCollection::TestArrayUInt64 value); + virtual bool validateTestDerivedArrayAttributeAttributeRequestedValue(const DerivedTypeCollection::TestArrayUInt64& value); + virtual void onRemoteTestDerivedArrayAttributeAttributeChanged(); + class RemoteEventHandler: public virtual TestFreedesktopInterfaceStubRemoteEvent { + public: + RemoteEventHandler(TestFreedesktopInterfaceStubDefault* defaultStub); + + virtual bool onRemoteSetTestPredefinedTypeAttributeAttribute(uint32_t value); + virtual bool onRemoteSetTestPredefinedTypeAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId, uint32_t value); + virtual void onRemoteTestPredefinedTypeAttributeAttributeChanged(); + + + virtual bool onRemoteSetTestDerivedStructAttributeAttribute(DerivedTypeCollection::TestStructExtended value); + virtual bool onRemoteSetTestDerivedStructAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::TestStructExtended value); + virtual void onRemoteTestDerivedStructAttributeAttributeChanged(); + + virtual bool onRemoteSetTestDerivedArrayAttributeAttribute(DerivedTypeCollection::TestArrayUInt64 value); + virtual bool onRemoteSetTestDerivedArrayAttributeAttribute(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::TestArrayUInt64 value); + virtual void onRemoteTestDerivedArrayAttributeAttributeChanged(); + + + private: + TestFreedesktopInterfaceStubDefault* defaultStub_; + }; +private: + TestFreedesktopInterfaceStubDefault::RemoteEventHandler remoteEventHandler_; + + uint32_t testPredefinedTypeAttributeAttributeValue_; + uint32_t testReadonlyAttributeAttributeValue_; + DerivedTypeCollection::TestStructExtended testDerivedStructAttributeAttributeValue_; + DerivedTypeCollection::TestArrayUInt64 testDerivedArrayAttributeAttributeValue_; + + CommonAPI::Version interfaceVersion_; +}; + +} // namespace tests +} // namespace commonapi + +#endif // COMMONAPI_TESTS_Test_Freedesktop_Interface_STUB_DEFAULT_H_ diff --git a/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp b/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp index 32d2294..9cd1cf9 100644 --- a/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp +++ b/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp @@ -139,9 +139,10 @@ CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< > TestInterfaceDBusStubAdapterInternal::setTestPredefinedTypeAttributeAttributeStubDispatcher( &TestInterfaceStub::getTestPredefinedTypeAttributeAttribute, &TestInterfaceStubRemoteEvent::onRemoteSetTestPredefinedTypeAttributeAttribute, - &TestInterfaceStubRemoteEvent::onRemoteTestPredefinedTypeAttributeAttributeChanged, - &TestInterfaceStubAdapter::fireTestPredefinedTypeAttributeAttributeChanged, - "u"); + &TestInterfaceStubRemoteEvent::onRemoteTestPredefinedTypeAttributeAttributeChanged + ,&TestInterfaceStubAdapter::fireTestPredefinedTypeAttributeAttributeChanged + ,"u" + ); CommonAPI::DBus::DBusGetAttributeStubDispatcher< TestInterfaceStub, DerivedTypeCollection::TestStructExtended @@ -152,9 +153,10 @@ CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< > TestInterfaceDBusStubAdapterInternal::setTestDerivedStructAttributeAttributeStubDispatcher( &TestInterfaceStub::getTestDerivedStructAttributeAttribute, &TestInterfaceStubRemoteEvent::onRemoteSetTestDerivedStructAttributeAttribute, - &TestInterfaceStubRemoteEvent::onRemoteTestDerivedStructAttributeAttributeChanged, - &TestInterfaceStubAdapter::fireTestDerivedStructAttributeAttributeChanged, - "(sqi)"); + &TestInterfaceStubRemoteEvent::onRemoteTestDerivedStructAttributeAttributeChanged + ,&TestInterfaceStubAdapter::fireTestDerivedStructAttributeAttributeChanged + ,"(sqi)" + ); CommonAPI::DBus::DBusGetAttributeStubDispatcher< TestInterfaceStub, DerivedTypeCollection::TestArrayUInt64 @@ -165,9 +167,10 @@ CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< > TestInterfaceDBusStubAdapterInternal::setTestDerivedArrayAttributeAttributeStubDispatcher( &TestInterfaceStub::getTestDerivedArrayAttributeAttribute, &TestInterfaceStubRemoteEvent::onRemoteSetTestDerivedArrayAttributeAttribute, - &TestInterfaceStubRemoteEvent::onRemoteTestDerivedArrayAttributeAttributeChanged, - &TestInterfaceStubAdapter::fireTestDerivedArrayAttributeAttributeChanged, - "at"); + &TestInterfaceStubRemoteEvent::onRemoteTestDerivedArrayAttributeAttributeChanged + ,&TestInterfaceStubAdapter::fireTestDerivedArrayAttributeAttributeChanged + ,"at" + ); CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< @@ -397,6 +400,9 @@ const TestInterfaceDBusStubAdapterHelper::StubDispatcherTable& TestInterfaceDBus return stubDispatcherTable_; } +const CommonAPI::DBus::StubAttributeTable& TestInterfaceDBusStubAdapterInternal::getStubAttributeTable() { + return stubAttributeTable_; +} TestInterfaceDBusStubAdapterInternal::TestInterfaceDBusStubAdapterInternal( const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, @@ -447,12 +453,17 @@ TestInterfaceDBusStubAdapterInternal::TestInterfaceDBusStubAdapterInternal( { { "subscribeForTestBroadcastWithOutArgsSelective", "" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::subscribeTestBroadcastWithOutArgsSelectiveStubDispatcher } , { { "unsubscribeFromTestBroadcastWithOutArgsSelective", "" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::unsubscribeTestBroadcastWithOutArgsSelectiveStubDispatcher } - }) { + }), + stubAttributeTable_() { subscribersForTestSelectiveBroadcastSelective_ = std::make_shared<CommonAPI::ClientIdList>(); subscribersForTestBroadcastWithOutArgsSelective_ = std::make_shared<CommonAPI::ClientIdList>(); stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::getTestInterfaceInterfaceVersionStubDispatcher }); } +const bool TestInterfaceDBusStubAdapterInternal::hasFreedesktopProperties() { + return false; +} + } // namespace tests } // namespace commonapi diff --git a/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.h b/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.h index f0f31ff..44c87e9 100644 --- a/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.h +++ b/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.h @@ -41,6 +41,8 @@ class TestInterfaceDBusStubAdapterInternal: public virtual TestInterfaceStubAdap ~TestInterfaceDBusStubAdapterInternal(); + virtual const bool hasFreedesktopProperties(); + void fireTestPredefinedTypeAttributeAttributeChanged(const uint32_t& value); void fireTestDerivedStructAttributeAttributeChanged(const DerivedTypeCollection::TestStructExtended& value); void fireTestDerivedArrayAttributeAttributeChanged(const DerivedTypeCollection::TestArrayUInt64& value); @@ -59,6 +61,7 @@ class TestInterfaceDBusStubAdapterInternal: public virtual TestInterfaceStubAdap const TestInterfaceDBusStubAdapterHelper::StubDispatcherTable& getStubDispatcherTable(); + const CommonAPI::DBus::StubAttributeTable& getStubAttributeTable(); void deactivateManagedInstances(); @@ -171,9 +174,10 @@ static CommonAPI::DBus::DBusMethodWithReplyAdapterDispatcher< protected: virtual const char* getMethodsDBusIntrospectionXmlData() const; - - private: + + private: TestInterfaceDBusStubAdapterHelper::StubDispatcherTable stubDispatcherTable_; + CommonAPI::DBus::StubAttributeTable stubAttributeTable_; }; class TestInterfaceDBusStubAdapter: public TestInterfaceDBusStubAdapterInternal, public std::enable_shared_from_this<TestInterfaceDBusStubAdapter> { diff --git a/src/test/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.cpp b/src/test/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.cpp index 9411f53..d6ef6c8 100644 --- a/src/test/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.cpp +++ b/src/test/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.cpp @@ -79,6 +79,9 @@ const BranchInterfaceDBusStubAdapterHelper::StubDispatcherTable& BranchInterface return stubDispatcherTable_; } +const CommonAPI::DBus::StubAttributeTable& BranchInterfaceDBusStubAdapterInternal::getStubAttributeTable() { + return stubAttributeTable_; +} BranchInterfaceDBusStubAdapterInternal::BranchInterfaceDBusStubAdapterInternal( const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, @@ -107,11 +110,16 @@ BranchInterfaceDBusStubAdapterInternal::BranchInterfaceDBusStubAdapterInternal( false), stubDispatcherTable_({ { { "testBranchMethod", "is" }, &commonapi::tests::managed::BranchInterfaceDBusStubAdapterInternal::testBranchMethodStubDispatcher } - }) { + }), + stubAttributeTable_() { stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::managed::BranchInterfaceDBusStubAdapterInternal::getBranchInterfaceInterfaceVersionStubDispatcher }); } +const bool BranchInterfaceDBusStubAdapterInternal::hasFreedesktopProperties() { + return false; +} + } // namespace managed } // namespace tests } // namespace commonapi diff --git a/src/test/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.h b/src/test/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.h index 730a0e5..d0a1d24 100644 --- a/src/test/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.h +++ b/src/test/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.h @@ -42,10 +42,13 @@ class BranchInterfaceDBusStubAdapterInternal: public virtual BranchInterfaceStub ~BranchInterfaceDBusStubAdapterInternal(); + virtual const bool hasFreedesktopProperties(); + const BranchInterfaceDBusStubAdapterHelper::StubDispatcherTable& getStubDispatcherTable(); + const CommonAPI::DBus::StubAttributeTable& getStubAttributeTable(); void deactivateManagedInstances(); @@ -68,9 +71,10 @@ static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< protected: virtual const char* getMethodsDBusIntrospectionXmlData() const; - - private: + + private: BranchInterfaceDBusStubAdapterHelper::StubDispatcherTable stubDispatcherTable_; + CommonAPI::DBus::StubAttributeTable stubAttributeTable_; }; class BranchInterfaceDBusStubAdapter: public BranchInterfaceDBusStubAdapterInternal, public std::enable_shared_from_this<BranchInterfaceDBusStubAdapter> { diff --git a/src/test/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.cpp b/src/test/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.cpp index 5411efa..1224eeb 100644 --- a/src/test/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.cpp +++ b/src/test/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.cpp @@ -79,6 +79,9 @@ const LeafInterfaceDBusStubAdapterHelper::StubDispatcherTable& LeafInterfaceDBus return stubDispatcherTable_; } +const CommonAPI::DBus::StubAttributeTable& LeafInterfaceDBusStubAdapterInternal::getStubAttributeTable() { + return stubAttributeTable_; +} LeafInterfaceDBusStubAdapterInternal::LeafInterfaceDBusStubAdapterInternal( const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, @@ -107,11 +110,16 @@ LeafInterfaceDBusStubAdapterInternal::LeafInterfaceDBusStubAdapterInternal( false), stubDispatcherTable_({ { { "testLeafMethod", "is" }, &commonapi::tests::managed::LeafInterfaceDBusStubAdapterInternal::testLeafMethodStubDispatcher } - }) { + }), + stubAttributeTable_() { stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::managed::LeafInterfaceDBusStubAdapterInternal::getLeafInterfaceInterfaceVersionStubDispatcher }); } +const bool LeafInterfaceDBusStubAdapterInternal::hasFreedesktopProperties() { + return false; +} + } // namespace managed } // namespace tests } // namespace commonapi diff --git a/src/test/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.h b/src/test/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.h index 4819095..6930bda 100644 --- a/src/test/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.h +++ b/src/test/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.h @@ -42,10 +42,13 @@ class LeafInterfaceDBusStubAdapterInternal: public virtual LeafInterfaceStubAdap ~LeafInterfaceDBusStubAdapterInternal(); + virtual const bool hasFreedesktopProperties(); + const LeafInterfaceDBusStubAdapterHelper::StubDispatcherTable& getStubDispatcherTable(); + const CommonAPI::DBus::StubAttributeTable& getStubAttributeTable(); void deactivateManagedInstances(); @@ -68,9 +71,10 @@ static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< protected: virtual const char* getMethodsDBusIntrospectionXmlData() const; - - private: + + private: LeafInterfaceDBusStubAdapterHelper::StubDispatcherTable stubDispatcherTable_; + CommonAPI::DBus::StubAttributeTable stubAttributeTable_; }; class LeafInterfaceDBusStubAdapter: public LeafInterfaceDBusStubAdapterInternal, public std::enable_shared_from_this<LeafInterfaceDBusStubAdapter> { diff --git a/src/test/commonapi/tests/managed/RootInterfaceDBusStubAdapter.cpp b/src/test/commonapi/tests/managed/RootInterfaceDBusStubAdapter.cpp index a56a381..e5e8f7c 100644 --- a/src/test/commonapi/tests/managed/RootInterfaceDBusStubAdapter.cpp +++ b/src/test/commonapi/tests/managed/RootInterfaceDBusStubAdapter.cpp @@ -103,110 +103,113 @@ const RootInterfaceDBusStubAdapterHelper::StubDispatcherTable& RootInterfaceDBus return stubDispatcherTable_; } - -bool RootInterfaceDBusStubAdapterInternal::registerManagedStubLeafInterface(std::shared_ptr<LeafInterfaceStub> stub, const std::string& instance) { - if (registeredLeafInterfaceInstances.find(instance) == registeredLeafInterfaceInstances.end()) { - std::string commonApiAddress = "local:commonapi.tests.managed.LeafInterface:" + instance; - - std::string interfaceName; - std::string connectionName; - std::string objectPath; - - CommonAPI::DBus::DBusAddressTranslator::getInstance().searchForDBusAddress( - commonApiAddress, - interfaceName, - connectionName, - objectPath); - - if (objectPath.compare(0, dbusObjectPath_.length(), dbusObjectPath_) == 0) { - auto dbusStubAdapter = factory_->createDBusStubAdapter(stub, "commonapi.tests.managed.LeafInterface", - instance, "commonapi.tests.managed.LeafInterface", "local"); - - bool success = CommonAPI::DBus::DBusServicePublisher::getInstance()->registerManagedService(dbusStubAdapter); - if (success) { - bool isServiceExportSuccessful = dbusConnection_->getDBusObjectManager()->exportManagedDBusStubAdapter(dbusObjectPath_, dbusStubAdapter); - if (isServiceExportSuccessful) { - registeredLeafInterfaceInstances.insert(instance); - return true; - } else { - CommonAPI::DBus::DBusServicePublisher::getInstance()->unregisterManagedService(commonApiAddress); - } - } - } - } - return false; -} - -bool RootInterfaceDBusStubAdapterInternal::deregisterManagedStubLeafInterface(const std::string& instance) { - std::string commonApiAddress = "local:commonapi.tests.managed.LeafInterface:" + instance; - if (registeredLeafInterfaceInstances.find(instance) != registeredLeafInterfaceInstances.end()) { - std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> dbusStubAdapter = - CommonAPI::DBus::DBusServicePublisher::getInstance()->getRegisteredService(commonApiAddress); - if (dbusStubAdapter != nullptr) { - dbusConnection_->getDBusObjectManager()->unexportManagedDBusStubAdapter(dbusObjectPath_, dbusStubAdapter); - CommonAPI::DBus::DBusServicePublisher::getInstance()->unregisterManagedService(commonApiAddress); - registeredLeafInterfaceInstances.erase(instance); - return true; - } - } - return false; +const CommonAPI::DBus::StubAttributeTable& RootInterfaceDBusStubAdapterInternal::getStubAttributeTable() { + return stubAttributeTable_; } -std::set<std::string>& RootInterfaceDBusStubAdapterInternal::getLeafInterfaceInstances() { - return registeredLeafInterfaceInstances; -} - -bool RootInterfaceDBusStubAdapterInternal::registerManagedStubBranchInterface(std::shared_ptr<BranchInterfaceStub> stub, const std::string& instance) { - if (registeredBranchInterfaceInstances.find(instance) == registeredBranchInterfaceInstances.end()) { - std::string commonApiAddress = "local:commonapi.tests.managed.BranchInterface:" + instance; - - std::string interfaceName; - std::string connectionName; - std::string objectPath; - - CommonAPI::DBus::DBusAddressTranslator::getInstance().searchForDBusAddress( - commonApiAddress, - interfaceName, - connectionName, - objectPath); - - if (objectPath.compare(0, dbusObjectPath_.length(), dbusObjectPath_) == 0) { - auto dbusStubAdapter = factory_->createDBusStubAdapter(stub, "commonapi.tests.managed.BranchInterface", - instance, "commonapi.tests.managed.BranchInterface", "local"); - - bool success = CommonAPI::DBus::DBusServicePublisher::getInstance()->registerManagedService(dbusStubAdapter); - if (success) { - bool isServiceExportSuccessful = dbusConnection_->getDBusObjectManager()->exportManagedDBusStubAdapter(dbusObjectPath_, dbusStubAdapter); - if (isServiceExportSuccessful) { - registeredBranchInterfaceInstances.insert(instance); - return true; - } else { - CommonAPI::DBus::DBusServicePublisher::getInstance()->unregisterManagedService(commonApiAddress); - } - } - } - } - return false; -} - -bool RootInterfaceDBusStubAdapterInternal::deregisterManagedStubBranchInterface(const std::string& instance) { - std::string commonApiAddress = "local:commonapi.tests.managed.BranchInterface:" + instance; - if (registeredBranchInterfaceInstances.find(instance) != registeredBranchInterfaceInstances.end()) { - std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> dbusStubAdapter = - CommonAPI::DBus::DBusServicePublisher::getInstance()->getRegisteredService(commonApiAddress); - if (dbusStubAdapter != nullptr) { - dbusConnection_->getDBusObjectManager()->unexportManagedDBusStubAdapter(dbusObjectPath_, dbusStubAdapter); - CommonAPI::DBus::DBusServicePublisher::getInstance()->unregisterManagedService(commonApiAddress); - registeredBranchInterfaceInstances.erase(instance); - return true; - } - } - return false; -} - -std::set<std::string>& RootInterfaceDBusStubAdapterInternal::getBranchInterfaceInstances() { - return registeredBranchInterfaceInstances; -} + bool RootInterfaceDBusStubAdapterInternal::registerManagedStubLeafInterface(std::shared_ptr<LeafInterfaceStub> stub, const std::string& instance) { + if (registeredLeafInterfaceInstances.find(instance) == registeredLeafInterfaceInstances.end()) { + std::string commonApiAddress = "local:commonapi.tests.managed.LeafInterface:" + instance; + + std::string interfaceName; + std::string connectionName; + std::string objectPath; + + CommonAPI::DBus::DBusAddressTranslator::getInstance().searchForDBusAddress( + commonApiAddress, + interfaceName, + connectionName, + objectPath); + + if (objectPath.compare(0, dbusObjectPath_.length(), dbusObjectPath_) == 0) { + auto dbusStubAdapter = factory_->createDBusStubAdapter(stub, "commonapi.tests.managed.LeafInterface", + instance, "commonapi.tests.managed.LeafInterface", "local"); + + bool success = CommonAPI::DBus::DBusServicePublisher::getInstance()->registerManagedService(dbusStubAdapter); + if (success) { + bool isServiceExportSuccessful = dbusConnection_->getDBusObjectManager()->exportManagedDBusStubAdapter(dbusObjectPath_, dbusStubAdapter); + if (isServiceExportSuccessful) { + registeredLeafInterfaceInstances.insert(instance); + return true; + } else { + CommonAPI::DBus::DBusServicePublisher::getInstance()->unregisterManagedService(commonApiAddress); + } + } + } + } + return false; + } + + bool RootInterfaceDBusStubAdapterInternal::deregisterManagedStubLeafInterface(const std::string& instance) { + std::string commonApiAddress = "local:commonapi.tests.managed.LeafInterface:" + instance; + if (registeredLeafInterfaceInstances.find(instance) != registeredLeafInterfaceInstances.end()) { + std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> dbusStubAdapter = + CommonAPI::DBus::DBusServicePublisher::getInstance()->getRegisteredService(commonApiAddress); + if (dbusStubAdapter != nullptr) { + dbusConnection_->getDBusObjectManager()->unexportManagedDBusStubAdapter(dbusObjectPath_, dbusStubAdapter); + CommonAPI::DBus::DBusServicePublisher::getInstance()->unregisterManagedService(commonApiAddress); + registeredLeafInterfaceInstances.erase(instance); + return true; + } + } + return false; + } + + std::set<std::string>& RootInterfaceDBusStubAdapterInternal::getLeafInterfaceInstances() { + return registeredLeafInterfaceInstances; + } + + bool RootInterfaceDBusStubAdapterInternal::registerManagedStubBranchInterface(std::shared_ptr<BranchInterfaceStub> stub, const std::string& instance) { + if (registeredBranchInterfaceInstances.find(instance) == registeredBranchInterfaceInstances.end()) { + std::string commonApiAddress = "local:commonapi.tests.managed.BranchInterface:" + instance; + + std::string interfaceName; + std::string connectionName; + std::string objectPath; + + CommonAPI::DBus::DBusAddressTranslator::getInstance().searchForDBusAddress( + commonApiAddress, + interfaceName, + connectionName, + objectPath); + + if (objectPath.compare(0, dbusObjectPath_.length(), dbusObjectPath_) == 0) { + auto dbusStubAdapter = factory_->createDBusStubAdapter(stub, "commonapi.tests.managed.BranchInterface", + instance, "commonapi.tests.managed.BranchInterface", "local"); + + bool success = CommonAPI::DBus::DBusServicePublisher::getInstance()->registerManagedService(dbusStubAdapter); + if (success) { + bool isServiceExportSuccessful = dbusConnection_->getDBusObjectManager()->exportManagedDBusStubAdapter(dbusObjectPath_, dbusStubAdapter); + if (isServiceExportSuccessful) { + registeredBranchInterfaceInstances.insert(instance); + return true; + } else { + CommonAPI::DBus::DBusServicePublisher::getInstance()->unregisterManagedService(commonApiAddress); + } + } + } + } + return false; + } + + bool RootInterfaceDBusStubAdapterInternal::deregisterManagedStubBranchInterface(const std::string& instance) { + std::string commonApiAddress = "local:commonapi.tests.managed.BranchInterface:" + instance; + if (registeredBranchInterfaceInstances.find(instance) != registeredBranchInterfaceInstances.end()) { + std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> dbusStubAdapter = + CommonAPI::DBus::DBusServicePublisher::getInstance()->getRegisteredService(commonApiAddress); + if (dbusStubAdapter != nullptr) { + dbusConnection_->getDBusObjectManager()->unexportManagedDBusStubAdapter(dbusObjectPath_, dbusStubAdapter); + CommonAPI::DBus::DBusServicePublisher::getInstance()->unregisterManagedService(commonApiAddress); + registeredBranchInterfaceInstances.erase(instance); + return true; + } + } + return false; + } + + std::set<std::string>& RootInterfaceDBusStubAdapterInternal::getBranchInterfaceInstances() { + return registeredBranchInterfaceInstances; + } RootInterfaceDBusStubAdapterInternal::RootInterfaceDBusStubAdapterInternal( const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, @@ -235,11 +238,16 @@ RootInterfaceDBusStubAdapterInternal::RootInterfaceDBusStubAdapterInternal( true), stubDispatcherTable_({ { { "testRootMethod", "is" }, &commonapi::tests::managed::RootInterfaceDBusStubAdapterInternal::testRootMethodStubDispatcher } - }) { + }), + stubAttributeTable_() { stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::managed::RootInterfaceDBusStubAdapterInternal::getRootInterfaceInterfaceVersionStubDispatcher }); } +const bool RootInterfaceDBusStubAdapterInternal::hasFreedesktopProperties() { + return false; +} + } // namespace managed } // namespace tests } // namespace commonapi diff --git a/src/test/commonapi/tests/managed/RootInterfaceDBusStubAdapter.h b/src/test/commonapi/tests/managed/RootInterfaceDBusStubAdapter.h index 929e6c5..95b8e7e 100644 --- a/src/test/commonapi/tests/managed/RootInterfaceDBusStubAdapter.h +++ b/src/test/commonapi/tests/managed/RootInterfaceDBusStubAdapter.h @@ -42,6 +42,8 @@ class RootInterfaceDBusStubAdapterInternal: public virtual RootInterfaceStubAdap ~RootInterfaceDBusStubAdapterInternal(); + virtual const bool hasFreedesktopProperties(); + bool registerManagedStubLeafInterface(std::shared_ptr<LeafInterfaceStub>, const std::string&); @@ -52,6 +54,7 @@ class RootInterfaceDBusStubAdapterInternal: public virtual RootInterfaceStubAdap std::set<std::string>& getBranchInterfaceInstances(); const RootInterfaceDBusStubAdapterHelper::StubDispatcherTable& getStubDispatcherTable(); + const CommonAPI::DBus::StubAttributeTable& getStubAttributeTable(); void deactivateManagedInstances(); @@ -74,11 +77,12 @@ static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< protected: virtual const char* getMethodsDBusIntrospectionXmlData() const; - - private: + + private: std::set<std::string> registeredLeafInterfaceInstances; std::set<std::string> registeredBranchInterfaceInstances; RootInterfaceDBusStubAdapterHelper::StubDispatcherTable stubDispatcherTable_; + CommonAPI::DBus::StubAttributeTable stubAttributeTable_; }; class RootInterfaceDBusStubAdapter: public RootInterfaceDBusStubAdapterInternal, public std::enable_shared_from_this<RootInterfaceDBusStubAdapter> { diff --git a/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.cpp b/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.cpp index 4ddba05..d96bcf8 100644 --- a/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.cpp +++ b/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.cpp @@ -81,58 +81,61 @@ const SecondRootDBusStubAdapterHelper::StubDispatcherTable& SecondRootDBusStubAd return stubDispatcherTable_; } - -bool SecondRootDBusStubAdapterInternal::registerManagedStubLeafInterface(std::shared_ptr<LeafInterfaceStub> stub, const std::string& instance) { - if (registeredLeafInterfaceInstances.find(instance) == registeredLeafInterfaceInstances.end()) { - std::string commonApiAddress = "local:commonapi.tests.managed.LeafInterface:" + instance; - - std::string interfaceName; - std::string connectionName; - std::string objectPath; - - CommonAPI::DBus::DBusAddressTranslator::getInstance().searchForDBusAddress( - commonApiAddress, - interfaceName, - connectionName, - objectPath); - - if (objectPath.compare(0, dbusObjectPath_.length(), dbusObjectPath_) == 0) { - auto dbusStubAdapter = factory_->createDBusStubAdapter(stub, "commonapi.tests.managed.LeafInterface", - instance, "commonapi.tests.managed.LeafInterface", "local"); - - bool success = CommonAPI::DBus::DBusServicePublisher::getInstance()->registerManagedService(dbusStubAdapter); - if (success) { - bool isServiceExportSuccessful = dbusConnection_->getDBusObjectManager()->exportManagedDBusStubAdapter(dbusObjectPath_, dbusStubAdapter); - if (isServiceExportSuccessful) { - registeredLeafInterfaceInstances.insert(instance); - return true; - } else { - CommonAPI::DBus::DBusServicePublisher::getInstance()->unregisterManagedService(commonApiAddress); - } - } - } - } - return false; -} - -bool SecondRootDBusStubAdapterInternal::deregisterManagedStubLeafInterface(const std::string& instance) { - std::string commonApiAddress = "local:commonapi.tests.managed.LeafInterface:" + instance; - if (registeredLeafInterfaceInstances.find(instance) != registeredLeafInterfaceInstances.end()) { - std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> dbusStubAdapter = - CommonAPI::DBus::DBusServicePublisher::getInstance()->getRegisteredService(commonApiAddress); - if (dbusStubAdapter != nullptr) { - dbusConnection_->getDBusObjectManager()->unexportManagedDBusStubAdapter(dbusObjectPath_, dbusStubAdapter); - CommonAPI::DBus::DBusServicePublisher::getInstance()->unregisterManagedService(commonApiAddress); - registeredLeafInterfaceInstances.erase(instance); - return true; - } - } - return false; +const CommonAPI::DBus::StubAttributeTable& SecondRootDBusStubAdapterInternal::getStubAttributeTable() { + return stubAttributeTable_; } -std::set<std::string>& SecondRootDBusStubAdapterInternal::getLeafInterfaceInstances() { - return registeredLeafInterfaceInstances; -} + bool SecondRootDBusStubAdapterInternal::registerManagedStubLeafInterface(std::shared_ptr<LeafInterfaceStub> stub, const std::string& instance) { + if (registeredLeafInterfaceInstances.find(instance) == registeredLeafInterfaceInstances.end()) { + std::string commonApiAddress = "local:commonapi.tests.managed.LeafInterface:" + instance; + + std::string interfaceName; + std::string connectionName; + std::string objectPath; + + CommonAPI::DBus::DBusAddressTranslator::getInstance().searchForDBusAddress( + commonApiAddress, + interfaceName, + connectionName, + objectPath); + + if (objectPath.compare(0, dbusObjectPath_.length(), dbusObjectPath_) == 0) { + auto dbusStubAdapter = factory_->createDBusStubAdapter(stub, "commonapi.tests.managed.LeafInterface", + instance, "commonapi.tests.managed.LeafInterface", "local"); + + bool success = CommonAPI::DBus::DBusServicePublisher::getInstance()->registerManagedService(dbusStubAdapter); + if (success) { + bool isServiceExportSuccessful = dbusConnection_->getDBusObjectManager()->exportManagedDBusStubAdapter(dbusObjectPath_, dbusStubAdapter); + if (isServiceExportSuccessful) { + registeredLeafInterfaceInstances.insert(instance); + return true; + } else { + CommonAPI::DBus::DBusServicePublisher::getInstance()->unregisterManagedService(commonApiAddress); + } + } + } + } + return false; + } + + bool SecondRootDBusStubAdapterInternal::deregisterManagedStubLeafInterface(const std::string& instance) { + std::string commonApiAddress = "local:commonapi.tests.managed.LeafInterface:" + instance; + if (registeredLeafInterfaceInstances.find(instance) != registeredLeafInterfaceInstances.end()) { + std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> dbusStubAdapter = + CommonAPI::DBus::DBusServicePublisher::getInstance()->getRegisteredService(commonApiAddress); + if (dbusStubAdapter != nullptr) { + dbusConnection_->getDBusObjectManager()->unexportManagedDBusStubAdapter(dbusObjectPath_, dbusStubAdapter); + CommonAPI::DBus::DBusServicePublisher::getInstance()->unregisterManagedService(commonApiAddress); + registeredLeafInterfaceInstances.erase(instance); + return true; + } + } + return false; + } + + std::set<std::string>& SecondRootDBusStubAdapterInternal::getLeafInterfaceInstances() { + return registeredLeafInterfaceInstances; + } SecondRootDBusStubAdapterInternal::SecondRootDBusStubAdapterInternal( const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, @@ -160,11 +163,16 @@ SecondRootDBusStubAdapterInternal::SecondRootDBusStubAdapterInternal( std::dynamic_pointer_cast<SecondRootStub>(stub), true), stubDispatcherTable_({ - }) { + }), + stubAttributeTable_() { stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::managed::SecondRootDBusStubAdapterInternal::getSecondRootInterfaceVersionStubDispatcher }); } +const bool SecondRootDBusStubAdapterInternal::hasFreedesktopProperties() { + return false; +} + } // namespace managed } // namespace tests } // namespace commonapi diff --git a/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.h b/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.h index 4a2afde..604b552 100644 --- a/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.h +++ b/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.h @@ -42,6 +42,8 @@ class SecondRootDBusStubAdapterInternal: public virtual SecondRootStubAdapter, p ~SecondRootDBusStubAdapterInternal(); + virtual const bool hasFreedesktopProperties(); + bool registerManagedStubLeafInterface(std::shared_ptr<LeafInterfaceStub>, const std::string&); @@ -49,6 +51,7 @@ class SecondRootDBusStubAdapterInternal: public virtual SecondRootStubAdapter, p std::set<std::string>& getLeafInterfaceInstances(); const SecondRootDBusStubAdapterHelper::StubDispatcherTable& getStubDispatcherTable(); + const CommonAPI::DBus::StubAttributeTable& getStubAttributeTable(); void deactivateManagedInstances(); @@ -66,10 +69,11 @@ static CommonAPI::DBus::DBusGetAttributeStubDispatcher< protected: virtual const char* getMethodsDBusIntrospectionXmlData() const; - - private: + + private: std::set<std::string> registeredLeafInterfaceInstances; SecondRootDBusStubAdapterHelper::StubDispatcherTable stubDispatcherTable_; + CommonAPI::DBus::StubAttributeTable stubAttributeTable_; }; class SecondRootDBusStubAdapter: public SecondRootDBusStubAdapterInternal, public std::enable_shared_from_this<SecondRootDBusStubAdapter> { |