From 89720d3c63bbd22cbccc80cdc92c2f2dd20193ba Mon Sep 17 00:00:00 2001 From: Lutz Bichler Date: Tue, 27 Oct 2020 10:02:03 +0100 Subject: capicxx-core-runtime 3.2.0 --- include/CommonAPI/Address.hpp | 10 +- include/CommonAPI/Attribute.hpp | 4 +- include/CommonAPI/AttributeExtension.hpp | 2 +- include/CommonAPI/ByteBuffer.hpp | 6 +- include/CommonAPI/CallInfo.hpp | 25 +++-- include/CommonAPI/CommonAPI.hpp | 6 +- include/CommonAPI/Config.hpp | 6 +- include/CommonAPI/ContainerUtils.hpp | 17 ++-- include/CommonAPI/Deployable.hpp | 9 +- include/CommonAPI/Deployment.hpp | 2 +- include/CommonAPI/Enumeration.hpp | 2 +- include/CommonAPI/Event.hpp | 93 +++++++++++------- include/CommonAPI/Export.hpp | 2 +- .../Extensions/AttributeCacheExtension.hpp | 2 +- include/CommonAPI/Factory.hpp | 6 +- include/CommonAPI/IniFileReader.hpp | 6 +- include/CommonAPI/InputStream.hpp | 10 +- include/CommonAPI/Logger.hpp | 107 ++++++++++----------- include/CommonAPI/LoggerImpl.hpp | 77 --------------- include/CommonAPI/MainLoopContext.hpp | 4 +- include/CommonAPI/OutputStream.hpp | 15 ++- include/CommonAPI/Proxy.hpp | 7 +- include/CommonAPI/ProxyManager.hpp | 4 +- include/CommonAPI/RangedInteger.hpp | 91 ++++++++++++++++++ include/CommonAPI/Runtime.hpp | 9 +- include/CommonAPI/SelectiveEvent.hpp | 28 ------ include/CommonAPI/SerializableArguments.hpp | 4 +- include/CommonAPI/Struct.hpp | 2 +- include/CommonAPI/Stub.hpp | 5 +- include/CommonAPI/TypeOutputStream.hpp | 4 +- include/CommonAPI/Types.hpp | 21 +++- include/CommonAPI/Utils.hpp | 9 +- include/CommonAPI/Variant.hpp | 16 +-- include/CommonAPI/Version.hpp | 6 +- 34 files changed, 340 insertions(+), 277 deletions(-) delete mode 100644 include/CommonAPI/LoggerImpl.hpp create mode 100644 include/CommonAPI/RangedInteger.hpp delete mode 100644 include/CommonAPI/SelectiveEvent.hpp (limited to 'include') 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 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 can be included directly, this file may disappear or change contents." +#error "Only 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 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 can be included directly, this file may disappear or change contents." +#endif + #ifndef COMMONAPI_CALLINFO_HPP_ #define COMMONAPI_CALLINFO_HPP_ #include #include +#include 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 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 can be included directly, this file may disappear or change contents." +#error "Only can be included directly, this file may disappear or change contents." #endif #ifndef COMMONAPI_CONTAINERUTILS_HPP_ @@ -16,18 +16,17 @@ #include namespace CommonAPI { + class ClientId; -struct COMMONAPI_EXPORT SharedPointerClientIdContentHash : public std::unary_function, size_t> { - size_t operator()(const std::shared_ptr& t) const; +struct COMMONAPI_EXPORT SharedPointerClientIdContentHash { + size_t operator()(const std::shared_ptr &_t) const; }; -struct COMMONAPI_EXPORT SharedPointerClientIdContentEqual : public std::binary_function, std::shared_ptr, bool> { - bool operator()(const std::shared_ptr& a, const std::shared_ptr& b) const; +struct COMMONAPI_EXPORT SharedPointerClientIdContentEqual { + bool operator()(const std::shared_ptr &_lhs, const std::shared_ptr &_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 can be included directly, this file may disappear or change contents." +#error "Only 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(_depl)) { }; + Deployable(const Deployable &_other) + : value_(_other.value_), + depl_(_other.depl_) { + } + Deployable& operator=(const Deployable &_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 can be included directly, this file may disappear or change contents." +#error "Only 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 @@ -107,14 +107,12 @@ typename Event::Subscription Event::subscribe(List bool isFirstListener; Listeners listeners; - { - std::lock_guard 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::unsubscribe(const Subscription subscription) { bool hasUnsubscribed(false); Listener listener; - { - std::lock_guard 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::unsubscribe(const Subscription subscription) { template void Event::notifyListeners(const Arguments_&... eventArguments) { - std::lock_guard itsLock(mutex_); + + notificationMutex_.lock(); + subscriptionMutex_.lock(); for (auto iterator = pendingUnsubscriptions_.begin(); iterator != pendingUnsubscriptions_.end(); iterator++) { @@ -183,14 +182,19 @@ void Event::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 void Event::notifySpecificListener(const Subscription subscription, const Arguments_&... eventArguments) { - std::lock_guard itsLock(mutex_); + + notificationMutex_.lock(); + subscriptionMutex_.lock(); for (auto iterator = pendingUnsubscriptions_.begin(); iterator != pendingUnsubscriptions_.end(); iterator++) { @@ -206,16 +210,22 @@ void Event::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 void Event::notifySpecificError(const Subscription subscription, const CallStatus status) { - std::lock_guard itsLock(mutex_); + + notificationMutex_.lock(); + subscriptionMutex_.lock(); for (auto iterator = pendingUnsubscriptions_.begin(); iterator != pendingUnsubscriptions_.end(); iterator++) { @@ -230,6 +240,7 @@ void Event::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::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::notifySpecificError(const Subscription subscription, pendingSubscriptions_.erase(subscription); } } + subscriptionMutex_.unlock(); } } template void Event::notifyErrorListeners(const CallStatus status) { - std::lock_guard itsLock(mutex_); + + notificationMutex_.lock(); + subscriptionMutex_.lock(); for (auto iterator = pendingUnsubscriptions_.begin(); iterator != pendingUnsubscriptions_.end(); iterator++) { @@ -274,12 +291,16 @@ void Event::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 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 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 can be included directly, this file may disappear or change contents." +#error "Only can be included directly, this file may disappear or change contents." #endif #ifndef COMMONAPI_INPUT_STREAM_HPP_ @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -90,6 +91,11 @@ public: return get()->readValue(_value, _depl); } + template + InputStream &readValue(RangedInteger &_value, const Deployment_ *_depl = nullptr) { + return get()->readValue(_value, _depl); + } + template InputStream &readValue(Struct &_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 can be included directly, this file may disappear or change contents." +#endif + #ifndef COMMONAPI_LOGGER_HPP_ #define COMMONAPI_LOGGER_HPP_ -#include +#include +#include +#include -#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 #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 - 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(_entries)...); } template - COMMONAPI_EXPORT static void error(LogEntries_... _entries) { -#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_ERROR - log(LoggerImpl::Level::LL_ERROR, _entries...); -#else - std::tuple args(_entries...); -#endif + COMMONAPI_EXPORT static void error(LogEntries_&&... _entries) { + log(Logger::Level::CAPI_LOG_ERROR, std::forward(_entries)...); } template - COMMONAPI_EXPORT static void warning(LogEntries_... _entries) { -#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_WARNING - log(LoggerImpl::Level::LL_WARNING, _entries...); -#else - std::tuple args(_entries...); -#endif + COMMONAPI_EXPORT static void warning(LogEntries_&&... _entries) { + log(Logger::Level::CAPI_LOG_WARNING, std::forward(_entries)...); } template - COMMONAPI_EXPORT static void info(LogEntries_... _entries) { -#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_INFO - log(LoggerImpl::Level::LL_INFO, _entries...); -#else - std::tuple args(_entries...); -#endif + COMMONAPI_EXPORT static void info(LogEntries_&&... _entries) { + log(Logger::Level::CAPI_LOG_INFO, std::forward(_entries)...); } template - COMMONAPI_EXPORT static void debug(LogEntries_... _entries) { -#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_DEBUG - log(LoggerImpl::Level::LL_DEBUG, _entries...); -#else - std::tuple args(_entries...); -#endif + COMMONAPI_EXPORT static void debug(LogEntries_&&... _entries) { + log(Logger::Level::CAPI_LOG_DEBUG, std::forward(_entries)...); } template - COMMONAPI_EXPORT static void verbose(LogEntries_... _entries) { -#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_VERBOSE - log(LoggerImpl::Level::LL_VERBOSE, _entries...); -#else - std::tuple args(_entries...); -#endif + COMMONAPI_EXPORT static void verbose(LogEntries_&&... _entries) { + log(Logger::Level::CAPI_LOG_VERBOSE, std::forward(_entries)...); } template - 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(_entries)...); + Logger::doLog(_level, buffer.str()); } -#else - (void)_level; - std::tuple 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_; + + 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 - 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(_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 -#endif - -#include -#include -#include -#include -#include - -#include - - -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 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 can be included directly, this file may disappear or change contents." +#error "Only 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 can be included directly, this file may disappear or change contents." +#error "Only can be included directly, this file may disappear or change contents." #endif #ifndef COMMONAPI_OUTPUTSTREAM_HPP_ @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -95,6 +96,11 @@ public: return get()->writeValue(_value, _depl); } + template + OutputStream &writeValue(const RangedInteger &_value, const Deployment_ *_depl = nullptr) { + return get()->writeValue(_value, _depl); + } + template OutputStream &writeValue(const Struct &_value, const Deployment_ *_depl = nullptr) { return get()->writeValue(_value, _depl); @@ -210,6 +216,11 @@ OutputStream &operator<<(OutputStream &_output, const Enumer return _output.template writeValue(_value); } +template +OutputStream &operator<<(OutputStream &_output, const RangedInteger &_value) { + return _output.template writeValue(_value); +} + template OutputStream &operator<<(OutputStream &_output, const Struct &_value) { return _output.template writeValue(_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 can be included directly, this file may disappear or change contents." +#error "Only 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 getCompletionFuture(); + virtual std::future 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 can be included directly, this file may disappear or change contents." +#error "Only 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 can be included directly, this file may disappear or change contents." +#endif + +#ifndef COMMONAPI_RANGEDINTEGER_HPP +#define COMMONAPI_RANGEDINTEGER_HPP + +namespace CommonAPI { + template + 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 can be included directly, this file may disappear or change contents." +#error "Only 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 class ProxyClass_, typename ... AttributeExtensions_> COMMONAPI_EXPORT std::shared_ptr< ProxyClass_ @@ -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> factories_; std::shared_ptr 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 can be included directly, this file may disappear or change contents." -#endif - -#ifndef COMMONAPI_SELECTIVEEVENT_HPP_ -#define COMMONAPI_SELECTIVEEVENT_HPP_ - -#include - -namespace CommonAPI { - -template -class SelectiveEvent: public Event { -public: - typedef typename Event::Listener Listener; - typedef typename Event::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 can be included directly, this file may disappear or change contents." +#error "Only 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 can be included directly, this file may disappear or change contents." +#error "Only 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 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 can be included directly, this file may disappear or change contents." +#error "Only 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 can be included directly, this file may disappear or change contents." +#error "Only can be included directly, this file may disappear or change contents." #endif #ifndef COMMONAPI_TYPES_HPP_ @@ -16,6 +16,10 @@ #include #include +#ifndef _WIN32 +#include +#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 #include #include +#include #include #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 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 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 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 can be included directly, this file may disappear or change contents." +#endif + +#ifndef COMMONAPI_VARIANT_HPP_ +#define COMMONAPI_VARIANT_HPP_ + #include #include #include @@ -10,18 +17,11 @@ #include #include -#if !defined (COMMONAPI_INTERNAL_COMPILATION) -#error "Only can be included directly, this file may disappear or change contents." -#endif #include #include #include - -#ifndef COMMONAPI_VARIANT_HPP_ -#define COMMONAPI_VARIANT_HPP_ - namespace CommonAPI { template 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 can be included directly, this file may disappear or change contents." +#error "Only 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_ -- cgit v1.2.1