summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/CommonAPI/DBus/CommonAPIDBus.hpp7
-rw-r--r--include/CommonAPI/DBus/DBusAddress.hpp4
-rw-r--r--include/CommonAPI/DBus/DBusAddressTranslator.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusAttribute.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusClientId.hpp6
-rw-r--r--include/CommonAPI/DBus/DBusConfig.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusConnection.hpp4
-rw-r--r--include/CommonAPI/DBus/DBusDaemonProxy.hpp8
-rw-r--r--include/CommonAPI/DBus/DBusDeployment.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusError.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusErrorEvent.hpp12
-rw-r--r--include/CommonAPI/DBus/DBusEvent.hpp6
-rw-r--r--include/CommonAPI/DBus/DBusFactory.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusFreedesktopAttribute.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusFreedesktopPropertiesStub.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusFreedesktopStubAdapterHelper.hpp38
-rw-r--r--include/CommonAPI/DBus/DBusFreedesktopVariant.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusFunctionalHash.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusHelper.hpp12
-rw-r--r--include/CommonAPI/DBus/DBusInputStream.hpp68
-rw-r--r--include/CommonAPI/DBus/DBusInstanceAvailabilityStatusChangedEvent.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusInterfaceHandler.hpp2
-rwxr-xr-xinclude/CommonAPI/DBus/DBusMainLoop.hpp29
-rw-r--r--include/CommonAPI/DBus/DBusMainLoopContext.hpp41
-rw-r--r--include/CommonAPI/DBus/DBusMessage.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusMultiEvent.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusObjectManager.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusObjectManagerStub.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusOutputStream.hpp68
-rw-r--r--include/CommonAPI/DBus/DBusProxy.hpp3
-rw-r--r--include/CommonAPI/DBus/DBusProxyAsyncCallbackHandler.hpp16
-rw-r--r--include/CommonAPI/DBus/DBusProxyAsyncSignalMemberCallbackHandler.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusProxyBase.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusProxyConnection.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusProxyHelper.hpp74
-rw-r--r--include/CommonAPI/DBus/DBusProxyManager.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusSelectiveEvent.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusSerializableArguments.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusServiceRegistry.hpp8
-rw-r--r--include/CommonAPI/DBus/DBusStubAdapter.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusStubAdapterHelper.hpp293
-rw-r--r--include/CommonAPI/DBus/DBusTypes.hpp2
-rw-r--r--include/CommonAPI/DBus/DBusUtils.hpp2
-rw-r--r--include/pugixml/pugixml.hpp105
44 files changed, 492 insertions, 360 deletions
diff --git a/include/CommonAPI/DBus/CommonAPIDBus.hpp b/include/CommonAPI/DBus/CommonAPIDBus.hpp
index 3df526d..e4c2366 100644
--- a/include/CommonAPI/DBus/CommonAPIDBus.hpp
+++ b/include/CommonAPI/DBus/CommonAPIDBus.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2015-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
@@ -8,11 +8,14 @@
#ifndef COMMONAPI_INTERNAL_COMPILATION
#define COMMONAPI_INTERNAL_COMPILATION
+#define HAS_DEFINED_COMMONAPI_INTERNAL_COMPILATION_HERE
#endif
#include "DBusAddressTranslator.hpp"
+#ifdef HAS_DEFINED_COMMONAPI_INTERNAL_COMPILATION_HERE
#undef COMMONAPI_INTERNAL_COMPILATION
+#undef HAS_DEFINED_COMMONAPI_INTERNAL_COMPILATION_HERE
+#endif
#endif // COMMONAPI_DBUS_HPP_
-
diff --git a/include/CommonAPI/DBus/DBusAddress.hpp b/include/CommonAPI/DBus/DBusAddress.hpp
index 171a482..81b0fea 100644
--- a/include/CommonAPI/DBus/DBusAddress.hpp
+++ b/include/CommonAPI/DBus/DBusAddress.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2015-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
@@ -26,6 +26,8 @@ public:
COMMONAPI_EXPORT DBusAddress(const DBusAddress &_source);
COMMONAPI_EXPORT virtual ~DBusAddress();
+ COMMONAPI_EXPORT DBusAddress &operator=(const DBusAddress &_other);
+
COMMONAPI_EXPORT bool operator==(const DBusAddress &_other) const;
COMMONAPI_EXPORT bool operator!=(const DBusAddress &_other) const;
COMMONAPI_EXPORT bool operator<(const DBusAddress &_other) const;
diff --git a/include/CommonAPI/DBus/DBusAddressTranslator.hpp b/include/CommonAPI/DBus/DBusAddressTranslator.hpp
index bad7b19..28e9c34 100644
--- a/include/CommonAPI/DBus/DBusAddressTranslator.hpp
+++ b/include/CommonAPI/DBus/DBusAddressTranslator.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusAttribute.hpp b/include/CommonAPI/DBus/DBusAttribute.hpp
index 5db6b49..344cdca 100644
--- a/include/CommonAPI/DBus/DBusAttribute.hpp
+++ b/include/CommonAPI/DBus/DBusAttribute.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusClientId.hpp b/include/CommonAPI/DBus/DBusClientId.hpp
index f5f5e85..2f3bbd0 100644
--- a/include/CommonAPI/DBus/DBusClientId.hpp
+++ b/include/CommonAPI/DBus/DBusClientId.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
@@ -38,6 +38,10 @@ public:
COMMONAPI_EXPORT const char * getDBusId();
COMMONAPI_EXPORT DBusMessage createMessage(const std::string objectPath, const std::string interfaceName, const std::string signalName) const;
+
+ COMMONAPI_EXPORT uid_t getUid() const;
+ COMMONAPI_EXPORT gid_t getGid() const;
+
protected:
std::string dbusId_;
};
diff --git a/include/CommonAPI/DBus/DBusConfig.hpp b/include/CommonAPI/DBus/DBusConfig.hpp
index 3043c8e..2375c0c 100644
--- a/include/CommonAPI/DBus/DBusConfig.hpp
+++ b/include/CommonAPI/DBus/DBusConfig.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusConnection.hpp b/include/CommonAPI/DBus/DBusConnection.hpp
index ef4e0dc..310d180 100644
--- a/include/CommonAPI/DBus/DBusConnection.hpp
+++ b/include/CommonAPI/DBus/DBusConnection.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
@@ -217,8 +217,6 @@ public:
template<class Function, class... Arguments>
COMMONAPI_EXPORT void proxyPushFunctionToMainLoop(Function&& _function, Arguments&& ... _args);
- COMMONAPI_EXPORT void setPendingCallTimedOut(DBusPendingCall* _pendingCall, ::DBusTimeout* _timeout) const;
-
#ifdef COMMONAPI_DBUS_TEST
inline std::weak_ptr<DBusMainloop> getLoop() { return loop_; }
#endif
diff --git a/include/CommonAPI/DBus/DBusDaemonProxy.hpp b/include/CommonAPI/DBus/DBusDaemonProxy.hpp
index 22d461f..04ae1e2 100644
--- a/include/CommonAPI/DBus/DBusDaemonProxy.hpp
+++ b/include/CommonAPI/DBus/DBusDaemonProxy.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
@@ -55,7 +55,7 @@ class DBusDaemonProxy : public DBusProxyBase,
typedef std::function<void(const CommonAPI::CallStatus&, std::string)> GetNameOwnerAsyncCallback;
COMMONAPI_EXPORT DBusDaemonProxy(const std::shared_ptr<DBusProxyConnection>& dbusConnection);
- COMMONAPI_EXPORT virtual ~DBusDaemonProxy() {}
+ COMMONAPI_EXPORT virtual ~DBusDaemonProxy();
COMMONAPI_EXPORT virtual bool isAvailable() const;
COMMONAPI_EXPORT virtual bool isAvailableBlocking() const;
@@ -112,7 +112,7 @@ class DBusDaemonProxy : public DBusProxyBase,
const bool success = DBusSerializableArguments<std::string>::serialize(outputStream, busName);
if (!success) {
std::promise<CallStatus> promise;
- promise.set_value(CallStatus::OUT_OF_MEMORY);
+ promise.set_value(CallStatus::SERIALIZATION_ERROR);
return promise.get_future();
}
outputStream.flush();
@@ -170,7 +170,7 @@ class DBusDaemonProxy : public DBusProxyBase,
const bool success = DBusSerializableArguments<std::string>::serialize(outputStream, busName);
if (!success) {
std::promise<CallStatus> promise;
- promise.set_value(CallStatus::OUT_OF_MEMORY);
+ promise.set_value(CallStatus::SERIALIZATION_ERROR);
return promise.get_future();
}
outputStream.flush();
diff --git a/include/CommonAPI/DBus/DBusDeployment.hpp b/include/CommonAPI/DBus/DBusDeployment.hpp
index 9eec01f..566f7ea 100644
--- a/include/CommonAPI/DBus/DBusDeployment.hpp
+++ b/include/CommonAPI/DBus/DBusDeployment.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2014-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusError.hpp b/include/CommonAPI/DBus/DBusError.hpp
index 25d7864..977ec79 100644
--- a/include/CommonAPI/DBus/DBusError.hpp
+++ b/include/CommonAPI/DBus/DBusError.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusErrorEvent.hpp b/include/CommonAPI/DBus/DBusErrorEvent.hpp
index 966f9e1..0ab53aa 100644
--- a/include/CommonAPI/DBus/DBusErrorEvent.hpp
+++ b/include/CommonAPI/DBus/DBusErrorEvent.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
@@ -73,19 +73,21 @@ public:
private:
- template <int... DeplIn_ArgIndices>
+ template <size_t... DeplIn_ArgIndices>
inline void initialize(index_sequence<DeplIn_ArgIndices...>, const std::tuple<DeplIn_Args*...> &_in) {
in_ = std::make_tuple(std::get<DeplIn_ArgIndices>(_in)...);
}
- template <int... InArgIndices_>
+ template <size_t... InArgIndices_>
void deserialize(const DBusMessage &_reply,
index_sequence<InArgIndices_...>) {
if (sizeof...(InArgs_) > 0) {
DBusInputStream dbusInputStream(_reply);
const bool success = DBusSerializableArguments<CommonAPI::Deployable<InArgs_, DeplIn_Args>...>::deserialize(dbusInputStream, std::get<InArgIndices_>(in_)...);
- if (!success)
+ if (!success) {
+ COMMONAPI_ERROR("DBusErrorEvent::", __func__, "(", errorName_, "): deserialization failed!");
return;
+ }
this->notifyListeners(errorName_, std::move(std::get<InArgIndices_>(in_).getValue())...);
}
}
@@ -96,7 +98,7 @@ private:
class DBusErrorEventHelper {
public:
- template <int... ErrorEventsIndices_, class... ErrorEvents_>
+ template <size_t... ErrorEventsIndices_, class... ErrorEvents_>
static void notifyListeners(const DBusMessage &_reply,
const std::string &_errorName,
index_sequence<ErrorEventsIndices_...>,
diff --git a/include/CommonAPI/DBus/DBusEvent.hpp b/include/CommonAPI/DBus/DBusEvent.hpp
index c954a88..05046cd 100644
--- a/include/CommonAPI/DBus/DBusEvent.hpp
+++ b/include/CommonAPI/DBus/DBusEvent.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
@@ -155,7 +155,7 @@ public:
std::get<3>(subscription_) = "";
}
- template<int ... Indices_>
+ template<size_t ... Indices_>
inline void handleSignalDBusMessage(const DBusMessage &_message, index_sequence<Indices_...>) {
DBusInputStream input(_message);
if (DBusSerializableArguments<
@@ -165,7 +165,7 @@ public:
}
}
- template<int ... Indices_>
+ template<size_t ... Indices_>
inline void handleSignalDBusMessage(const uint32_t tag, const DBusMessage &_message, index_sequence<Indices_...>) {
DBusInputStream input(_message);
if (DBusSerializableArguments<
diff --git a/include/CommonAPI/DBus/DBusFactory.hpp b/include/CommonAPI/DBus/DBusFactory.hpp
index 9654a94..e54bbe6 100644
--- a/include/CommonAPI/DBus/DBusFactory.hpp
+++ b/include/CommonAPI/DBus/DBusFactory.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusFreedesktopAttribute.hpp b/include/CommonAPI/DBus/DBusFreedesktopAttribute.hpp
index 28b41da..6d26505 100644
--- a/include/CommonAPI/DBus/DBusFreedesktopAttribute.hpp
+++ b/include/CommonAPI/DBus/DBusFreedesktopAttribute.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2015-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusFreedesktopPropertiesStub.hpp b/include/CommonAPI/DBus/DBusFreedesktopPropertiesStub.hpp
index 0a0914d..ac4270a 100644
--- a/include/CommonAPI/DBus/DBusFreedesktopPropertiesStub.hpp
+++ b/include/CommonAPI/DBus/DBusFreedesktopPropertiesStub.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusFreedesktopStubAdapterHelper.hpp b/include/CommonAPI/DBus/DBusFreedesktopStubAdapterHelper.hpp
index 56f2f17..a183446 100644
--- a/include/CommonAPI/DBus/DBusFreedesktopStubAdapterHelper.hpp
+++ b/include/CommonAPI/DBus/DBusFreedesktopStubAdapterHelper.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2015-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
@@ -44,8 +44,8 @@ public:
typedef typename DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>::LockStubFunctor LockStubFunctor;
typedef typename DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>::GetStubFunctor GetStubFunctor;
- DBusGetFreedesktopAttributeStubDispatcher(LockStubFunctor _lockStubFunctor, GetStubFunctor _getStubFunctor, AttributeDepl_ *_depl = nullptr)
- : DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_lockStubFunctor, _getStubFunctor, "v", _depl) {
+ DBusGetFreedesktopAttributeStubDispatcher(LockStubFunctor _lockStubFunctor, GetStubFunctor _getStubFunctor, const bool _isImplemented, AttributeDepl_ *_depl = nullptr)
+ : DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_lockStubFunctor, _getStubFunctor, "v", _isImplemented, _depl) {
}
virtual ~DBusGetFreedesktopAttributeStubDispatcher() {};
@@ -93,15 +93,13 @@ public:
typedef bool (RemoteEventHandlerType::*OnRemoteSetFunctor)(std::shared_ptr<CommonAPI::ClientId>, AttributeType_);
typedef void (RemoteEventHandlerType::*OnRemoteChangedFunctor)();
- DBusSetFreedesktopAttributeStubDispatcher(
- LockStubFunctor _lockStubFunctor,
- GetStubFunctor _getStubFunctor,
- OnRemoteSetFunctor _onRemoteSetFunctor,
- OnRemoteChangedFunctor _onRemoteChangedFunctor,
+ DBusSetFreedesktopAttributeStubDispatcher(LockStubFunctor _lockStubFunctor, GetStubFunctor _getStubFunctor,
+ OnRemoteSetFunctor _onRemoteSetFunctor, OnRemoteChangedFunctor _onRemoteChangedFunctor,
+ const bool _isImplemented,
AttributeDepl_ * _depl = nullptr)
- : DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_lockStubFunctor, _getStubFunctor, "v", _depl),
- DBusGetFreedesktopAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_lockStubFunctor, _getStubFunctor, _depl),
- DBusSetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_lockStubFunctor, _getStubFunctor, _onRemoteSetFunctor, _onRemoteChangedFunctor, "v", _depl) {
+ : DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_lockStubFunctor, _getStubFunctor, "v", _isImplemented, _depl),
+ DBusGetFreedesktopAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_lockStubFunctor, _getStubFunctor, _isImplemented, _depl),
+ DBusSetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_lockStubFunctor, _getStubFunctor, _onRemoteSetFunctor, _onRemoteChangedFunctor, "v", _isImplemented, _depl) {
}
virtual ~DBusSetFreedesktopAttributeStubDispatcher() {};
@@ -133,18 +131,16 @@ public:
typedef typename StubClass_::StubAdapterType StubAdapterType;
typedef void (StubAdapterType::*FireChangedFunctor)(const AttributeType_&);
- DBusSetFreedesktopObservableAttributeStubDispatcher(
- LockStubFunctor _lockStubFunctor,
- GetStubFunctor _getStubFunctor,
- OnRemoteSetFunctor _onRemoteSetFunctor,
- OnRemoteChangedFunctor _onRemoteChangedFunctor,
+ DBusSetFreedesktopObservableAttributeStubDispatcher(LockStubFunctor _lockStubFunctor, GetStubFunctor _getStubFunctor,
+ OnRemoteSetFunctor _onRemoteSetFunctor, OnRemoteChangedFunctor _onRemoteChangedFunctor,
FireChangedFunctor _fireChangedFunctor,
+ const bool _isImplemented,
AttributeDepl_ *_depl = nullptr)
- : DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_lockStubFunctor, _getStubFunctor, "v", _depl),
- DBusGetFreedesktopAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_lockStubFunctor, _getStubFunctor, _depl),
- DBusSetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_lockStubFunctor, _getStubFunctor, _onRemoteSetFunctor, _onRemoteChangedFunctor, "v", _depl),
- DBusSetFreedesktopAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_lockStubFunctor, _getStubFunctor, _onRemoteSetFunctor, _onRemoteChangedFunctor, _depl),
- DBusSetObservableAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_lockStubFunctor, _getStubFunctor, _onRemoteSetFunctor, _onRemoteChangedFunctor, _fireChangedFunctor, "v", _depl) {
+ : DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_lockStubFunctor, _getStubFunctor, "v", _isImplemented, _depl),
+ DBusGetFreedesktopAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_lockStubFunctor, _getStubFunctor, _isImplemented, _depl),
+ DBusSetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_lockStubFunctor, _getStubFunctor, _onRemoteSetFunctor, _onRemoteChangedFunctor, "v", _isImplemented, _depl),
+ DBusSetFreedesktopAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_lockStubFunctor, _getStubFunctor, _onRemoteSetFunctor, _onRemoteChangedFunctor, _isImplemented, _depl),
+ DBusSetObservableAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_lockStubFunctor, _getStubFunctor, _onRemoteSetFunctor, _onRemoteChangedFunctor, _fireChangedFunctor, "v", _isImplemented, _depl) {
}
};
diff --git a/include/CommonAPI/DBus/DBusFreedesktopVariant.hpp b/include/CommonAPI/DBus/DBusFreedesktopVariant.hpp
index bd1fb58..530c434 100644
--- a/include/CommonAPI/DBus/DBusFreedesktopVariant.hpp
+++ b/include/CommonAPI/DBus/DBusFreedesktopVariant.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2014-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusFunctionalHash.hpp b/include/CommonAPI/DBus/DBusFunctionalHash.hpp
index fbc1ea3..f83345d 100644
--- a/include/CommonAPI/DBus/DBusFunctionalHash.hpp
+++ b/include/CommonAPI/DBus/DBusFunctionalHash.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusHelper.hpp b/include/CommonAPI/DBus/DBusHelper.hpp
index ebde2b8..7aa07d9 100644
--- a/include/CommonAPI/DBus/DBusHelper.hpp
+++ b/include/CommonAPI/DBus/DBusHelper.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
@@ -16,23 +16,23 @@
namespace CommonAPI {
namespace DBus {
-template <int ...>
+template <size_t ...>
struct index_sequence {};
-template <int N_, int ...S_>
+template <size_t N_, size_t ...S_>
struct make_sequence : make_sequence<N_-1, N_-1, S_...> {};
-template <int ...S_>
+template <size_t ...S_>
struct make_sequence<0, S_...> {
typedef index_sequence<S_...> type;
};
-template <int N_, int Offset_, int ...S_>
+template <size_t N_, size_t Offset_, size_t ...S_>
struct make_sequence_range : make_sequence_range<N_-1, Offset_, N_-1+Offset_, S_...> {};
-template <int Offset_, int ...S_>
+template <size_t Offset_, size_t ...S_>
struct make_sequence_range<0, Offset_, S_...> {
typedef index_sequence<S_...> type;
};
diff --git a/include/CommonAPI/DBus/DBusInputStream.hpp b/include/CommonAPI/DBus/DBusInputStream.hpp
index 568dc4d..a4f3609 100644
--- a/include/CommonAPI/DBus/DBusInputStream.hpp
+++ b/include/CommonAPI/DBus/DBusInputStream.hpp
@@ -107,6 +107,19 @@ public:
return (*this);
}
+ template<int minimum, int maximum>
+ COMMONAPI_EXPORT InputStream &readValue(RangedInteger<minimum, maximum> &_value, const EmptyDeployment *) {
+ int tmpValue;
+ readValue(tmpValue, static_cast<EmptyDeployment *>(nullptr));
+ if(!_value.validate()) {
+ setError();
+ }
+ if (!hasError()) {
+ _value = tmpValue;
+ }
+ return (*this);
+ }
+
template<class Deployment_, typename Base_>
COMMONAPI_EXPORT InputStream &readValue(Enumeration<Base_> &_value, const Deployment_ *_depl) {
Base_ tmpValue;
@@ -479,40 +492,51 @@ private:
_readRaw(length + 1);
}
- template<typename Type_>
- COMMONAPI_EXPORT void alignVector(typename std::enable_if<!std::is_class<Type_>::value>::type * = nullptr,
- typename std::enable_if<!is_std_vector<Type_>::value>::type * = nullptr,
- typename std::enable_if<!is_std_unordered_map<Type_>::value>::type * = nullptr) {
+ template<typename Type_,
+ typename std::enable_if<(!std::is_class<Type_>::value &&
+ !is_std_vector<Type_>::value &&
+ !is_std_unordered_map<Type_>::value), int>::type = 0>
+ COMMONAPI_EXPORT void alignVector() {
if (4 < sizeof(Type_)) align(8);
}
- template<typename Type_>
- COMMONAPI_EXPORT void alignVector(typename std::enable_if<!std::is_same<Type_, std::string>::value>::type * = nullptr,
- typename std::enable_if<std::is_class<Type_>::value>::type * = nullptr,
- typename std::enable_if<!is_std_vector<Type_>::value>::type * = nullptr,
- typename std::enable_if<!is_std_unordered_map<Type_>::value>::type * = nullptr,
- typename std::enable_if<!std::is_base_of<Enumeration<int32_t>, Type_>::value>::type * = nullptr) {
+ template<typename Type_,
+ typename std::enable_if<(!std::is_same<Type_, std::string>::value &&
+ std::is_class<Type_>::value &&
+ !is_std_vector<Type_>::value &&
+ !is_std_unordered_map<Type_>::value &&
+ !std::is_base_of<Enumeration<uint8_t>, Type_>::value &&
+ !std::is_base_of<Enumeration<uint16_t>, Type_>::value &&
+ !std::is_base_of<Enumeration<uint32_t>, Type_>::value &&
+ !std::is_base_of<Enumeration<int8_t>, Type_>::value &&
+ !std::is_base_of<Enumeration<int16_t>, Type_>::value &&
+ !std::is_base_of<Enumeration<int32_t>, Type_>::value), int>::type = 0>
+ COMMONAPI_EXPORT void alignVector() {
align(8);
}
- template<typename Type_>
- COMMONAPI_EXPORT void alignVector(typename std::enable_if<std::is_same<Type_, std::string>::value>::type * = nullptr) {
+ template<typename Type_,
+ typename std::enable_if<(std::is_same<Type_, std::string>::value ||
+ is_std_vector<Type_>::value ||
+ std::is_base_of<Enumeration<uint8_t>, Type_>::value ||
+ std::is_base_of<Enumeration<int8_t>, Type_>::value), int>::type = 0>
+ COMMONAPI_EXPORT void alignVector() {
// Intentionally do nothing
}
- template<typename Type_>
- COMMONAPI_EXPORT void alignVector(typename std::enable_if<is_std_vector<Type_>::value>::type * = nullptr) {
- // Intentionally do nothing
- }
-
- template<typename Type_>
- COMMONAPI_EXPORT void alignVector(typename std::enable_if<is_std_unordered_map<Type_>::value>::type * = nullptr) {
+ template<typename Type_,
+ typename std::enable_if<(is_std_unordered_map<Type_>::value ||
+ std::is_base_of<Enumeration<uint32_t>, Type_>::value ||
+ std::is_base_of<Enumeration<int32_t>, Type_>::value), int>::type = 0>
+ COMMONAPI_EXPORT void alignVector() {
align(4);
}
- template<typename Type_>
- COMMONAPI_EXPORT void alignVector(typename std::enable_if<std::is_base_of<Enumeration<int32_t>, Type_>::value>::type * = nullptr) {
- align(4);
+ template<typename Type_,
+ typename std::enable_if<(std::is_base_of<Enumeration<uint16_t>, Type_>::value ||
+ std::is_base_of<Enumeration<int16_t>, Type_>::value), int>::type = 0>
+ COMMONAPI_EXPORT void alignVector() {
+ align(2);
}
char *begin_;
diff --git a/include/CommonAPI/DBus/DBusInstanceAvailabilityStatusChangedEvent.hpp b/include/CommonAPI/DBus/DBusInstanceAvailabilityStatusChangedEvent.hpp
index 91fa410..a65172f 100644
--- a/include/CommonAPI/DBus/DBusInstanceAvailabilityStatusChangedEvent.hpp
+++ b/include/CommonAPI/DBus/DBusInstanceAvailabilityStatusChangedEvent.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusInterfaceHandler.hpp b/include/CommonAPI/DBus/DBusInterfaceHandler.hpp
index 9804aff..8b331b4 100644
--- a/include/CommonAPI/DBus/DBusInterfaceHandler.hpp
+++ b/include/CommonAPI/DBus/DBusInterfaceHandler.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusMainLoop.hpp b/include/CommonAPI/DBus/DBusMainLoop.hpp
index 2ca7202..0fd5851 100755
--- a/include/CommonAPI/DBus/DBusMainLoop.hpp
+++ b/include/CommonAPI/DBus/DBusMainLoop.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
@@ -98,16 +98,13 @@ class DBusMainLoop {
struct DispatchSourceToDispatchStruct {
DispatchSource* dispatchSource_;
- std::mutex* mutex_;
- bool isExecuted_; /* execution flag: indicates, whether the dispatchSource is dispatched currently */
- bool deleteObject_; /* delete flag: indicates, whether the dispatchSource can be deleted*/
+ std::atomic<bool> isExecuted_; /* execution flag: indicates, whether the dispatchSource is dispatched currently */
+ std::atomic<bool> deleteObject_; /* delete flag: indicates, whether the dispatchSource can be deleted*/
DispatchSourceToDispatchStruct(DispatchSource* _dispatchSource,
- std::mutex* _mutex,
bool _isExecuted,
bool _deleteObject) {
dispatchSource_ = _dispatchSource;
- mutex_ = _mutex;
isExecuted_ = _isExecuted;
deleteObject_ = _deleteObject;
}
@@ -115,18 +112,15 @@ class DBusMainLoop {
struct TimeoutToDispatchStruct {
Timeout* timeout_;
- std::mutex* mutex_;
- bool isExecuted_; /* execution flag: indicates, whether the timeout is dispatched currently */
- bool deleteObject_; /* delete flag: indicates, whether the timeout can be deleted*/
- bool timeoutElapsed_; /* timeout elapsed flag: indicates, whether the timeout is elapsed*/
+ std::atomic<bool> isExecuted_; /* execution flag: indicates, whether the timeout is dispatched currently */
+ std::atomic<bool> deleteObject_; /* delete flag: indicates, whether the timeout can be deleted*/
+ std::atomic<bool> timeoutElapsed_; /* timeout elapsed flag: indicates, whether the timeout is elapsed*/
TimeoutToDispatchStruct(Timeout* _timeout,
- std::mutex* _mutex,
bool _isExecuted,
bool _deleteObject,
bool _timeoutElapsed) {
timeout_ = _timeout;
- mutex_ = _mutex;
isExecuted_ = _isExecuted;
deleteObject_ = _deleteObject;
timeoutElapsed_ = _timeoutElapsed;
@@ -136,18 +130,15 @@ class DBusMainLoop {
struct WatchToDispatchStruct {
int fd_;
Watch* watch_;
- std::mutex* mutex_;
- bool isExecuted_; /* execution flag: indicates, whether the watch is dispatched currently */
- bool deleteObject_; /* delete flag: indicates, whether the watch can be deleted*/
+ std::atomic<bool> isExecuted_; /* execution flag: indicates, whether the watch is dispatched currently */
+ std::atomic<bool> deleteObject_; /* delete flag: indicates, whether the watch can be deleted*/
WatchToDispatchStruct(int _fd,
Watch* _watch,
- std::mutex* _mutex,
bool _isExecuted,
bool _deleteObject) {
fd_ = _fd;
watch_ = _watch;
- mutex_ = _mutex;
isExecuted_ = _isExecuted;
deleteObject_ = _deleteObject;
}
@@ -157,7 +148,7 @@ class DBusMainLoop {
std::multimap<DispatchPriority, WatchToDispatchStruct*> registeredWatches_;
std::multimap<DispatchPriority, TimeoutToDispatchStruct*> registeredTimeouts_;
- std::mutex dispatchSourcesMutex_;
+ std::recursive_mutex dispatchSourcesMutex_;
std::mutex watchesMutex_;
std::mutex timeoutsMutex_;
@@ -179,7 +170,7 @@ class DBusMainLoop {
#endif
std::atomic<bool> hasToStop_;
- bool isBroken_;
+ std::atomic<bool> isBroken_;
};
} // namespace DBus
diff --git a/include/CommonAPI/DBus/DBusMainLoopContext.hpp b/include/CommonAPI/DBus/DBusMainLoopContext.hpp
index ecb49ee..c74dc91 100644
--- a/include/CommonAPI/DBus/DBusMainLoopContext.hpp
+++ b/include/CommonAPI/DBus/DBusMainLoopContext.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
@@ -28,7 +28,7 @@ class DBusConnection;
class DBusDispatchSource: public DispatchSource {
public:
- DBusDispatchSource(DBusConnection* dbusConnection);
+ DBusDispatchSource(std::weak_ptr<DBusConnection> dbusConnection);
~DBusDispatchSource();
bool prepare(int64_t& timeout);
@@ -36,7 +36,7 @@ class DBusDispatchSource: public DispatchSource {
bool dispatch();
private:
- DBusConnection* dbusConnection_;
+ std::weak_ptr<DBusConnection> dbusConnection_;
};
class DBusQueueWatch;
@@ -146,41 +146,6 @@ private:
};
-
-class DBusTimeout: public Timeout {
- public:
- DBusTimeout(::DBusTimeout* libdbusTimeout,
- std::weak_ptr<MainLoopContext>& mainLoopContext,
- std::weak_ptr<DBusConnection>& dbusConnection);
-
- bool isReadyToBeMonitored();
- void startMonitoring();
- void stopMonitoring();
-
- bool dispatch();
-
- int64_t getTimeoutInterval() const;
- int64_t getReadyTime() const;
-
- void setPendingCall(DBusPendingCall* _pendingCall);
-
-#ifdef _WIN32
- __declspec(thread) static DBusTimeout *currentTimeout_;
-#else
- thread_local static DBusTimeout *currentTimeout_;
-#endif
-
- private:
- void recalculateDueTime();
-
- std::atomic<int64_t> dueTimeInMs_;
- ::DBusTimeout* libdbusTimeout_;
- std::weak_ptr<MainLoopContext> mainLoopContext_;
- std::weak_ptr<DBusConnection> dbusConnection_;
- DBusPendingCall *pendingCall_;
-};
-
-
} // namespace DBus
} // namespace CommonAPI
diff --git a/include/CommonAPI/DBus/DBusMessage.hpp b/include/CommonAPI/DBus/DBusMessage.hpp
index b30749e..3fdf5f4 100644
--- a/include/CommonAPI/DBus/DBusMessage.hpp
+++ b/include/CommonAPI/DBus/DBusMessage.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusMultiEvent.hpp b/include/CommonAPI/DBus/DBusMultiEvent.hpp
index cf18a48..cd9be83 100644
--- a/include/CommonAPI/DBus/DBusMultiEvent.hpp
+++ b/include/CommonAPI/DBus/DBusMultiEvent.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusObjectManager.hpp b/include/CommonAPI/DBus/DBusObjectManager.hpp
index 432e733..94d2dcd 100644
--- a/include/CommonAPI/DBus/DBusObjectManager.hpp
+++ b/include/CommonAPI/DBus/DBusObjectManager.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusObjectManagerStub.hpp b/include/CommonAPI/DBus/DBusObjectManagerStub.hpp
index d8de02d..c27333d 100644
--- a/include/CommonAPI/DBus/DBusObjectManagerStub.hpp
+++ b/include/CommonAPI/DBus/DBusObjectManagerStub.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusOutputStream.hpp b/include/CommonAPI/DBus/DBusOutputStream.hpp
index 8719146..a337845 100644
--- a/include/CommonAPI/DBus/DBusOutputStream.hpp
+++ b/include/CommonAPI/DBus/DBusOutputStream.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2014-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
@@ -138,6 +138,15 @@ public:
return (*this);
}
+ template<int minimum, int maximum>
+ COMMONAPI_EXPORT OutputStream &writeValue(const RangedInteger<minimum, maximum> &_value, const EmptyDeployment *) {
+ if (_value.validate())
+ writeValue(_value.value_, static_cast<EmptyDeployment *>(nullptr));
+ else
+ setError();
+ return (*this);
+ }
+
template<class Deployment_, typename Base_>
COMMONAPI_EXPORT OutputStream &writeValue(const Enumeration<Base_> &_value, const Deployment_ *_depl = nullptr) {
return writeValue(static_cast<Base_>(_value), _depl);
@@ -359,40 +368,51 @@ private:
COMMONAPI_EXPORT void pushPosition();
COMMONAPI_EXPORT size_t popPosition();
- template<typename Type_>
- COMMONAPI_EXPORT void alignVector(typename std::enable_if<!std::is_class<Type_>::value>::type * = nullptr,
- typename std::enable_if<!is_std_vector<Type_>::value>::type * = nullptr,
- typename std::enable_if<!is_std_unordered_map<Type_>::value>::type * = nullptr) {
+ template<typename Type_,
+ typename std::enable_if<(!std::is_class<Type_>::value &&
+ !is_std_vector<Type_>::value &&
+ !is_std_unordered_map<Type_>::value), int>::type = 0>
+ COMMONAPI_EXPORT void alignVector() {
if (4 < sizeof(Type_)) align(8);
}
- template<typename Type_>
- COMMONAPI_EXPORT void alignVector(typename std::enable_if<!std::is_same<Type_, std::string>::value>::type * = nullptr,
- typename std::enable_if<std::is_class<Type_>::value>::type * = nullptr,
- typename std::enable_if<!is_std_vector<Type_>::value>::type * = nullptr,
- typename std::enable_if<!is_std_unordered_map<Type_>::value>::type * = nullptr,
- typename std::enable_if<!std::is_base_of<Enumeration<int32_t>, Type_>::value>::type * = nullptr) {
+ template<typename Type_,
+ typename std::enable_if<(!std::is_same<Type_, std::string>::value &&
+ std::is_class<Type_>::value &&
+ !is_std_vector<Type_>::value &&
+ !is_std_unordered_map<Type_>::value &&
+ !std::is_base_of<Enumeration<uint8_t>, Type_>::value &&
+ !std::is_base_of<Enumeration<uint16_t>, Type_>::value &&
+ !std::is_base_of<Enumeration<uint32_t>, Type_>::value &&
+ !std::is_base_of<Enumeration<int8_t>, Type_>::value &&
+ !std::is_base_of<Enumeration<int16_t>, Type_>::value &&
+ !std::is_base_of<Enumeration<int32_t>, Type_>::value), int>::type = 0>
+ COMMONAPI_EXPORT void alignVector() {
align(8);
}
- template<typename Type_>
- COMMONAPI_EXPORT void alignVector(typename std::enable_if<std::is_same<Type_, std::string>::value>::type * = nullptr) {
+ template<typename Type_,
+ typename std::enable_if<(std::is_same<Type_, std::string>::value ||
+ is_std_vector<Type_>::value ||
+ std::is_base_of<Enumeration<uint8_t>, Type_>::value ||
+ std::is_base_of<Enumeration<int8_t>, Type_>::value), int>::type = 0>
+ COMMONAPI_EXPORT void alignVector() {
// Intentionally do nothing
}
- template<typename Type_>
- COMMONAPI_EXPORT void alignVector(typename std::enable_if<is_std_vector<Type_>::value>::type * = nullptr) {
- // Intentionally do nothing
- }
-
- template<typename Type_>
- COMMONAPI_EXPORT void alignVector(typename std::enable_if<is_std_unordered_map<Type_>::value>::type * = nullptr) {
+ template<typename Type_,
+ typename std::enable_if<(is_std_unordered_map<Type_>::value ||
+ std::is_base_of<Enumeration<uint32_t>, Type_>::value ||
+ std::is_base_of<Enumeration<int32_t>, Type_>::value), int>::type = 0>
+ COMMONAPI_EXPORT void alignVector() {
align(4);
}
- template<typename Type_>
- COMMONAPI_EXPORT void alignVector(typename std::enable_if<std::is_base_of<Enumeration<int32_t>, Type_>::value>::type * = nullptr) {
- align(4);
+ template<typename Type_,
+ typename std::enable_if<(std::is_base_of<Enumeration<uint16_t>, Type_>::value ||
+ std::is_base_of<Enumeration<int16_t>, Type_>::value), int>::type = 0>
+ COMMONAPI_EXPORT void alignVector() {
+ align(2);
}
COMMONAPI_EXPORT void setError();
@@ -459,7 +479,7 @@ private:
COMMONAPI_EXPORT size_t getCurrentStreamPosition();
- DBusError dbusError_;
+ bool errorOccurred_;
DBusMessage dbusMessage_;
std::vector<size_t> positions_;
diff --git a/include/CommonAPI/DBus/DBusProxy.hpp b/include/CommonAPI/DBus/DBusProxy.hpp
index 9a85a8d..19edf21 100644
--- a/include/CommonAPI/DBus/DBusProxy.hpp
+++ b/include/CommonAPI/DBus/DBusProxy.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2014-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
@@ -181,4 +181,3 @@ private:
} // namespace CommonAPI
#endif // COMMONAPI_DBUS_DBUSPROXY_HPP_
-
diff --git a/include/CommonAPI/DBus/DBusProxyAsyncCallbackHandler.hpp b/include/CommonAPI/DBus/DBusProxyAsyncCallbackHandler.hpp
index 25b2ecd..f1c8ac7 100644
--- a/include/CommonAPI/DBus/DBusProxyAsyncCallbackHandler.hpp
+++ b/include/CommonAPI/DBus/DBusProxyAsyncCallbackHandler.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2014-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
@@ -119,7 +119,7 @@ class DBusProxyAsyncCallbackHandler :
std::tuple<ArgTypes_...> args_;
private:
- template <int... ArgIndices_>
+ template <size_t... ArgIndices_>
inline CallStatus handleDBusMessageReply(
const CallStatus _dbusMessageCallStatus,
const DBusMessage& _dbusMessage,
@@ -132,10 +132,9 @@ class DBusProxyAsyncCallbackHandler :
if (_dbusMessageCallStatus == CallStatus::SUCCESS) {
DBusInputStream dbusInputStream(_dbusMessage);
- if(DBusSerializableArguments<ArgTypes_...>::deserialize(dbusInputStream,
+ if(!DBusSerializableArguments<ArgTypes_...>::deserialize(dbusInputStream,
std::get<ArgIndices_>(_argTuple)...)) {
- } else {
- callStatus = CallStatus::REMOTE_ERROR;
+ callStatus = CallStatus::SERIALIZATION_ERROR;
}
}
@@ -195,7 +194,7 @@ public:
private:
- template <int... ArgIndices_>
+ template <size_t... ArgIndices_>
inline CallStatus handleDBusMessageReply(
const CallStatus _dbusMessageCallStatus,
const DBusMessage& _dbusMessage,
@@ -208,10 +207,9 @@ private:
if (_dbusMessageCallStatus == CallStatus::SUCCESS) {
DBusInputStream dbusInputStream(_dbusMessage);
- if(DBusSerializableArguments<ArgTypes_...>::deserialize(dbusInputStream,
+ if (!DBusSerializableArguments<ArgTypes_...>::deserialize(dbusInputStream,
std::get<ArgIndices_>(_argTuple)...)) {
- } else {
- callStatus = CallStatus::REMOTE_ERROR;
+ callStatus = CallStatus::SERIALIZATION_ERROR;
}
} else {
if(_dbusMessage.isErrorType()) {
diff --git a/include/CommonAPI/DBus/DBusProxyAsyncSignalMemberCallbackHandler.hpp b/include/CommonAPI/DBus/DBusProxyAsyncSignalMemberCallbackHandler.hpp
index a768e45..cd89207 100644
--- a/include/CommonAPI/DBus/DBusProxyAsyncSignalMemberCallbackHandler.hpp
+++ b/include/CommonAPI/DBus/DBusProxyAsyncSignalMemberCallbackHandler.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2015-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusProxyBase.hpp b/include/CommonAPI/DBus/DBusProxyBase.hpp
index fd9c33d..4c1dade 100644
--- a/include/CommonAPI/DBus/DBusProxyBase.hpp
+++ b/include/CommonAPI/DBus/DBusProxyBase.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2014-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusProxyConnection.hpp b/include/CommonAPI/DBus/DBusProxyConnection.hpp
index 4d9f3e0..177bbe8 100644
--- a/include/CommonAPI/DBus/DBusProxyConnection.hpp
+++ b/include/CommonAPI/DBus/DBusProxyConnection.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusProxyHelper.hpp b/include/CommonAPI/DBus/DBusProxyHelper.hpp
index 2337fab..1202f4e 100644
--- a/include/CommonAPI/DBus/DBusProxyHelper.hpp
+++ b/include/CommonAPI/DBus/DBusProxyHelper.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
@@ -15,6 +15,8 @@
#include <memory>
#include <string>
+#include <CommonAPI/Logger.hpp>
+
#include <CommonAPI/DBus/DBusAddress.hpp>
#include <CommonAPI/DBus/DBusConfig.hpp>
#include <CommonAPI/DBus/DBusMessage.hpp>
@@ -62,7 +64,13 @@ struct DBusProxyHelper<In_<DBusInputStream, DBusOutputStream, InArgs_...>,
if (sizeof...(InArgs_) > 0) {
DBusOutputStream output(message);
if (!DBusSerializableArguments<InArgs_...>::serialize(output, _in...)) {
- _status = CallStatus::OUT_OF_MEMORY;
+ COMMONAPI_ERROR("MethodSync(dbus): serialization failed: [",
+ message.getObjectPath(), " ",
+ message.getInterface(), " ",
+ message.getMember(), " ",
+ message.getSerial(), "]");
+
+ _status = CallStatus::SERIALIZATION_ERROR;
return;
}
output.flush();
@@ -87,7 +95,13 @@ struct DBusProxyHelper<In_<DBusInputStream, DBusOutputStream, InArgs_...>,
if (sizeof...(InArgs_) > 0) {
DBusOutputStream output(_message);
if (!DBusSerializableArguments<InArgs_...>::serialize(output, _in...)) {
- _status = CallStatus::OUT_OF_MEMORY;
+ COMMONAPI_ERROR("MethodSync w/ reply (dbus): serialization failed: [",
+ _message.getObjectPath(), " ",
+ _message.getInterface(), " ",
+ _message.getMember(), " ",
+ _message.getSerial(), "]");
+
+ _status = CallStatus::SERIALIZATION_ERROR;
return;
}
output.flush();
@@ -103,7 +117,13 @@ struct DBusProxyHelper<In_<DBusInputStream, DBusOutputStream, InArgs_...>,
if (sizeof...(OutArgs_) > 0) {
DBusInputStream input(reply);
if (!DBusSerializableArguments<OutArgs_...>::deserialize(input, _out...)) {
- _status = CallStatus::REMOTE_ERROR;
+ COMMONAPI_ERROR("MethodSync w/ reply (dbus): reply deserialization failed: [",
+ reply.getObjectPath(), " ",
+ reply.getInterface(), " ",
+ reply.getMember(), " ",
+ reply.getSerial(), "]");
+
+ _status = CallStatus::SERIALIZATION_ERROR;
return;
}
}
@@ -188,8 +208,14 @@ struct DBusProxyHelper<In_<DBusInputStream, DBusOutputStream, InArgs_...>,
InArgs_...
>::serialize(output, _in...);
if (!success) {
+ COMMONAPI_ERROR("MethodAsync (dbus): serialization failed: [",
+ _message.getObjectPath(), " ",
+ _message.getInterface(), " ",
+ _message.getMember(), " ",
+ _message.getSerial(), "]");
+
std::promise<CallStatus> promise;
- promise.set_value(CallStatus::OUT_OF_MEMORY);
+ promise.set_value(CallStatus::SERIALIZATION_ERROR);
return promise.get_future();
}
output.flush();
@@ -206,7 +232,11 @@ struct DBusProxyHelper<In_<DBusInputStream, DBusOutputStream, InArgs_...>,
try {
callStatusFuture = dbusMessageReplyAsyncHandler->getFuture();
} catch (std::exception& e) {
- COMMONAPI_ERROR("MethodAsync(dbus): messageReplyAsyncHandler future failed(", e.what(), ")");
+ COMMONAPI_ERROR("MethodAsync(dbus): messageReplyAsyncHandler future failed(",
+ e.what(), ") [", _message.getObjectPath(), " ",
+ _message.getInterface(), " ",
+ _message.getMember(), " ",
+ _message.getSerial(), "]");
}
if(_proxy.isAvailable()) {
@@ -317,7 +347,7 @@ struct DBusProxyHelper<In_<DBusInputStream, DBusOutputStream, InArgs_...>,
return callMethodAsync(_proxy, message, _info, _in..., _function, _out);
}
- template <int... ArgIndices_>
+ template <size_t... ArgIndices_>
static void callCallbackOnNotAvailable(std::function<void(CallStatus, OutArgs_&...)> _callback,
index_sequence<ArgIndices_...>, std::tuple<OutArgs_...> _out) {
const CallStatus status(CallStatus::NOT_AVAILABLE);
@@ -347,7 +377,13 @@ struct DBusProxyHelper<In_<DBusInputStream, DBusOutputStream, InArgs_...>,
if (sizeof...(InArgs_) > 0) {
DBusOutputStream output(_message);
if (!DBusSerializableArguments<InArgs_...>::serialize(output, _in...)) {
- _status = CallStatus::OUT_OF_MEMORY;
+ COMMONAPI_ERROR("MethodSync w/ reply and error events (dbus): serialization failed: [",
+ _message.getObjectPath(), " ",
+ _message.getInterface(), " ",
+ _message.getMember(), " ",
+ _message.getSerial(), "]");
+
+ _status = CallStatus::SERIALIZATION_ERROR;
return;
}
output.flush();
@@ -367,7 +403,13 @@ struct DBusProxyHelper<In_<DBusInputStream, DBusOutputStream, InArgs_...>,
if (sizeof...(OutArgs_) > 0) {
DBusInputStream input(reply);
if (!DBusSerializableArguments<OutArgs_...>::deserialize(input, _out...)) {
- _status = CallStatus::REMOTE_ERROR;
+ COMMONAPI_ERROR("MethodSync w/ reply and error events (dbus): reply deserialization failed: [",
+ reply.getObjectPath(), " ",
+ reply.getInterface(), " ",
+ reply.getMember(), " ",
+ reply.getSerial(), "]");
+
+ _status = CallStatus::SERIALIZATION_ERROR;
return;
}
}
@@ -413,8 +455,14 @@ struct DBusProxyHelper<In_<DBusInputStream, DBusOutputStream, InArgs_...>,
InArgs_...
>::serialize(output, _in...);
if (!success) {
+ COMMONAPI_ERROR("MethodAsync w/ reply and error events (dbus): serialization failed: [",
+ _message.getObjectPath(), " ",
+ _message.getInterface(), " ",
+ _message.getMember(), " ",
+ _message.getSerial(), "]");
+
std::promise<CallStatus> promise;
- promise.set_value(CallStatus::OUT_OF_MEMORY);
+ promise.set_value(CallStatus::SERIALIZATION_ERROR);
return promise.get_future();
}
output.flush();
@@ -431,7 +479,11 @@ struct DBusProxyHelper<In_<DBusInputStream, DBusOutputStream, InArgs_...>,
try {
callStatusFuture = dbusMessageReplyAsyncHandler->getFuture();
} catch (std::exception& e) {
- COMMONAPI_ERROR("MethodAsync(dbus): messageReplyAsyncHandler future failed(", e.what(), ")");
+ COMMONAPI_ERROR("MethodAsync(dbus): messageReplyAsyncHandler future failed(",
+ e.what(), ") [", _message.getObjectPath(), " ",
+ _message.getInterface(), " ",
+ _message.getMember(), " ",
+ _message.getSerial(), "]");
}
if(_proxy.isAvailable()) {
diff --git a/include/CommonAPI/DBus/DBusProxyManager.hpp b/include/CommonAPI/DBus/DBusProxyManager.hpp
index f8829b4..a5ac79e 100644
--- a/include/CommonAPI/DBus/DBusProxyManager.hpp
+++ b/include/CommonAPI/DBus/DBusProxyManager.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusSelectiveEvent.hpp b/include/CommonAPI/DBus/DBusSelectiveEvent.hpp
index da140b0..b8be8a8 100644
--- a/include/CommonAPI/DBus/DBusSelectiveEvent.hpp
+++ b/include/CommonAPI/DBus/DBusSelectiveEvent.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusSerializableArguments.hpp b/include/CommonAPI/DBus/DBusSerializableArguments.hpp
index 771de26..c2adf89 100644
--- a/include/CommonAPI/DBus/DBusSerializableArguments.hpp
+++ b/include/CommonAPI/DBus/DBusSerializableArguments.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusServiceRegistry.hpp b/include/CommonAPI/DBus/DBusServiceRegistry.hpp
index 2edcd8f..d27b153 100644
--- a/include/CommonAPI/DBus/DBusServiceRegistry.hpp
+++ b/include/CommonAPI/DBus/DBusServiceRegistry.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
@@ -46,7 +46,7 @@ class DBusAddress;
class DBusAddressTranslator;
class DBusDaemonProxy;
-class DBusServiceRegistry: public std::enable_shared_from_this<DBusServiceRegistry>,
+class COMMONAPI_EXPORT DBusServiceRegistry: public std::enable_shared_from_this<DBusServiceRegistry>,
public DBusProxyConnection::DBusSignalHandler {
public:
enum class DBusRecordState {
@@ -73,8 +73,8 @@ class DBusServiceRegistry: public std::enable_shared_from_this<DBusServiceRegist
typedef std::function<void(const DBusObjectManagerStub::DBusObjectPathAndInterfacesDict)> GetAvailableServiceInstancesCallback;
- static std::shared_ptr<DBusServiceRegistry> get(std::shared_ptr<DBusProxyConnection> _connection, bool _insert=true);
- static void remove(std::shared_ptr<DBusProxyConnection> _connection);
+ static std::shared_ptr<DBusServiceRegistry> get(const std::shared_ptr<DBusProxyConnection> &_connection, bool _insert=true);
+ static void remove(const std::shared_ptr<DBusProxyConnection> &_connection);
DBusServiceRegistry(std::shared_ptr<DBusProxyConnection> dbusProxyConnection);
diff --git a/include/CommonAPI/DBus/DBusStubAdapter.hpp b/include/CommonAPI/DBus/DBusStubAdapter.hpp
index 882ec8f..434c6e7 100644
--- a/include/CommonAPI/DBus/DBusStubAdapter.hpp
+++ b/include/CommonAPI/DBus/DBusStubAdapter.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusStubAdapterHelper.hpp b/include/CommonAPI/DBus/DBusStubAdapterHelper.hpp
index d4252ab..8a64c3b 100644
--- a/include/CommonAPI/DBus/DBusStubAdapterHelper.hpp
+++ b/include/CommonAPI/DBus/DBusStubAdapterHelper.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
@@ -380,6 +380,11 @@ struct DBusStubSignalHelper<In_<DBusInputStream, DBusOutputStream, InArgs_...>>
DBusOutputStream outputStream(dbusMessage);
const bool success = DBusSerializableArguments<InArgs_...>::serialize(outputStream, inArgs...);
if (!success) {
+ COMMONAPI_ERROR("DBusStubSignalHelper (dbus): serialization failed! [",
+ dbusMessage.getObjectPath(), " ",
+ dbusMessage.getInterface(), ".",
+ dbusMessage.getMember(), " ",
+ dbusMessage.getSerial());
return false;
}
outputStream.flush();
@@ -422,6 +427,11 @@ struct DBusStubSignalHelper<In_<DBusInputStream, DBusOutputStream, InArgs_...>>
DBusOutputStream outputStream(dbusMessage);
const bool success = DBusSerializableArguments<InArgs_...>::serialize(outputStream, inArgs...);
if (!success) {
+ COMMONAPI_ERROR("DBusStubSignalHelper 2 (dbus): serialization failed! [",
+ dbusMessage.getObjectPath(), " ",
+ dbusMessage.getInterface(), ".",
+ dbusMessage.getMember(), " ",
+ dbusMessage.getSerial());
return false;
}
outputStream.flush();
@@ -445,8 +455,8 @@ class DBusMethodStubDispatcher<StubClass_, In_<InArgs_...>, DeplIn_<DeplIn_Args.
typedef typename StubClass_::RemoteEventHandlerType RemoteEventHandlerType;
typedef void (StubClass_::*StubFunctor_)(std::shared_ptr<CommonAPI::ClientId>, InArgs_...);
- DBusMethodStubDispatcher(StubFunctor_ stubFunctor, std::tuple<DeplIn_Args*...> _in):
- stubFunctor_(stubFunctor) {
+ DBusMethodStubDispatcher(StubFunctor_ stubFunctor, const bool _isImplemented, std::tuple<DeplIn_Args*...> _in):
+ stubFunctor_(stubFunctor), isImplemented_(_isImplemented) {
initialize(typename make_sequence_range<sizeof...(DeplIn_Args), 0>::type(), _in);
}
@@ -455,16 +465,20 @@ class DBusMethodStubDispatcher<StubClass_, In_<InArgs_...>, DeplIn_<DeplIn_Args.
std::weak_ptr<DBusProxyConnection> _connection) {
(void) _remoteEventHandler;
(void) _connection;
+
+ if (!this->isImplemented_)
+ return false;
+
return handleDBusMessage(dbusMessage, stub, typename make_sequence_range<sizeof...(InArgs_), 0>::type());
}
private:
- template <int... DeplIn_ArgIndices>
+ template <size_t... DeplIn_ArgIndices>
inline void initialize(index_sequence<DeplIn_ArgIndices...>, std::tuple<DeplIn_Args*...> &_in) {
in_ = std::make_tuple(std::get<DeplIn_ArgIndices>(_in)...);
}
- template <int... InArgIndices_>
+ template <size_t... InArgIndices_>
inline bool handleDBusMessage(const DBusMessage& dbusMessage,
const std::shared_ptr<StubClass_>& stub,
index_sequence<InArgIndices_...>) {
@@ -472,8 +486,14 @@ class DBusMethodStubDispatcher<StubClass_, In_<InArgs_...>, DeplIn_<DeplIn_Args.
if (sizeof...(InArgs_) > 0) {
DBusInputStream dbusInputStream(dbusMessage);
const bool success = DBusSerializableArguments<CommonAPI::Deployable<InArgs_, DeplIn_Args>...>::deserialize(dbusInputStream, std::get<InArgIndices_>(in_)...);
- if (!success)
+ if (!success) {
+ COMMONAPI_ERROR("DBusMethodStubDispatcher (dbus): deserialization failed! [",
+ dbusMessage.getObjectPath(), " ",
+ dbusMessage.getInterface(), ".",
+ dbusMessage.getMember(), " ",
+ dbusMessage.getSerial());
return false;
+ }
}
std::shared_ptr<DBusClientId> clientId = std::make_shared<DBusClientId>(std::string(dbusMessage.getSender()));
@@ -484,6 +504,7 @@ class DBusMethodStubDispatcher<StubClass_, In_<InArgs_...>, DeplIn_<DeplIn_Args.
}
StubFunctor_ stubFunctor_;
+ const bool isImplemented_;
std::tuple<CommonAPI::Deployable<InArgs_, DeplIn_Args>...> in_;
};
@@ -512,13 +533,15 @@ class DBusMethodWithReplyStubDispatcher<
std::shared_ptr<CommonAPI::ClientId>, InArgs_..., ReplyType_t);
DBusMethodWithReplyStubDispatcher(StubFunctor_ _stubFunctor,
- const char* _dbusReplySignature,
- const std::tuple<DeplIn_Args*...>& _inDepArgs,
- const std::tuple<DeplOutArgs_*...>& _outDepArgs):
- out_(_outDepArgs),
- currentCall_(0),
- stubFunctor_(_stubFunctor),
- dbusReplySignature_(_dbusReplySignature) {
+ const char* _dbusReplySignature,
+ const bool _isImplemented,
+ const std::tuple<DeplIn_Args*...> &_inDepArgs,
+ const std::tuple<DeplOutArgs_*...> &_outDepArgs)
+ : out_(_outDepArgs),
+ currentCall_(0),
+ isImplemented_(_isImplemented),
+ stubFunctor_(_stubFunctor),
+ dbusReplySignature_(_dbusReplySignature) {
initialize(typename make_sequence_range<sizeof...(DeplIn_Args), 0>::type(), _inDepArgs);
}
@@ -528,6 +551,10 @@ class DBusMethodWithReplyStubDispatcher<
RemoteEventHandlerType* _remoteEventHandler,
std::weak_ptr<DBusProxyConnection> _connection) {
(void) _remoteEventHandler;
+
+ if (!this->isImplemented_)
+ return false;
+
connection_ = _connection;
return handleDBusMessage(
_dbusMessage,
@@ -560,15 +587,16 @@ protected:
std::mutex mutex_; // protects pending_
std::weak_ptr<DBusProxyConnection> connection_;
+ const bool isImplemented_;
private:
- template <int... DeplIn_ArgIndices>
+ template <size_t... DeplIn_ArgIndices>
inline void initialize(index_sequence<DeplIn_ArgIndices...>, const std::tuple<DeplIn_Args*...>& _in) {
in_ = std::make_tuple(std::get<DeplIn_ArgIndices>(_in)...);
}
- template <int... InArgIndices_, int... OutArgIndices_>
+ template <size_t... InArgIndices_, size_t... OutArgIndices_>
inline bool handleDBusMessage(const DBusMessage& _dbusMessage,
const std::shared_ptr<StubClass_>& _stub,
index_sequence<InArgIndices_...>,
@@ -576,8 +604,14 @@ private:
if (sizeof...(DeplIn_Args) > 0) {
DBusInputStream dbusInputStream(_dbusMessage);
const bool success = DBusSerializableArguments<CommonAPI::Deployable<InArgs_, DeplIn_Args>...>::deserialize(dbusInputStream, std::get<InArgIndices_>(in_)...);
- if (!success)
+ if (!success) {
+ COMMONAPI_ERROR("DBusMethodWithReplyStubDispatcher (dbus): deserialization failed! [",
+ _dbusMessage.getObjectPath(), " ",
+ _dbusMessage.getInterface(), ".",
+ _dbusMessage.getMember(), " ",
+ _dbusMessage.getSerial());
return false;
+ }
}
std::shared_ptr<DBusClientId> clientId
@@ -603,7 +637,7 @@ private:
return true;
}
- template<int... OutArgIndices_>
+ template<size_t... OutArgIndices_>
bool sendReplyInternal(const CommonAPI::CallId_t _call,
index_sequence<OutArgIndices_...>,
const std::tuple<CommonAPI::Deployable<OutArgs_, DeplOutArgs_>...>& _args) {
@@ -616,6 +650,11 @@ private:
output, std::get<OutArgIndices_>(_args)...)) {
(void)_args;
pending_.erase(_call);
+ COMMONAPI_ERROR("DBusMethodWithReplyStubDispatcher (dbus): serialization failed! [",
+ reply->second.getObjectPath(), " ",
+ reply->second.getInterface(), ".",
+ reply->second.getMember(), " ",
+ reply->second.getSerial());
return false;
}
output.flush();
@@ -664,29 +703,26 @@ class DBusMethodWithReplyStubDispatcher<
typedef void (StubClass_::*StubFunctor_)(
std::shared_ptr<CommonAPI::ClientId>, CommonAPI::CallId_t, InArgs_..., ReplyType_t, ErrorReplies_...);
- DBusMethodWithReplyStubDispatcher(StubFunctor_ _stubFunctor,
- const char* _dbusReplySignature,
- const std::tuple<DeplIn_Args*...>& _inDepArgs,
- const std::tuple<DeplOutArgs_*...>& _outDepArgs,
- const ErrorReplies_... _errorReplies) :
- DBusMethodWithReplyStubDispatcher<
- StubClass_,
- In_<InArgs_...>,
- Out_<OutArgs_...>,
- DeplIn_<DeplIn_Args...>,
- DeplOut_<DeplOutArgs_...>>(
- NULL,
- _dbusReplySignature,
- _inDepArgs,
- _outDepArgs),
- stubFunctor_(_stubFunctor),
- errorReplies_(std::make_tuple(_errorReplies...)) { }
+ DBusMethodWithReplyStubDispatcher(StubFunctor_ _stubFunctor, const char* _dbusReplySignature,
+ const bool _isImplemented,
+ const std::tuple<DeplIn_Args*...> &_inDepArgs,
+ const std::tuple<DeplOutArgs_*...> &_outDepArgs,
+ const ErrorReplies_... _errorReplies)
+ : DBusMethodWithReplyStubDispatcher<StubClass_, In_<InArgs_...>, Out_<OutArgs_...>,
+ DeplIn_<DeplIn_Args...>, DeplOut_<DeplOutArgs_...>>(NULL,
+ _dbusReplySignature, _isImplemented, _inDepArgs, _outDepArgs),
+ stubFunctor_(_stubFunctor),
+ errorReplies_(std::make_tuple(_errorReplies...)) { }
bool dispatchDBusMessage(const DBusMessage& _dbusMessage,
const std::shared_ptr<StubClass_>& _stub,
RemoteEventHandlerType* _remoteEventHandler,
std::weak_ptr<DBusProxyConnection> _connection) {
(void) _remoteEventHandler;
+
+ if (!this->isImplemented_)
+ return false;
+
this->connection_ = _connection;
return handleDBusMessage(
_dbusMessage,
@@ -716,7 +752,7 @@ class DBusMethodWithReplyStubDispatcher<
private:
- template <int... InArgIndices_, int... OutArgIndices_, int... ErrorRepliesIndices_>
+ template <size_t... InArgIndices_, size_t... OutArgIndices_, size_t... ErrorRepliesIndices_>
inline bool handleDBusMessage(const DBusMessage& _dbusMessage,
const std::shared_ptr<StubClass_>& _stub,
index_sequence<InArgIndices_...>,
@@ -725,8 +761,14 @@ private:
if (sizeof...(DeplIn_Args) > 0) {
DBusInputStream dbusInputStream(_dbusMessage);
const bool success = DBusSerializableArguments<CommonAPI::Deployable<InArgs_, DeplIn_Args>...>::deserialize(dbusInputStream, std::get<InArgIndices_>(this->in_)...);
- if (!success)
+ if (!success) {
+ COMMONAPI_ERROR("DBusMethodWithReplyStubDispatcher w/ error replies (dbus): deserialization failed! [",
+ _dbusMessage.getObjectPath(), " ",
+ _dbusMessage.getInterface(), ".",
+ _dbusMessage.getMember(), " ",
+ _dbusMessage.getSerial());
return false;
+ }
}
std::shared_ptr<DBusClientId> clientId
@@ -754,7 +796,7 @@ private:
return true;
}
- template<int... ErrorReplyOutArgIndices_, class... ErrorReplyOutArgs_, class ...ErrorReplyDeplOutArgs_>
+ template<size_t... ErrorReplyOutArgIndices_, class... ErrorReplyOutArgs_, class ...ErrorReplyDeplOutArgs_>
bool sendErrorReplyInternal(CommonAPI::CallId_t _call,
index_sequence<ErrorReplyOutArgIndices_...>,
const std::tuple<CommonAPI::Deployable<ErrorReplyOutArgs_, ErrorReplyDeplOutArgs_>...>& _args) {
@@ -767,6 +809,11 @@ private:
output, std::get<ErrorReplyOutArgIndices_>(_args)...)) {
(void)_args;
this->pending_.erase(_call);
+ COMMONAPI_ERROR("DBusMethodWithReplyStubDispatcher w/ error replies 2 (dbus): serialization failed! [",
+ reply->second.getObjectPath(), " ",
+ reply->second.getInterface(), ".",
+ reply->second.getMember(), " ",
+ reply->second.getSerial());
return false;
}
output.flush();
@@ -795,24 +842,27 @@ template <
typename StubAdapterClass_,
template <class...> class In_, class... InArgs_,
template <class...> class Out_, class... OutArgs_>
-class DBusMethodWithReplyAdapterDispatcher<StubClass_, StubAdapterClass_, In_<InArgs_...>, Out_<OutArgs_...> >:
- public StubDispatcher<StubClass_> {
+class DBusMethodWithReplyAdapterDispatcher<StubClass_, StubAdapterClass_, In_<InArgs_...>, Out_<OutArgs_...> >
+ : public StubDispatcher<StubClass_> {
public:
typedef typename StubClass_::RemoteEventHandlerType RemoteEventHandlerType;
typedef void (StubAdapterClass_::*StubFunctor_)(std::shared_ptr<CommonAPI::ClientId>, InArgs_..., OutArgs_&...);
typedef typename CommonAPI::Stub<typename StubClass_::StubAdapterType, typename StubClass_::RemoteEventType> StubType;
- DBusMethodWithReplyAdapterDispatcher(StubFunctor_ stubFunctor, const char* dbusReplySignature):
- stubFunctor_(stubFunctor),
- dbusReplySignature_(dbusReplySignature) {
+ DBusMethodWithReplyAdapterDispatcher(StubFunctor_ stubFunctor, const char* dbusReplySignature, const bool _isImplemented)
+ : stubFunctor_(stubFunctor),
+ dbusReplySignature_(dbusReplySignature),
+ isImplemented_(_isImplemented) {
}
bool dispatchDBusMessage(const DBusMessage& dbusMessage, const std::shared_ptr<StubClass_>& stub,
- RemoteEventHandlerType* _remoteEventHandler,
- std::weak_ptr<DBusProxyConnection> _connection) {
+ RemoteEventHandlerType *_remoteEventHandler, std::weak_ptr<DBusProxyConnection> _connection) {
(void)_remoteEventHandler;
+ if (!this->isImplemented_)
+ return false;
+
std::tuple<InArgs_..., OutArgs_...> argTuple;
return handleDBusMessage(
dbusMessage,
@@ -823,7 +873,7 @@ class DBusMethodWithReplyAdapterDispatcher<StubClass_, StubAdapterClass_, In_<In
}
private:
- template <int... InArgIndices_, int... OutArgIndices_>
+ template <size_t... InArgIndices_, size_t... OutArgIndices_>
inline bool handleDBusMessage(const DBusMessage& dbusMessage,
const std::shared_ptr<StubClass_>& stub,
std::weak_ptr<DBusProxyConnection> _connection,
@@ -835,8 +885,14 @@ class DBusMethodWithReplyAdapterDispatcher<StubClass_, StubAdapterClass_, In_<In
if (sizeof...(InArgs_) > 0) {
DBusInputStream dbusInputStream(dbusMessage);
const bool success = DBusSerializableArguments<InArgs_...>::deserialize(dbusInputStream, std::get<InArgIndices_>(argTuple)...);
- if (!success)
+ if (!success) {
+ COMMONAPI_ERROR("DBusMethodWithReplyAdapterDispatcher (dbus): deserialization failed! [",
+ dbusMessage.getObjectPath(), " ",
+ dbusMessage.getInterface(), ".",
+ dbusMessage.getMember(), " ",
+ dbusMessage.getSerial());
return false;
+ }
}
std::shared_ptr<DBusClientId> clientId = std::make_shared<DBusClientId>(std::string(dbusMessage.getSender()));
@@ -847,8 +903,14 @@ class DBusMethodWithReplyAdapterDispatcher<StubClass_, StubAdapterClass_, In_<In
if (sizeof...(OutArgs_) > 0) {
DBusOutputStream dbusOutputStream(dbusMessageReply);
const bool success = DBusSerializableArguments<OutArgs_...>::serialize(dbusOutputStream, std::get<OutArgIndices_>(argTuple)...);
- if (!success)
+ if (!success) {
+ COMMONAPI_ERROR("DBusMethodWithReplyAdapterDispatcher (dbus): serialization failed! [",
+ dbusMessageReply.getObjectPath(), " ",
+ dbusMessageReply.getInterface(), ".",
+ dbusMessageReply.getMember(), " ",
+ dbusMessageReply.getSerial());
return false;
+ }
dbusOutputStream.flush();
}
@@ -863,6 +925,7 @@ class DBusMethodWithReplyAdapterDispatcher<StubClass_, StubAdapterClass_, In_<In
StubFunctor_ stubFunctor_;
const char* dbusReplySignature_;
+ const bool isImplemented_;
};
@@ -875,19 +938,25 @@ class DBusGetAttributeStubDispatcher: public virtual StubDispatcher<StubClass_>
typedef typename StubClass_::StubAdapterType StubAdapterType;
typedef typename CommonAPI::Stub<StubAdapterType, typename StubClass_::RemoteEventType> StubType;
- DBusGetAttributeStubDispatcher(LockStubFunctor _lockStubFunctor, GetStubFunctor _getStubFunctor, const char *_signature, AttributeDepl_ *_depl = nullptr):
- lockStubFunctor_(_lockStubFunctor),
- getStubFunctor_(_getStubFunctor),
- signature_(_signature),
- depl_(_depl) {
+ DBusGetAttributeStubDispatcher(LockStubFunctor _lockStubFunctor, GetStubFunctor _getStubFunctor, const char *_signature,
+ const bool _isImplemented,
+ AttributeDepl_ *_depl = nullptr)
+ : lockStubFunctor_(_lockStubFunctor),
+ getStubFunctor_(_getStubFunctor),
+ signature_(_signature),
+ isImplemented_(_isImplemented),
+ depl_(_depl) {
}
virtual ~DBusGetAttributeStubDispatcher() {};
bool dispatchDBusMessage(const DBusMessage& dbusMessage, const std::shared_ptr<StubClass_>& stub,
- RemoteEventHandlerType* _remoteEventHandler,
- std::weak_ptr<DBusProxyConnection> _connection) {
+ RemoteEventHandlerType* _remoteEventHandler, std::weak_ptr<DBusProxyConnection> _connection) {
(void) _remoteEventHandler;
+
+ if (!this->isImplemented_)
+ return false;
+
return sendAttributeValueReply(dbusMessage, stub, _connection);
}
@@ -929,6 +998,7 @@ class DBusGetAttributeStubDispatcher: public virtual StubDispatcher<StubClass_>
LockStubFunctor lockStubFunctor_;
GetStubFunctor getStubFunctor_;
const char* signature_;
+ const bool isImplemented_;
AttributeDepl_ *depl_;
};
@@ -942,25 +1012,26 @@ class DBusSetAttributeStubDispatcher: public virtual DBusGetAttributeStubDispatc
typedef bool (RemoteEventHandlerType::*OnRemoteSetFunctor)(std::shared_ptr<CommonAPI::ClientId>, AttributeType_);
typedef void (RemoteEventHandlerType::*OnRemoteChangedFunctor)();
- DBusSetAttributeStubDispatcher(LockStubFunctor lockStubFunctor,
- GetStubFunctor getStubFunctor,
- OnRemoteSetFunctor onRemoteSetFunctor,
- OnRemoteChangedFunctor onRemoteChangedFunctor,
- const char* dbusSignature,
- AttributeDepl_ *_depl = nullptr) :
- DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(lockStubFunctor, getStubFunctor, dbusSignature, _depl),
- onRemoteSetFunctor_(onRemoteSetFunctor),
- onRemoteChangedFunctor_(onRemoteChangedFunctor) {
+ DBusSetAttributeStubDispatcher(LockStubFunctor _lockStubFunctor, GetStubFunctor _getStubFunctor,
+ OnRemoteSetFunctor onRemoteSetFunctor, OnRemoteChangedFunctor onRemoteChangedFunctor,
+ const char *_signature,
+ const bool _isImplemented,
+ AttributeDepl_ *_depl = nullptr)
+ : DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_lockStubFunctor, _getStubFunctor, _signature, _isImplemented, _depl),
+ onRemoteSetFunctor_(onRemoteSetFunctor),
+ onRemoteChangedFunctor_(onRemoteChangedFunctor) {
}
virtual ~DBusSetAttributeStubDispatcher() {};
- bool dispatchDBusMessage(const DBusMessage& dbusMessage, const std::shared_ptr<StubClass_>& stub,
- RemoteEventHandlerType* _remoteEventHandler,
- std::weak_ptr<DBusProxyConnection> _connection) {
+ bool dispatchDBusMessage(const DBusMessage &_message, const std::shared_ptr<StubClass_> &_stub,
+ RemoteEventHandlerType *_remoteEventHandler, std::weak_ptr<DBusProxyConnection> _connection) {
bool attributeValueChanged;
- if (!setAttributeValue(dbusMessage, stub, _remoteEventHandler, _connection, attributeValueChanged))
+ if (!this->isImplemented_)
+ return false;
+
+ if (!setAttributeValue(_message, _stub, _remoteEventHandler, _connection, attributeValueChanged))
return false;
if (attributeValueChanged)
@@ -970,46 +1041,47 @@ class DBusSetAttributeStubDispatcher: public virtual DBusGetAttributeStubDispatc
}
protected:
- virtual AttributeType_ retrieveAttributeValue(const DBusMessage& dbusMessage, bool& errorOccured) {
- errorOccured = false;
+ virtual AttributeType_ retrieveAttributeValue(const DBusMessage &_message, bool &_errorOccured) {
+ _errorOccured = false;
- DBusInputStream dbusInputStream(dbusMessage);
- CommonAPI::Deployable<AttributeType_, AttributeDepl_> attributeValue(this->depl_);
- dbusInputStream >> attributeValue;
+ DBusInputStream itsInput(_message);
+ CommonAPI::Deployable<AttributeType_, AttributeDepl_> itsValue(this->depl_);
+ itsInput >> itsValue;
- if (dbusInputStream.hasError()) {
- errorOccured = true;
+ if (itsInput.hasError()) {
+ _errorOccured = true;
}
- return attributeValue.getValue();
+ return itsValue.getValue();
}
- inline bool setAttributeValue(const DBusMessage& dbusMessage,
- const std::shared_ptr<StubClass_>& stub,
- RemoteEventHandlerType* _remoteEventHandler,
- std::weak_ptr<DBusProxyConnection> _connection,
- bool& attributeValueChanged) {
+ inline bool setAttributeValue(const DBusMessage &_message,
+ const std::shared_ptr<StubClass_> &_stub,
+ RemoteEventHandlerType *_remoteEventHandler,
+ std::weak_ptr<DBusProxyConnection> _connection,
+ bool &_hasChanged) {
bool errorOccured;
- CommonAPI::Deployable<AttributeType_, AttributeDepl_> attributeValue(
- retrieveAttributeValue(dbusMessage, errorOccured), this->depl_);
+ CommonAPI::Deployable<AttributeType_, AttributeDepl_> itsValue(
+ retrieveAttributeValue(_message, errorOccured), this->depl_);
- if(errorOccured) {
+ if (errorOccured) {
return false;
}
- std::shared_ptr<DBusClientId> clientId = std::make_shared<DBusClientId>(std::string(dbusMessage.getSender()));
+ std::shared_ptr<DBusClientId> clientId = std::make_shared<DBusClientId>(std::string(_message.getSender()));
- attributeValueChanged = (_remoteEventHandler->*onRemoteSetFunctor_)(clientId, std::move(attributeValue.getValue()));
+ _hasChanged = (_remoteEventHandler->*onRemoteSetFunctor_)(clientId, std::move(itsValue.getValue()));
- return this->sendAttributeValueReply(dbusMessage, stub, _connection);
+ return this->sendAttributeValueReply(_message, _stub, _connection);
}
- inline void notifyOnRemoteChanged(RemoteEventHandlerType* _remoteEventHandler) {
+ inline void notifyOnRemoteChanged(RemoteEventHandlerType *_remoteEventHandler) {
(_remoteEventHandler->*onRemoteChangedFunctor_)();
}
- inline const AttributeType_& getAttributeValue(std::shared_ptr<CommonAPI::ClientId> clientId, const std::shared_ptr<StubClass_>& stub) {
- return (stub.get()->*(this->getStubFunctor_))(clientId);
+ inline AttributeType_ getAttributeValue(std::shared_ptr<CommonAPI::ClientId> _client,
+ const std::shared_ptr<StubClass_> &_stub) {
+ return (_stub.get()->*(this->getStubFunctor_))(_client);
}
const OnRemoteSetFunctor onRemoteSetFunctor_;
@@ -1018,7 +1090,7 @@ class DBusSetAttributeStubDispatcher: public virtual DBusGetAttributeStubDispatc
template <typename StubClass_, typename AttributeType_, typename AttributeDepl_ = EmptyDeployment>
class DBusSetObservableAttributeStubDispatcher: public virtual DBusSetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_> {
- public:
+public:
typedef typename StubClass_::RemoteEventHandlerType RemoteEventHandlerType;
typedef typename StubClass_::StubAdapterType StubAdapterType;
typedef typename DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>::LockStubFunctor LockStubFunctor;
@@ -1028,43 +1100,44 @@ class DBusSetObservableAttributeStubDispatcher: public virtual DBusSetAttributeS
typedef typename CommonAPI::Stub<StubAdapterType, typename StubClass_::RemoteEventType> StubType;
typedef void (StubAdapterType::*FireChangedFunctor)(const AttributeType_&);
- DBusSetObservableAttributeStubDispatcher(LockStubFunctor lockStubFunctor,
- GetStubFunctor getStubFunctor,
- OnRemoteSetFunctor onRemoteSetFunctor,
- OnRemoteChangedFunctor onRemoteChangedFunctor,
- FireChangedFunctor fireChangedFunctor,
- const char* dbusSignature,
- AttributeDepl_ *_depl = nullptr)
+ DBusSetObservableAttributeStubDispatcher(LockStubFunctor _lockStubFunctor, GetStubFunctor _getStubFunctor,
+ OnRemoteSetFunctor onRemoteSetFunctor, OnRemoteChangedFunctor onRemoteChangedFunctor,
+ FireChangedFunctor fireChangedFunctor,
+ const char* dbusSignature,
+ const bool _isImplemented,
+ AttributeDepl_ *_depl = nullptr)
: DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(
- lockStubFunctor, getStubFunctor, dbusSignature, _depl),
+ _lockStubFunctor, _getStubFunctor, dbusSignature, _isImplemented, _depl),
DBusSetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(
- lockStubFunctor, getStubFunctor, onRemoteSetFunctor, onRemoteChangedFunctor, dbusSignature, _depl),
+ _lockStubFunctor, _getStubFunctor, onRemoteSetFunctor, onRemoteChangedFunctor, dbusSignature, _depl),
fireChangedFunctor_(fireChangedFunctor) {
}
virtual ~DBusSetObservableAttributeStubDispatcher() {};
- bool dispatchDBusMessage(const DBusMessage& dbusMessage, const std::shared_ptr<StubClass_>& stub,
- RemoteEventHandlerType* _remoteEventHandler,
- std::weak_ptr<DBusProxyConnection> _connection) {
- bool attributeValueChanged;
- if (!this->setAttributeValue(dbusMessage, stub, _remoteEventHandler, _connection, attributeValueChanged))
+ bool dispatchDBusMessage(const DBusMessage &_message, const std::shared_ptr<StubClass_> &_stub,
+ RemoteEventHandlerType *_remoteEventHandler, std::weak_ptr<DBusProxyConnection> _connection) {
+
+ if (!this->isImplemented_)
+ return false;
+
+ bool hasChanged;
+ if (!this->setAttributeValue(_message, _stub, _remoteEventHandler, _connection, hasChanged))
return false;
- if (attributeValueChanged) {
- std::shared_ptr<DBusClientId> clientId = std::make_shared<DBusClientId>(std::string(dbusMessage.getSender()));
- fireAttributeValueChanged(clientId, _remoteEventHandler, stub);
+ if (hasChanged) {
+ std::shared_ptr<DBusClientId> itsClient = std::make_shared<DBusClientId>(std::string(_message.getSender()));
+ fireAttributeValueChanged(itsClient, _remoteEventHandler, _stub);
this->notifyOnRemoteChanged(_remoteEventHandler);
}
return true;
}
+
protected:
virtual void fireAttributeValueChanged(std::shared_ptr<CommonAPI::ClientId> _client,
- RemoteEventHandlerType* _remoteEventHandler,
- const std::shared_ptr<StubClass_> _stub) {
+ RemoteEventHandlerType *_remoteEventHandler, const std::shared_ptr<StubClass_> _stub) {
(void)_remoteEventHandler;
-
auto stubAdapter = _stub->StubType::getStubAdapter();
(_stub.get()->*DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>::lockStubFunctor_)(true);
(stubAdapter.get()->*fireChangedFunctor_)(this->getAttributeValue(_client, _stub));
diff --git a/include/CommonAPI/DBus/DBusTypes.hpp b/include/CommonAPI/DBus/DBusTypes.hpp
index ec7e092..fa7ae9c 100644
--- a/include/CommonAPI/DBus/DBusTypes.hpp
+++ b/include/CommonAPI/DBus/DBusTypes.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2014-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/CommonAPI/DBus/DBusUtils.hpp b/include/CommonAPI/DBus/DBusUtils.hpp
index 03fd401..5b4dbd6 100644
--- a/include/CommonAPI/DBus/DBusUtils.hpp
+++ b/include/CommonAPI/DBus/DBusUtils.hpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2013-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// 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/.
diff --git a/include/pugixml/pugixml.hpp b/include/pugixml/pugixml.hpp
index 77b4dcf..50dcdea 100644
--- a/include/pugixml/pugixml.hpp
+++ b/include/pugixml/pugixml.hpp
@@ -48,9 +48,14 @@
# endif
#endif
-// If no API is defined, assume default
#ifndef PUGIXML_API
-# define PUGIXML_API
+# if defined(__GNUC__)
+# define PUGIXML_API __attribute__((visibility("default")))
+# elif defined(_MSC_VER) && _MSC_VER >= 1300
+# define PUGIXML_API
+# else
+# define PUGIXML_API
+# endif
#endif
// If no API for classes is defined, assume default
@@ -124,13 +129,13 @@ namespace pugi
// This flag determines if EOL characters are normalized (converted to #xA) during parsing. This flag is on by default.
const unsigned int parse_eol = 0x0020;
-
+
// This flag determines if attribute values are normalized using CDATA normalization rules during parsing. This flag is on by default.
const unsigned int parse_wconv_attribute = 0x0040;
// This flag determines if attribute values are normalized using NMTOKENS normalization rules during parsing. This flag is off by default.
const unsigned int parse_wnorm_attribute = 0x0080;
-
+
// This flag determines if document declaration (node_declaration) is added to the DOM tree. This flag is off by default.
const unsigned int parse_declaration = 0x0100;
@@ -168,16 +173,16 @@ namespace pugi
};
// Formatting flags
-
+
// Indent the nodes that are written to output stream with as many indentation strings as deep the node is in DOM tree. This flag is on by default.
const unsigned int format_indent = 0x01;
-
+
// Write encoding-specific BOM to the output stream. This flag is off by default.
const unsigned int format_write_bom = 0x02;
// Use raw output mode (no indentation and no line breaks are written). This flag is off by default.
const unsigned int format_raw = 0x04;
-
+
// Omit default XML declaration even if there is no declaration in the document. This flag is off by default.
const unsigned int format_no_declaration = 0x08;
@@ -190,7 +195,7 @@ namespace pugi
// The default set of formatting flags.
// Nodes are indented depending on their depth in DOM tree, a default declaration is output if document has none.
const unsigned int format_default = format_indent;
-
+
// Forward declarations
struct xml_attribute_struct;
struct xml_node_struct;
@@ -204,7 +209,7 @@ namespace pugi
class xml_node;
class xml_text;
-
+
#ifndef PUGIXML_NO_XPATH
class xpath_node;
class xpath_node_set;
@@ -277,13 +282,13 @@ namespace pugi
private:
xml_attribute_struct* _attr;
-
+
typedef void (*unspecified_bool_type)(xml_attribute***);
public:
// Default constructor. Constructs an empty attribute.
xml_attribute();
-
+
// Constructs attribute from internal pointer
explicit xml_attribute(xml_attribute_struct* attr);
@@ -378,7 +383,7 @@ namespace pugi
// Borland C++ workaround
bool operator!() const;
-
+
// Comparison operators (compares wrapped node pointers)
bool operator==(const xml_node& r) const;
bool operator!=(const xml_node& r) const;
@@ -396,7 +401,7 @@ namespace pugi
// Get node name/value, or "" if node is empty or it has no name/value
const char_t* name() const;
const char_t* value() const;
-
+
// Get attribute list
xml_attribute first_attribute() const;
xml_attribute last_attribute() const;
@@ -408,7 +413,7 @@ namespace pugi
// Get next/previous sibling in the children list of the parent node
xml_node next_sibling() const;
xml_node previous_sibling() const;
-
+
// Get parent node
xml_node parent() const;
@@ -433,7 +438,7 @@ namespace pugi
// Set node name/value (returns false if node is empty, there is not enough memory, or node can not have name/value)
bool set_name(const char_t* rhs);
bool set_value(const char_t* rhs);
-
+
// Add attribute with specified name. Returns added attribute, or empty attribute on errors.
xml_attribute append_attribute(const char_t* name);
xml_attribute prepend_attribute(const char_t* name);
@@ -476,11 +481,11 @@ namespace pugi
template <typename Predicate> xml_attribute find_attribute(Predicate pred) const
{
if (!_root) return xml_attribute();
-
+
for (xml_attribute attrib = first_attribute(); attrib; attrib = attrib.next_attribute())
if (pred(attrib))
return attrib;
-
+
return xml_attribute();
}
@@ -488,11 +493,11 @@ namespace pugi
template <typename Predicate> xml_node find_child(Predicate pred) const
{
if (!_root) return xml_node();
-
+
for (xml_node node = first_child(); node; node = node.next_sibling())
if (pred(node))
return node;
-
+
return xml_node();
}
@@ -502,7 +507,7 @@ namespace pugi
if (!_root) return xml_node();
xml_node cur = first_child();
-
+
while (cur._root && cur._root != _root)
{
if (pred(cur)) return cur;
@@ -534,7 +539,7 @@ namespace pugi
// Recursively traverse subtree with xml_tree_walker
bool traverse(xml_tree_walker& walker);
-
+
#ifndef PUGIXML_NO_XPATH
// Select single node by evaluating XPath query. Returns first node from the resulting node set.
xpath_node select_single_node(const char_t* query, xpath_variable_set* variables = 0) const;
@@ -544,7 +549,7 @@ namespace pugi
xpath_node_set select_nodes(const char_t* query, xpath_variable_set* variables = 0) const;
xpath_node_set select_nodes(const xpath_query& query) const;
#endif
-
+
// Print subtree using a writer object
void print(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
@@ -781,11 +786,11 @@ namespace pugi
private:
int _depth;
-
+
protected:
// Get current traversal depth
int depth() const;
-
+
public:
xml_tree_walker();
virtual ~xml_tree_walker();
@@ -852,7 +857,7 @@ namespace pugi
char_t* _buffer;
char _memory[192];
-
+
// Non-copyable semantics
xml_document(const xml_document&);
const xml_document& operator=(const xml_document&);
@@ -960,7 +965,7 @@ namespace pugi
// Non-copyable semantics
xpath_variable(const xpath_variable&);
xpath_variable& operator=(const xpath_variable&);
-
+
public:
// Get variable name
const char_t* name() const;
@@ -1035,21 +1040,21 @@ namespace pugi
// Get query expression return type
xpath_value_type return_type() const;
-
+
// Evaluate expression as boolean value in the specified context; performs type conversion if necessary.
// If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
bool evaluate_boolean(const xpath_node& n) const;
-
+
// Evaluate expression as double value in the specified context; performs type conversion if necessary.
// If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
double evaluate_number(const xpath_node& n) const;
-
+
#ifndef PUGIXML_NO_STL
// Evaluate expression as string value in the specified context; performs type conversion if necessary.
// If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
string_t evaluate_string(const xpath_node& n) const;
#endif
-
+
// Evaluate expression as string value in the specified context; performs type conversion if necessary.
// At most capacity characters are written to the destination buffer, full result size is returned (includes terminating zero).
// If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors.
@@ -1070,7 +1075,7 @@ namespace pugi
// Borland C++ workaround
bool operator!() const;
};
-
+
#ifndef PUGIXML_NO_EXCEPTIONS
// XPath exception class
class PUGIXML_CLASS xpath_exception: public std::exception
@@ -1089,20 +1094,20 @@ namespace pugi
const xpath_parse_result& result() const;
};
#endif
-
+
// XPath node class (either xml_node or xml_attribute)
class PUGIXML_CLASS xpath_node
{
private:
xml_node _node;
xml_attribute _attribute;
-
+
typedef void (*unspecified_bool_type)(xpath_node***);
public:
// Default constructor; constructs empty XPath node
xpath_node();
-
+
// Construct XPath node from XML node/attribute
xpath_node(const xml_node& node);
xpath_node(const xml_attribute& attribute, const xml_node& parent);
@@ -1110,13 +1115,13 @@ namespace pugi
// Get node/attribute, if any
xml_node node() const;
xml_attribute attribute() const;
-
+
// Get parent of contained node/attribute
xml_node parent() const;
// Safe bool conversion operator
operator unspecified_bool_type() const;
-
+
// Borland C++ workaround
bool operator!() const;
@@ -1142,10 +1147,10 @@ namespace pugi
type_sorted, // Sorted by document order (ascending)
type_sorted_reverse // Sorted by document order (descending)
};
-
+
// Constant iterator type
typedef const xpath_node* const_iterator;
-
+
// Default constructor. Constructs empty set.
xpath_node_set();
@@ -1154,38 +1159,38 @@ namespace pugi
// Destructor
~xpath_node_set();
-
+
// Copy constructor/assignment operator
xpath_node_set(const xpath_node_set& ns);
xpath_node_set& operator=(const xpath_node_set& ns);
// Get collection type
type_t type() const;
-
+
// Get collection size
size_t size() const;
// Indexing operator
const xpath_node& operator[](size_t index) const;
-
+
// Collection iterators
const_iterator begin() const;
const_iterator end() const;
// Sort the collection in ascending/descending order by document order
void sort(bool reverse = false);
-
+
// Get first node in the collection by document order
xpath_node first() const;
-
+
// Check if collection is empty
bool empty() const;
-
+
private:
type_t _type;
-
+
xpath_node _storage;
-
+
xpath_node* _begin;
xpath_node* _end;
@@ -1197,7 +1202,7 @@ namespace pugi
// Convert wide string to UTF8
std::basic_string<char, std::char_traits<char>, std::allocator<char> > PUGIXML_FUNCTION as_utf8(const wchar_t* str);
std::basic_string<char, std::char_traits<char>, std::allocator<char> > PUGIXML_FUNCTION as_utf8(const std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >& str);
-
+
// Convert UTF8 to wide string
std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > PUGIXML_FUNCTION as_wide(const char* str);
std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > PUGIXML_FUNCTION as_wide(const std::basic_string<char, std::char_traits<char>, std::allocator<char> >& str);
@@ -1205,13 +1210,13 @@ namespace pugi
// Memory allocation function interface; returns pointer to allocated memory or NULL on failure
typedef void* (*allocation_function)(size_t size);
-
+
// Memory deallocation function interface
typedef void (*deallocation_function)(void* ptr);
// Override default memory management functions. All subsequent allocations/deallocations will be performed via supplied functions.
void PUGIXML_FUNCTION set_memory_management_functions(allocation_function allocate, deallocation_function deallocate);
-
+
// Get current memory management functions
allocation_function PUGIXML_FUNCTION get_memory_allocation_function();
deallocation_function PUGIXML_FUNCTION get_memory_deallocation_function();
@@ -1253,7 +1258,7 @@ namespace std
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND