diff options
author | Dirk Huss <dirk_huss@mentor.com> | 2015-11-25 14:59:52 +0100 |
---|---|---|
committer | Dirk Huss <dirk_huss@mentor.com> | 2015-11-25 14:59:52 +0100 |
commit | faea5f299525500093843da72215d279c3eb483d (patch) | |
tree | 559a22a4f9844a4f8d04d8e39f37d04da797d1a0 /src/test/src-gen/dbus/v1/commonapi/tests/TestInterfaceManagerDBusStubAdapter.cpp | |
parent | db96446ece67ba1f495811e29838e8c7bc7984ff (diff) | |
download | genivi-common-api-dbus-runtime-faea5f299525500093843da72215d279c3eb483d.tar.gz |
CommonAPI-D-Bus 3.1.43.1.4
Diffstat (limited to 'src/test/src-gen/dbus/v1/commonapi/tests/TestInterfaceManagerDBusStubAdapter.cpp')
-rw-r--r-- | src/test/src-gen/dbus/v1/commonapi/tests/TestInterfaceManagerDBusStubAdapter.cpp | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/src/test/src-gen/dbus/v1/commonapi/tests/TestInterfaceManagerDBusStubAdapter.cpp b/src/test/src-gen/dbus/v1/commonapi/tests/TestInterfaceManagerDBusStubAdapter.cpp new file mode 100644 index 0000000..511b538 --- /dev/null +++ b/src/test/src-gen/dbus/v1/commonapi/tests/TestInterfaceManagerDBusStubAdapter.cpp @@ -0,0 +1,149 @@ +/* +* This file was generated by the CommonAPI Generators. +* Used org.genivi.commonapi.dbus 3.1.4.v201511201313. +* Used org.franca.core 0.9.1.201412191134. +* +* 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 <v1/commonapi/tests/TestInterfaceManager.hpp> +#include <v1/commonapi/tests/TestInterfaceManagerDBusStubAdapter.hpp> + +namespace v1 { +namespace commonapi { +namespace tests { + +std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> createTestInterfaceManagerDBusStubAdapter( + const CommonAPI::DBus::DBusAddress &_address, + const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection> &_connection, + const std::shared_ptr<CommonAPI::StubBase> &_stub) { + return std::make_shared<TestInterfaceManagerDBusStubAdapter>(_address, _connection, _stub); +} + +INITIALIZER(registerTestInterfaceManagerDBusStubAdapter) { + CommonAPI::DBus::Factory::get()->registerStubAdapterCreateMethod( + TestInterfaceManager::getInterface(), &createTestInterfaceManagerDBusStubAdapter); +} + +TestInterfaceManagerDBusStubAdapterInternal::~TestInterfaceManagerDBusStubAdapterInternal() { + deactivateManagedInstances(); + TestInterfaceManagerDBusStubAdapterHelper::deinit(); +} + +void TestInterfaceManagerDBusStubAdapterInternal::deactivateManagedInstances() { + std::set<std::string>::iterator iter; + std::set<std::string>::iterator iterNext; + + iter = registeredTestInterfaceInstances.begin(); + while (iter != registeredTestInterfaceInstances.end()) { + iterNext = std::next(iter); + + if (deregisterManagedStubTestInterface(*iter)) { + iter = iterNext; + } + else { + iter++; + } + } +} + +const char* TestInterfaceManagerDBusStubAdapterInternal::getMethodsDBusIntrospectionXmlData() const { + static const std::string introspectionData = + "<method name=\"getInterfaceVersion\">\n" + "<arg name=\"value\" type=\"uu\" direction=\"out\" />" + "</method>\n" + + "" + ; + return introspectionData.c_str(); +} + +CommonAPI::DBus::DBusGetAttributeStubDispatcher< + ::v1::commonapi::tests::TestInterfaceManagerStub, + CommonAPI::Version + > TestInterfaceManagerDBusStubAdapterInternal::getTestInterfaceManagerInterfaceVersionStubDispatcher(&TestInterfaceManagerStub::getInterfaceVersion, "uu"); + + + + + + + + +const TestInterfaceManagerDBusStubAdapterHelper::StubDispatcherTable& TestInterfaceManagerDBusStubAdapterInternal::getStubDispatcherTable() { + return stubDispatcherTable_; +} + +const CommonAPI::DBus::StubAttributeTable& TestInterfaceManagerDBusStubAdapterInternal::getStubAttributeTable() { + return stubAttributeTable_; +} +bool TestInterfaceManagerDBusStubAdapterInternal::registerManagedStubTestInterface(std::shared_ptr<::v1::commonapi::tests::TestInterfaceStub> _stub, const std::string &_instance) { + if (registeredTestInterfaceInstances.find(_instance) == registeredTestInterfaceInstances.end()) { + std::string itsAddress = "local:commonapi.tests.TestInterface:" + _instance; + CommonAPI::DBus::DBusAddress itsDBusAddress; + CommonAPI::DBus::DBusAddressTranslator::get()->translate(itsAddress, itsDBusAddress); + + std::string objectPath(itsDBusAddress.getObjectPath()); + std::string adapterObjectPath(getDBusAddress().getObjectPath()); + + if (objectPath.compare(0, adapterObjectPath.length(), adapterObjectPath) == 0) { + std::shared_ptr<CommonAPI::DBus::Factory> itsFactory = CommonAPI::DBus::Factory::get(); + + auto stubAdapter = itsFactory->createDBusStubAdapter(_stub, "commonapi.tests.TestInterface", itsDBusAddress, connection_); + bool isRegistered = itsFactory->registerManagedService(stubAdapter); + if (isRegistered) { + bool isExported = connection_->getDBusObjectManager()->exportManagedDBusStubAdapter(adapterObjectPath, stubAdapter); + if (isExported) { + registeredTestInterfaceInstances.insert(_instance); + return true; + } else { + itsFactory->unregisterManagedService(itsAddress); + } + } + } + } + return false; +} + +bool TestInterfaceManagerDBusStubAdapterInternal::deregisterManagedStubTestInterface(const std::string &_instance) { + std::string itsAddress = "local:commonapi.tests.TestInterface:" + _instance; + if (registeredTestInterfaceInstances.find(_instance) != registeredTestInterfaceInstances.end()) { + std::shared_ptr<CommonAPI::DBus::Factory> itsFactory = CommonAPI::DBus::Factory::get(); + std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> stubAdapter + = itsFactory->getRegisteredService(itsAddress); + if (stubAdapter) { + connection_->getDBusObjectManager()->unexportManagedDBusStubAdapter( + getDBusAddress().getObjectPath(), stubAdapter); + itsFactory->unregisterManagedService(itsAddress); + registeredTestInterfaceInstances.erase(_instance); + return true; + } + } + return false; +} + +std::set<std::string>& TestInterfaceManagerDBusStubAdapterInternal::getTestInterfaceInstances() { + return registeredTestInterfaceInstances; +} + +TestInterfaceManagerDBusStubAdapterInternal::TestInterfaceManagerDBusStubAdapterInternal( + const CommonAPI::DBus::DBusAddress &_address, + const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection> &_connection, + const std::shared_ptr<CommonAPI::StubBase> &_stub) + : CommonAPI::DBus::DBusStubAdapter(_address, _connection,true), + TestInterfaceManagerDBusStubAdapterHelper(_address, _connection, std::dynamic_pointer_cast<TestInterfaceManagerStub>(_stub), true), + stubDispatcherTable_({ + }), + stubAttributeTable_() { + + stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::TestInterfaceManagerDBusStubAdapterInternal::getTestInterfaceManagerInterfaceVersionStubDispatcher }); +} + +bool TestInterfaceManagerDBusStubAdapterInternal::hasFreedesktopProperties() { + return false; +} + +} // namespace tests +} // namespace commonapi +} // namespace v1 |