diff options
Diffstat (limited to 'src/test/commonapi/tests/managed')
38 files changed, 741 insertions, 670 deletions
diff --git a/src/test/commonapi/tests/managed/BranchInterface.h b/src/test/commonapi/tests/managed/BranchInterface.h index 385c656..30749ef 100644 --- a/src/test/commonapi/tests/managed/BranchInterface.h +++ b/src/test/commonapi/tests/managed/BranchInterface.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -77,7 +77,7 @@ namespace CommonAPI { namespace std { //hashes for types - + //hashes for error types //Hash for testBranchMethodError template<> diff --git a/src/test/commonapi/tests/managed/BranchInterfaceDBusProxy.cpp b/src/test/commonapi/tests/managed/BranchInterfaceDBusProxy.cpp index 8c557c5..98a3664 100644 --- a/src/test/commonapi/tests/managed/BranchInterfaceDBusProxy.cpp +++ b/src/test/commonapi/tests/managed/BranchInterfaceDBusProxy.cpp @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -47,7 +47,7 @@ void BranchInterfaceDBusProxy::testBranchMethod(const int32_t& inInt, const std: *this, "testBranchMethod", "is", - inInt, inString, + inInt, inString, callStatus, methodError , outInt, outString); diff --git a/src/test/commonapi/tests/managed/BranchInterfaceDBusProxy.h b/src/test/commonapi/tests/managed/BranchInterfaceDBusProxy.h index 89d520e..23e17a2 100644 --- a/src/test/commonapi/tests/managed/BranchInterfaceDBusProxy.h +++ b/src/test/commonapi/tests/managed/BranchInterfaceDBusProxy.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -12,8 +12,6 @@ #include <commonapi/tests/managed/BranchInterfaceProxyBase.h> - - #if !defined (COMMONAPI_INTERNAL_COMPILATION) #define COMMONAPI_INTERNAL_COMPILATION #endif @@ -45,13 +43,13 @@ class BranchInterfaceDBusProxy: virtual public BranchInterfaceProxyBase, virtual virtual void testBranchMethod(const int32_t& inInt, const std::string& inString, CommonAPI::CallStatus& callStatus, BranchInterface::testBranchMethodError& methodError, int32_t& outInt, std::string& outString); virtual std::future<CommonAPI::CallStatus> testBranchMethodAsync(const int32_t& inInt, const std::string& inString, TestBranchMethodAsyncCallback callback); - + virtual void getOwnVersion(uint16_t& ownVersionMajor, uint16_t& ownVersionMinor) const; private: - + }; diff --git a/src/test/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.cpp b/src/test/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.cpp index d4c0a62..3c14d6b 100644 --- a/src/test/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.cpp +++ b/src/test/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.cpp @@ -1,99 +1,114 @@ - /* - * This file was generated by the CommonAPI Generators. - * Used org.genivi.commonapi.core 2.1.4.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 "BranchInterfaceDBusStubAdapter.h" - #include <commonapi/tests/managed/BranchInterface.h> - - namespace commonapi { - namespace tests { - namespace managed { - - std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> createBranchInterfaceDBusStubAdapter( - 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<BranchInterfaceDBusStubAdapter>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection, stubBase); - } - - __attribute__((constructor)) void registerBranchInterfaceDBusStubAdapter(void) { - CommonAPI::DBus::DBusFactory::registerAdapterFactoryMethod(BranchInterface::getInterfaceId(), - &createBranchInterfaceDBusStubAdapter); - } - - - - BranchInterfaceDBusStubAdapterInternal::~BranchInterfaceDBusStubAdapterInternal() { - deactivateManagedInstances(); - BranchInterfaceDBusStubAdapterHelper::deinit(); - BranchInterfaceDBusStubAdapterHelper::stub_.reset(); - } - - void BranchInterfaceDBusStubAdapterInternal::deactivateManagedInstances() { - } - - const char* BranchInterfaceDBusStubAdapterInternal::getMethodsDBusIntrospectionXmlData() const { - static const std::string introspectionData = - "<method name=\"testBranchMethod\">\n" - "<arg name=\"inInt\" type=\"i\" direction=\"in\" />\n" - "<arg name=\"inString\" type=\"s\" direction=\"in\" />\n" - "<arg name=\"methodError\" type=\"i\" direction=\"out\" />\n" - "<arg name=\"outInt\" type=\"i\" direction=\"out\" />\n" - "<arg name=\"outString\" type=\"s\" direction=\"out\" />\n" - "</method>\n" - - ; - return introspectionData.c_str(); - } - - - static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< - BranchInterfaceStub, - std::tuple<int32_t, std::string>, - std::tuple<BranchInterface::testBranchMethodError, int32_t, std::string> - > testBranchMethodStubDispatcher(&BranchInterfaceStub::testBranchMethod, "iis"); - - - - const BranchInterfaceDBusStubAdapterHelper::StubDispatcherTable& BranchInterfaceDBusStubAdapterInternal::getStubDispatcherTable() { - return stubDispatcherTable_; - } - - - BranchInterfaceDBusStubAdapterInternal::BranchInterfaceDBusStubAdapterInternal( - 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), - BranchInterfaceDBusStubAdapterHelper(factory, commonApiAddress, dbusInterfaceName, dbusBusName, dbusObjectPath, - dbusConnection, std::dynamic_pointer_cast<BranchInterfaceStub>(stub), - false), - stubDispatcherTable_({ - { { "testBranchMethod", "is" }, &commonapi::tests::managed::testBranchMethodStubDispatcher } - }) { - - } - - } // namespace managed - } // namespace tests - } // namespace commonapi +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.4.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 "BranchInterfaceDBusStubAdapter.h" +#include <commonapi/tests/managed/BranchInterface.h> + +namespace commonapi { +namespace tests { +namespace managed { + +std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> createBranchInterfaceDBusStubAdapter( + 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<BranchInterfaceDBusStubAdapter>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection, stubBase); +} + +__attribute__((constructor)) void registerBranchInterfaceDBusStubAdapter(void) { + CommonAPI::DBus::DBusFactory::registerAdapterFactoryMethod(BranchInterface::getInterfaceId(), + &createBranchInterfaceDBusStubAdapter); +} + + + +BranchInterfaceDBusStubAdapterInternal::~BranchInterfaceDBusStubAdapterInternal() { + deactivateManagedInstances(); + BranchInterfaceDBusStubAdapterHelper::deinit(); + BranchInterfaceDBusStubAdapterHelper::stub_.reset(); +} + +void BranchInterfaceDBusStubAdapterInternal::deactivateManagedInstances() { +} + +const char* BranchInterfaceDBusStubAdapterInternal::getMethodsDBusIntrospectionXmlData() const { + static const std::string introspectionData = + "<method name=\"getInterfaceVersion\">\n" + "<arg name=\"value\" type=\"uu\" direction=\"out\" />" + "</method>\n" + "<method name=\"testBranchMethod\">\n" + "<arg name=\"inInt\" type=\"i\" direction=\"in\" />\n" + "<arg name=\"inString\" type=\"s\" direction=\"in\" />\n" + "<arg name=\"methodError\" type=\"i\" direction=\"out\" />\n" + "<arg name=\"outInt\" type=\"i\" direction=\"out\" />\n" + "<arg name=\"outString\" type=\"s\" direction=\"out\" />\n" + "</method>\n" + + ; + return introspectionData.c_str(); +} + +static CommonAPI::DBus::DBusGetAttributeStubDispatcher< + BranchInterfaceStub, + CommonAPI::Version + > getBranchInterfaceInterfaceVersionStubDispatcher(&BranchInterfaceStub::getInterfaceVersion, "uu"); + + +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + BranchInterfaceStub, + std::tuple<int32_t, std::string>, + std::tuple<BranchInterface::testBranchMethodError, int32_t, std::string> + > testBranchMethodStubDispatcher(&BranchInterfaceStub::testBranchMethod, "iis"); + + + +const BranchInterfaceDBusStubAdapterHelper::StubDispatcherTable& BranchInterfaceDBusStubAdapterInternal::getStubDispatcherTable() { + return stubDispatcherTable_; +} + + +BranchInterfaceDBusStubAdapterInternal::BranchInterfaceDBusStubAdapterInternal( + 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), + BranchInterfaceDBusStubAdapterHelper( + factory, + commonApiAddress, + dbusInterfaceName, + dbusBusName, + dbusObjectPath, + dbusConnection, + std::dynamic_pointer_cast<BranchInterfaceStub>(stub), + false), + stubDispatcherTable_({ + { { "testBranchMethod", "is" }, &commonapi::tests::managed::testBranchMethodStubDispatcher } + }) { + + stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::managed::getBranchInterfaceInterfaceVersionStubDispatcher }); +} + +} // 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 21e46a2..a7dde87 100644 --- a/src/test/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.h +++ b/src/test/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -12,7 +12,6 @@ #include <commonapi/tests/managed/BranchInterfaceStub.h> - #if !defined (COMMONAPI_INTERNAL_COMPILATION) #define COMMONAPI_INTERNAL_COMPILATION #endif @@ -44,12 +43,12 @@ class BranchInterfaceDBusStubAdapterInternal: public BranchInterfaceStubAdapter, ~BranchInterfaceDBusStubAdapterInternal(); - + const BranchInterfaceDBusStubAdapterHelper::StubDispatcherTable& getStubDispatcherTable(); - + void deactivateManagedInstances(); - + protected: virtual const char* getMethodsDBusIntrospectionXmlData() const; diff --git a/src/test/commonapi/tests/managed/BranchInterfaceProxy.h b/src/test/commonapi/tests/managed/BranchInterfaceProxy.h index 6517b8d..828c95a 100644 --- a/src/test/commonapi/tests/managed/BranchInterfaceProxy.h +++ b/src/test/commonapi/tests/managed/BranchInterfaceProxy.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -30,9 +30,9 @@ class BranchInterfaceProxy: virtual public BranchInterface, virtual public Branc public: BranchInterfaceProxy(std::shared_ptr<CommonAPI::Proxy> delegate); ~BranchInterfaceProxy(); - + typedef BranchInterface InterfaceType; - + @@ -57,7 +57,7 @@ public: * It will provide the same value for CallStatus as will be handed to the callback. */ virtual std::future<CommonAPI::CallStatus> testBranchMethodAsync(const int32_t& inInt, const std::string& inString, TestBranchMethodAsyncCallback callback); - + /** * Returns the CommonAPI address of the remote partner this proxy communicates with. @@ -169,7 +169,6 @@ CommonAPI::InterfaceVersionAttribute& BranchInterfaceProxy<_AttributeExtensions. return delegate_->getInterfaceVersionAttribute(); } - } // namespace managed } // namespace tests diff --git a/src/test/commonapi/tests/managed/BranchInterfaceProxyBase.h b/src/test/commonapi/tests/managed/BranchInterfaceProxyBase.h index d5a61c1..cbfcf74 100644 --- a/src/test/commonapi/tests/managed/BranchInterfaceProxyBase.h +++ b/src/test/commonapi/tests/managed/BranchInterfaceProxyBase.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -14,7 +14,6 @@ - #if !defined (COMMONAPI_INTERNAL_COMPILATION) #define COMMONAPI_INTERNAL_COMPILATION #endif diff --git a/src/test/commonapi/tests/managed/BranchInterfaceStub.h b/src/test/commonapi/tests/managed/BranchInterfaceStub.h index 160312a..c129327 100644 --- a/src/test/commonapi/tests/managed/BranchInterfaceStub.h +++ b/src/test/commonapi/tests/managed/BranchInterfaceStub.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -38,10 +38,9 @@ namespace managed { class BranchInterfaceStubAdapter: virtual public CommonAPI::StubAdapter, public BranchInterface { public: - - + + virtual void deactivateManagedInstances() = 0; - protected: /** * Defines properties for storing the ClientIds of clients / proxies that have @@ -78,16 +77,15 @@ class BranchInterfaceStubRemoteEvent { class BranchInterfaceStub : public virtual CommonAPI::Stub<BranchInterfaceStubAdapter, BranchInterfaceStubRemoteEvent> { public: virtual ~BranchInterfaceStub() { } + virtual const CommonAPI::Version& getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId) = 0; /// This is the method that will be called on remote calls on the method testBranchMethod. virtual void testBranchMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, int32_t inInt, std::string inString, BranchInterface::testBranchMethodError& methodError, int32_t& outInt, std::string& outString) = 0; - - + using CommonAPI::Stub<BranchInterfaceStubAdapter, BranchInterfaceStubRemoteEvent>::initStubAdapter; typedef CommonAPI::Stub<BranchInterfaceStubAdapter, BranchInterfaceStubRemoteEvent>::StubAdapterType StubAdapterType; typedef CommonAPI::Stub<BranchInterfaceStubAdapter, BranchInterfaceStubRemoteEvent>::RemoteEventHandlerType RemoteEventHandlerType; - }; } // namespace managed diff --git a/src/test/commonapi/tests/managed/BranchInterfaceStubDefault.cpp b/src/test/commonapi/tests/managed/BranchInterfaceStubDefault.cpp index 039c64c..65a807b 100644 --- a/src/test/commonapi/tests/managed/BranchInterfaceStubDefault.cpp +++ b/src/test/commonapi/tests/managed/BranchInterfaceStubDefault.cpp @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -14,7 +14,12 @@ namespace tests { namespace managed { BranchInterfaceStubDefault::BranchInterfaceStubDefault(): - remoteEventHandler_(this) { + remoteEventHandler_(this), + interfaceVersion_(BranchInterface::getInterfaceVersion()) { +} + +const CommonAPI::Version& BranchInterfaceStubDefault::getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId) { + return interfaceVersion_; } BranchInterfaceStubRemoteEvent* BranchInterfaceStubDefault::initStubAdapter(const std::shared_ptr<BranchInterfaceStubAdapter>& stubAdapter) { diff --git a/src/test/commonapi/tests/managed/BranchInterfaceStubDefault.h b/src/test/commonapi/tests/managed/BranchInterfaceStubDefault.h index 90b0787..c191a83 100644 --- a/src/test/commonapi/tests/managed/BranchInterfaceStubDefault.h +++ b/src/test/commonapi/tests/managed/BranchInterfaceStubDefault.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -34,12 +34,14 @@ public: BranchInterfaceStubRemoteEvent* initStubAdapter(const std::shared_ptr<BranchInterfaceStubAdapter>& stubAdapter); + const CommonAPI::Version& getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId); + virtual void testBranchMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, int32_t inInt, std::string inString, BranchInterface::testBranchMethodError& methodError, int32_t& outInt, std::string& outString); virtual void testBranchMethod(int32_t inInt, std::string inString, BranchInterface::testBranchMethodError& methodError, int32_t& outInt, std::string& outString); - + protected: private: @@ -54,6 +56,8 @@ private: RemoteEventHandler remoteEventHandler_; + + CommonAPI::Version interfaceVersion_; }; } // namespace managed diff --git a/src/test/commonapi/tests/managed/LeafInterface.h b/src/test/commonapi/tests/managed/LeafInterface.h index d3a05cd..45bf376 100644 --- a/src/test/commonapi/tests/managed/LeafInterface.h +++ b/src/test/commonapi/tests/managed/LeafInterface.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -77,7 +77,7 @@ namespace CommonAPI { namespace std { //hashes for types - + //hashes for error types //Hash for testLeafMethodError template<> diff --git a/src/test/commonapi/tests/managed/LeafInterfaceDBusProxy.cpp b/src/test/commonapi/tests/managed/LeafInterfaceDBusProxy.cpp index 5c163da..da6cef5 100644 --- a/src/test/commonapi/tests/managed/LeafInterfaceDBusProxy.cpp +++ b/src/test/commonapi/tests/managed/LeafInterfaceDBusProxy.cpp @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -47,7 +47,7 @@ void LeafInterfaceDBusProxy::testLeafMethod(const int32_t& inInt, const std::str *this, "testLeafMethod", "is", - inInt, inString, + inInt, inString, callStatus, methodError , outInt, outString); diff --git a/src/test/commonapi/tests/managed/LeafInterfaceDBusProxy.h b/src/test/commonapi/tests/managed/LeafInterfaceDBusProxy.h index 17fde80..e257805 100644 --- a/src/test/commonapi/tests/managed/LeafInterfaceDBusProxy.h +++ b/src/test/commonapi/tests/managed/LeafInterfaceDBusProxy.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -12,8 +12,6 @@ #include <commonapi/tests/managed/LeafInterfaceProxyBase.h> - - #if !defined (COMMONAPI_INTERNAL_COMPILATION) #define COMMONAPI_INTERNAL_COMPILATION #endif @@ -45,13 +43,13 @@ class LeafInterfaceDBusProxy: virtual public LeafInterfaceProxyBase, virtual pub virtual void testLeafMethod(const int32_t& inInt, const std::string& inString, CommonAPI::CallStatus& callStatus, LeafInterface::testLeafMethodError& methodError, int32_t& outInt, std::string& outString); virtual std::future<CommonAPI::CallStatus> testLeafMethodAsync(const int32_t& inInt, const std::string& inString, TestLeafMethodAsyncCallback callback); - + virtual void getOwnVersion(uint16_t& ownVersionMajor, uint16_t& ownVersionMinor) const; private: - + }; diff --git a/src/test/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.cpp b/src/test/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.cpp index 787d4ec..21441a3 100644 --- a/src/test/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.cpp +++ b/src/test/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.cpp @@ -1,99 +1,114 @@ - /* - * This file was generated by the CommonAPI Generators. - * Used org.genivi.commonapi.core 2.1.4.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 "LeafInterfaceDBusStubAdapter.h" - #include <commonapi/tests/managed/LeafInterface.h> - - namespace commonapi { - namespace tests { - namespace managed { - - std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> createLeafInterfaceDBusStubAdapter( - 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<LeafInterfaceDBusStubAdapter>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection, stubBase); - } - - __attribute__((constructor)) void registerLeafInterfaceDBusStubAdapter(void) { - CommonAPI::DBus::DBusFactory::registerAdapterFactoryMethod(LeafInterface::getInterfaceId(), - &createLeafInterfaceDBusStubAdapter); - } - - - - LeafInterfaceDBusStubAdapterInternal::~LeafInterfaceDBusStubAdapterInternal() { - deactivateManagedInstances(); - LeafInterfaceDBusStubAdapterHelper::deinit(); - LeafInterfaceDBusStubAdapterHelper::stub_.reset(); - } - - void LeafInterfaceDBusStubAdapterInternal::deactivateManagedInstances() { - } - - const char* LeafInterfaceDBusStubAdapterInternal::getMethodsDBusIntrospectionXmlData() const { - static const std::string introspectionData = - "<method name=\"testLeafMethod\">\n" - "<arg name=\"inInt\" type=\"i\" direction=\"in\" />\n" - "<arg name=\"inString\" type=\"s\" direction=\"in\" />\n" - "<arg name=\"methodError\" type=\"i\" direction=\"out\" />\n" - "<arg name=\"outInt\" type=\"i\" direction=\"out\" />\n" - "<arg name=\"outString\" type=\"s\" direction=\"out\" />\n" - "</method>\n" - - ; - return introspectionData.c_str(); - } - - - static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< - LeafInterfaceStub, - std::tuple<int32_t, std::string>, - std::tuple<LeafInterface::testLeafMethodError, int32_t, std::string> - > testLeafMethodStubDispatcher(&LeafInterfaceStub::testLeafMethod, "iis"); - - - - const LeafInterfaceDBusStubAdapterHelper::StubDispatcherTable& LeafInterfaceDBusStubAdapterInternal::getStubDispatcherTable() { - return stubDispatcherTable_; - } - - - LeafInterfaceDBusStubAdapterInternal::LeafInterfaceDBusStubAdapterInternal( - 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), - LeafInterfaceDBusStubAdapterHelper(factory, commonApiAddress, dbusInterfaceName, dbusBusName, dbusObjectPath, - dbusConnection, std::dynamic_pointer_cast<LeafInterfaceStub>(stub), - false), - stubDispatcherTable_({ - { { "testLeafMethod", "is" }, &commonapi::tests::managed::testLeafMethodStubDispatcher } - }) { - - } - - } // namespace managed - } // namespace tests - } // namespace commonapi +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.4.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 "LeafInterfaceDBusStubAdapter.h" +#include <commonapi/tests/managed/LeafInterface.h> + +namespace commonapi { +namespace tests { +namespace managed { + +std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> createLeafInterfaceDBusStubAdapter( + 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<LeafInterfaceDBusStubAdapter>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection, stubBase); +} + +__attribute__((constructor)) void registerLeafInterfaceDBusStubAdapter(void) { + CommonAPI::DBus::DBusFactory::registerAdapterFactoryMethod(LeafInterface::getInterfaceId(), + &createLeafInterfaceDBusStubAdapter); +} + + + +LeafInterfaceDBusStubAdapterInternal::~LeafInterfaceDBusStubAdapterInternal() { + deactivateManagedInstances(); + LeafInterfaceDBusStubAdapterHelper::deinit(); + LeafInterfaceDBusStubAdapterHelper::stub_.reset(); +} + +void LeafInterfaceDBusStubAdapterInternal::deactivateManagedInstances() { +} + +const char* LeafInterfaceDBusStubAdapterInternal::getMethodsDBusIntrospectionXmlData() const { + static const std::string introspectionData = + "<method name=\"getInterfaceVersion\">\n" + "<arg name=\"value\" type=\"uu\" direction=\"out\" />" + "</method>\n" + "<method name=\"testLeafMethod\">\n" + "<arg name=\"inInt\" type=\"i\" direction=\"in\" />\n" + "<arg name=\"inString\" type=\"s\" direction=\"in\" />\n" + "<arg name=\"methodError\" type=\"i\" direction=\"out\" />\n" + "<arg name=\"outInt\" type=\"i\" direction=\"out\" />\n" + "<arg name=\"outString\" type=\"s\" direction=\"out\" />\n" + "</method>\n" + + ; + return introspectionData.c_str(); +} + +static CommonAPI::DBus::DBusGetAttributeStubDispatcher< + LeafInterfaceStub, + CommonAPI::Version + > getLeafInterfaceInterfaceVersionStubDispatcher(&LeafInterfaceStub::getInterfaceVersion, "uu"); + + +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + LeafInterfaceStub, + std::tuple<int32_t, std::string>, + std::tuple<LeafInterface::testLeafMethodError, int32_t, std::string> + > testLeafMethodStubDispatcher(&LeafInterfaceStub::testLeafMethod, "iis"); + + + +const LeafInterfaceDBusStubAdapterHelper::StubDispatcherTable& LeafInterfaceDBusStubAdapterInternal::getStubDispatcherTable() { + return stubDispatcherTable_; +} + + +LeafInterfaceDBusStubAdapterInternal::LeafInterfaceDBusStubAdapterInternal( + 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), + LeafInterfaceDBusStubAdapterHelper( + factory, + commonApiAddress, + dbusInterfaceName, + dbusBusName, + dbusObjectPath, + dbusConnection, + std::dynamic_pointer_cast<LeafInterfaceStub>(stub), + false), + stubDispatcherTable_({ + { { "testLeafMethod", "is" }, &commonapi::tests::managed::testLeafMethodStubDispatcher } + }) { + + stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::managed::getLeafInterfaceInterfaceVersionStubDispatcher }); +} + +} // 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 f60c9b5..f0ecb1f 100644 --- a/src/test/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.h +++ b/src/test/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -12,7 +12,6 @@ #include <commonapi/tests/managed/LeafInterfaceStub.h> - #if !defined (COMMONAPI_INTERNAL_COMPILATION) #define COMMONAPI_INTERNAL_COMPILATION #endif @@ -44,12 +43,12 @@ class LeafInterfaceDBusStubAdapterInternal: public LeafInterfaceStubAdapter, pub ~LeafInterfaceDBusStubAdapterInternal(); - + const LeafInterfaceDBusStubAdapterHelper::StubDispatcherTable& getStubDispatcherTable(); - + void deactivateManagedInstances(); - + protected: virtual const char* getMethodsDBusIntrospectionXmlData() const; diff --git a/src/test/commonapi/tests/managed/LeafInterfaceStub.h b/src/test/commonapi/tests/managed/LeafInterfaceStub.h index 95ef485..921e78f 100644 --- a/src/test/commonapi/tests/managed/LeafInterfaceStub.h +++ b/src/test/commonapi/tests/managed/LeafInterfaceStub.h @@ -78,16 +78,15 @@ class LeafInterfaceStubRemoteEvent { class LeafInterfaceStub : public virtual CommonAPI::Stub<LeafInterfaceStubAdapter, LeafInterfaceStubRemoteEvent> { public: virtual ~LeafInterfaceStub() { } + virtual const CommonAPI::Version& getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId) = 0; /// This is the method that will be called on remote calls on the method testLeafMethod. virtual void testLeafMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, int32_t inInt, std::string inString, LeafInterface::testLeafMethodError& methodError, int32_t& outInt, std::string& outString) = 0; - using CommonAPI::Stub<LeafInterfaceStubAdapter, LeafInterfaceStubRemoteEvent>::initStubAdapter; typedef CommonAPI::Stub<LeafInterfaceStubAdapter, LeafInterfaceStubRemoteEvent>::StubAdapterType StubAdapterType; typedef CommonAPI::Stub<LeafInterfaceStubAdapter, LeafInterfaceStubRemoteEvent>::RemoteEventHandlerType RemoteEventHandlerType; - }; } // namespace managed diff --git a/src/test/commonapi/tests/managed/LeafInterfaceStubDefault.cpp b/src/test/commonapi/tests/managed/LeafInterfaceStubDefault.cpp index f653e18..fe18ffc 100644 --- a/src/test/commonapi/tests/managed/LeafInterfaceStubDefault.cpp +++ b/src/test/commonapi/tests/managed/LeafInterfaceStubDefault.cpp @@ -14,7 +14,12 @@ namespace tests { namespace managed { LeafInterfaceStubDefault::LeafInterfaceStubDefault(): - remoteEventHandler_(this) { + remoteEventHandler_(this), + interfaceVersion_(LeafInterface::getInterfaceVersion()) { +} + +const CommonAPI::Version& LeafInterfaceStubDefault::getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId) { + return interfaceVersion_; } LeafInterfaceStubRemoteEvent* LeafInterfaceStubDefault::initStubAdapter(const std::shared_ptr<LeafInterfaceStubAdapter>& stubAdapter) { diff --git a/src/test/commonapi/tests/managed/LeafInterfaceStubDefault.h b/src/test/commonapi/tests/managed/LeafInterfaceStubDefault.h index e9227b8..a13cada 100644 --- a/src/test/commonapi/tests/managed/LeafInterfaceStubDefault.h +++ b/src/test/commonapi/tests/managed/LeafInterfaceStubDefault.h @@ -33,6 +33,8 @@ public: LeafInterfaceStubDefault(); LeafInterfaceStubRemoteEvent* initStubAdapter(const std::shared_ptr<LeafInterfaceStubAdapter>& stubAdapter); + + const CommonAPI::Version& getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId); virtual void testLeafMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, int32_t inInt, std::string inString, LeafInterface::testLeafMethodError& methodError, int32_t& outInt, std::string& outString); @@ -54,6 +56,8 @@ private: RemoteEventHandler remoteEventHandler_; + + CommonAPI::Version interfaceVersion_; }; } // namespace managed diff --git a/src/test/commonapi/tests/managed/RootInterface.h b/src/test/commonapi/tests/managed/RootInterface.h index 7894869..7cd0288 100644 --- a/src/test/commonapi/tests/managed/RootInterface.h +++ b/src/test/commonapi/tests/managed/RootInterface.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -78,7 +78,7 @@ namespace CommonAPI { namespace std { //hashes for types - + //hashes for error types //Hash for testRootMethodError template<> diff --git a/src/test/commonapi/tests/managed/RootInterfaceDBusProxy.cpp b/src/test/commonapi/tests/managed/RootInterfaceDBusProxy.cpp index b7eb845..c9b14e1 100644 --- a/src/test/commonapi/tests/managed/RootInterfaceDBusProxy.cpp +++ b/src/test/commonapi/tests/managed/RootInterfaceDBusProxy.cpp @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -49,7 +49,7 @@ void RootInterfaceDBusProxy::testRootMethod(const int32_t& inInt, const std::str *this, "testRootMethod", "is", - inInt, inString, + inInt, inString, callStatus, methodError , outInt, outString); diff --git a/src/test/commonapi/tests/managed/RootInterfaceDBusProxy.h b/src/test/commonapi/tests/managed/RootInterfaceDBusProxy.h index 07f5798..a59ab2e 100644 --- a/src/test/commonapi/tests/managed/RootInterfaceDBusProxy.h +++ b/src/test/commonapi/tests/managed/RootInterfaceDBusProxy.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -12,8 +12,6 @@ #include <commonapi/tests/managed/RootInterfaceProxyBase.h> - - #if !defined (COMMONAPI_INTERNAL_COMPILATION) #define COMMONAPI_INTERNAL_COMPILATION #endif @@ -46,7 +44,7 @@ class RootInterfaceDBusProxy: virtual public RootInterfaceProxyBase, virtual pub virtual void testRootMethod(const int32_t& inInt, const std::string& inString, CommonAPI::CallStatus& callStatus, RootInterface::testRootMethodError& methodError, int32_t& outInt, std::string& outString); virtual std::future<CommonAPI::CallStatus> testRootMethodAsync(const int32_t& inInt, const std::string& inString, TestRootMethodAsyncCallback callback); - + virtual CommonAPI::ProxyManager& getProxyManagerLeafInterface(); virtual CommonAPI::ProxyManager& getProxyManagerBranchInterface(); @@ -54,7 +52,7 @@ class RootInterfaceDBusProxy: virtual public RootInterfaceProxyBase, virtual pub private: - + CommonAPI::DBus::DBusProxyManager proxyManagerLeafInterface_; CommonAPI::DBus::DBusProxyManager proxyManagerBranchInterface_; }; diff --git a/src/test/commonapi/tests/managed/RootInterfaceDBusStubAdapter.cpp b/src/test/commonapi/tests/managed/RootInterfaceDBusStubAdapter.cpp index 66a9965..0ae8c1f 100644 --- a/src/test/commonapi/tests/managed/RootInterfaceDBusStubAdapter.cpp +++ b/src/test/commonapi/tests/managed/RootInterfaceDBusStubAdapter.cpp @@ -1,215 +1,230 @@ - /* - * This file was generated by the CommonAPI Generators. - * Used org.genivi.commonapi.core 2.1.4.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 "RootInterfaceDBusStubAdapter.h" - #include <commonapi/tests/managed/RootInterface.h> - - namespace commonapi { - namespace tests { - namespace managed { - - std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> createRootInterfaceDBusStubAdapter( - 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<RootInterfaceDBusStubAdapter>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection, stubBase); - } - - __attribute__((constructor)) void registerRootInterfaceDBusStubAdapter(void) { - CommonAPI::DBus::DBusFactory::registerAdapterFactoryMethod(RootInterface::getInterfaceId(), - &createRootInterfaceDBusStubAdapter); - } - - - - RootInterfaceDBusStubAdapterInternal::~RootInterfaceDBusStubAdapterInternal() { - deactivateManagedInstances(); - RootInterfaceDBusStubAdapterHelper::deinit(); - RootInterfaceDBusStubAdapterHelper::stub_.reset(); - } - - void RootInterfaceDBusStubAdapterInternal::deactivateManagedInstances() { - for(std::set<std::string>::iterator iter = registeredLeafInterfaceInstances.begin(); - iter != registeredLeafInterfaceInstances.end(); ++iter) { - deregisterManagedStubLeafInterface(*iter); - } - for(std::set<std::string>::iterator iter = registeredBranchInterfaceInstances.begin(); - iter != registeredBranchInterfaceInstances.end(); ++iter) { - deregisterManagedStubBranchInterface(*iter); - } - } - - const char* RootInterfaceDBusStubAdapterInternal::getMethodsDBusIntrospectionXmlData() const { - static const std::string introspectionData = - "<method name=\"testRootMethod\">\n" - "<arg name=\"inInt\" type=\"i\" direction=\"in\" />\n" - "<arg name=\"inString\" type=\"s\" direction=\"in\" />\n" - "<arg name=\"methodError\" type=\"i\" direction=\"out\" />\n" - "<arg name=\"outInt\" type=\"i\" direction=\"out\" />\n" - "<arg name=\"outString\" type=\"s\" direction=\"out\" />\n" - "</method>\n" - - ; - return introspectionData.c_str(); - } - - - static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< - RootInterfaceStub, - std::tuple<int32_t, std::string>, - std::tuple<RootInterface::testRootMethodError, int32_t, std::string> - > testRootMethodStubDispatcher(&RootInterfaceStub::testRootMethod, "iis"); - - - - const RootInterfaceDBusStubAdapterHelper::StubDispatcherTable& RootInterfaceDBusStubAdapterInternal::getStubDispatcherTable() { - 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 { - const bool isManagedDeregistrationSuccessful = - 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 { - const bool isManagedDeregistrationSuccessful = - 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, - 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, - true), - RootInterfaceDBusStubAdapterHelper(factory, commonApiAddress, dbusInterfaceName, dbusBusName, dbusObjectPath, - dbusConnection, std::dynamic_pointer_cast<RootInterfaceStub>(stub), - true), - stubDispatcherTable_({ - { { "testRootMethod", "is" }, &commonapi::tests::managed::testRootMethodStubDispatcher } - }) { - - } - - } // namespace managed - } // namespace tests - } // namespace commonapi +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.4.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 "RootInterfaceDBusStubAdapter.h" +#include <commonapi/tests/managed/RootInterface.h> + +namespace commonapi { +namespace tests { +namespace managed { + +std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> createRootInterfaceDBusStubAdapter( + 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<RootInterfaceDBusStubAdapter>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection, stubBase); +} + +__attribute__((constructor)) void registerRootInterfaceDBusStubAdapter(void) { + CommonAPI::DBus::DBusFactory::registerAdapterFactoryMethod(RootInterface::getInterfaceId(), + &createRootInterfaceDBusStubAdapter); +} + + + +RootInterfaceDBusStubAdapterInternal::~RootInterfaceDBusStubAdapterInternal() { + deactivateManagedInstances(); + RootInterfaceDBusStubAdapterHelper::deinit(); + RootInterfaceDBusStubAdapterHelper::stub_.reset(); +} + +void RootInterfaceDBusStubAdapterInternal::deactivateManagedInstances() { + for(std::set<std::string>::iterator iter = registeredLeafInterfaceInstances.begin(); + iter != registeredLeafInterfaceInstances.end(); ++iter) { + deregisterManagedStubLeafInterface(*iter); + } + for(std::set<std::string>::iterator iter = registeredBranchInterfaceInstances.begin(); + iter != registeredBranchInterfaceInstances.end(); ++iter) { + deregisterManagedStubBranchInterface(*iter); + } +} + +const char* RootInterfaceDBusStubAdapterInternal::getMethodsDBusIntrospectionXmlData() const { + static const std::string introspectionData = + "<method name=\"getInterfaceVersion\">\n" + "<arg name=\"value\" type=\"uu\" direction=\"out\" />" + "</method>\n" + "<method name=\"testRootMethod\">\n" + "<arg name=\"inInt\" type=\"i\" direction=\"in\" />\n" + "<arg name=\"inString\" type=\"s\" direction=\"in\" />\n" + "<arg name=\"methodError\" type=\"i\" direction=\"out\" />\n" + "<arg name=\"outInt\" type=\"i\" direction=\"out\" />\n" + "<arg name=\"outString\" type=\"s\" direction=\"out\" />\n" + "</method>\n" + + ; + return introspectionData.c_str(); +} + +static CommonAPI::DBus::DBusGetAttributeStubDispatcher< + RootInterfaceStub, + CommonAPI::Version + > getRootInterfaceInterfaceVersionStubDispatcher(&RootInterfaceStub::getInterfaceVersion, "uu"); + + +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + RootInterfaceStub, + std::tuple<int32_t, std::string>, + std::tuple<RootInterface::testRootMethodError, int32_t, std::string> + > testRootMethodStubDispatcher(&RootInterfaceStub::testRootMethod, "iis"); + + + +const RootInterfaceDBusStubAdapterHelper::StubDispatcherTable& RootInterfaceDBusStubAdapterInternal::getStubDispatcherTable() { + 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 { + const bool isManagedDeregistrationSuccessful = + 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 { + const bool isManagedDeregistrationSuccessful = + 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, + 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, + true), + RootInterfaceDBusStubAdapterHelper( + factory, + commonApiAddress, + dbusInterfaceName, + dbusBusName, + dbusObjectPath, + dbusConnection, + std::dynamic_pointer_cast<RootInterfaceStub>(stub), + true), + stubDispatcherTable_({ + { { "testRootMethod", "is" }, &commonapi::tests::managed::testRootMethodStubDispatcher } + }) { + + stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::managed::getRootInterfaceInterfaceVersionStubDispatcher }); +} + +} // 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 01ef3a4..c46abfa 100644 --- a/src/test/commonapi/tests/managed/RootInterfaceDBusStubAdapter.h +++ b/src/test/commonapi/tests/managed/RootInterfaceDBusStubAdapter.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -12,7 +12,6 @@ #include <commonapi/tests/managed/RootInterfaceStub.h> - #if !defined (COMMONAPI_INTERNAL_COMPILATION) #define COMMONAPI_INTERNAL_COMPILATION #endif @@ -44,7 +43,7 @@ class RootInterfaceDBusStubAdapterInternal: public RootInterfaceStubAdapter, pub ~RootInterfaceDBusStubAdapterInternal(); - + bool registerManagedStubLeafInterface(std::shared_ptr<LeafInterfaceStub>, const std::string&); bool deregisterManagedStubLeafInterface(const std::string&); std::set<std::string>& getLeafInterfaceInstances(); @@ -53,9 +52,9 @@ class RootInterfaceDBusStubAdapterInternal: public RootInterfaceStubAdapter, pub std::set<std::string>& getBranchInterfaceInstances(); const RootInterfaceDBusStubAdapterHelper::StubDispatcherTable& getStubDispatcherTable(); - + void deactivateManagedInstances(); - + protected: virtual const char* getMethodsDBusIntrospectionXmlData() const; diff --git a/src/test/commonapi/tests/managed/RootInterfaceProxy.h b/src/test/commonapi/tests/managed/RootInterfaceProxy.h index 672c0d5..076fec7 100644 --- a/src/test/commonapi/tests/managed/RootInterfaceProxy.h +++ b/src/test/commonapi/tests/managed/RootInterfaceProxy.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -30,9 +30,9 @@ class RootInterfaceProxy: virtual public RootInterface, virtual public RootInter public: RootInterfaceProxy(std::shared_ptr<CommonAPI::Proxy> delegate); ~RootInterfaceProxy(); - + typedef RootInterface InterfaceType; - + @@ -57,7 +57,7 @@ public: * It will provide the same value for CallStatus as will be handed to the callback. */ virtual std::future<CommonAPI::CallStatus> testRootMethodAsync(const int32_t& inInt, const std::string& inString, TestRootMethodAsyncCallback callback); - + virtual CommonAPI::ProxyManager& getProxyManagerLeafInterface(); virtual CommonAPI::ProxyManager& getProxyManagerBranchInterface(); @@ -171,7 +171,6 @@ CommonAPI::InterfaceVersionAttribute& RootInterfaceProxy<_AttributeExtensions... return delegate_->getInterfaceVersionAttribute(); } - template <typename ... _AttributeExtensions> CommonAPI::ProxyManager& RootInterfaceProxy<_AttributeExtensions...>::getProxyManagerLeafInterface() { return delegate_->getProxyManagerLeafInterface(); diff --git a/src/test/commonapi/tests/managed/RootInterfaceProxyBase.h b/src/test/commonapi/tests/managed/RootInterfaceProxyBase.h index 550093f..167adc7 100644 --- a/src/test/commonapi/tests/managed/RootInterfaceProxyBase.h +++ b/src/test/commonapi/tests/managed/RootInterfaceProxyBase.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -13,7 +13,6 @@ #include "RootInterface.h" - #include <commonapi/tests/managed/BranchInterfaceStub.h> #include <commonapi/tests/managed/LeafInterfaceStub.h> diff --git a/src/test/commonapi/tests/managed/RootInterfaceStub.h b/src/test/commonapi/tests/managed/RootInterfaceStub.h index 0dbd088..3e28cc1 100644 --- a/src/test/commonapi/tests/managed/RootInterfaceStub.h +++ b/src/test/commonapi/tests/managed/RootInterfaceStub.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -40,16 +40,15 @@ namespace managed { class RootInterfaceStubAdapter: virtual public CommonAPI::StubAdapter, public RootInterface { public: - + virtual bool registerManagedStubLeafInterface(std::shared_ptr<LeafInterfaceStub>, const std::string&) = 0; virtual bool deregisterManagedStubLeafInterface(const std::string&) = 0; virtual std::set<std::string>& getLeafInterfaceInstances() = 0; virtual bool registerManagedStubBranchInterface(std::shared_ptr<BranchInterfaceStub>, const std::string&) = 0; virtual bool deregisterManagedStubBranchInterface(const std::string&) = 0; virtual std::set<std::string>& getBranchInterfaceInstances() = 0; - + virtual void deactivateManagedInstances() = 0; - protected: /** * Defines properties for storing the ClientIds of clients / proxies that have @@ -86,22 +85,21 @@ class RootInterfaceStubRemoteEvent { class RootInterfaceStub : public virtual CommonAPI::Stub<RootInterfaceStubAdapter, RootInterfaceStubRemoteEvent> { public: virtual ~RootInterfaceStub() { } + virtual const CommonAPI::Version& getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId) = 0; /// This is the method that will be called on remote calls on the method testRootMethod. virtual void testRootMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, int32_t inInt, std::string inString, RootInterface::testRootMethodError& methodError, int32_t& outInt, std::string& outString) = 0; - + virtual bool registerManagedStubLeafInterface(std::shared_ptr<LeafInterfaceStub>, const std::string&) = 0; virtual bool deregisterManagedStubLeafInterface(const std::string&) = 0; virtual std::set<std::string>& getLeafInterfaceInstances() = 0; virtual bool registerManagedStubBranchInterface(std::shared_ptr<BranchInterfaceStub>, const std::string&) = 0; virtual bool deregisterManagedStubBranchInterface(const std::string&) = 0; virtual std::set<std::string>& getBranchInterfaceInstances() = 0; - using CommonAPI::Stub<RootInterfaceStubAdapter, RootInterfaceStubRemoteEvent>::initStubAdapter; typedef CommonAPI::Stub<RootInterfaceStubAdapter, RootInterfaceStubRemoteEvent>::StubAdapterType StubAdapterType; typedef CommonAPI::Stub<RootInterfaceStubAdapter, RootInterfaceStubRemoteEvent>::RemoteEventHandlerType RemoteEventHandlerType; - }; } // namespace managed diff --git a/src/test/commonapi/tests/managed/RootInterfaceStubDefault.cpp b/src/test/commonapi/tests/managed/RootInterfaceStubDefault.cpp index cf09dc0..4eb108a 100644 --- a/src/test/commonapi/tests/managed/RootInterfaceStubDefault.cpp +++ b/src/test/commonapi/tests/managed/RootInterfaceStubDefault.cpp @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -15,7 +15,12 @@ namespace managed { RootInterfaceStubDefault::RootInterfaceStubDefault(): autoInstanceCounter_(0), - remoteEventHandler_(this) { + remoteEventHandler_(this), + interfaceVersion_(RootInterface::getInterfaceVersion()) { +} + +const CommonAPI::Version& RootInterfaceStubDefault::getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId) { + return interfaceVersion_; } RootInterfaceStubRemoteEvent* RootInterfaceStubDefault::initStubAdapter(const std::shared_ptr<RootInterfaceStubAdapter>& stubAdapter) { diff --git a/src/test/commonapi/tests/managed/RootInterfaceStubDefault.h b/src/test/commonapi/tests/managed/RootInterfaceStubDefault.h index 1379a82..9249fc4 100644 --- a/src/test/commonapi/tests/managed/RootInterfaceStubDefault.h +++ b/src/test/commonapi/tests/managed/RootInterfaceStubDefault.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -34,12 +34,14 @@ public: RootInterfaceStubRemoteEvent* initStubAdapter(const std::shared_ptr<RootInterfaceStubAdapter>& stubAdapter); + const CommonAPI::Version& getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId); + virtual void testRootMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, int32_t inInt, std::string inString, RootInterface::testRootMethodError& methodError, int32_t& outInt, std::string& outString); virtual void testRootMethod(int32_t inInt, std::string inString, RootInterface::testRootMethodError& methodError, int32_t& outInt, std::string& outString); - + bool registerManagedStubLeafInterfaceAutoInstance(std::shared_ptr<LeafInterfaceStub>); bool registerManagedStubLeafInterface(std::shared_ptr<LeafInterfaceStub>, const std::string&); bool deregisterManagedStubLeafInterface(const std::string&); @@ -63,6 +65,8 @@ private: RemoteEventHandler remoteEventHandler_; uint32_t autoInstanceCounter_; + + CommonAPI::Version interfaceVersion_; }; } // namespace managed diff --git a/src/test/commonapi/tests/managed/SecondRoot.h b/src/test/commonapi/tests/managed/SecondRoot.h index 4104797..2aef3a6 100644 --- a/src/test/commonapi/tests/managed/SecondRoot.h +++ b/src/test/commonapi/tests/managed/SecondRoot.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -55,7 +55,7 @@ namespace CommonAPI { namespace std { //hashes for types - + //hashes for error types } diff --git a/src/test/commonapi/tests/managed/SecondRootDBusProxy.cpp b/src/test/commonapi/tests/managed/SecondRootDBusProxy.cpp index f43fde1..39bd825 100644 --- a/src/test/commonapi/tests/managed/SecondRootDBusProxy.cpp +++ b/src/test/commonapi/tests/managed/SecondRootDBusProxy.cpp @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * diff --git a/src/test/commonapi/tests/managed/SecondRootDBusProxy.h b/src/test/commonapi/tests/managed/SecondRootDBusProxy.h index 81f752e..cd75f59 100644 --- a/src/test/commonapi/tests/managed/SecondRootDBusProxy.h +++ b/src/test/commonapi/tests/managed/SecondRootDBusProxy.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -12,8 +12,6 @@ #include <commonapi/tests/managed/SecondRootProxyBase.h> - - #if !defined (COMMONAPI_INTERNAL_COMPILATION) #define COMMONAPI_INTERNAL_COMPILATION #endif @@ -44,14 +42,14 @@ class SecondRootDBusProxy: virtual public SecondRootProxyBase, virtual public Co - + virtual CommonAPI::ProxyManager& getProxyManagerLeafInterface(); virtual void getOwnVersion(uint16_t& ownVersionMajor, uint16_t& ownVersionMinor) const; private: - + CommonAPI::DBus::DBusProxyManager proxyManagerLeafInterface_; }; diff --git a/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.cpp b/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.cpp index fffe746..a6c7c6d 100644 --- a/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.cpp +++ b/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.cpp @@ -1,145 +1,160 @@ - /* - * This file was generated by the CommonAPI Generators. - * Used org.genivi.commonapi.core 2.1.4.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 "SecondRootDBusStubAdapter.h" - #include <commonapi/tests/managed/SecondRoot.h> - - namespace commonapi { - namespace tests { - namespace managed { - - std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> createSecondRootDBusStubAdapter( - 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<SecondRootDBusStubAdapter>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection, stubBase); - } - - __attribute__((constructor)) void registerSecondRootDBusStubAdapter(void) { - CommonAPI::DBus::DBusFactory::registerAdapterFactoryMethod(SecondRoot::getInterfaceId(), - &createSecondRootDBusStubAdapter); - } - - - - SecondRootDBusStubAdapterInternal::~SecondRootDBusStubAdapterInternal() { - deactivateManagedInstances(); - SecondRootDBusStubAdapterHelper::deinit(); - SecondRootDBusStubAdapterHelper::stub_.reset(); - } - - void SecondRootDBusStubAdapterInternal::deactivateManagedInstances() { - for(std::set<std::string>::iterator iter = registeredLeafInterfaceInstances.begin(); - iter != registeredLeafInterfaceInstances.end(); ++iter) { - deregisterManagedStubLeafInterface(*iter); - } - } - - const char* SecondRootDBusStubAdapterInternal::getMethodsDBusIntrospectionXmlData() const { - static const std::string introspectionData = - - "" - ; - return introspectionData.c_str(); - } - - - - - - const SecondRootDBusStubAdapterHelper::StubDispatcherTable& SecondRootDBusStubAdapterInternal::getStubDispatcherTable() { - 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 { - const bool isManagedDeregistrationSuccessful = - 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, - 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, - true), - SecondRootDBusStubAdapterHelper(factory, commonApiAddress, dbusInterfaceName, dbusBusName, dbusObjectPath, - dbusConnection, std::dynamic_pointer_cast<SecondRootStub>(stub), - true), - stubDispatcherTable_({ - }) { - - } - - } // namespace managed - } // namespace tests - } // namespace commonapi +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.4.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 "SecondRootDBusStubAdapter.h" +#include <commonapi/tests/managed/SecondRoot.h> + +namespace commonapi { +namespace tests { +namespace managed { + +std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> createSecondRootDBusStubAdapter( + 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<SecondRootDBusStubAdapter>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection, stubBase); +} + +__attribute__((constructor)) void registerSecondRootDBusStubAdapter(void) { + CommonAPI::DBus::DBusFactory::registerAdapterFactoryMethod(SecondRoot::getInterfaceId(), + &createSecondRootDBusStubAdapter); +} + + + +SecondRootDBusStubAdapterInternal::~SecondRootDBusStubAdapterInternal() { + deactivateManagedInstances(); + SecondRootDBusStubAdapterHelper::deinit(); + SecondRootDBusStubAdapterHelper::stub_.reset(); +} + +void SecondRootDBusStubAdapterInternal::deactivateManagedInstances() { + for(std::set<std::string>::iterator iter = registeredLeafInterfaceInstances.begin(); + iter != registeredLeafInterfaceInstances.end(); ++iter) { + deregisterManagedStubLeafInterface(*iter); + } +} + +const char* SecondRootDBusStubAdapterInternal::getMethodsDBusIntrospectionXmlData() const { + static const std::string introspectionData = + "<method name=\"getInterfaceVersion\">\n" + "<arg name=\"value\" type=\"uu\" direction=\"out\" />" + "</method>\n" + + "" + ; + return introspectionData.c_str(); +} + +static CommonAPI::DBus::DBusGetAttributeStubDispatcher< + SecondRootStub, + CommonAPI::Version + > getSecondRootInterfaceVersionStubDispatcher(&SecondRootStub::getInterfaceVersion, "uu"); + + + + + +const SecondRootDBusStubAdapterHelper::StubDispatcherTable& SecondRootDBusStubAdapterInternal::getStubDispatcherTable() { + 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 { + const bool isManagedDeregistrationSuccessful = + 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, + 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, + true), + SecondRootDBusStubAdapterHelper( + factory, + commonApiAddress, + dbusInterfaceName, + dbusBusName, + dbusObjectPath, + dbusConnection, + std::dynamic_pointer_cast<SecondRootStub>(stub), + true), + stubDispatcherTable_({ + }) { + + stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::managed::getSecondRootInterfaceVersionStubDispatcher }); +} + +} // 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 fc646db..ba5f2ac 100644 --- a/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.h +++ b/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -12,7 +12,6 @@ #include <commonapi/tests/managed/SecondRootStub.h> - #if !defined (COMMONAPI_INTERNAL_COMPILATION) #define COMMONAPI_INTERNAL_COMPILATION #endif @@ -44,15 +43,15 @@ class SecondRootDBusStubAdapterInternal: public SecondRootStubAdapter, public Se ~SecondRootDBusStubAdapterInternal(); - + bool registerManagedStubLeafInterface(std::shared_ptr<LeafInterfaceStub>, const std::string&); bool deregisterManagedStubLeafInterface(const std::string&); std::set<std::string>& getLeafInterfaceInstances(); const SecondRootDBusStubAdapterHelper::StubDispatcherTable& getStubDispatcherTable(); - + void deactivateManagedInstances(); - + protected: virtual const char* getMethodsDBusIntrospectionXmlData() const; diff --git a/src/test/commonapi/tests/managed/SecondRootProxy.h b/src/test/commonapi/tests/managed/SecondRootProxy.h index fa0cb20..1efb856 100644 --- a/src/test/commonapi/tests/managed/SecondRootProxy.h +++ b/src/test/commonapi/tests/managed/SecondRootProxy.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -30,13 +30,13 @@ class SecondRootProxy: virtual public SecondRoot, virtual public SecondRootProxy public: SecondRootProxy(std::shared_ptr<CommonAPI::Proxy> delegate); ~SecondRootProxy(); - + typedef SecondRoot InterfaceType; - - + + virtual CommonAPI::ProxyManager& getProxyManagerLeafInterface(); /** @@ -140,7 +140,6 @@ CommonAPI::InterfaceVersionAttribute& SecondRootProxy<_AttributeExtensions...>:: return delegate_->getInterfaceVersionAttribute(); } - template <typename ... _AttributeExtensions> CommonAPI::ProxyManager& SecondRootProxy<_AttributeExtensions...>::getProxyManagerLeafInterface() { return delegate_->getProxyManagerLeafInterface(); diff --git a/src/test/commonapi/tests/managed/SecondRootProxyBase.h b/src/test/commonapi/tests/managed/SecondRootProxyBase.h index 8006139..68cd1fa 100644 --- a/src/test/commonapi/tests/managed/SecondRootProxyBase.h +++ b/src/test/commonapi/tests/managed/SecondRootProxyBase.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -13,7 +13,6 @@ #include "SecondRoot.h" - #include <commonapi/tests/managed/LeafInterfaceStub.h> #if !defined (COMMONAPI_INTERNAL_COMPILATION) diff --git a/src/test/commonapi/tests/managed/SecondRootStub.h b/src/test/commonapi/tests/managed/SecondRootStub.h index 98a73cb..5b1d449 100644 --- a/src/test/commonapi/tests/managed/SecondRootStub.h +++ b/src/test/commonapi/tests/managed/SecondRootStub.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -38,13 +38,12 @@ namespace managed { class SecondRootStubAdapter: virtual public CommonAPI::StubAdapter, public SecondRoot { public: - + virtual bool registerManagedStubLeafInterface(std::shared_ptr<LeafInterfaceStub>, const std::string&) = 0; virtual bool deregisterManagedStubLeafInterface(const std::string&) = 0; virtual std::set<std::string>& getLeafInterfaceInstances() = 0; - + virtual void deactivateManagedInstances() = 0; - protected: /** * Defines properties for storing the ClientIds of clients / proxies that have @@ -81,17 +80,16 @@ class SecondRootStubRemoteEvent { class SecondRootStub : public virtual CommonAPI::Stub<SecondRootStubAdapter, SecondRootStubRemoteEvent> { public: virtual ~SecondRootStub() { } + virtual const CommonAPI::Version& getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId) = 0; + - virtual bool registerManagedStubLeafInterface(std::shared_ptr<LeafInterfaceStub>, const std::string&) = 0; virtual bool deregisterManagedStubLeafInterface(const std::string&) = 0; virtual std::set<std::string>& getLeafInterfaceInstances() = 0; - using CommonAPI::Stub<SecondRootStubAdapter, SecondRootStubRemoteEvent>::initStubAdapter; typedef CommonAPI::Stub<SecondRootStubAdapter, SecondRootStubRemoteEvent>::StubAdapterType StubAdapterType; typedef CommonAPI::Stub<SecondRootStubAdapter, SecondRootStubRemoteEvent>::RemoteEventHandlerType RemoteEventHandlerType; - }; } // namespace managed diff --git a/src/test/commonapi/tests/managed/SecondRootStubDefault.cpp b/src/test/commonapi/tests/managed/SecondRootStubDefault.cpp index 51feea1..bda4c2e 100644 --- a/src/test/commonapi/tests/managed/SecondRootStubDefault.cpp +++ b/src/test/commonapi/tests/managed/SecondRootStubDefault.cpp @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -15,7 +15,12 @@ namespace managed { SecondRootStubDefault::SecondRootStubDefault(): autoInstanceCounter_(0), - remoteEventHandler_(this) { + remoteEventHandler_(this), + interfaceVersion_(SecondRoot::getInterfaceVersion()) { +} + +const CommonAPI::Version& SecondRootStubDefault::getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId) { + return interfaceVersion_; } SecondRootStubRemoteEvent* SecondRootStubDefault::initStubAdapter(const std::shared_ptr<SecondRootStubAdapter>& stubAdapter) { diff --git a/src/test/commonapi/tests/managed/SecondRootStubDefault.h b/src/test/commonapi/tests/managed/SecondRootStubDefault.h index daaca19..55cdd3d 100644 --- a/src/test/commonapi/tests/managed/SecondRootStubDefault.h +++ b/src/test/commonapi/tests/managed/SecondRootStubDefault.h @@ -1,5 +1,5 @@ /* -* This file was generated by the CommonAPI Generators. +* This file was generated by the CommonAPI Generators. * Used org.genivi.commonapi.core 2.1.4.qualifier. * Used org.franca.core 0.8.10.201309262002. * @@ -34,9 +34,11 @@ public: SecondRootStubRemoteEvent* initStubAdapter(const std::shared_ptr<SecondRootStubAdapter>& stubAdapter); + const CommonAPI::Version& getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId); + + - bool registerManagedStubLeafInterfaceAutoInstance(std::shared_ptr<LeafInterfaceStub>); bool registerManagedStubLeafInterface(std::shared_ptr<LeafInterfaceStub>, const std::string&); bool deregisterManagedStubLeafInterface(const std::string&); @@ -56,6 +58,8 @@ private: RemoteEventHandler remoteEventHandler_; uint32_t autoInstanceCounter_; + + CommonAPI::Version interfaceVersion_; }; } // namespace managed |