diff options
author | Stefan Laner <laner@itestra.de> | 2013-11-11 15:54:39 +0100 |
---|---|---|
committer | Johannes Schanda <schanda@itestra.de> | 2013-11-11 17:19:22 +0100 |
commit | fed37ac724ee21809d2125f910c919658bded8ce (patch) | |
tree | b7b3d8400677346278c178bf2aba26b0f1173cc6 /src | |
parent | d9cb110053436e4c04fdcb067848adefaf36d836 (diff) | |
download | genivi-common-api-dbus-runtime-fed37ac724ee21809d2125f910c919658bded8ce.tar.gz |
added test for two managers for the same interface
extended test for sending structs that have a map with enum key as
member
Change-Id: Ib245bf1a9132c1494513d4e8eee512a2eca68449
Diffstat (limited to 'src')
30 files changed, 977 insertions, 28 deletions
diff --git a/src/CommonAPI/DBus/DBusProxyHelper.h b/src/CommonAPI/DBus/DBusProxyHelper.h index 0a316be..da8896f 100644 --- a/src/CommonAPI/DBus/DBusProxyHelper.h +++ b/src/CommonAPI/DBus/DBusProxyHelper.h @@ -200,7 +200,7 @@ template< const _InArgs&... inArgs, _AsyncCallback asyncCallback) { - return callMethodAsync( + callMethodAsync( dbusProxy, dbusProxy.getDBusBusName().c_str(), dbusProxy.getDBusObjectPath().c_str(), diff --git a/src/test/DBusFactoryTest.cpp b/src/test/DBusFactoryTest.cpp index 1131fb7..fc68d1f 100644 --- a/src/test/DBusFactoryTest.cpp +++ b/src/test/DBusFactoryTest.cpp @@ -117,6 +117,9 @@ TEST_F(DBusProxyFactoryTest, CreatesDefaultExtendedTestProxy) { commonapi::tests::TestInterfaceProxy, myExtensions::AttributeTestExtension>("local:commonapi.tests.TestInterface:commonapi.tests.TestInterface"); ASSERT_TRUE((bool)defaultTestProxy); + + auto attributeExtension = defaultTestProxy->getTestDerivedArrayAttributeAttributeExtension(); + ASSERT_TRUE(attributeExtension.testExtensionMethod()); } TEST_F(DBusProxyFactoryTest, CreatesIndividuallyExtendedTestProxy) { diff --git a/src/test/DBusManagedTest.cpp b/src/test/DBusManagedTest.cpp index 16e74a7..c83ebe5 100644 --- a/src/test/DBusManagedTest.cpp +++ b/src/test/DBusManagedTest.cpp @@ -27,6 +27,7 @@ #include "commonapi/tests/managed/RootInterfaceProxy.h" #include "commonapi/tests/managed/RootInterfaceDBusProxy.h" #include "commonapi/tests/managed/LeafInterfaceProxy.h" +#include "commonapi/tests/managed/SecondRootStubDefault.h" #include <gtest/gtest.h> #include <algorithm> @@ -36,6 +37,7 @@ static const std::string rootAddress = "local:commonapi.tests.managed.RootInterface:commonapi.tests.managed.RootInterface"; static const std::string leafInstance = "commonapi.tests.managed.RootInterface.LeafInterface"; +static const std::string secondLeafInstance = "commonapi.tests.managed.RootInterface.LeafInterface2"; static const std::string leafAddress = "local:commonapi.tests.managed.LeafInterface:" + leafInstance; static const std::string dbusServiceName = "CommonAPI.DBus.DBusObjectManagerStubTest"; @@ -350,6 +352,10 @@ protected: return "local:commonapi.tests.managed.RootInterface" + suffix + ":commonapi.tests.managed.RootInterface"; } + inline const std::string getSuffixedSecondRootAddress(const std::string& suffix) { + return "local:commonapi.tests.managed.SecondRoot" + suffix + ":commonapi.tests.managed.SecondRoot"; + } + inline const bool registerRootStubForSuffix(const std::string& suffix) { std::shared_ptr<commonapi::tests::managed::RootInterfaceStubDefault> rootStub = std::make_shared< commonapi::tests::managed::RootInterfaceStubDefault>(); @@ -365,7 +371,7 @@ protected: template<typename _ProxyType> bool waitForAllProxiesToBeAvailable(const std::vector<_ProxyType>& dbusProxies) { bool allAreAvailable = false; - for (size_t i = 0; i < 200 && !allAreAvailable; i++) { + for (size_t i = 0; i < 500 && !allAreAvailable; i++) { allAreAvailable = std::all_of( dbusProxies.begin(), dbusProxies.end(), @@ -562,6 +568,25 @@ TEST_F(DBusManagedTestExtended, RegisterSeveralRootsAndSeveralLeafsForEachOnSame // EXPECT_TRUE(dbusObjectPathAndInterfacesDict.empty()); } +TEST_F(DBusManagedTestExtended, RegisterTwoRootsForSameLeafInterface) { + ASSERT_TRUE(registerRootStubForSuffix("One")); + + std::shared_ptr<commonapi::tests::managed::SecondRootStubDefault> secondRootStub = std::make_shared< + commonapi::tests::managed::SecondRootStubDefault>(); + const std::string rootAddress = getSuffixedRootAddress("Two"); + runtime_->getServicePublisher()->registerService(secondRootStub, rootAddress, serviceFactory_); + + + auto leafStub1 = std::make_shared<commonapi::tests::managed::LeafInterfaceStubDefault>(); + auto leafStub2 = std::make_shared<commonapi::tests::managed::LeafInterfaceStubDefault>(); + + bool leafStub1Registered = rootStubs_.begin()->second->registerManagedStubLeafInterface(leafStub1, leafInstance); + ASSERT_TRUE(leafStub1Registered); + + bool leafStub2Registered = secondRootStub->registerManagedStubLeafInterface(leafStub2, secondLeafInstance); + ASSERT_TRUE(leafStub2Registered); +} + //XXX: Needs tests for invalid instances for the children. //XXX: Also later on need auto generated instance ID test and //XXX: If stub cannot manage, ensure the objectManager interface does not appear on dbus diff --git a/src/test/DBusPolymorphicTest.cpp b/src/test/DBusPolymorphicTest.cpp index 4e5ab0b..65930cb 100644 --- a/src/test/DBusPolymorphicTest.cpp +++ b/src/test/DBusPolymorphicTest.cpp @@ -280,6 +280,16 @@ TEST_F(PolymorphicTest, SendStructWithPolymorphicMember) { ASSERT_TRUE(testStub->firstElementIsExtended_); } +TEST_F(PolymorphicTest, SendStructWithMapWithEnumKeyMember) { + CommonAPI::CallStatus stat; + commonapi::tests::DerivedTypeCollection::StructWithEnumKeyMap inputStruct; + inputStruct.testMap.insert( { commonapi::tests::DerivedTypeCollection::TestEnum::E_OK, "test" } ); + + proxy_->TestStructWithEnumKeyMapMember(inputStruct, stat); + + ASSERT_EQ(stat, CommonAPI::CallStatus::SUCCESS); +} + int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/src/test/commonapi/tests/DerivedTypeCollection.cpp b/src/test/commonapi/tests/DerivedTypeCollection.cpp index 99ba25f..16a1b4e 100644 --- a/src/test/commonapi/tests/DerivedTypeCollection.cpp +++ b/src/test/commonapi/tests/DerivedTypeCollection.cpp @@ -198,6 +198,29 @@ void StructWithPolymorphicMember::writeToOutputStream(CommonAPI::OutputStream& o outputStream << polymorphicMember; } +StructWithEnumKeyMap::StructWithEnumKeyMap(const TestEnumMap& testMapValue): + testMap(testMapValue) +{ +} + + +bool operator==(const StructWithEnumKeyMap& lhs, const StructWithEnumKeyMap& rhs) { + if (&lhs == &rhs) + return true; + + return + lhs.testMap == rhs.testMap + ; +} + +void StructWithEnumKeyMap::readFromInputStream(CommonAPI::InputStream& inputStream) { + inputStream >> testMap; +} + +void StructWithEnumKeyMap::writeToOutputStream(CommonAPI::OutputStream& outputStream) const { + outputStream << testMap; +} + } // namespace DerivedTypeCollection } // namespace tests } // namespace commonapi diff --git a/src/test/commonapi/tests/DerivedTypeCollection.h b/src/test/commonapi/tests/DerivedTypeCollection.h index f967f47..5cdcfd0 100644 --- a/src/test/commonapi/tests/DerivedTypeCollection.h +++ b/src/test/commonapi/tests/DerivedTypeCollection.h @@ -207,6 +207,23 @@ namespace DerivedTypeCollection { typeOutputStream.endWriteStructType(); } }; + struct StructWithEnumKeyMap: CommonAPI::SerializableStruct { + TestEnumMap testMap; + + StructWithEnumKeyMap() = default; + StructWithEnumKeyMap(const TestEnumMap& testMap); + + + virtual void readFromInputStream(CommonAPI::InputStream& inputStream); + virtual void writeToOutputStream(CommonAPI::OutputStream& outputStream) const; + + static inline void writeToTypeOutputStream(CommonAPI::TypeOutputStream& typeOutputStream) { + typeOutputStream.beginWriteMapType(); + typeOutputStream.writeInt32Type(); + typeOutputStream.writeStringType(); + typeOutputStream.endWriteMapType(); + } + }; bool operator==(const TestStructExtended& lhs, const TestStructExtended& rhs); inline bool operator!=(const TestStructExtended& lhs, const TestStructExtended& rhs) { @@ -323,6 +340,10 @@ bool operator==(const StructWithPolymorphicMember& lhs, const StructWithPolymorp inline bool operator!=(const StructWithPolymorphicMember& lhs, const StructWithPolymorphicMember& rhs) { return !(lhs == rhs); } +bool operator==(const StructWithEnumKeyMap& lhs, const StructWithEnumKeyMap& rhs); +inline bool operator!=(const StructWithEnumKeyMap& lhs, const StructWithEnumKeyMap& rhs) { + return !(lhs == rhs); +} static inline const char* getTypeCollectionName() { diff --git a/src/test/commonapi/tests/TestInterfaceDBusProxy.cpp b/src/test/commonapi/tests/TestInterfaceDBusProxy.cpp index 9b38b8e..ef42634 100644 --- a/src/test/commonapi/tests/TestInterfaceDBusProxy.cpp +++ b/src/test/commonapi/tests/TestInterfaceDBusProxy.cpp @@ -233,6 +233,25 @@ std::future<CommonAPI::CallStatus> TestInterfaceDBusProxy::TestStructWithPolymor inStruct, std::move(callback)); } +void TestInterfaceDBusProxy::TestStructWithEnumKeyMapMember(const DerivedTypeCollection::StructWithEnumKeyMap& inStruct, CommonAPI::CallStatus& callStatus) { + CommonAPI::DBus::DBusProxyHelper<CommonAPI::DBus::DBusSerializableArguments<DerivedTypeCollection::StructWithEnumKeyMap>, + CommonAPI::DBus::DBusSerializableArguments<> >::callMethodWithReply( + *this, + "TestStructWithEnumKeyMapMember", + "(a{is})", + inStruct, + callStatus + ); +} +std::future<CommonAPI::CallStatus> TestInterfaceDBusProxy::TestStructWithEnumKeyMapMemberAsync(const DerivedTypeCollection::StructWithEnumKeyMap& inStruct, TestStructWithEnumKeyMapMemberAsyncCallback callback) { + return CommonAPI::DBus::DBusProxyHelper<CommonAPI::DBus::DBusSerializableArguments<DerivedTypeCollection::StructWithEnumKeyMap>, + CommonAPI::DBus::DBusSerializableArguments<> >::callMethodAsync( + *this, + "TestStructWithEnumKeyMapMember", + "(a{is})", + inStruct, + std::move(callback)); +} diff --git a/src/test/commonapi/tests/TestInterfaceDBusProxy.h b/src/test/commonapi/tests/TestInterfaceDBusProxy.h index 805030a..9ac236a 100644 --- a/src/test/commonapi/tests/TestInterfaceDBusProxy.h +++ b/src/test/commonapi/tests/TestInterfaceDBusProxy.h @@ -68,6 +68,8 @@ class TestInterfaceDBusProxy: virtual public TestInterfaceProxyBase, virtual pub virtual std::future<CommonAPI::CallStatus> TestMapWithPolymorphicStructKeyMethodAsync(const DerivedTypeCollection::MapPolymorphicToInt& inMap, TestMapWithPolymorphicStructKeyMethodAsyncCallback callback); virtual void TestStructWithPolymorphicMemberMethod(const DerivedTypeCollection::StructWithPolymorphicMember& inStruct, CommonAPI::CallStatus& callStatus); virtual std::future<CommonAPI::CallStatus> TestStructWithPolymorphicMemberMethodAsync(const DerivedTypeCollection::StructWithPolymorphicMember& inStruct, TestStructWithPolymorphicMemberMethodAsyncCallback callback); + virtual void TestStructWithEnumKeyMapMember(const DerivedTypeCollection::StructWithEnumKeyMap& inStruct, CommonAPI::CallStatus& callStatus); + virtual std::future<CommonAPI::CallStatus> TestStructWithEnumKeyMapMemberAsync(const DerivedTypeCollection::StructWithEnumKeyMap& inStruct, TestStructWithEnumKeyMapMemberAsyncCallback callback); virtual void getOwnVersion(uint16_t& ownVersionMajor, uint16_t& ownVersionMinor) const; diff --git a/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp b/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp index bd41183..40cb19e 100644 --- a/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp +++ b/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp @@ -129,6 +129,9 @@ const char* TestInterfaceDBusStubAdapter::getMethodsDBusIntrospectionXmlData() c "<method name=\"TestStructWithPolymorphicMemberMethod\">\n" "<arg name=\"inStruct\" type=\"(u(uv))\" direction=\"in\" />\n" "</method>\n" + "<method name=\"TestStructWithEnumKeyMapMember\">\n" + "<arg name=\"inStruct\" type=\"(a{is})\" direction=\"in\" />\n" + "</method>\n" ; return introspectionData; @@ -223,6 +226,11 @@ static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< std::tuple<DerivedTypeCollection::StructWithPolymorphicMember>, std::tuple<> > testStructWithPolymorphicMemberMethodStubDispatcher(&TestInterfaceStub::TestStructWithPolymorphicMemberMethod, ""); +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + TestInterfaceStub, + std::tuple<DerivedTypeCollection::StructWithEnumKeyMap>, + std::tuple<> + > testStructWithEnumKeyMapMemberStubDispatcher(&TestInterfaceStub::TestStructWithEnumKeyMapMember, ""); void TestInterfaceDBusStubAdapter::fireTestPredefinedTypeAttributeAttributeChanged(const uint32_t& value) { CommonAPI::DBus::DBusStubSignalHelper<CommonAPI::DBus::DBusSerializableArguments<uint32_t>> @@ -414,7 +422,8 @@ const TestInterfaceDBusStubAdapter::StubDispatcherTable& TestInterfaceDBusStubAd { { "TestArrayOfPolymorphicStructMethod", "a(uv)" }, &commonapi::tests::testArrayOfPolymorphicStructMethodStubDispatcher }, { { "TestMapOfPolymorphicStructMethod", "a{y(uv)}" }, &commonapi::tests::testMapOfPolymorphicStructMethodStubDispatcher }, { { "TestMapWithPolymorphicStructKeyMethod", "a{(uv)y}" }, &commonapi::tests::testMapWithPolymorphicStructKeyMethodStubDispatcher }, - { { "TestStructWithPolymorphicMemberMethod", "(u(uv))" }, &commonapi::tests::testStructWithPolymorphicMemberMethodStubDispatcher } + { { "TestStructWithPolymorphicMemberMethod", "(u(uv))" }, &commonapi::tests::testStructWithPolymorphicMemberMethodStubDispatcher }, + { { "TestStructWithEnumKeyMapMember", "(a{is})" }, &commonapi::tests::testStructWithEnumKeyMapMemberStubDispatcher } , { { "subscribeForTestSelectiveBroadcastSelective", "" }, &commonapi::tests::subscribeTestSelectiveBroadcastSelectiveStubDispatcher }, { { "unsubscribeFromTestSelectiveBroadcastSelective", "" }, &commonapi::tests::unsubscribeTestSelectiveBroadcastSelectiveStubDispatcher }, diff --git a/src/test/commonapi/tests/TestInterfaceProxy.h b/src/test/commonapi/tests/TestInterfaceProxy.h index 8343deb..e940343 100644 --- a/src/test/commonapi/tests/TestInterfaceProxy.h +++ b/src/test/commonapi/tests/TestInterfaceProxy.h @@ -249,6 +249,26 @@ class TestInterfaceProxy: virtual public TestInterface, virtual public TestInter * It will provide the same value for CallStatus as will be handed to the callback. */ virtual std::future<CommonAPI::CallStatus> TestStructWithPolymorphicMemberMethodAsync(const DerivedTypeCollection::StructWithPolymorphicMember& inStruct, TestStructWithPolymorphicMemberMethodAsyncCallback callback); + /** + * Calls TestStructWithEnumKeyMapMember with synchronous semantics. + * + * All const parameters are input parameters to this method. + * The CallStatus will be filled when the method returns and indicate either + * "SUCCESS" or which type of error has occurred. In case of an error, ONLY the CallStatus + * will be set. + */ + virtual void TestStructWithEnumKeyMapMember(const DerivedTypeCollection::StructWithEnumKeyMap& inStruct, CommonAPI::CallStatus& callStatus); + /** + * Calls TestStructWithEnumKeyMapMember with asynchronous semantics. + * + * The provided callback will be called when the reply to this call arrives or + * an error occurs during the call. The CallStatus will indicate either "SUCCESS" + * or which type of error has occurred. In case of any error, ONLY the CallStatus + * will have a defined value. + * The std::future returned by this method will be fulfilled at arrival of the reply. + * It will provide the same value for CallStatus as will be handed to the callback. + */ + virtual std::future<CommonAPI::CallStatus> TestStructWithEnumKeyMapMemberAsync(const DerivedTypeCollection::StructWithEnumKeyMap& inStruct, TestStructWithEnumKeyMapMemberAsyncCallback callback); /** @@ -451,6 +471,15 @@ template <typename ... _AttributeExtensions> std::future<CommonAPI::CallStatus> TestInterfaceProxy<_AttributeExtensions...>::TestStructWithPolymorphicMemberMethodAsync(const DerivedTypeCollection::StructWithPolymorphicMember& inStruct, TestStructWithPolymorphicMemberMethodAsyncCallback callback) { return delegate_->TestStructWithPolymorphicMemberMethodAsync(inStruct, callback); } +template <typename ... _AttributeExtensions> +void TestInterfaceProxy<_AttributeExtensions...>::TestStructWithEnumKeyMapMember(const DerivedTypeCollection::StructWithEnumKeyMap& inStruct, CommonAPI::CallStatus& callStatus) { + delegate_->TestStructWithEnumKeyMapMember(inStruct, callStatus); +} + +template <typename ... _AttributeExtensions> +std::future<CommonAPI::CallStatus> TestInterfaceProxy<_AttributeExtensions...>::TestStructWithEnumKeyMapMemberAsync(const DerivedTypeCollection::StructWithEnumKeyMap& inStruct, TestStructWithEnumKeyMapMemberAsyncCallback callback) { + return delegate_->TestStructWithEnumKeyMapMemberAsync(inStruct, callback); +} template <typename ... _AttributeExtensions> std::string TestInterfaceProxy<_AttributeExtensions...>::getAddress() const { diff --git a/src/test/commonapi/tests/TestInterfaceProxyBase.h b/src/test/commonapi/tests/TestInterfaceProxyBase.h index 3be09cb..ff2dd5d 100644 --- a/src/test/commonapi/tests/TestInterfaceProxyBase.h +++ b/src/test/commonapi/tests/TestInterfaceProxyBase.h @@ -57,6 +57,7 @@ class TestInterfaceProxyBase: virtual public CommonAPI::Proxy { typedef std::function<void(const CommonAPI::CallStatus&)> TestMapOfPolymorphicStructMethodAsyncCallback; typedef std::function<void(const CommonAPI::CallStatus&)> TestMapWithPolymorphicStructKeyMethodAsyncCallback; typedef std::function<void(const CommonAPI::CallStatus&)> TestStructWithPolymorphicMemberMethodAsyncCallback; + typedef std::function<void(const CommonAPI::CallStatus&)> TestStructWithEnumKeyMapMemberAsyncCallback; virtual TestPredefinedTypeAttributeAttribute& getTestPredefinedTypeAttributeAttribute() = 0; virtual TestDerivedStructAttributeAttribute& getTestDerivedStructAttributeAttribute() = 0; @@ -84,6 +85,8 @@ class TestInterfaceProxyBase: virtual public CommonAPI::Proxy { virtual std::future<CommonAPI::CallStatus> TestMapWithPolymorphicStructKeyMethodAsync(const DerivedTypeCollection::MapPolymorphicToInt& inMap, TestMapWithPolymorphicStructKeyMethodAsyncCallback callback) = 0; virtual void TestStructWithPolymorphicMemberMethod(const DerivedTypeCollection::StructWithPolymorphicMember& inStruct, CommonAPI::CallStatus& callStatus) = 0; virtual std::future<CommonAPI::CallStatus> TestStructWithPolymorphicMemberMethodAsync(const DerivedTypeCollection::StructWithPolymorphicMember& inStruct, TestStructWithPolymorphicMemberMethodAsyncCallback callback) = 0; + virtual void TestStructWithEnumKeyMapMember(const DerivedTypeCollection::StructWithEnumKeyMap& inStruct, CommonAPI::CallStatus& callStatus) = 0; + virtual std::future<CommonAPI::CallStatus> TestStructWithEnumKeyMapMemberAsync(const DerivedTypeCollection::StructWithEnumKeyMap& inStruct, TestStructWithEnumKeyMapMemberAsyncCallback callback) = 0; }; } // namespace tests diff --git a/src/test/commonapi/tests/TestInterfaceStub.h b/src/test/commonapi/tests/TestInterfaceStub.h index 93c67ac..4cc48e7 100644 --- a/src/test/commonapi/tests/TestInterfaceStub.h +++ b/src/test/commonapi/tests/TestInterfaceStub.h @@ -157,6 +157,8 @@ class TestInterfaceStub : public CommonAPI::Stub<TestInterfaceStubAdapter , Test virtual void TestMapWithPolymorphicStructKeyMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::MapPolymorphicToInt inMap) = 0; /// This is the method that will be called on remote calls on the method TestStructWithPolymorphicMemberMethod. virtual void TestStructWithPolymorphicMemberMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::StructWithPolymorphicMember inStruct) = 0; + /// This is the method that will be called on remote calls on the method TestStructWithEnumKeyMapMember. + virtual void TestStructWithEnumKeyMapMember(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::StructWithEnumKeyMap inStruct) = 0; /// Sends a broadcast event for TestPredefinedTypeBroadcast. virtual void fireTestPredefinedTypeBroadcastEvent(const uint32_t& uint32Value, const std::string& stringValue) = 0; /** diff --git a/src/test/commonapi/tests/TestInterfaceStubDefault.cpp b/src/test/commonapi/tests/TestInterfaceStubDefault.cpp index 93d43bc..5003bd0 100644 --- a/src/test/commonapi/tests/TestInterfaceStubDefault.cpp +++ b/src/test/commonapi/tests/TestInterfaceStubDefault.cpp @@ -238,6 +238,14 @@ void TestInterfaceStubDefault::TestStructWithPolymorphicMemberMethod(DerivedType // No operation in default } +void TestInterfaceStubDefault::TestStructWithEnumKeyMapMember(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::StructWithEnumKeyMap inStruct) { + // Call old style methods in default + TestStructWithEnumKeyMapMember(inStruct); +} +void TestInterfaceStubDefault::TestStructWithEnumKeyMapMember(DerivedTypeCollection::StructWithEnumKeyMap inStruct) { + // No operation in default +} + void TestInterfaceStubDefault::fireTestPredefinedTypeBroadcastEvent(const uint32_t& uint32Value, const std::string& stringValue) { stubAdapter_->fireTestPredefinedTypeBroadcastEvent(uint32Value, stringValue); diff --git a/src/test/commonapi/tests/TestInterfaceStubDefault.h b/src/test/commonapi/tests/TestInterfaceStubDefault.h index 04998cb..ff320ea 100644 --- a/src/test/commonapi/tests/TestInterfaceStubDefault.h +++ b/src/test/commonapi/tests/TestInterfaceStubDefault.h @@ -72,6 +72,9 @@ class TestInterfaceStubDefault : public TestInterfaceStub { virtual void TestStructWithPolymorphicMemberMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::StructWithPolymorphicMember inStruct); virtual void TestStructWithPolymorphicMemberMethod(DerivedTypeCollection::StructWithPolymorphicMember inStruct); + virtual void TestStructWithEnumKeyMapMember(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::StructWithEnumKeyMap inStruct); + virtual void TestStructWithEnumKeyMapMember(DerivedTypeCollection::StructWithEnumKeyMap inStruct); + virtual void fireTestPredefinedTypeBroadcastEvent(const uint32_t& uint32Value, const std::string& stringValue); virtual void fireTestSelectiveBroadcastSelective(const std::shared_ptr<CommonAPI::ClientIdList> receivers = NULL); diff --git a/src/test/commonapi/tests/managed/LeafInterfaceProxy.h b/src/test/commonapi/tests/managed/LeafInterfaceProxy.h index 6001346..94f8bcb 100644 --- a/src/test/commonapi/tests/managed/LeafInterfaceProxy.h +++ b/src/test/commonapi/tests/managed/LeafInterfaceProxy.h @@ -1,11 +1,11 @@ /* * This file was generated by the CommonAPI Generators. -* Used org.genivi.commonapi.core 2.1.0.qualifier. -* Used org.franca.core 0.8.9.201308271211. +* Used org.genivi.commonapi.core 2.1.3.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/. +* 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_MANAGED_Leaf_Interface_PROXY_H_ #define COMMONAPI_TESTS_MANAGED_Leaf_Interface_PROXY_H_ diff --git a/src/test/commonapi/tests/managed/LeafInterfaceProxyBase.h b/src/test/commonapi/tests/managed/LeafInterfaceProxyBase.h index a4eb7cb..7e8d718 100644 --- a/src/test/commonapi/tests/managed/LeafInterfaceProxyBase.h +++ b/src/test/commonapi/tests/managed/LeafInterfaceProxyBase.h @@ -1,11 +1,11 @@ /* * This file was generated by the CommonAPI Generators. -* Used org.genivi.commonapi.core 2.1.0.qualifier. -* Used org.franca.core 0.8.9.201308271211. +* Used org.genivi.commonapi.core 2.1.3.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/. +* 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_MANAGED_Leaf_Interface_PROXY_BASE_H_ #define COMMONAPI_TESTS_MANAGED_Leaf_Interface_PROXY_BASE_H_ diff --git a/src/test/commonapi/tests/managed/LeafInterfaceStub.h b/src/test/commonapi/tests/managed/LeafInterfaceStub.h index c41ecaa..d31561b 100644 --- a/src/test/commonapi/tests/managed/LeafInterfaceStub.h +++ b/src/test/commonapi/tests/managed/LeafInterfaceStub.h @@ -1,11 +1,11 @@ /* * This file was generated by the CommonAPI Generators. -* Used org.genivi.commonapi.core 2.1.0.qualifier. -* Used org.franca.core 0.8.9.201308271211. +* Used org.genivi.commonapi.core 2.1.3.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/. +* 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_MANAGED_Leaf_Interface_STUB_H_ #define COMMONAPI_TESTS_MANAGED_Leaf_Interface_STUB_H_ diff --git a/src/test/commonapi/tests/managed/LeafInterfaceStubDefault.cpp b/src/test/commonapi/tests/managed/LeafInterfaceStubDefault.cpp index 2ce07be..01dd58b 100644 --- a/src/test/commonapi/tests/managed/LeafInterfaceStubDefault.cpp +++ b/src/test/commonapi/tests/managed/LeafInterfaceStubDefault.cpp @@ -1,11 +1,11 @@ /* * This file was generated by the CommonAPI Generators. -* Used org.genivi.commonapi.core 2.1.0.qualifier. -* Used org.franca.core 0.8.9.201308271211. +* Used org.genivi.commonapi.core 2.1.3.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/. +* 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/managed/LeafInterfaceStubDefault.h> diff --git a/src/test/commonapi/tests/managed/LeafInterfaceStubDefault.h b/src/test/commonapi/tests/managed/LeafInterfaceStubDefault.h index ee324c3..fdedc9c 100644 --- a/src/test/commonapi/tests/managed/LeafInterfaceStubDefault.h +++ b/src/test/commonapi/tests/managed/LeafInterfaceStubDefault.h @@ -1,11 +1,11 @@ /* * This file was generated by the CommonAPI Generators. -* Used org.genivi.commonapi.core 2.1.0.qualifier. -* Used org.franca.core 0.8.9.201308271211. +* Used org.genivi.commonapi.core 2.1.3.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/. +* 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_MANAGED_Leaf_Interface_STUB_DEFAULT_H_ #define COMMONAPI_TESTS_MANAGED_Leaf_Interface_STUB_DEFAULT_H_ diff --git a/src/test/commonapi/tests/managed/SecondRoot.h b/src/test/commonapi/tests/managed/SecondRoot.h new file mode 100644 index 0000000..0b55364 --- /dev/null +++ b/src/test/commonapi/tests/managed/SecondRoot.h @@ -0,0 +1,61 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.3.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_MANAGED_Second_Root_H_ +#define COMMONAPI_TESTS_MANAGED_Second_Root_H_ + + +#include <set> + +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#define COMMONAPI_INTERNAL_COMPILATION +#endif + +#include <CommonAPI/types.h> + +#undef COMMONAPI_INTERNAL_COMPILATION + +namespace commonapi { +namespace tests { +namespace managed { + +class SecondRoot { + public: + virtual ~SecondRoot() { } + + static inline const char* getInterfaceId(); + static inline CommonAPI::Version getInterfaceVersion(); +}; + +const char* SecondRoot::getInterfaceId() { + static const char* interfaceId = "commonapi.tests.managed.SecondRoot"; + return interfaceId; +} + +CommonAPI::Version SecondRoot::getInterfaceVersion() { + return CommonAPI::Version(1, 0); +} + + +} // namespace managed +} // namespace tests +} // namespace commonapi + +namespace CommonAPI { + +} + + +namespace std { + //hashes for types + + //hashes for error types +} + +#endif // COMMONAPI_TESTS_MANAGED_Second_Root_H_ diff --git a/src/test/commonapi/tests/managed/SecondRootDBusProxy.cpp b/src/test/commonapi/tests/managed/SecondRootDBusProxy.cpp new file mode 100644 index 0000000..b1eb31a --- /dev/null +++ b/src/test/commonapi/tests/managed/SecondRootDBusProxy.cpp @@ -0,0 +1,58 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.3.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 "SecondRootDBusProxy.h" + +namespace commonapi { +namespace tests { +namespace managed { + +std::shared_ptr<CommonAPI::DBus::DBusProxy> createSecondRootDBusProxy( + 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<SecondRootDBusProxy>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection); +} + +__attribute__((constructor)) void registerSecondRootDBusProxy(void) { + CommonAPI::DBus::DBusFactory::registerProxyFactoryMethod(SecondRoot::getInterfaceId(), + &createSecondRootDBusProxy); +} + +SecondRootDBusProxy::SecondRootDBusProxy( + 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) +, proxyManagerLeafInterface_(*this, "commonapi.tests.managed.LeafInterface", factory) + { + } + + + + +CommonAPI::ProxyManager& SecondRootDBusProxy::getProxyManagerLeafInterface() { + return proxyManagerLeafInterface_; +} + + +void SecondRootDBusProxy::getOwnVersion(uint16_t& ownVersionMajor, uint16_t& ownVersionMinor) const { + ownVersionMajor = 1; + ownVersionMinor = 0; +} + +} // namespace managed +} // namespace tests +} // namespace commonapi diff --git a/src/test/commonapi/tests/managed/SecondRootDBusProxy.h b/src/test/commonapi/tests/managed/SecondRootDBusProxy.h new file mode 100644 index 0000000..4942927 --- /dev/null +++ b/src/test/commonapi/tests/managed/SecondRootDBusProxy.h @@ -0,0 +1,62 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.3.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_MANAGED_Second_Root_DBUS_PROXY_H_ +#define COMMONAPI_TESTS_MANAGED_Second_Root_DBUS_PROXY_H_ + +#include <commonapi/tests/managed/SecondRootProxyBase.h> + +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#define COMMONAPI_INTERNAL_COMPILATION +#endif + +#include <CommonAPI/DBus/DBusFactory.h> +#include <CommonAPI/DBus/DBusProxy.h> +#include <CommonAPI/DBus/DBusProxyManager.h> + +#undef COMMONAPI_INTERNAL_COMPILATION + +#include <string> + +namespace commonapi { +namespace tests { +namespace managed { + +class SecondRootDBusProxy: virtual public SecondRootProxyBase, virtual public CommonAPI::DBus::DBusProxy { + public: + SecondRootDBusProxy( + 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 ~SecondRootDBusProxy() { } + + + + + virtual CommonAPI::ProxyManager& getProxyManagerLeafInterface(); + + virtual void getOwnVersion(uint16_t& ownVersionMajor, uint16_t& ownVersionMinor) const; + + private: + + + CommonAPI::DBus::DBusProxyManager proxyManagerLeafInterface_; +}; + + + +} // namespace managed +} // namespace tests +} // namespace commonapi + +#endif // COMMONAPI_TESTS_MANAGED_Second_Root_DBUS_PROXY_H_ diff --git a/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.cpp b/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.cpp new file mode 100644 index 0000000..e7e7719 --- /dev/null +++ b/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.cpp @@ -0,0 +1,135 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.3.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); +} + +SecondRootDBusStubAdapter::SecondRootDBusStubAdapter( + 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): + SecondRootDBusStubAdapterHelper(factory, commonApiAddress, dbusInterfaceName, dbusBusName, dbusObjectPath, + dbusConnection, std::dynamic_pointer_cast<SecondRootStub>(stub), + true) { +} + +SecondRootDBusStubAdapter::~SecondRootDBusStubAdapter() { + deactivateManagedInstances(); + deinit(); + stub_.reset(); +} + +void SecondRootDBusStubAdapter::deactivateManagedInstances() { + for(std::set<std::string>::iterator iter = registeredLeafInterfaceInstances.begin(); + iter != registeredLeafInterfaceInstances.end(); ++iter) { + deregisterManagedStubLeafInterface(*iter); + } +} + +const char* SecondRootDBusStubAdapter::getMethodsDBusIntrospectionXmlData() const { + static const char* introspectionData = + + "" + ; + return introspectionData; +} + + + + + + +const SecondRootDBusStubAdapter::StubDispatcherTable& SecondRootDBusStubAdapter::getStubDispatcherTable() { + static const SecondRootDBusStubAdapter::StubDispatcherTable stubDispatcherTable = { + }; + return stubDispatcherTable; +} + + +bool SecondRootDBusStubAdapter::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 SecondRootDBusStubAdapter::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>& SecondRootDBusStubAdapter::getLeafInterfaceInstances() { + return registeredLeafInterfaceInstances; +} + +} // namespace managed +} // namespace tests +} // namespace commonapi diff --git a/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.h b/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.h new file mode 100644 index 0000000..8fdb7dc --- /dev/null +++ b/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.h @@ -0,0 +1,66 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.3.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_MANAGED_Second_Root_DBUS_STUB_ADAPTER_H_ +#define COMMONAPI_TESTS_MANAGED_Second_Root_DBUS_STUB_ADAPTER_H_ + +#include <commonapi/tests/managed/SecondRootStub.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 { +namespace managed { + +typedef CommonAPI::DBus::DBusStubAdapterHelper<SecondRootStub> SecondRootDBusStubAdapterHelper; + +class SecondRootDBusStubAdapter: public SecondRootStubAdapter, public SecondRootDBusStubAdapterHelper { + public: + SecondRootDBusStubAdapter( + 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); + + ~SecondRootDBusStubAdapter(); + + + + bool registerManagedStubLeafInterface(std::shared_ptr<LeafInterfaceStub>, const std::string&); + bool deregisterManagedStubLeafInterface(const std::string&); + std::set<std::string>& getLeafInterfaceInstances(); + + const StubDispatcherTable& getStubDispatcherTable(); + + void deactivateManagedInstances(); + + protected: + virtual const char* getMethodsDBusIntrospectionXmlData() const; + + private: + std::set<std::string> registeredLeafInterfaceInstances; +}; + +} // namespace managed +} // namespace tests +} // namespace commonapi + +#endif // COMMONAPI_TESTS_MANAGED_Second_Root_DBUS_STUB_ADAPTER_H_ diff --git a/src/test/commonapi/tests/managed/SecondRootProxy.h b/src/test/commonapi/tests/managed/SecondRootProxy.h new file mode 100644 index 0000000..2eb8cc1 --- /dev/null +++ b/src/test/commonapi/tests/managed/SecondRootProxy.h @@ -0,0 +1,149 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.3.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_MANAGED_Second_Root_PROXY_H_ +#define COMMONAPI_TESTS_MANAGED_Second_Root_PROXY_H_ + +#include "SecondRootProxyBase.h" + +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#define COMMONAPI_INTERNAL_COMPILATION +#endif + + +#undef COMMONAPI_INTERNAL_COMPILATION + +namespace commonapi { +namespace tests { +namespace managed { + +template <typename ... _AttributeExtensions> +class SecondRootProxy: virtual public SecondRoot, virtual public SecondRootProxyBase, public _AttributeExtensions... { + public: + SecondRootProxy(std::shared_ptr<CommonAPI::Proxy> delegate); + ~SecondRootProxy(); + + + + + virtual CommonAPI::ProxyManager& getProxyManagerLeafInterface(); + + /** + * 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<SecondRootProxyBase> delegate_; +}; + + +// +// SecondRootProxy Implementation +// +template <typename ... _AttributeExtensions> +SecondRootProxy<_AttributeExtensions...>::SecondRootProxy(std::shared_ptr<CommonAPI::Proxy> delegate): + delegate_(std::dynamic_pointer_cast<SecondRootProxyBase>(delegate)), + _AttributeExtensions(*(std::dynamic_pointer_cast<SecondRootProxyBase>(delegate)))... { +} + +template <typename ... _AttributeExtensions> +SecondRootProxy<_AttributeExtensions...>::~SecondRootProxy() { +} + + +template <typename ... _AttributeExtensions> +std::string SecondRootProxy<_AttributeExtensions...>::getAddress() const { + return delegate_->getAddress(); +} + +template <typename ... _AttributeExtensions> +const std::string& SecondRootProxy<_AttributeExtensions...>::getDomain() const { + return delegate_->getDomain(); +} + +template <typename ... _AttributeExtensions> +const std::string& SecondRootProxy<_AttributeExtensions...>::getServiceId() const { + return delegate_->getServiceId(); +} + +template <typename ... _AttributeExtensions> +const std::string& SecondRootProxy<_AttributeExtensions...>::getInstanceId() const { + return delegate_->getInstanceId(); +} + +template <typename ... _AttributeExtensions> +bool SecondRootProxy<_AttributeExtensions...>::isAvailable() const { + return delegate_->isAvailable(); +} + +template <typename ... _AttributeExtensions> +bool SecondRootProxy<_AttributeExtensions...>::isAvailableBlocking() const { + return delegate_->isAvailableBlocking(); +} + +template <typename ... _AttributeExtensions> +CommonAPI::ProxyStatusEvent& SecondRootProxy<_AttributeExtensions...>::getProxyStatusEvent() { + return delegate_->getProxyStatusEvent(); +} + +template <typename ... _AttributeExtensions> +CommonAPI::InterfaceVersionAttribute& SecondRootProxy<_AttributeExtensions...>::getInterfaceVersionAttribute() { + return delegate_->getInterfaceVersionAttribute(); +} + + +template <typename ... _AttributeExtensions> +CommonAPI::ProxyManager& SecondRootProxy<_AttributeExtensions...>::getProxyManagerLeafInterface() { + return delegate_->getProxyManagerLeafInterface(); +} + +} // namespace managed +} // namespace tests +} // namespace commonapi + + +#endif // COMMONAPI_TESTS_MANAGED_Second_Root_PROXY_H_ diff --git a/src/test/commonapi/tests/managed/SecondRootProxyBase.h b/src/test/commonapi/tests/managed/SecondRootProxyBase.h new file mode 100644 index 0000000..2c6d805 --- /dev/null +++ b/src/test/commonapi/tests/managed/SecondRootProxyBase.h @@ -0,0 +1,45 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.3.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_MANAGED_Second_Root_PROXY_BASE_H_ +#define COMMONAPI_TESTS_MANAGED_Second_Root_PROXY_BASE_H_ + +#include "SecondRoot.h" + + +#include <commonapi/tests/managed/LeafInterfaceStub.h> + +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#define COMMONAPI_INTERNAL_COMPILATION +#endif + + +#include <CommonAPI/ProxyManager.h> +#include <CommonAPI/Proxy.h> + +#undef COMMONAPI_INTERNAL_COMPILATION + +namespace commonapi { +namespace tests { +namespace managed { + +class SecondRootProxyBase: virtual public CommonAPI::Proxy { + public: + + + + + virtual CommonAPI::ProxyManager& getProxyManagerLeafInterface() = 0; +}; + +} // namespace managed +} // namespace tests +} // namespace commonapi + +#endif // COMMONAPI_TESTS_MANAGED_Second_Root_PROXY_BASE_H_ diff --git a/src/test/commonapi/tests/managed/SecondRootStub.h b/src/test/commonapi/tests/managed/SecondRootStub.h new file mode 100644 index 0000000..7789e5d --- /dev/null +++ b/src/test/commonapi/tests/managed/SecondRootStub.h @@ -0,0 +1,96 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.3.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_MANAGED_Second_Root_STUB_H_ +#define COMMONAPI_TESTS_MANAGED_Second_Root_STUB_H_ + + + +#include <commonapi/tests/managed/LeafInterfaceStub.h> + +#include "SecondRoot.h" + +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#define COMMONAPI_INTERNAL_COMPILATION +#endif + + +#include <CommonAPI/Stub.h> + +#undef COMMONAPI_INTERNAL_COMPILATION + +namespace commonapi { +namespace tests { +namespace managed { + +/** + * Receives messages from remote and handles all dispatching of deserialized calls + * to a stub for the service SecondRoot. 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 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 + * subscribed to the selective broadcasts + */ +}; + + +/** + * Defines the necessary callbacks to handle remote set events related to the attributes + * defined in the IDL description for SecondRoot. + * 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 SecondRootStubRemoteEvent { + public: + virtual ~SecondRootStubRemoteEvent() { } + +}; + + +/** + * Defines the interface that must be implemented by any class that should provide + * the service SecondRoot 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 SecondRootStub : public CommonAPI::Stub<SecondRootStubAdapter , SecondRootStubRemoteEvent> { + public: + virtual ~SecondRootStub() { } + + + + 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; +}; + +} // namespace managed +} // namespace tests +} // namespace commonapi + +#endif // COMMONAPI_TESTS_MANAGED_Second_Root_STUB_H_ diff --git a/src/test/commonapi/tests/managed/SecondRootStubDefault.cpp b/src/test/commonapi/tests/managed/SecondRootStubDefault.cpp new file mode 100644 index 0000000..2e1f42b --- /dev/null +++ b/src/test/commonapi/tests/managed/SecondRootStubDefault.cpp @@ -0,0 +1,52 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.3.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/managed/SecondRootStubDefault.h> + +namespace commonapi { +namespace tests { +namespace managed { + +SecondRootStubDefault::SecondRootStubDefault(): + autoInstanceCounter_(0), + remoteEventHandler_(this) { +} + +SecondRootStubRemoteEvent* SecondRootStubDefault::initStubAdapter(const std::shared_ptr<SecondRootStubAdapter>& stubAdapter) { + stubAdapter_ = stubAdapter; + return &remoteEventHandler_; +} + + + + +bool SecondRootStubDefault::registerManagedStubLeafInterfaceAutoInstance(std::shared_ptr<LeafInterfaceStub> stub) { + autoInstanceCounter_++; + std::stringstream ss; + ss << stubAdapter_->getInstanceId() << ".i" << autoInstanceCounter_; + std::string instance = ss.str(); + return stubAdapter_->registerManagedStubLeafInterface(stub, instance); +} +bool SecondRootStubDefault::registerManagedStubLeafInterface(std::shared_ptr<LeafInterfaceStub> stub, const std::string& instance) { + return stubAdapter_->registerManagedStubLeafInterface(stub, instance); +} +bool SecondRootStubDefault::deregisterManagedStubLeafInterface(const std::string& instance) { + return stubAdapter_->deregisterManagedStubLeafInterface(instance); +} +std::set<std::string>& SecondRootStubDefault::getLeafInterfaceInstances() { + return stubAdapter_->getLeafInterfaceInstances(); +} + +SecondRootStubDefault::RemoteEventHandler::RemoteEventHandler(SecondRootStubDefault* defaultStub): + defaultStub_(defaultStub) { +} + +} // namespace managed +} // namespace tests +} // namespace commonapi diff --git a/src/test/commonapi/tests/managed/SecondRootStubDefault.h b/src/test/commonapi/tests/managed/SecondRootStubDefault.h new file mode 100644 index 0000000..7c3a99d --- /dev/null +++ b/src/test/commonapi/tests/managed/SecondRootStubDefault.h @@ -0,0 +1,65 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.core 2.1.3.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_MANAGED_Second_Root_STUB_DEFAULT_H_ +#define COMMONAPI_TESTS_MANAGED_Second_Root_STUB_DEFAULT_H_ + +#include <commonapi/tests/managed/SecondRootStub.h> +#include <sstream> + +namespace commonapi { +namespace tests { +namespace managed { + +/** + * Provides a default implementation for SecondRootStubRemoteEvent and + * SecondRootStub. 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 SecondRootStubDefault : public SecondRootStub { + public: + SecondRootStubDefault(); + + SecondRootStubRemoteEvent* initStubAdapter(const std::shared_ptr<SecondRootStubAdapter>& stubAdapter); + + + + + bool registerManagedStubLeafInterfaceAutoInstance(std::shared_ptr<LeafInterfaceStub>); + bool registerManagedStubLeafInterface(std::shared_ptr<LeafInterfaceStub>, const std::string&); + bool deregisterManagedStubLeafInterface(const std::string&); + std::set<std::string>& getLeafInterfaceInstances(); + + protected: + std::shared_ptr<SecondRootStubAdapter> stubAdapter_; + private: + class RemoteEventHandler: public SecondRootStubRemoteEvent { + public: + RemoteEventHandler(SecondRootStubDefault* defaultStub); + + + private: + SecondRootStubDefault* defaultStub_; + }; + + RemoteEventHandler remoteEventHandler_; + uint32_t autoInstanceCounter_; + +}; + +} // namespace managed +} // namespace tests +} // namespace commonapi + +#endif // COMMONAPI_TESTS_MANAGED_Second_Root_STUB_DEFAULT_H_ diff --git a/src/test/root.fidl b/src/test/root.fidl index 1183953..094eacf 100644 --- a/src/test/root.fidl +++ b/src/test/root.fidl @@ -49,3 +49,6 @@ interface RootInterface manages LeafInterface, BranchInterface { } +interface SecondRoot manages LeafInterface { + version { major 1 minor 0 } +} |