summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuergen Gehring <juergen.gehring@bmw.de>2018-01-25 01:02:22 -0800
committerJuergen Gehring <juergen.gehring@bmw.de>2018-01-25 01:02:22 -0800
commit1b5f83a9bcfcf5b36e183eace369cdfadb5d295f (patch)
tree00affb36639747f1ccc9a3640b8ee9ca5bcec548
parentc989150260f4327ce5704b6d617b2d6548d67d56 (diff)
downloadgenivi-common-api-dbus-runtime-1b5f83a9bcfcf5b36e183eace369cdfadb5d295f.tar.gz
capicxx-dbus-runtime 3.1.12.43.1.12.4
-rw-r--r--CHANGES3
-rw-r--r--include/CommonAPI/DBus/DBusFreedesktopStubAdapterHelper.hpp25
-rw-r--r--include/CommonAPI/DBus/DBusStubAdapterHelper.hpp35
3 files changed, 38 insertions, 25 deletions
diff --git a/CHANGES b/CHANGES
index f077acb..02e6a1b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,8 @@
Changes
=======
+v3.1.12.4
+- support 'lock functors' in AttributeDispatcher(s)
+
v3.1.12.3
- Fixed data race in generated StubDefault when using attributes
- use eventfd instead of pipe in Watch
diff --git a/include/CommonAPI/DBus/DBusFreedesktopStubAdapterHelper.hpp b/include/CommonAPI/DBus/DBusFreedesktopStubAdapterHelper.hpp
index 42b8f92..56f2f17 100644
--- a/include/CommonAPI/DBus/DBusFreedesktopStubAdapterHelper.hpp
+++ b/include/CommonAPI/DBus/DBusFreedesktopStubAdapterHelper.hpp
@@ -41,10 +41,11 @@ class DBusGetFreedesktopAttributeStubDispatcher
: public virtual DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>,
public virtual DBusGetFreedesktopAttributeStubDispatcherBase<StubClass_> {
public:
+ typedef typename DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>::LockStubFunctor LockStubFunctor;
typedef typename DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>::GetStubFunctor GetStubFunctor;
- DBusGetFreedesktopAttributeStubDispatcher(GetStubFunctor _getStubFunctor, AttributeDepl_ *_depl = nullptr)
- : DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_getStubFunctor, "v", _depl) {
+ DBusGetFreedesktopAttributeStubDispatcher(LockStubFunctor _lockStubFunctor, GetStubFunctor _getStubFunctor, AttributeDepl_ *_depl = nullptr)
+ : DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_lockStubFunctor, _getStubFunctor, "v", _depl) {
}
virtual ~DBusGetFreedesktopAttributeStubDispatcher() {};
@@ -86,19 +87,21 @@ class DBusSetFreedesktopAttributeStubDispatcher
: public virtual DBusGetFreedesktopAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>,
public virtual DBusSetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_> {
public:
+ typedef typename DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>::LockStubFunctor LockStubFunctor;
typedef typename DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>::GetStubFunctor GetStubFunctor;
typedef typename StubClass_::RemoteEventHandlerType RemoteEventHandlerType;
typedef bool (RemoteEventHandlerType::*OnRemoteSetFunctor)(std::shared_ptr<CommonAPI::ClientId>, AttributeType_);
typedef void (RemoteEventHandlerType::*OnRemoteChangedFunctor)();
DBusSetFreedesktopAttributeStubDispatcher(
+ LockStubFunctor _lockStubFunctor,
GetStubFunctor _getStubFunctor,
OnRemoteSetFunctor _onRemoteSetFunctor,
OnRemoteChangedFunctor _onRemoteChangedFunctor,
AttributeDepl_ * _depl = nullptr)
- : DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_getStubFunctor, "v", _depl),
- DBusGetFreedesktopAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_getStubFunctor, _depl),
- DBusSetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_getStubFunctor, _onRemoteSetFunctor, _onRemoteChangedFunctor, "v", _depl) {
+ : 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) {
}
virtual ~DBusSetFreedesktopAttributeStubDispatcher() {};
@@ -123,6 +126,7 @@ class DBusSetFreedesktopObservableAttributeStubDispatcher
: public virtual DBusSetFreedesktopAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>,
public virtual DBusSetObservableAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_> {
public:
+ typedef typename DBusSetFreedesktopAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>::LockStubFunctor LockStubFunctor;
typedef typename DBusSetFreedesktopAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>::GetStubFunctor GetStubFunctor;
typedef typename DBusSetFreedesktopAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>::OnRemoteSetFunctor OnRemoteSetFunctor;
typedef typename DBusSetFreedesktopAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>::OnRemoteChangedFunctor OnRemoteChangedFunctor;
@@ -130,16 +134,17 @@ public:
typedef void (StubAdapterType::*FireChangedFunctor)(const AttributeType_&);
DBusSetFreedesktopObservableAttributeStubDispatcher(
+ LockStubFunctor _lockStubFunctor,
GetStubFunctor _getStubFunctor,
OnRemoteSetFunctor _onRemoteSetFunctor,
OnRemoteChangedFunctor _onRemoteChangedFunctor,
FireChangedFunctor _fireChangedFunctor,
AttributeDepl_ *_depl = nullptr)
- : DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_getStubFunctor, "v", _depl),
- DBusGetFreedesktopAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_getStubFunctor, _depl),
- DBusSetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_getStubFunctor, _onRemoteSetFunctor, _onRemoteChangedFunctor, "v", _depl),
- DBusSetFreedesktopAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_getStubFunctor, _onRemoteSetFunctor, _onRemoteChangedFunctor, _depl),
- DBusSetObservableAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(_getStubFunctor, _onRemoteSetFunctor, _onRemoteChangedFunctor, _fireChangedFunctor, "v", _depl) {
+ : 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) {
}
};
diff --git a/include/CommonAPI/DBus/DBusStubAdapterHelper.hpp b/include/CommonAPI/DBus/DBusStubAdapterHelper.hpp
index 980d88e..d4252ab 100644
--- a/include/CommonAPI/DBus/DBusStubAdapterHelper.hpp
+++ b/include/CommonAPI/DBus/DBusStubAdapterHelper.hpp
@@ -870,11 +870,13 @@ template <typename StubClass_, typename AttributeType_, typename AttributeDepl_
class DBusGetAttributeStubDispatcher: public virtual StubDispatcher<StubClass_> {
public:
typedef typename StubClass_::RemoteEventHandlerType RemoteEventHandlerType;
+ typedef void (StubClass_::*LockStubFunctor)(bool);
typedef const AttributeType_& (StubClass_::*GetStubFunctor)(std::shared_ptr<CommonAPI::ClientId>);
typedef typename StubClass_::StubAdapterType StubAdapterType;
typedef typename CommonAPI::Stub<StubAdapterType, typename StubClass_::RemoteEventType> StubType;
- DBusGetAttributeStubDispatcher(GetStubFunctor _getStubFunctor, const char *_signature, AttributeDepl_ *_depl = nullptr):
+ DBusGetAttributeStubDispatcher(LockStubFunctor _lockStubFunctor, GetStubFunctor _getStubFunctor, const char *_signature, AttributeDepl_ *_depl = nullptr):
+ lockStubFunctor_(_lockStubFunctor),
getStubFunctor_(_getStubFunctor),
signature_(_signature),
depl_(_depl) {
@@ -894,10 +896,9 @@ class DBusGetAttributeStubDispatcher: public virtual StubDispatcher<StubClass_>
std::shared_ptr<DBusClientId> clientId = std::make_shared<DBusClientId>(std::string(dbusMessage.getSender()));
auto varDepl = CommonAPI::DBus::VariantDeployment<AttributeDepl_>(true, depl_); // presuming FreeDesktop variant deployment, as support for "legacy" service only
- auto stubAdapter = stub->StubType::getStubAdapter();
- stubAdapter->lockAttributes();
+ (stub.get()->*lockStubFunctor_)(true);
auto deployable = CommonAPI::Deployable<CommonAPI::Variant<AttributeType_>, CommonAPI::DBus::VariantDeployment<AttributeDepl_>>((stub.get()->*getStubFunctor_)(clientId), &varDepl);
- stubAdapter->unlockAttributes();
+ (stub.get()->*lockStubFunctor_)(false);
_output << deployable;
_output.flush();
@@ -910,10 +911,9 @@ class DBusGetAttributeStubDispatcher: public virtual StubDispatcher<StubClass_>
std::shared_ptr<DBusClientId> clientId = std::make_shared<DBusClientId>(std::string(dbusMessage.getSender()));
- auto stubAdapter = stub->StubType::getStubAdapter();
- stubAdapter->lockAttributes();
+ (stub.get()->*lockStubFunctor_)(true);
auto deployable = CommonAPI::Deployable<AttributeType_, AttributeDepl_>((stub.get()->*getStubFunctor_)(clientId), depl_);
- stubAdapter->unlockAttributes();
+ (stub.get()->*lockStubFunctor_)(false);
dbusOutputStream << deployable;
dbusOutputStream.flush();
@@ -926,7 +926,7 @@ class DBusGetAttributeStubDispatcher: public virtual StubDispatcher<StubClass_>
}
}
-
+ LockStubFunctor lockStubFunctor_;
GetStubFunctor getStubFunctor_;
const char* signature_;
AttributeDepl_ *depl_;
@@ -937,16 +937,18 @@ class DBusSetAttributeStubDispatcher: public virtual DBusGetAttributeStubDispatc
public:
typedef typename StubClass_::RemoteEventHandlerType RemoteEventHandlerType;
+ typedef typename DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>::LockStubFunctor LockStubFunctor;
typedef typename DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>::GetStubFunctor GetStubFunctor;
typedef bool (RemoteEventHandlerType::*OnRemoteSetFunctor)(std::shared_ptr<CommonAPI::ClientId>, AttributeType_);
typedef void (RemoteEventHandlerType::*OnRemoteChangedFunctor)();
- DBusSetAttributeStubDispatcher(GetStubFunctor getStubFunctor,
+ DBusSetAttributeStubDispatcher(LockStubFunctor lockStubFunctor,
+ GetStubFunctor getStubFunctor,
OnRemoteSetFunctor onRemoteSetFunctor,
OnRemoteChangedFunctor onRemoteChangedFunctor,
const char* dbusSignature,
AttributeDepl_ *_depl = nullptr) :
- DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(getStubFunctor, dbusSignature, _depl),
+ DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(lockStubFunctor, getStubFunctor, dbusSignature, _depl),
onRemoteSetFunctor_(onRemoteSetFunctor),
onRemoteChangedFunctor_(onRemoteChangedFunctor) {
}
@@ -1019,22 +1021,24 @@ class DBusSetObservableAttributeStubDispatcher: public virtual DBusSetAttributeS
public:
typedef typename StubClass_::RemoteEventHandlerType RemoteEventHandlerType;
typedef typename StubClass_::StubAdapterType StubAdapterType;
+ typedef typename DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>::LockStubFunctor LockStubFunctor;
typedef typename DBusSetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>::GetStubFunctor GetStubFunctor;
typedef typename DBusSetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>::OnRemoteSetFunctor OnRemoteSetFunctor;
typedef typename DBusSetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>::OnRemoteChangedFunctor OnRemoteChangedFunctor;
typedef typename CommonAPI::Stub<StubAdapterType, typename StubClass_::RemoteEventType> StubType;
typedef void (StubAdapterType::*FireChangedFunctor)(const AttributeType_&);
- DBusSetObservableAttributeStubDispatcher(GetStubFunctor getStubFunctor,
+ DBusSetObservableAttributeStubDispatcher(LockStubFunctor lockStubFunctor,
+ GetStubFunctor getStubFunctor,
OnRemoteSetFunctor onRemoteSetFunctor,
OnRemoteChangedFunctor onRemoteChangedFunctor,
FireChangedFunctor fireChangedFunctor,
const char* dbusSignature,
AttributeDepl_ *_depl = nullptr)
: DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(
- getStubFunctor, dbusSignature, _depl),
+ lockStubFunctor, getStubFunctor, dbusSignature, _depl),
DBusSetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>(
- getStubFunctor, onRemoteSetFunctor, onRemoteChangedFunctor, dbusSignature, _depl),
+ lockStubFunctor, getStubFunctor, onRemoteSetFunctor, onRemoteChangedFunctor, dbusSignature, _depl),
fireChangedFunctor_(fireChangedFunctor) {
}
@@ -1060,10 +1064,11 @@ protected:
const std::shared_ptr<StubClass_> _stub) {
(void)_remoteEventHandler;
+
auto stubAdapter = _stub->StubType::getStubAdapter();
- stubAdapter->lockAttributes();
+ (_stub.get()->*DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>::lockStubFunctor_)(true);
(stubAdapter.get()->*fireChangedFunctor_)(this->getAttributeValue(_client, _stub));
- stubAdapter->unlockAttributes();
+ (_stub.get()->*DBusGetAttributeStubDispatcher<StubClass_, AttributeType_, AttributeDepl_>::lockStubFunctor_)(false);
}
const FireChangedFunctor fireChangedFunctor_;