diff options
author | Lutz Bichler <Lutz.Bichler@bmw.de> | 2020-10-27 10:02:03 +0100 |
---|---|---|
committer | Lutz Bichler <Lutz.Bichler@bmw.de> | 2020-10-27 10:02:03 +0100 |
commit | 89720d3c63bbd22cbccc80cdc92c2f2dd20193ba (patch) | |
tree | 591c45dba85c98fdd8e141827bdb6e82aaad4f59 /include | |
parent | 99ebf3461f51e4899f06457d6aafdaa4adecd278 (diff) | |
download | genivi-common-api-runtime-89720d3c63bbd22cbccc80cdc92c2f2dd20193ba.tar.gz |
Diffstat (limited to 'include')
34 files changed, 340 insertions, 277 deletions
diff --git a/include/CommonAPI/Address.hpp b/include/CommonAPI/Address.hpp index bf21f65..767fca4 100644 --- a/include/CommonAPI/Address.hpp +++ b/include/CommonAPI/Address.hpp @@ -1,8 +1,12 @@ -// 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/. +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." +#endif + #ifndef COMMONAPI_ADDRESS_HPP_ #define COMMONAPI_ADDRESS_HPP_ @@ -21,7 +25,9 @@ public: const std::string &_interface, const std::string &_instance); COMMONAPI_EXPORT Address(const Address &_source); - COMMONAPI_EXPORT virtual ~Address(); + COMMONAPI_EXPORT virtual ~Address() = default; + + COMMONAPI_EXPORT Address &operator=(const Address &_other); COMMONAPI_EXPORT bool operator==(const Address &_other) const; COMMONAPI_EXPORT bool operator!=(const Address &_other) const; diff --git a/include/CommonAPI/Attribute.hpp b/include/CommonAPI/Attribute.hpp index 16ed47e..7c8fd2a 100644 --- a/include/CommonAPI/Attribute.hpp +++ b/include/CommonAPI/Attribute.hpp @@ -1,10 +1,10 @@ -// 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/. #if !defined (COMMONAPI_INTERNAL_COMPILATION) -#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents." +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." #endif #ifndef COMMONAPI_ATTRIBUTE_HPP_ diff --git a/include/CommonAPI/AttributeExtension.hpp b/include/CommonAPI/AttributeExtension.hpp index 569be18..f95752a 100644 --- a/include/CommonAPI/AttributeExtension.hpp +++ b/include/CommonAPI/AttributeExtension.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/ByteBuffer.hpp b/include/CommonAPI/ByteBuffer.hpp index b8f72a5..5cbc354 100644 --- a/include/CommonAPI/ByteBuffer.hpp +++ b/include/CommonAPI/ByteBuffer.hpp @@ -1,8 +1,12 @@ -// 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/. +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." +#endif + #ifndef COMMONAPI_BYTE_BUFFER_HPP_ #define COMMONAPI_BYTE_BUFFER_HPP_ diff --git a/include/CommonAPI/CallInfo.hpp b/include/CommonAPI/CallInfo.hpp index 0195e6b..c12f8da 100644 --- a/include/CommonAPI/CallInfo.hpp +++ b/include/CommonAPI/CallInfo.hpp @@ -1,29 +1,26 @@ -// 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/. +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." +#endif + #ifndef COMMONAPI_CALLINFO_HPP_ #define COMMONAPI_CALLINFO_HPP_ #include <CommonAPI/Config.hpp> #include <CommonAPI/Types.hpp> +#include <string> namespace CommonAPI { struct COMMONAPI_EXPORT CallInfo { - CallInfo() - : timeout_(DEFAULT_SEND_TIMEOUT_MS), sender_(0) { - } - CallInfo(Timeout_t _timeout) - : timeout_(_timeout), sender_(0) { - } - CallInfo(Timeout_t _timeout, Sender_t _sender) - : timeout_(_timeout), sender_(_sender) { - } - CallInfo(const CallInfo &_other) - : timeout_(_other.timeout_), sender_(_other.sender_) { - } + CallInfo(); + CallInfo(Timeout_t _timeout); + CallInfo(const CallInfo &_other); + CallInfo(Timeout_t _timeout, Sender_t _sender); Timeout_t timeout_; Sender_t sender_; @@ -31,4 +28,4 @@ struct COMMONAPI_EXPORT CallInfo { } // namespace CommonAPI -#endif // COMMONAPI_ADDRESS_HPP_ +#endif // COMMONAPI_CALLINFO_HPP_ diff --git a/include/CommonAPI/CommonAPI.hpp b/include/CommonAPI/CommonAPI.hpp index a609350..21f224f 100644 --- a/include/CommonAPI/CommonAPI.hpp +++ b/include/CommonAPI/CommonAPI.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/. @@ -8,6 +8,7 @@ #ifndef COMMONAPI_INTERNAL_COMPILATION #define COMMONAPI_INTERNAL_COMPILATION +#define HAS_DEFINED_COMMONAPI_INTERNAL_COMPILATION_HERE #endif #include "Address.hpp" @@ -18,6 +19,9 @@ #include "Runtime.hpp" #include "Types.hpp" +#ifdef HAS_DEFINED_COMMONAPI_INTERNAL_COMPILATION_HERE #undef COMMONAPI_INTERNAL_COMPILATION +#undef HAS_DEFINED_COMMONAPI_INTERNAL_COMPILATION_HERE +#endif #endif // COMMONAPI_HPP_ diff --git a/include/CommonAPI/Config.hpp b/include/CommonAPI/Config.hpp index aff41d3..8b822c9 100644 --- a/include/CommonAPI/Config.hpp +++ b/include/CommonAPI/Config.hpp @@ -1,8 +1,12 @@ -// 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/. +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." +#endif + #ifndef COMMONAPI_CONFIG_HPP_ #define COMMONAPI_CONFIG_HPP_ diff --git a/include/CommonAPI/ContainerUtils.hpp b/include/CommonAPI/ContainerUtils.hpp index c436ae9..1f4b313 100644 --- a/include/CommonAPI/ContainerUtils.hpp +++ b/include/CommonAPI/ContainerUtils.hpp @@ -1,10 +1,10 @@ -// 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/. #if !defined (COMMONAPI_INTERNAL_COMPILATION) -#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents." +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." #endif #ifndef COMMONAPI_CONTAINERUTILS_HPP_ @@ -16,18 +16,17 @@ #include <CommonAPI/Export.hpp> namespace CommonAPI { + class ClientId; -struct COMMONAPI_EXPORT SharedPointerClientIdContentHash : public std::unary_function<std::shared_ptr<ClientId>, size_t> { - size_t operator()(const std::shared_ptr<ClientId>& t) const; +struct COMMONAPI_EXPORT SharedPointerClientIdContentHash { + size_t operator()(const std::shared_ptr<ClientId> &_t) const; }; -struct COMMONAPI_EXPORT SharedPointerClientIdContentEqual : public std::binary_function<std::shared_ptr<ClientId>, std::shared_ptr<ClientId>, bool> { - bool operator()(const std::shared_ptr<ClientId>& a, const std::shared_ptr<ClientId>& b) const; +struct COMMONAPI_EXPORT SharedPointerClientIdContentEqual { + bool operator()(const std::shared_ptr<ClientId> &_lhs, const std::shared_ptr<ClientId> &_rhs) const; }; - -} // namespace std - +} // namespace CommonAPI #endif // COMMONAPI_CONTAINERUTILS_HPP_ diff --git a/include/CommonAPI/Deployable.hpp b/include/CommonAPI/Deployable.hpp index cf269e8..c4f80e7 100644 --- a/include/CommonAPI/Deployable.hpp +++ b/include/CommonAPI/Deployable.hpp @@ -1,10 +1,10 @@ -// 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/. #if !defined (COMMONAPI_INTERNAL_COMPILATION) -#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents." +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." #endif #ifndef COMMONAPI_DEPLOYABLE_HPP_ @@ -28,6 +28,11 @@ struct Deployable : DeployableBase depl_(const_cast<TypeDepl_ *>(_depl)) { }; + Deployable(const Deployable<Type_, TypeDepl_> &_other) + : value_(_other.value_), + depl_(_other.depl_) { + } + Deployable<Type_, TypeDepl_>& operator=(const Deployable<Type_, TypeDepl_> &_source) { value_ = _source.value_; depl_ = _source.depl_; diff --git a/include/CommonAPI/Deployment.hpp b/include/CommonAPI/Deployment.hpp index e398cdd..67eb559 100644 --- a/include/CommonAPI/Deployment.hpp +++ b/include/CommonAPI/Deployment.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/Enumeration.hpp b/include/CommonAPI/Enumeration.hpp index 7d6ef28..2c5275d 100644 --- a/include/CommonAPI/Enumeration.hpp +++ b/include/CommonAPI/Enumeration.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/Event.hpp b/include/CommonAPI/Event.hpp index d2be59d..1d638e6 100644 --- a/include/CommonAPI/Event.hpp +++ b/include/CommonAPI/Event.hpp @@ -1,10 +1,10 @@ -// 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/. #if !defined (COMMONAPI_INTERNAL_COMPILATION) -#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents." +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." #endif #ifndef COMMONAPI_EVENT_HPP_ @@ -97,8 +97,8 @@ private: ListenersMap pendingSubscriptions_; SubscriptionsSet pendingUnsubscriptions_; - std::recursive_mutex mutex_; - std::mutex abi_placeholder_; + std::mutex notificationMutex_; + std::mutex subscriptionMutex_; }; template<typename ... Arguments_> @@ -107,14 +107,12 @@ typename Event<Arguments_...>::Subscription Event<Arguments_...>::subscribe(List bool isFirstListener; Listeners listeners; - { - std::lock_guard<std::recursive_mutex> itsLock(mutex_); - subscription = nextSubscription_++; - isFirstListener = (0 == pendingSubscriptions_.size()) && (pendingUnsubscriptions_.size() == subscriptions_.size()); - listener = std::move(listener); - listeners = std::make_tuple(listener, std::move(errorListener)); - pendingSubscriptions_[subscription] = std::move(listeners); - } + subscriptionMutex_.lock(); + subscription = nextSubscription_++; + isFirstListener = (0 == pendingSubscriptions_.size()) && (pendingUnsubscriptions_.size() == subscriptions_.size()); + listeners = std::make_tuple(listener, std::move(errorListener)); + pendingSubscriptions_[subscription] = std::move(listeners); + subscriptionMutex_.unlock(); if (isFirstListener) { if (!pendingUnsubscriptions_.empty()) @@ -132,31 +130,30 @@ void Event<Arguments_...>::unsubscribe(const Subscription subscription) { bool hasUnsubscribed(false); Listener listener; - { - std::lock_guard<std::recursive_mutex> itsLock(mutex_); - auto listenerIterator = subscriptions_.find(subscription); - if (subscriptions_.end() != listenerIterator) { - if (pendingUnsubscriptions_.end() == pendingUnsubscriptions_.find(subscription)) { - if (0 == pendingSubscriptions_.erase(subscription)) { - pendingUnsubscriptions_.insert(subscription); - listener = std::get<0>(listenerIterator->second); - hasUnsubscribed = true; - } - isLastListener = (pendingUnsubscriptions_.size() == subscriptions_.size()); + subscriptionMutex_.lock(); + auto listenerIterator = subscriptions_.find(subscription); + if (subscriptions_.end() != listenerIterator) { + if (pendingUnsubscriptions_.end() == pendingUnsubscriptions_.find(subscription)) { + if (0 == pendingSubscriptions_.erase(subscription)) { + pendingUnsubscriptions_.insert(subscription); + listener = std::get<0>(listenerIterator->second); + hasUnsubscribed = true; } + isLastListener = (pendingUnsubscriptions_.size() == subscriptions_.size()); } - else { - listenerIterator = pendingSubscriptions_.find(subscription); - if (pendingSubscriptions_.end() != listenerIterator) { - listener = std::get<0>(listenerIterator->second); - if (0 != pendingSubscriptions_.erase(subscription)) { - isLastListener = (pendingUnsubscriptions_.size() == subscriptions_.size()); - hasUnsubscribed = true; - } + } + else { + listenerIterator = pendingSubscriptions_.find(subscription); + if (pendingSubscriptions_.end() != listenerIterator) { + listener = std::get<0>(listenerIterator->second); + if (0 != pendingSubscriptions_.erase(subscription)) { + isLastListener = (pendingUnsubscriptions_.size() == subscriptions_.size()); + hasUnsubscribed = true; } } - isLastListener = isLastListener && (0 == pendingSubscriptions_.size()); } + isLastListener = isLastListener && (0 == pendingSubscriptions_.size()); + subscriptionMutex_.unlock(); if (hasUnsubscribed) { onListenerRemoved(listener, subscription); @@ -168,7 +165,9 @@ void Event<Arguments_...>::unsubscribe(const Subscription subscription) { template<typename ... Arguments_> void Event<Arguments_...>::notifyListeners(const Arguments_&... eventArguments) { - std::lock_guard<std::recursive_mutex> itsLock(mutex_); + + notificationMutex_.lock(); + subscriptionMutex_.lock(); for (auto iterator = pendingUnsubscriptions_.begin(); iterator != pendingUnsubscriptions_.end(); iterator++) { @@ -183,14 +182,19 @@ void Event<Arguments_...>::notifyListeners(const Arguments_&... eventArguments) } pendingSubscriptions_.clear(); + subscriptionMutex_.unlock(); for (auto iterator = subscriptions_.begin(); iterator != subscriptions_.end(); iterator++) { (std::get<0>(iterator->second))(eventArguments...); } + + notificationMutex_.unlock(); } template<typename ... Arguments_> void Event<Arguments_...>::notifySpecificListener(const Subscription subscription, const Arguments_&... eventArguments) { - std::lock_guard<std::recursive_mutex> itsLock(mutex_); + + notificationMutex_.lock(); + subscriptionMutex_.lock(); for (auto iterator = pendingUnsubscriptions_.begin(); iterator != pendingUnsubscriptions_.end(); iterator++) { @@ -206,16 +210,22 @@ void Event<Arguments_...>::notifySpecificListener(const Subscription subscriptio } pendingSubscriptions_.clear(); + + subscriptionMutex_.unlock(); for (auto iterator = subscriptions_.begin(); iterator != subscriptions_.end(); iterator++) { if (subscription == iterator->first) { (std::get<0>(iterator->second))(eventArguments...); } } + + notificationMutex_.unlock(); } template<typename ... Arguments_> void Event<Arguments_...>::notifySpecificError(const Subscription subscription, const CallStatus status) { - std::lock_guard<std::recursive_mutex> itsLock(mutex_); + + notificationMutex_.lock(); + subscriptionMutex_.lock(); for (auto iterator = pendingUnsubscriptions_.begin(); iterator != pendingUnsubscriptions_.end(); iterator++) { @@ -230,6 +240,7 @@ void Event<Arguments_...>::notifySpecificError(const Subscription subscription, } pendingSubscriptions_.clear(); + subscriptionMutex_.unlock(); for (auto iterator = subscriptions_.begin(); iterator != subscriptions_.end(); iterator++) { if (subscription == iterator->first) { ErrorListener listener = std::get<1>(iterator->second); @@ -239,7 +250,10 @@ void Event<Arguments_...>::notifySpecificError(const Subscription subscription, } } + notificationMutex_.unlock(); + if (status != CommonAPI::CallStatus::SUCCESS) { + subscriptionMutex_.lock(); auto listenerIterator = subscriptions_.find(subscription); if (subscriptions_.end() != listenerIterator) { if (pendingUnsubscriptions_.end() == pendingUnsubscriptions_.find(subscription)) { @@ -254,12 +268,15 @@ void Event<Arguments_...>::notifySpecificError(const Subscription subscription, pendingSubscriptions_.erase(subscription); } } + subscriptionMutex_.unlock(); } } template<typename ... Arguments_> void Event<Arguments_...>::notifyErrorListeners(const CallStatus status) { - std::lock_guard<std::recursive_mutex> itsLock(mutex_); + + notificationMutex_.lock(); + subscriptionMutex_.lock(); for (auto iterator = pendingUnsubscriptions_.begin(); iterator != pendingUnsubscriptions_.end(); iterator++) { @@ -274,12 +291,16 @@ void Event<Arguments_...>::notifyErrorListeners(const CallStatus status) { } pendingSubscriptions_.clear(); + subscriptionMutex_.unlock(); + for (auto iterator = subscriptions_.begin(); iterator != subscriptions_.end(); iterator++) { ErrorListener listener = std::get<1>(iterator->second); if (listener) { listener(status); } } + + notificationMutex_.unlock(); } diff --git a/include/CommonAPI/Export.hpp b/include/CommonAPI/Export.hpp index c7965f8..7ac00ac 100644 --- a/include/CommonAPI/Export.hpp +++ b/include/CommonAPI/Export.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/Extensions/AttributeCacheExtension.hpp b/include/CommonAPI/Extensions/AttributeCacheExtension.hpp index 051bb09..b486c68 100644 --- a/include/CommonAPI/Extensions/AttributeCacheExtension.hpp +++ b/include/CommonAPI/Extensions/AttributeCacheExtension.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/Factory.hpp b/include/CommonAPI/Factory.hpp index b71b26f..d27b518 100644 --- a/include/CommonAPI/Factory.hpp +++ b/include/CommonAPI/Factory.hpp @@ -1,8 +1,12 @@ -// 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/. +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." +#endif + #ifndef COMMONAPI_FACTORY_HPP_ #define COMMONAPI_FACTORY_HPP_ diff --git a/include/CommonAPI/IniFileReader.hpp b/include/CommonAPI/IniFileReader.hpp index 6fea715..0ae6e01 100644 --- a/include/CommonAPI/IniFileReader.hpp +++ b/include/CommonAPI/IniFileReader.hpp @@ -1,8 +1,12 @@ -// 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/. +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." +#endif + #ifndef COMMONAPI_INIFILEREADER_HPP_ #define COMMONAPI_INIFILEREADER_HPP_ diff --git a/include/CommonAPI/InputStream.hpp b/include/CommonAPI/InputStream.hpp index 0380a59..6b009a3 100644 --- a/include/CommonAPI/InputStream.hpp +++ b/include/CommonAPI/InputStream.hpp @@ -1,10 +1,10 @@ -// 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/. #if !defined (COMMONAPI_INTERNAL_COMPILATION) -#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents." +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." #endif #ifndef COMMONAPI_INPUT_STREAM_HPP_ @@ -16,6 +16,7 @@ #include <CommonAPI/Deployable.hpp> #include <CommonAPI/Deployment.hpp> #include <CommonAPI/Enumeration.hpp> +#include <CommonAPI/RangedInteger.hpp> #include <CommonAPI/Struct.hpp> #include <CommonAPI/Variant.hpp> #include <CommonAPI/Version.hpp> @@ -90,6 +91,11 @@ public: return get()->readValue(_value, _depl); } + template<class Deployment_, int minimum, int maximum> + InputStream &readValue(RangedInteger<minimum, maximum> &_value, const Deployment_ *_depl = nullptr) { + return get()->readValue(_value, _depl); + } + template<class Deployment_, typename... Types_> InputStream &readValue(Struct<Types_...> &_value, const Deployment_ *_depl = nullptr) { return get()->readValue(_value, _depl); diff --git a/include/CommonAPI/Logger.hpp b/include/CommonAPI/Logger.hpp index bb8c482..0658be8 100644 --- a/include/CommonAPI/Logger.hpp +++ b/include/CommonAPI/Logger.hpp @@ -1,24 +1,20 @@ -// 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/. +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." +#endif + #ifndef COMMONAPI_LOGGER_HPP_ #define COMMONAPI_LOGGER_HPP_ -#include <CommonAPI/LoggerImpl.hpp> +#include <memory> +#include <sstream> +#include <cstdint> -#define COMMONAPI_LOGLEVEL_NONE 0 -#define COMMONAPI_LOGLEVEL_FATAL 1 -#define COMMONAPI_LOGLEVEL_ERROR 2 -#define COMMONAPI_LOGLEVEL_WARNING 3 -#define COMMONAPI_LOGLEVEL_INFO 4 -#define COMMONAPI_LOGLEVEL_DEBUG 5 -#define COMMONAPI_LOGLEVEL_VERBOSE 6 - -#ifndef COMMONAPI_LOGLEVEL -#define COMMONAPI_LOGLEVEL COMMONAPI_LOGLEVEL_NONE -#endif +#include <CommonAPI/Export.hpp> #define COMMONAPI_FATAL CommonAPI::Logger::fatal #define COMMONAPI_ERROR CommonAPI::Logger::error @@ -29,84 +25,79 @@ namespace CommonAPI { + class Logger { public: + enum class Level : std::uint8_t COMMONAPI_EXPORT { + CAPI_LOG_NONE = 0, + CAPI_LOG_FATAL = 1, + CAPI_LOG_ERROR = 2, + CAPI_LOG_WARNING = 3, + CAPI_LOG_INFO = 4, + CAPI_LOG_DEBUG = 5, + CAPI_LOG_VERBOSE = 6 + }; + Logger(); + ~Logger(); template<typename... LogEntries_> - COMMONAPI_EXPORT static void fatal(LogEntries_... _entries) { - log(LoggerImpl::Level::LL_FATAL, _entries...); + COMMONAPI_EXPORT static void fatal(LogEntries_&&... _entries) { + log(Logger::Level::CAPI_LOG_FATAL, std::forward<LogEntries_>(_entries)...); } template<typename... LogEntries_> - COMMONAPI_EXPORT static void error(LogEntries_... _entries) { -#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_ERROR - log(LoggerImpl::Level::LL_ERROR, _entries...); -#else - std::tuple<LogEntries_...> args(_entries...); -#endif + COMMONAPI_EXPORT static void error(LogEntries_&&... _entries) { + log(Logger::Level::CAPI_LOG_ERROR, std::forward<LogEntries_>(_entries)...); } template<typename... LogEntries_> - COMMONAPI_EXPORT static void warning(LogEntries_... _entries) { -#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_WARNING - log(LoggerImpl::Level::LL_WARNING, _entries...); -#else - std::tuple<LogEntries_...> args(_entries...); -#endif + COMMONAPI_EXPORT static void warning(LogEntries_&&... _entries) { + log(Logger::Level::CAPI_LOG_WARNING, std::forward<LogEntries_>(_entries)...); } template<typename... LogEntries_> - COMMONAPI_EXPORT static void info(LogEntries_... _entries) { -#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_INFO - log(LoggerImpl::Level::LL_INFO, _entries...); -#else - std::tuple<LogEntries_...> args(_entries...); -#endif + COMMONAPI_EXPORT static void info(LogEntries_&&... _entries) { + log(Logger::Level::CAPI_LOG_INFO, std::forward<LogEntries_>(_entries)...); } template<typename... LogEntries_> - COMMONAPI_EXPORT static void debug(LogEntries_... _entries) { -#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_DEBUG - log(LoggerImpl::Level::LL_DEBUG, _entries...); -#else - std::tuple<LogEntries_...> args(_entries...); -#endif + COMMONAPI_EXPORT static void debug(LogEntries_&&... _entries) { + log(Logger::Level::CAPI_LOG_DEBUG, std::forward<LogEntries_>(_entries)...); } template<typename... LogEntries_> - COMMONAPI_EXPORT static void verbose(LogEntries_... _entries) { -#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_VERBOSE - log(LoggerImpl::Level::LL_VERBOSE, _entries...); -#else - std::tuple<LogEntries_...> args(_entries...); -#endif + COMMONAPI_EXPORT static void verbose(LogEntries_&&... _entries) { + log(Logger::Level::CAPI_LOG_VERBOSE, std::forward<LogEntries_>(_entries)...); } template<typename... LogEntries_> - COMMONAPI_EXPORT static void log(LoggerImpl::Level _level, LogEntries_... _entries) { -#if defined(USE_CONSOLE) || defined(USE_FILE) || defined(USE_DLT) - if (LoggerImpl::isLogged(_level)) { + COMMONAPI_EXPORT static void log(Logger::Level _level, LogEntries_&&... _entries) { + if (isLogged(_level)) { std::stringstream buffer; - log_intern(buffer, _entries...); - LoggerImpl::get()->doLog(_level, buffer.str()); + logIntern(buffer, std::forward<LogEntries_>(_entries)...); + Logger::doLog(_level, buffer.str()); } -#else - (void)_level; - std::tuple<LogEntries_...> args(_entries...); -#endif } - COMMONAPI_EXPORT static void init(bool, const std::string &, bool, const std::string &); + static void init(bool _useConsole, const std::string &_fileName, + bool _useDlt, const std::string& _level); private: - COMMONAPI_EXPORT static void log_intern(std::stringstream &_buffer) { + class LoggerImpl; + static std::unique_ptr<LoggerImpl> loggerImpl_; + + COMMONAPI_EXPORT static bool isLogged(Level _level); + COMMONAPI_EXPORT static void doLog(Level _level, const std::string& _message); + + COMMONAPI_EXPORT static void logIntern(std::stringstream &_buffer) { (void)_buffer; } template<typename LogEntry_, typename... MoreLogEntries_> - COMMONAPI_EXPORT static void log_intern(std::stringstream &_buffer, LogEntry_ _entry, MoreLogEntries_... _moreEntries) { + COMMONAPI_EXPORT static void logIntern(std::stringstream &_buffer, LogEntry_&& _entry, + MoreLogEntries_&& ... _moreEntries) { _buffer << _entry; - log_intern(_buffer, _moreEntries...); + logIntern(_buffer, std::forward<MoreLogEntries_>(_moreEntries)...); } }; diff --git a/include/CommonAPI/LoggerImpl.hpp b/include/CommonAPI/LoggerImpl.hpp deleted file mode 100644 index 1c69d87..0000000 --- a/include/CommonAPI/LoggerImpl.hpp +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2015-2017 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/. - -#ifndef COMMONAPI_LOGGER_IMPL_HPP_ -#define COMMONAPI_LOGGER_IMPL_HPP_ - -#ifdef USE_DLT -#include <dlt/dlt.h> -#endif - -#include <cstdint> -#include <fstream> -#include <memory> -#include <mutex> -#include <sstream> - -#include <CommonAPI/Export.hpp> - - -namespace CommonAPI { - -class Logger; - -class LoggerImpl { -public: - friend class Logger; - - enum class Level : uint8_t COMMONAPI_EXPORT { - LL_FATAL = 0, LL_ERROR = 1, LL_WARNING = 2, LL_INFO = 3, LL_DEBUG = 4, LL_VERBOSE = 5 - }; - - static void init(bool, const std::string &, bool, const std::string &); - -private: - - LoggerImpl(); - ~LoggerImpl(); - - COMMONAPI_EXPORT static bool isLogged(Level _level); - - COMMONAPI_EXPORT static LoggerImpl* get(); - - COMMONAPI_EXPORT void doLog(Level _level, const std::string &_message); - -#if defined(USE_CONSOLE) || defined(USE_FILE) || defined(USE_DLT) - static Level stringAsLevel(const std::string &_level); -#endif -#if defined(USE_CONSOLE) || defined(USE_FILE) - static std::string levelAsString(Level _level); -#endif -#ifdef USE_DLT - static DltLogLevelType levelAsDlt(Level _level); -#endif -#if defined(USE_CONSOLE) || defined(USE_FILE) - static std::mutex mutex_; -#endif -#if defined(USE_CONSOLE) || defined(USE_FILE) || defined(USE_DLT) - static Level maximumLogLevel_; -#endif -#ifdef USE_CONSOLE - static bool useConsole_; -#endif -#ifdef USE_FILE - static std::shared_ptr<std::ofstream> file_; -#endif -#ifdef USE_DLT - static bool useDlt_; - DLT_DECLARE_CONTEXT(dlt_); - bool ownAppID_; -#endif -}; - -} // namespace CommonAPI - -#endif // COMMONAPI_LOGGER_IMPL_HPP_ diff --git a/include/CommonAPI/MainLoopContext.hpp b/include/CommonAPI/MainLoopContext.hpp index f50e5b1..e0e53bd 100644 --- a/include/CommonAPI/MainLoopContext.hpp +++ b/include/CommonAPI/MainLoopContext.hpp @@ -1,10 +1,10 @@ -// 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/. #if !defined (COMMONAPI_INTERNAL_COMPILATION) -#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents." +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." #endif #ifndef COMMONAPI_MAINLOOPCONTEXT_HPP_ diff --git a/include/CommonAPI/OutputStream.hpp b/include/CommonAPI/OutputStream.hpp index 3a453b6..f68ca2b 100644 --- a/include/CommonAPI/OutputStream.hpp +++ b/include/CommonAPI/OutputStream.hpp @@ -1,10 +1,10 @@ -// 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/. #if !defined (COMMONAPI_INTERNAL_COMPILATION) -#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents." +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." #endif #ifndef COMMONAPI_OUTPUTSTREAM_HPP_ @@ -16,6 +16,7 @@ #include <CommonAPI/Deployable.hpp> #include <CommonAPI/Deployment.hpp> #include <CommonAPI/Enumeration.hpp> +#include <CommonAPI/RangedInteger.hpp> #include <CommonAPI/Struct.hpp> #include <CommonAPI/Variant.hpp> #include <CommonAPI/Version.hpp> @@ -95,6 +96,11 @@ public: return get()->writeValue(_value, _depl); } + template<class Deployment_, int minimum, int maximum> + OutputStream &writeValue(const RangedInteger<minimum, maximum> &_value, const Deployment_ *_depl = nullptr) { + return get()->writeValue(_value, _depl); + } + template<class Deployment_, typename... Types_> OutputStream &writeValue(const Struct<Types_...> &_value, const Deployment_ *_depl = nullptr) { return get()->writeValue(_value, _depl); @@ -210,6 +216,11 @@ OutputStream<Derived_> &operator<<(OutputStream<Derived_> &_output, const Enumer return _output.template writeValue<EmptyDeployment>(_value); } +template<class Derived_, int minimum, int maximum> +OutputStream<Derived_> &operator<<(OutputStream<Derived_> &_output, const RangedInteger<minimum, maximum> &_value) { + return _output.template writeValue<EmptyDeployment, minimum, maximum>(_value); +} + template<class Derived_, typename... Types_> OutputStream<Derived_> &operator<<(OutputStream<Derived_> &_output, const Struct<Types_...> &_value) { return _output.template writeValue<EmptyDeployment>(_value); diff --git a/include/CommonAPI/Proxy.hpp b/include/CommonAPI/Proxy.hpp index a96141c..4d27dd2 100644 --- a/include/CommonAPI/Proxy.hpp +++ b/include/CommonAPI/Proxy.hpp @@ -1,10 +1,10 @@ -// 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/. #if !defined (COMMONAPI_INTERNAL_COMPILATION) -#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents." +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." #endif #ifndef COMMONAPI_PROXY_HPP_ @@ -31,7 +31,7 @@ public: const Address &getAddress() const; - std::future<void> getCompletionFuture(); + virtual std::future<void> getCompletionFuture(); virtual bool isAvailable() const = 0; @@ -49,3 +49,4 @@ protected: } // namespace CommonAPI #endif // COMMONAPI_PROXY_HPP_ + diff --git a/include/CommonAPI/ProxyManager.hpp b/include/CommonAPI/ProxyManager.hpp index 42b4787..6246b91 100644 --- a/include/CommonAPI/ProxyManager.hpp +++ b/include/CommonAPI/ProxyManager.hpp @@ -1,10 +1,10 @@ -// 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/. #if !defined (COMMONAPI_INTERNAL_COMPILATION) -#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents." +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." #endif #ifndef COMMONAPI_PROXY_MANAGER_HPP_ diff --git a/include/CommonAPI/RangedInteger.hpp b/include/CommonAPI/RangedInteger.hpp new file mode 100644 index 0000000..ded4158 --- /dev/null +++ b/include/CommonAPI/RangedInteger.hpp @@ -0,0 +1,91 @@ +// 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/. + +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." +#endif + +#ifndef COMMONAPI_RANGEDINTEGER_HPP +#define COMMONAPI_RANGEDINTEGER_HPP + +namespace CommonAPI { + template <int minimum, int maximum> + struct RangedInteger { + + int value_; + + RangedInteger(int _value): + value_(_value) { + // assert(_value >= minimum && _value <= maximum); + } + RangedInteger(): + value_(minimum) { + } + ~RangedInteger() {} + + inline RangedInteger& operator= (const int _value) { + // assert(_value >= minimum && _value <= maximum); + value_ = _value; + return (*this); + } + inline operator int() const { + return value_; + } + + inline bool operator==(const RangedInteger &_other) const { + return (value_ == _other.value_); + } + + inline bool operator!=(const RangedInteger &_other) const { + return (value_ != _other.value_); + } + + inline bool operator<(const RangedInteger &_other) const { + return (value_ < _other.value_); + } + + inline bool operator<=(const RangedInteger &_other) const { + return (value_ <= _other.value_); + } + + inline bool operator>(const RangedInteger &_other) const { + return (value_ > _other.value_); + } + + inline bool operator>=(const RangedInteger &_other) const { + return (value_ >= _other.value_); + } + + inline bool operator==(const int &_other) const { + return (value_ == _other); + } + + inline bool operator!=(const int &_other) const { + return (value_ != _other); + } + + inline bool operator<(const int &_other) const { + return (value_ < _other); + } + + inline bool operator<=(const int &_other) const { + return (value_ <= _other); + } + + inline bool operator>(const int &_other) const { + return (value_ > _other); + } + + inline bool operator>=(const int &_other) const { + return (value_ >= _other); + } + + bool validate() const { + return value_ <= maximum && value_ >= minimum; + } + }; +} + +#endif diff --git a/include/CommonAPI/Runtime.hpp b/include/CommonAPI/Runtime.hpp index afd9fa0..61bd5fe 100644 --- a/include/CommonAPI/Runtime.hpp +++ b/include/CommonAPI/Runtime.hpp @@ -1,10 +1,10 @@ -// 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/. #if !defined (COMMONAPI_INTERNAL_COMPILATION) -#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents." +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." #endif #ifndef COMMONAPI_RUNTIME_HPP_ @@ -39,8 +39,6 @@ public: COMMONAPI_EXPORT Runtime(); COMMONAPI_EXPORT virtual ~Runtime(); - COMMONAPI_EXPORT void init(); - template<template<typename ...> class ProxyClass_, typename ... AttributeExtensions_> COMMONAPI_EXPORT std::shared_ptr< ProxyClass_<AttributeExtensions_...> @@ -138,8 +136,10 @@ public: inline const std::string &getDefaultBinding() const { return defaultBinding_; }; COMMONAPI_EXPORT void initFactories(); + COMMONAPI_EXPORT Timeout_t getDefaultCallTimeout() const; private: + COMMONAPI_EXPORT void init(); COMMONAPI_EXPORT bool readConfiguration(); COMMONAPI_EXPORT bool splitAddress(const std::string &, std::string &, std::string &, std::string &); @@ -174,6 +174,7 @@ private: std::string defaultBinding_; std::string defaultFolder_; std::string defaultConfig_; + Timeout_t defaultCallTimeout_; std::map<std::string, std::shared_ptr<Factory>> factories_; std::shared_ptr<Factory> defaultFactory_; diff --git a/include/CommonAPI/SelectiveEvent.hpp b/include/CommonAPI/SelectiveEvent.hpp deleted file mode 100644 index 6c7a6d8..0000000 --- a/include/CommonAPI/SelectiveEvent.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2013-2017 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/. - -#if !defined (COMMONAPI_INTERNAL_COMPILATION) -#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents." -#endif - -#ifndef COMMONAPI_SELECTIVEEVENT_HPP_ -#define COMMONAPI_SELECTIVEEVENT_HPP_ - -#include <CommonAPI/Event.hpp> - -namespace CommonAPI { - -template<typename ... Arguments_> -class SelectiveEvent: public Event<Arguments_...> { -public: - typedef typename Event<Arguments_...>::Listener Listener; - typedef typename Event<Arguments_...>::Subscription Subscription; - - virtual ~SelectiveEvent() {} -}; - -} // namespace CommonAPI - -#endif // COMMONAPI_SELECTIVEEVENT_HPP_ diff --git a/include/CommonAPI/SerializableArguments.hpp b/include/CommonAPI/SerializableArguments.hpp index 65f7ca1..5bd7a59 100644 --- a/include/CommonAPI/SerializableArguments.hpp +++ b/include/CommonAPI/SerializableArguments.hpp @@ -1,10 +1,10 @@ -// 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/. #if !defined (COMMONAPI_INTERNAL_COMPILATION) -#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents." +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." #endif #ifndef COMMONAPI_SERIALIZABLEARGUMENTS_HPP_ diff --git a/include/CommonAPI/Struct.hpp b/include/CommonAPI/Struct.hpp index 0427426..fbbefaf 100644 --- a/include/CommonAPI/Struct.hpp +++ b/include/CommonAPI/Struct.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/Stub.hpp b/include/CommonAPI/Stub.hpp index 9e4f4f8..8241bf1 100644 --- a/include/CommonAPI/Stub.hpp +++ b/include/CommonAPI/Stub.hpp @@ -1,10 +1,10 @@ -// 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/. #if !defined (COMMONAPI_INTERNAL_COMPILATION) -#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents." +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." #endif #ifndef COMMONAPI_STUB_HPP_ @@ -31,6 +31,7 @@ protected: class StubBase { public: virtual ~StubBase() {} + virtual bool hasElement(const uint32_t _id) const = 0; }; template<typename StubAdapter_, typename StubRemoteEventHandler_> diff --git a/include/CommonAPI/TypeOutputStream.hpp b/include/CommonAPI/TypeOutputStream.hpp index a170727..35e76a2 100644 --- a/include/CommonAPI/TypeOutputStream.hpp +++ b/include/CommonAPI/TypeOutputStream.hpp @@ -1,10 +1,10 @@ -// 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/. #if !defined (COMMONAPI_INTERNAL_COMPILATION) -#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents." +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." #endif #ifndef COMMONAPI_TYPEOUTPUTSTREAM_HPP_ diff --git a/include/CommonAPI/Types.hpp b/include/CommonAPI/Types.hpp index 2059def..750f50e 100644 --- a/include/CommonAPI/Types.hpp +++ b/include/CommonAPI/Types.hpp @@ -1,10 +1,10 @@ -// 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/. #if !defined (COMMONAPI_INTERNAL_COMPILATION) -#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents." +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." #endif #ifndef COMMONAPI_TYPES_HPP_ @@ -16,6 +16,10 @@ #include <memory> #include <tuple> +#ifndef _WIN32 +#include <sys/types.h> +#endif + // define CallStatus before including Event.hpp namespace CommonAPI { enum class CallStatus { @@ -26,7 +30,8 @@ namespace CommonAPI { REMOTE_ERROR, UNKNOWN, INVALID_VALUE, - SUBSCRIPTION_REFUSED + SUBSCRIPTION_REFUSED, + SERIALIZATION_ERROR }; } // namespace CommonAPI @@ -35,6 +40,7 @@ namespace CommonAPI { #include <CommonAPI/ContainerUtils.hpp> #include <CommonAPI/Event.hpp> #include <CommonAPI/Export.hpp> +#include <CommonAPI/RangedInteger.hpp> #include <CommonAPI/Version.hpp> #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) @@ -83,6 +89,13 @@ typedef std::string ConnectionId_t; typedef int Timeout_t; // in ms, -1 means "forever" typedef uint32_t Sender_t; +#ifdef _WIN32 +typedef std::uint32_t uid_t; +typedef std::uint32_t gid_t; +#else +typedef ::uid_t uid_t; +typedef ::gid_t gid_t; +#endif /** * \brief Identifies a client sending a call to a stub. * @@ -94,6 +107,8 @@ public: virtual ~ClientId() { } virtual bool operator==(ClientId& clientIdToCompare) = 0; virtual std::size_t hashCode() = 0; + virtual uid_t getUid() const = 0; + virtual gid_t getGid() const = 0; }; template <typename ... Args_> diff --git a/include/CommonAPI/Utils.hpp b/include/CommonAPI/Utils.hpp index 2dc926f..da37d89 100644 --- a/include/CommonAPI/Utils.hpp +++ b/include/CommonAPI/Utils.hpp @@ -1,8 +1,12 @@ -// 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/. +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." +#endif + #ifndef COMMONAPI_UTILS_HPP_ #define COMMONAPI_UTILS_HPP_ @@ -16,7 +20,6 @@ namespace CommonAPI { std::vector<std::string> COMMONAPI_EXPORT split(const std::string& s, char delim); void COMMONAPI_EXPORT trim(std::string &_s); - } //namespace CommonAPI -#endif /* COMMONAPI_UTILS_HPP_ */ +#endif // COMMONAPI_UTILS_HPP_ diff --git a/include/CommonAPI/Variant.hpp b/include/CommonAPI/Variant.hpp index c6cd40f..fc4398e 100644 --- a/include/CommonAPI/Variant.hpp +++ b/include/CommonAPI/Variant.hpp @@ -1,8 +1,15 @@ -// 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/. +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." +#endif + +#ifndef COMMONAPI_VARIANT_HPP_ +#define COMMONAPI_VARIANT_HPP_ + #include <cstdint> #include <iostream> #include <memory> @@ -10,18 +17,11 @@ #include <tuple> #include <type_traits> -#if !defined (COMMONAPI_INTERNAL_COMPILATION) -#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents." -#endif #include <CommonAPI/Deployable.hpp> #include <CommonAPI/Deployment.hpp> #include <CommonAPI/Logger.hpp> - -#ifndef COMMONAPI_VARIANT_HPP_ -#define COMMONAPI_VARIANT_HPP_ - namespace CommonAPI { template<class Derived_> diff --git a/include/CommonAPI/Version.hpp b/include/CommonAPI/Version.hpp index 0a23b88..89eb422 100644 --- a/include/CommonAPI/Version.hpp +++ b/include/CommonAPI/Version.hpp @@ -1,10 +1,10 @@ -// 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/. #if !defined (COMMONAPI_INTERNAL_COMPILATION) -#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents." +#error "Only <CommonAPI/CommonAPI.hpp> can be included directly, this file may disappear or change contents." #endif #ifndef COMMONAPI_VERSION_HPP_ @@ -26,4 +26,4 @@ struct Version { } // namespace CommonAPI -#endif // COMMONAPI_STRUCT_HPP_ +#endif // COMMONAPI_VERSION_HPP_ |