summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLutz Bichler <Lutz.Bichler@bmw.de>2020-10-27 10:02:03 +0100
committerLutz Bichler <Lutz.Bichler@bmw.de>2020-10-27 10:02:03 +0100
commit89720d3c63bbd22cbccc80cdc92c2f2dd20193ba (patch)
tree591c45dba85c98fdd8e141827bdb6e82aaad4f59
parent99ebf3461f51e4899f06457d6aafdaa4adecd278 (diff)
downloadgenivi-common-api-runtime-master.tar.gz
capicxx-core-runtime 3.2.0HEAD3.2.0master
-rw-r--r--Android.bp38
-rw-r--r--CHANGES4
-rw-r--r--CMakeLists.txt12
-rw-r--r--README.md17
-rw-r--r--docx/01_mainpage.dox2
-rw-r--r--include/CommonAPI/Address.hpp10
-rw-r--r--include/CommonAPI/Attribute.hpp4
-rw-r--r--include/CommonAPI/AttributeExtension.hpp2
-rw-r--r--include/CommonAPI/ByteBuffer.hpp6
-rw-r--r--include/CommonAPI/CallInfo.hpp25
-rw-r--r--include/CommonAPI/CommonAPI.hpp6
-rw-r--r--include/CommonAPI/Config.hpp6
-rw-r--r--include/CommonAPI/ContainerUtils.hpp17
-rw-r--r--include/CommonAPI/Deployable.hpp9
-rw-r--r--include/CommonAPI/Deployment.hpp2
-rw-r--r--include/CommonAPI/Enumeration.hpp2
-rw-r--r--include/CommonAPI/Event.hpp93
-rw-r--r--include/CommonAPI/Export.hpp2
-rw-r--r--include/CommonAPI/Extensions/AttributeCacheExtension.hpp2
-rw-r--r--include/CommonAPI/Factory.hpp6
-rw-r--r--include/CommonAPI/IniFileReader.hpp6
-rw-r--r--include/CommonAPI/InputStream.hpp10
-rw-r--r--include/CommonAPI/Logger.hpp107
-rw-r--r--include/CommonAPI/LoggerImpl.hpp77
-rw-r--r--include/CommonAPI/MainLoopContext.hpp4
-rw-r--r--include/CommonAPI/OutputStream.hpp15
-rw-r--r--include/CommonAPI/Proxy.hpp7
-rw-r--r--include/CommonAPI/ProxyManager.hpp4
-rw-r--r--include/CommonAPI/RangedInteger.hpp91
-rw-r--r--include/CommonAPI/Runtime.hpp9
-rw-r--r--include/CommonAPI/SelectiveEvent.hpp28
-rw-r--r--include/CommonAPI/SerializableArguments.hpp4
-rw-r--r--include/CommonAPI/Struct.hpp2
-rw-r--r--include/CommonAPI/Stub.hpp5
-rw-r--r--include/CommonAPI/TypeOutputStream.hpp4
-rw-r--r--include/CommonAPI/Types.hpp21
-rw-r--r--include/CommonAPI/Utils.hpp9
-rw-r--r--include/CommonAPI/Variant.hpp16
-rw-r--r--include/CommonAPI/Version.hpp6
-rw-r--r--src/CommonAPI/Address.cpp11
-rw-r--r--src/CommonAPI/CallInfo.cpp40
-rw-r--r--src/CommonAPI/ContainerUtils.cpp25
-rw-r--r--src/CommonAPI/IniFileReader.cpp7
-rw-r--r--src/CommonAPI/Logger.cpp193
-rw-r--r--src/CommonAPI/LoggerImpl.cpp200
-rw-r--r--src/CommonAPI/MainLoopContext.cpp2
-rw-r--r--src/CommonAPI/Proxy.cpp2
-rw-r--r--src/CommonAPI/ProxyManager.cpp2
-rw-r--r--src/CommonAPI/Runtime.cpp25
-rw-r--r--src/CommonAPI/Utils.cpp2
50 files changed, 685 insertions, 514 deletions
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..e368e33
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,38 @@
+capi_srcs = [
+ "src/CommonAPI/**/*.cpp"
+]
+
+cc_defaults {
+ name: "capi_defaults",
+ cppflags: [
+ "-std=c++11",
+ "-Wall",
+ "-Wextra",
+ "-Wformat",
+ "-Wformat-security",
+ "-Wconversion",
+ "-Wno-attributes",
+ "-fexceptions",
+ "-fstrict-aliasing",
+ "-fstack-protector",
+ "-fasynchronous-unwind-tables",
+ "-fno-omit-frame-pointer",
+ "-Werror",
+ "-fvisibility=hidden",
+ "-DCOMMONAPI_INTERNAL_COMPILATION"
+ ]
+}
+
+cc_library_shared {
+ name: "libCommonAPI",
+ vendor: true,
+ srcs: capi_srcs,
+ defaults: [
+ "capi_defaults"
+ ],
+ local_include_dirs: [
+ "include"
+ ],
+ export_include_dirs: ["include"],
+ rtti: true
+}
diff --git a/CHANGES b/CHANGES
index 65ddba3..b520b72 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,10 @@
Changes
=======
+v3.2.0
+- Support ABI compatible changes (additional attributes, broadcast and methods added to the end of
+ the interface specification)
+
v3.1.12.6
- Fix race condition leading to event delivery after unsubscription
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7897345..1d7b654 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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/.
@@ -9,8 +9,8 @@ PROJECT(libcommonapi)
# version of CommonAPI
SET( LIBCOMMONAPI_MAJOR_VERSION 3 )
-SET( LIBCOMMONAPI_MINOR_VERSION 1 )
-SET( LIBCOMMONAPI_PATCH_VERSION 12 )
+SET( LIBCOMMONAPI_MINOR_VERSION 2 )
+SET( LIBCOMMONAPI_PATCH_VERSION 0 )
message(STATUS "Project name: ${PROJECT_NAME}")
@@ -102,14 +102,14 @@ IF(MSVC)
add_definitions(-DCOMMONAPI_INTERNAL_COMPILATION -DCOMMONAPI_DLL_COMPILATION)
add_compile_options(/EHsc /wd4996)
ELSE ()
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wformat -Wformat-security -Wconversion -fexceptions -fstrict-aliasing -fstack-protector -fasynchronous-unwind-tables -fno-omit-frame-pointer -Werror -DCOMMONAPI_INTERNAL_COMPILATION")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wformat -Wformat-security -Wconversion -fexceptions -fstrict-aliasing -fstack-protector -fasynchronous-unwind-tables -fno-omit-frame-pointer -Werror -DCOMMONAPI_INTERNAL_COMPILATION -fvisibility=hidden")
ENDIF(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCOMMONAPI_LOGLEVEL=COMMONAPI_LOGLEVEL_${MAX_LOG_LEVEL}")
-
+
FIND_PACKAGE(PkgConfig)
pkg_check_modules(DLT "automotive-dlt >= 2.11")
-IF(DLT_FOUND)
+IF(DLT_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_DLT")
ENDIF(DLT_FOUND)
diff --git a/README.md b/README.md
index c74d56d..fa0b061 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
### CommonAPI C++ Core Runtime
##### Copyright
-Copyright (C) 2016-2017, Bayerische Motoren Werke Aktiengesellschaft (BMW AG).
-Copyright (C) 2016-2017, GENIVI Alliance, Inc.
+Copyright (C) 2016-2020, Bayerische Motoren Werke Aktiengesellschaft (BMW AG).
+Copyright (C) 2016-2020, GENIVI Alliance, Inc.
This file is part of GENIVI Project IPC Common API C++.
Contributions are licensed to the GENIVI Alliance under one or more Contribution License Agreements or MPL 2.0.
@@ -33,3 +33,16 @@ You can change the installation directory by the CMake variable _CMAKE_INSTALL_P
For further build instructions (build for windows, build documentation, tests etc.) please refer to the CommonAPI tutorial.
+##### Build Instructions for Android
+
+In general for building the Android source tree the instructions found on the pages from the Android Open Source Project (AOSP) apply (https://source.android.com/setup/build/requirements).
+
+To integrate the CommonAPI Core Runtime library into the build process, the source code together with the Android.bp file has to be inserted into the Android source tree (by simply copying or by fetching with a custom platform manifest).
+When building the Android source tree, the Android.bp file is automatically found and considered by the build system.
+
+In order that the CommonAPI Core Runtime library is also included in the Android image, the library has to be added to the PRODUCT_PACKAGES variable in one of a device/target specific makefile:
+
+```
+PRODUCT_PACKAGES += \
+ libCommonAPI
+```
diff --git a/docx/01_mainpage.dox b/docx/01_mainpage.dox
index 3a4940b..17ac6db 100644
--- a/docx/01_mainpage.dox
+++ b/docx/01_mainpage.dox
@@ -1,7 +1,7 @@
/**
* \copyright
*
- * Copyright (C) 2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+ * Copyright (C) 2015-2020 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* This file is part of GENIVI project IPC CommonAPI C++.
*
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_
diff --git a/src/CommonAPI/Address.cpp b/src/CommonAPI/Address.cpp
index a80b2cf..db9418c 100644
--- a/src/CommonAPI/Address.cpp
+++ b/src/CommonAPI/Address.cpp
@@ -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/.
@@ -12,7 +12,6 @@
namespace CommonAPI {
Address::Address() {
-
}
Address::Address(const std::string &_address) {
@@ -32,7 +31,13 @@ Address::Address(const Address &_source)
instance_(_source.instance_) {
}
-Address::~Address() {
+Address &
+Address::operator=(const Address &_other) {
+ domain_ = _other.domain_;
+ interface_ = _other.interface_;
+ instance_ = _other.instance_;
+
+ return (*this);
}
bool
diff --git a/src/CommonAPI/CallInfo.cpp b/src/CommonAPI/CallInfo.cpp
new file mode 100644
index 0000000..189e9d8
--- /dev/null
+++ b/src/CommonAPI/CallInfo.cpp
@@ -0,0 +1,40 @@
+// 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/.
+
+#include <CommonAPI/CallInfo.hpp>
+#include <CommonAPI/Runtime.hpp>
+
+namespace CommonAPI {
+
+CallInfo::CallInfo()
+ : CallInfo(DEFAULT_SEND_TIMEOUT_MS, 0) {
+}
+
+CallInfo::CallInfo(Timeout_t _timeout)
+ : CallInfo(_timeout, 0) {
+}
+
+CallInfo::CallInfo(const CallInfo &_other)
+ : CallInfo(_other.timeout_, _other.sender_) {
+}
+
+CallInfo::CallInfo(Timeout_t _timeout, Sender_t _sender)
+ : timeout_(_timeout), sender_(_sender) {
+
+ Timeout_t defaultCallTimeout = Runtime::get()->getDefaultCallTimeout();
+ const char *env = std::getenv("COMMONAPI_OVERRIDE_GLOBAL_CALL_TIMEOUT");
+
+ if ((_timeout == DEFAULT_SEND_TIMEOUT_MS) && defaultCallTimeout) {
+ timeout_ = defaultCallTimeout;
+ }
+ if (env) {
+ Timeout_t globalCallTimeout = std::stoi(env);
+ if (0 <= globalCallTimeout || globalCallTimeout == -1) {
+ timeout_ = globalCallTimeout;
+ }
+ }
+}
+
+} // namespace CommonAPI \ No newline at end of file
diff --git a/src/CommonAPI/ContainerUtils.cpp b/src/CommonAPI/ContainerUtils.cpp
index 71876bd..201e251 100644
--- a/src/CommonAPI/ContainerUtils.cpp
+++ b/src/CommonAPI/ContainerUtils.cpp
@@ -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/.
@@ -8,20 +8,23 @@
namespace CommonAPI {
-size_t SharedPointerClientIdContentHash::operator()(const std::shared_ptr<ClientId>& t) const {
- if (t) {
- return t->hashCode();
- } else {
- return 0;
+size_t
+SharedPointerClientIdContentHash::operator()(const std::shared_ptr<ClientId> &_t) const {
+ if (_t) {
+ return _t->hashCode();
}
+
+ return (0);
}
-bool SharedPointerClientIdContentEqual::operator()(const std::shared_ptr<ClientId>& a, const std::shared_ptr<ClientId>& b) const {
- if (a && b) {
- return *a==*b;
- } else {
- return false;
+bool
+SharedPointerClientIdContentEqual::operator()(
+ const std::shared_ptr<ClientId> &_lhs, const std::shared_ptr<ClientId> &_rhs) const {
+ if (_lhs && _rhs) {
+ return (*_lhs==*_rhs);
}
+
+ return (false);
}
} // namespace std
diff --git a/src/CommonAPI/IniFileReader.cpp b/src/CommonAPI/IniFileReader.cpp
index 94057e0..28b5013 100644
--- a/src/CommonAPI/IniFileReader.cpp
+++ b/src/CommonAPI/IniFileReader.cpp
@@ -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/.
@@ -45,6 +45,11 @@ IniFileReader::load(const std::string &_path) {
trim(line);
+ // Handle comments
+ std::size_t comment = line.find(';');
+ if (comment == 0)
+ continue;
+
std::size_t start = line.find('[');
if (start == 0) {
std::size_t end = line.find(']');
diff --git a/src/CommonAPI/Logger.cpp b/src/CommonAPI/Logger.cpp
index 268be6f..f5804c8 100644
--- a/src/CommonAPI/Logger.cpp
+++ b/src/CommonAPI/Logger.cpp
@@ -1,15 +1,198 @@
-// 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/.
-#include <CommonAPI/Logger.hpp>
#include <CommonAPI/Runtime.hpp>
+#include <CommonAPI/Logger.hpp>
+
+#ifdef USE_DLT
+#include <dlt/dlt.h>
+#endif
+
+#include <cstdint>
+#include <fstream>
+#include <memory>
+#include <mutex>
+#include <iostream>
namespace CommonAPI {
-void
- Logger::init(bool _useConsole, const std::string &_fileName, bool _useDlt, const std::string &_level) {
- LoggerImpl::init(_useConsole, _fileName, _useDlt, _level);
+
+class Logger::LoggerImpl {
+public:
+ LoggerImpl() :
+ maximumLogLevel_(Logger::Level::CAPI_LOG_INFO),
+ useConsole_(true),
+ useDlt_(false)
+#ifdef USE_DLT
+ , ownAppID_(false)
+#endif
+ {
+ }
+
+ void init(bool _useConsole, const std::string &_fileName, bool _useDlt,
+ const std::string& _level) {
+ useConsole_ = _useConsole;
+ maximumLogLevel_ = stringAsLevel(_level);
+ useDlt_ = _useDlt;
+
+ if (!_fileName.empty()) {
+ file_ = std::make_shared<std::ofstream>();
+ if (file_) {
+ file_->open(_fileName.c_str(),
+ std::ofstream::out | std::ofstream::app);
+ }
+ }
+#ifdef USE_DLT
+ if (useDlt_) {
+ std::string app = Runtime::getProperty("LogApplication");
+ if (!app.empty()) {
+ ownAppID_ = true;
+ DLT_REGISTER_APP(app.c_str(), "CommonAPI Application");
+ }
+
+ std::string context = Runtime::getProperty("LogContext");
+ if (context == "")
+ context = "CAPI";
+ DLT_REGISTER_CONTEXT(dlt_, context.c_str(), "CAPI");
+ }
+#endif
+ }
+
+ ~LoggerImpl() {
+#ifdef USE_DLT
+ if (useDlt_) {
+ DLT_UNREGISTER_CONTEXT(dlt_);
+ if (ownAppID_) {
+ DLT_UNREGISTER_APP()
+ ;
+ }
+ }
+#endif
+ }
+
+ bool isLogged(Logger::Level _level) {
+ return (_level <= maximumLogLevel_) ? true : false;
+ }
+
+ void doLog(Logger::Level _level, const std::string &_message) {
+ if (useConsole_) {
+ std::lock_guard<std::mutex> itsLock(mutex_);
+ std::cerr << "[CAPI][" << levelAsString(_level) << "] " << _message
+ << std::endl;
+ }
+ if (file_ && file_->is_open()) {
+ std::lock_guard<std::mutex> itsLock(mutex_);
+ (*(file_.get())) << "[CAPI][" << levelAsString(_level) << "] "
+ << _message << std::endl;
+ }
+
+#ifdef USE_DLT
+ if (useDlt_) {
+ DLT_LOG_STRING(dlt_, levelAsDlt(_level), _message.c_str());
+ }
+#endif
+
+ }
+
+ static Logger::Level stringAsLevel(const std::string &_level) {
+ Logger::Level level(Logger::Level::CAPI_LOG_INFO);
+ if (_level == "none") {
+ level = Logger::Level::CAPI_LOG_NONE;
+ } else if (_level == "fatal") {
+ level = Logger::Level::CAPI_LOG_FATAL;
+ } else if (_level == "error") {
+ level = Logger::Level::CAPI_LOG_ERROR;
+ } else if (_level == "warning") {
+ level = Logger::Level::CAPI_LOG_WARNING;
+ } else if (_level == "info") {
+ level = Logger::Level::CAPI_LOG_INFO;
+ } else if (_level == "debug") {
+ level = Logger::Level::CAPI_LOG_DEBUG;
+ } else if (_level == "verbose") {
+ level = Logger::Level::CAPI_LOG_VERBOSE;
+ }
+ return level;
+ }
+
+private:
+ static std::string levelAsString(Logger::Level _level) {
+ switch (_level) {
+ case Logger::Level::CAPI_LOG_NONE:
+ return "NONE";
+ case Logger::Level::CAPI_LOG_FATAL:
+ return "FATAL";
+ case Logger::Level::CAPI_LOG_ERROR:
+ return "ERROR";
+ case Logger::Level::CAPI_LOG_WARNING:
+ return "WARNING";
+ case Logger::Level::CAPI_LOG_INFO:
+ return "INFO";
+ case Logger::Level::CAPI_LOG_DEBUG:
+ return "DEBUG";
+ case Logger::Level::CAPI_LOG_VERBOSE:
+ return "VERBOSE";
+ default:
+ return "";
+ }
+ }
+
+#ifdef USE_DLT
+ static DltLogLevelType levelAsDlt(Logger::Level _level) {
+ switch (_level) {
+ case Logger::Level::CAPI_LOG_NONE:
+ return DLT_LOG_OFF;
+ case Logger::Level::CAPI_LOG_FATAL:
+ return DLT_LOG_FATAL;
+ case Logger::Level::CAPI_LOG_ERROR:
+ return DLT_LOG_ERROR;
+ case Logger::Level::CAPI_LOG_WARNING:
+ return DLT_LOG_WARN;
+ case Logger::Level::CAPI_LOG_INFO:
+ return DLT_LOG_INFO;
+ case Logger::Level::CAPI_LOG_DEBUG:
+ return DLT_LOG_DEBUG;
+ case Logger::Level::CAPI_LOG_VERBOSE:
+ return DLT_LOG_VERBOSE;
+ default:
+ return DLT_LOG_DEFAULT;
+ }
+ }
+#endif
+
+private:
+ std::mutex mutex_;
+
+ Logger::Level maximumLogLevel_;
+
+ bool useConsole_;
+
+ std::shared_ptr<std::ofstream> file_;
+
+ bool useDlt_;
+#ifdef USE_DLT
+ DLT_DECLARE_CONTEXT(dlt_)
+ bool ownAppID_;
+#endif
+};
+
+std::unique_ptr<Logger::LoggerImpl> Logger::loggerImpl_ =
+ std::unique_ptr<Logger::LoggerImpl>(new Logger::LoggerImpl());
+
+Logger::Logger() = default;
+Logger::~Logger() = default;
+
+void Logger::init(bool _useConsole, const std::string &_fileName, bool _useDlt,
+ const std::string& _level) {
+ loggerImpl_->init(_useConsole, _fileName, _useDlt, _level);
+}
+
+bool Logger::isLogged(Level _level) {
+ return loggerImpl_->isLogged(_level);
+}
+
+void Logger::doLog(Level _level, const std::string& _message) {
+ loggerImpl_->doLog(_level, _message);
}
} //namespace CommonAPI
diff --git a/src/CommonAPI/LoggerImpl.cpp b/src/CommonAPI/LoggerImpl.cpp
deleted file mode 100644
index fabb109..0000000
--- a/src/CommonAPI/LoggerImpl.cpp
+++ /dev/null
@@ -1,200 +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/.
-
-#include <iostream>
-
-#include <CommonAPI/LoggerImpl.hpp>
-#ifdef USE_DLT
-#include <CommonAPI/Runtime.hpp>
-#endif
-
-namespace CommonAPI {
-
-#if defined(USE_CONSOLE) || defined(USE_FILE)
-std::mutex LoggerImpl::mutex_;
-#endif
-
-#ifdef USE_CONSOLE
-bool LoggerImpl::useConsole_(true);
-#endif
-
-#ifdef USE_FILE
-std::shared_ptr<std::ofstream> LoggerImpl::file_;
-#endif
-
-#ifdef USE_DLT
-bool LoggerImpl::useDlt_(false);
-#endif
-
-#if defined(USE_CONSOLE) || defined(USE_FILE) || defined(USE_DLT)
-LoggerImpl::Level LoggerImpl::maximumLogLevel_(LoggerImpl::Level::LL_INFO);
-#endif
-
-LoggerImpl::LoggerImpl() {
-#ifdef USE_DLT
- if (useDlt_) {
- std::string app = Runtime::getProperty("LogApplication");
- if (!app.empty()) {
- ownAppID_ = true;
- DLT_REGISTER_APP(app.c_str(), "CommonAPI Application");
- }
-
- std::string context = Runtime::getProperty("LogContext");
- if (context == "") context = "CAPI";
- DLT_REGISTER_CONTEXT(dlt_, context.c_str(), "CAPI");
- }
-#endif
-}
-
-LoggerImpl::~LoggerImpl() {
-#ifdef USE_DLT
- if (useDlt_) {
- DLT_UNREGISTER_CONTEXT(dlt_);
- if (ownAppID_) {
- DLT_UNREGISTER_APP();
- }
- }
-#endif
-}
-
-LoggerImpl* LoggerImpl::get() {
- static LoggerImpl theLoggerImpl;
- return &theLoggerImpl;
-}
-
-
-void
-LoggerImpl::init(bool _useConsole, const std::string &_fileName, bool _useDlt, const std::string &_level) {
-#ifdef USE_CONSOLE
- useConsole_ = _useConsole;
-#else
- (void)_useConsole;
-#endif
-#ifdef USE_FILE
- if (_fileName != "") {
- file_ = std::make_shared<std::ofstream>();
- if (file_)
- file_->open(_fileName.c_str(), std::ofstream::out | std::ofstream::app);
- }
-#else
- (void)_fileName;
-#endif
-#ifdef USE_DLT
- useDlt_ = _useDlt;
-#else
- (void)_useDlt;
-#endif
-#if defined(USE_CONSOLE) || defined(USE_FILE) || defined(USE_DLT)
- maximumLogLevel_ = stringAsLevel(_level);
-#else
- (void)_level;
-#endif
-}
-
-void
-LoggerImpl::doLog(Level _level, const std::string &_message) {
-#ifdef USE_CONSOLE
- if (useConsole_) {
- std::lock_guard<std::mutex> itsLock(mutex_);
- std::cerr << "[CAPI][" << levelAsString(_level) << "] " << _message << std::endl;
- }
-#endif
-#ifdef USE_FILE
- if (file_ && file_->is_open()) {
- std::lock_guard<std::mutex> itsLock(mutex_);
- (*(file_.get())) << "[CAPI][" << levelAsString(_level) << "] " << _message << std::endl;
- }
-#endif
-#ifdef USE_DLT
- if (useDlt_) {
- DLT_LOG_STRING(dlt_, levelAsDlt(_level), _message.c_str());
- }
-#endif
-#if !defined(USE_CONSOLE) && !defined(USE_FILE) && !defined(USE_DLT)
- (void)_level;
- (void)_message;
-#endif
-}
-
-#if defined(USE_CONSOLE) || defined(USE_FILE) || defined(USE_DLT)
-LoggerImpl::Level
-LoggerImpl::stringAsLevel(const std::string &_level) {
- if (_level == "fatal")
- return Level::LL_FATAL;
-
- if (_level == "error")
- return Level::LL_ERROR;
-
- if (_level == "warning")
- return Level::LL_WARNING;
-
- if (_level == "info")
- return Level::LL_INFO;
-
- if (_level == "debug")
- return Level::LL_DEBUG;
-
- if (_level == "verbose")
- return Level::LL_VERBOSE;
-
- return Level::LL_INFO;
-}
-#endif
-
-#if defined(USE_CONSOLE) || defined(USE_FILE)
-std::string
-LoggerImpl::levelAsString(LoggerImpl::Level _level) {
- switch (_level) {
- case Level::LL_FATAL:
- return "FATAL";
- case Level::LL_ERROR:
- return "ERROR";
- case Level::LL_WARNING:
- return "WARNING";
- case Level::LL_INFO:
- return "INFO";
- case Level::LL_DEBUG:
- return "DEBUG";
- case Level::LL_VERBOSE:
- return "VERBOSE";
- default:
- return "";
- }
-}
-#endif
-
-#ifdef USE_DLT
-DltLogLevelType
-LoggerImpl::levelAsDlt(LoggerImpl::Level _level) {
- switch (_level) {
- case Level::LL_FATAL:
- return DLT_LOG_FATAL;
- case Level::LL_ERROR:
- return DLT_LOG_ERROR;
- case Level::LL_WARNING:
- return DLT_LOG_WARN;
- case Level::LL_INFO:
- return DLT_LOG_INFO;
- case Level::LL_DEBUG:
- return DLT_LOG_DEBUG;
- case Level::LL_VERBOSE:
- return DLT_LOG_VERBOSE;
- default:
- return DLT_LOG_DEFAULT;
- }
-}
-#endif
-
-bool
-LoggerImpl::isLogged(LoggerImpl::Level _level) {
-#if defined(USE_CONSOLE) || defined(USE_FILE) || defined(USE_DLT)
- return (_level <= maximumLogLevel_) ? true : false;
-#else
- (void)_level;
- return false;
-#endif
-}
-
-} // namespace CommonAPI
diff --git a/src/CommonAPI/MainLoopContext.cpp b/src/CommonAPI/MainLoopContext.cpp
index a097ce7..871d099 100644
--- a/src/CommonAPI/MainLoopContext.cpp
+++ b/src/CommonAPI/MainLoopContext.cpp
@@ -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/src/CommonAPI/Proxy.cpp b/src/CommonAPI/Proxy.cpp
index 6e22f5e..0c28618 100644
--- a/src/CommonAPI/Proxy.cpp
+++ b/src/CommonAPI/Proxy.cpp
@@ -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/src/CommonAPI/ProxyManager.cpp b/src/CommonAPI/ProxyManager.cpp
index e5183b0..dfc2e57 100644
--- a/src/CommonAPI/ProxyManager.cpp
+++ b/src/CommonAPI/ProxyManager.cpp
@@ -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/src/CommonAPI/Runtime.cpp b/src/CommonAPI/Runtime.cpp
index 9bae2e2..1f531a0 100644
--- a/src/CommonAPI/Runtime.cpp
+++ b/src/CommonAPI/Runtime.cpp
@@ -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/.
@@ -220,12 +220,17 @@ Runtime::readConfiguration() {
section = reader.getSection("default");
if (section) {
std::string binding = section->getValue("binding");
- if ("" != binding)
+ if ("" != binding) {
defaultBinding_ = binding;
-
+ }
std::string folder = section->getValue("folder");
- if ("" != folder)
+ if ("" != folder) {
defaultFolder_ = folder;
+ }
+ std::string callTimeout = section->getValue("callTimeout");
+ if ("" != callTimeout) {
+ defaultCallTimeout_ = std::stoi(callTimeout);
+ }
}
section = reader.getSection("proxy");
@@ -293,6 +298,10 @@ Runtime::createProxy(
bool
Runtime::registerStub(const std::string &_domain, const std::string &_interface, const std::string &_instance,
std::shared_ptr<StubBase> _stub, const ConnectionId_t &_connectionId) {
+ if (!_stub) {
+ return false;
+ }
+
if (!isInitialized_) {
initFactories();
}
@@ -311,6 +320,10 @@ Runtime::registerStub(const std::string &_domain, const std::string &_interface,
bool
Runtime::registerStub(const std::string &_domain, const std::string &_interface, const std::string &_instance,
std::shared_ptr<StubBase> _stub, std::shared_ptr<MainLoopContext> _context) {
+ if (!_stub) {
+ return false;
+ }
+
if (!isInitialized_) {
initFactories();
}
@@ -492,4 +505,8 @@ Runtime::registerStubHelper(const std::string &_domain, const std::string &_inte
false);
}
+Timeout_t Runtime::getDefaultCallTimeout() const {
+ return defaultCallTimeout_;
+}
+
} //Namespace CommonAPI
diff --git a/src/CommonAPI/Utils.cpp b/src/CommonAPI/Utils.cpp
index a2058c0..8f7f6e7 100644
--- a/src/CommonAPI/Utils.cpp
+++ b/src/CommonAPI/Utils.cpp
@@ -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/.