summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDirk Huss <dirk_huss@mentor.com>2016-05-25 19:00:32 +0200
committerDirk Huss <dirk_huss@mentor.com>2016-05-25 19:00:32 +0200
commit534894b27a5e6b86cf8d2bd7b53d55d04f2a1bcc (patch)
tree3ee994cc8d94f3c5e96c1b88dd15bc9d58e81e89 /include
parent1c158272e2ee4b93021a97ac3b5c207a137b0d2c (diff)
downloadgenivi-common-api-runtime-534894b27a5e6b86cf8d2bd7b53d55d04f2a1bcc.tar.gz
CommonAPI 3.1.83.1.8
Diffstat (limited to 'include')
-rw-r--r--include/CommonAPI/Address.hpp2
-rw-r--r--include/CommonAPI/Config.hpp6
-rw-r--r--include/CommonAPI/Event.hpp31
-rw-r--r--include/CommonAPI/Export.hpp4
-rw-r--r--include/CommonAPI/Extensions/AttributeCacheExtension.hpp1
-rw-r--r--include/CommonAPI/Logger.hpp84
-rw-r--r--include/CommonAPI/LoggerImpl.hpp77
-rw-r--r--include/CommonAPI/Runtime.hpp2
-rw-r--r--include/CommonAPI/Variant.hpp22
9 files changed, 142 insertions, 87 deletions
diff --git a/include/CommonAPI/Address.hpp b/include/CommonAPI/Address.hpp
index 74a13d4..39cac8b 100644
--- a/include/CommonAPI/Address.hpp
+++ b/include/CommonAPI/Address.hpp
@@ -15,7 +15,7 @@ namespace CommonAPI {
class Address {
public:
- COMMONAPI_EXPORT Address() = default;
+ COMMONAPI_EXPORT Address();
COMMONAPI_EXPORT Address(const std::string &_address);
COMMONAPI_EXPORT Address(const std::string &_domain,
const std::string &_interface,
diff --git a/include/CommonAPI/Config.hpp b/include/CommonAPI/Config.hpp
index fb99bf3..e4450d5 100644
--- a/include/CommonAPI/Config.hpp
+++ b/include/CommonAPI/Config.hpp
@@ -10,7 +10,11 @@
namespace CommonAPI {
-static const Timeout_t DEFAULT_SEND_TIMEOUT_MS = 5000;
+#ifndef DEFAULT_SEND_TIMEOUT
+#define DEFAULT_SEND_TIMEOUT 5000
+#endif
+
+static const Timeout_t DEFAULT_SEND_TIMEOUT_MS = DEFAULT_SEND_TIMEOUT;
} // namespace CommonAPI
diff --git a/include/CommonAPI/Event.hpp b/include/CommonAPI/Event.hpp
index a31c677..91da3d6 100644
--- a/include/CommonAPI/Event.hpp
+++ b/include/CommonAPI/Event.hpp
@@ -71,7 +71,7 @@ public:
protected:
void notifyListeners(const Arguments_&... _eventArguments);
void notifySpecificListener(const Subscription _subscription, const Arguments_&... _eventArguments);
- void notifyError(const CallStatus status);
+ void notifySpecificError(const Subscription _subscription, const CallStatus status);
virtual void onFirstListenerAdded(const Listener &_listener) {
(void)_listener;
@@ -216,7 +216,7 @@ void Event<Arguments_...>::notifySpecificListener(const Subscription subscriptio
}
template<typename ... Arguments_>
-void Event<Arguments_...>::notifyError(const CallStatus status) {
+void Event<Arguments_...>::notifySpecificError(const Subscription subscription, const CallStatus status) {
subscriptionMutex_.lock();
notificationMutex_.lock();
@@ -236,13 +236,34 @@ void Event<Arguments_...>::notifyError(const CallStatus status) {
subscriptionMutex_.unlock();
for (auto iterator = subscriptions_.begin(); iterator != subscriptions_.end(); iterator++) {
- ErrorListener listener = std::get<1>(iterator->second);
- if (listener) {
- listener(status);
+ if (subscription == iterator->first) {
+ ErrorListener listener = std::get<1>(iterator->second);
+ if (listener) {
+ listener(status);
+ }
}
}
notificationMutex_.unlock();
+
+ if (status != CommonAPI::CallStatus::SUCCESS) {
+ 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);
+ }
+ }
+ }
+ else {
+ listenerIterator = pendingSubscriptions_.find(subscription);
+ if (pendingSubscriptions_.end() != listenerIterator) {
+ pendingSubscriptions_.erase(subscription);
+ }
+ }
+ subscriptionMutex_.unlock();
+ }
}
} // namespace CommonAPI
diff --git a/include/CommonAPI/Export.hpp b/include/CommonAPI/Export.hpp
index 1513ac9..b95693b 100644
--- a/include/CommonAPI/Export.hpp
+++ b/include/CommonAPI/Export.hpp
@@ -8,6 +8,7 @@
#ifdef WIN32
#define COMMONAPI_EXPORT __declspec(dllexport)
+ #define COMMONAPI_EXPORT_CLASS_EXPLICIT
#if COMMONAPI_DLL_COMPILATION
#define COMMONAPI_IMPORT_EXPORT __declspec(dllexport)
@@ -15,7 +16,8 @@
#define COMMONAPI_IMPORT_EXPORT __declspec(dllimport)
#endif
#else
- #define COMMONAPI_EXPORT
+ #define COMMONAPI_EXPORT __attribute__ ((visibility ("default")))
+ #define COMMONAPI_EXPORT_CLASS_EXPLICIT COMMONAPI_EXPORT
#define COMMONAPI_IMPORT_EXPORT
#endif
diff --git a/include/CommonAPI/Extensions/AttributeCacheExtension.hpp b/include/CommonAPI/Extensions/AttributeCacheExtension.hpp
index f6a0cb1..7a8e8d5 100644
--- a/include/CommonAPI/Extensions/AttributeCacheExtension.hpp
+++ b/include/CommonAPI/Extensions/AttributeCacheExtension.hpp
@@ -8,7 +8,6 @@
#include <CommonAPI/CommonAPI.hpp>
-#include <cassert>
#include <memory>
#include <type_traits>
diff --git a/include/CommonAPI/Logger.hpp b/include/CommonAPI/Logger.hpp
index 52a55bf..b4047ac 100644
--- a/include/CommonAPI/Logger.hpp
+++ b/include/CommonAPI/Logger.hpp
@@ -6,19 +6,9 @@
#ifndef COMMONAPI_LOGGER_HPP_
#define COMMONAPI_LOGGER_HPP_
-#ifdef USE_DLT
-#include <dlt/dlt.h>
-#endif
-
-#include <cstdint>
-#include <fstream>
-#include <memory>
-#include <mutex>
-#include <sstream>
-
-#include <CommonAPI/Export.hpp>
+#include <CommonAPI/LoggerImpl.hpp>
-#define COMMONAPI_LOGLEVEL_NONE 0
+#define COMMONAPI_LOGLEVEL_NONE 0
#define COMMONAPI_LOGLEVEL_FATAL 1
#define COMMONAPI_LOGLEVEL_ERROR 2
#define COMMONAPI_LOGLEVEL_WARNING 3
@@ -34,42 +24,42 @@
#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_FATAL
#define COMMONAPI_FATAL(...) \
- do { Logger::log(Logger::Level::LL_FATAL, __VA_ARGS__); } while (false);
+ do { Logger::log(LoggerImpl::Level::LL_FATAL, __VA_ARGS__); } while (false);
#else
#define COMMONAPI_FATAL(...)
#endif
#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_ERROR
#define COMMONAPI_ERROR(...) \
- do { Logger::log(Logger::Level::LL_ERROR, __VA_ARGS__); } while (false);
+ do { Logger::log(LoggerImpl::Level::LL_ERROR, __VA_ARGS__); } while (false);
#else
#define COMMONAPI_ERROR(...)
#endif
#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_WARNING
#define COMMONAPI_WARNING(...) \
- do { Logger::log(Logger::Level::LL_WARNING, __VA_ARGS__); } while (false);
+ do { Logger::log(LoggerImpl::Level::LL_WARNING, __VA_ARGS__); } while (false);
#else
#define COMMONAPI_WARNING(...)
#endif
#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_INFO
#define COMMONAPI_INFO(...) \
- do { Logger::log(Logger::Level::LL_INFO, __VA_ARGS__); } while (false);
+ do { Logger::log(LoggerImpl::Level::LL_INFO, __VA_ARGS__); } while (false);
#else
#define COMMONAPI_INFO(...)
#endif
#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_DEBUG
#define COMMONAPI_DEBUG(...) \
- do { Logger::log(Logger::Level::LL_DEBUG, __VA_ARGS__); } while (false);
+ do { Logger::log(LoggerImpl::Level::LL_DEBUG, __VA_ARGS__); } while (false);
#else
#define COMMONAPI_DEBUG(...)
#endif
#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_VERBOSE
#define COMMONAPI_VERBOSE(...) \
- do { Logger::log(Logger::Level::LL_VERBOSE, __VA_ARGS__); } while (false);
+ do { Logger::log(LoggerImpl::Level::LL_VERBOSE, __VA_ARGS__); } while (false);
#else
#define COMMONAPI_VERBOSE(...)
#endif
@@ -77,39 +67,39 @@
#else // !WIN32
#define COMMONAPI_FATAL(params...) \
- do { Logger::log(Logger::Level::LL_FATAL, params); } while (false);
+ do { Logger::log(LoggerImpl::Level::LL_FATAL, params); } while (false);
#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_ERROR
#define COMMONAPI_ERROR(params...) \
- do { Logger::log(Logger::Level::LL_ERROR, params); } while (false);
+ do { Logger::log(LoggerImpl::Level::LL_ERROR, params); } while (false);
#else
#define COMMONAPI_ERROR(params...)
#endif
#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_WARNING
#define COMMONAPI_WARNING(params...) \
- do { Logger::log(Logger::Level::LL_WARNING, params); } while (false);
+ do { Logger::log(LoggerImpl::Level::LL_WARNING, params); } while (false);
#else
#define COMMONAPI_WARNING(params...)
#endif
#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_INFO
#define COMMONAPI_INFO(params...) \
- do { Logger::log(Logger::Level::LL_INFO, params); } while (false);
+ do { Logger::log(LoggerImpl::Level::LL_INFO, params); } while (false);
#else
#define COMMONAPI_INFO(params...)
#endif
#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_DEBUG
#define COMMONAPI_DEBUG(params...) \
- do { Logger::log(Logger::Level::LL_DEBUG, params); } while (false);
+ do { Logger::log(LoggerImpl::Level::LL_DEBUG, params); } while (false);
#else
#define COMMONAPI_DEBUG(params...)
#endif
#if COMMONAPI_LOGLEVEL >= COMMONAPI_LOGLEVEL_VERBOSE
#define COMMONAPI_VERBOSE(params...) \
- do { Logger::log(Logger::Level::LL_VERBOSE, params); } while (false);
+ do { Logger::log(LoggerImpl::Level::LL_VERBOSE, params); } while (false);
#else
#define COMMONAPI_VERBOSE(params...)
#endif
@@ -120,20 +110,14 @@ namespace CommonAPI {
class Logger {
public:
- COMMONAPI_EXPORT enum class Level : uint8_t {
- LL_FATAL = 0, LL_ERROR = 1, LL_WARNING = 2, LL_INFO = 3, LL_DEBUG = 4, LL_VERBOSE = 5
- };
-
- COMMONAPI_EXPORT Logger();
- COMMONAPI_EXPORT ~Logger();
template<typename... LogEntries_>
- COMMONAPI_EXPORT static void log(Level _level, LogEntries_... _entries) {
+ COMMONAPI_EXPORT static void log(LoggerImpl::Level _level, LogEntries_... _entries) {
#if defined(USE_CONSOLE) || defined(USE_FILE) || defined(USE_DLT)
- if (_level < maximumLogLevel_) {
+ if (LoggerImpl::isLogged(_level)) {
std::stringstream buffer;
log_intern(buffer, _entries...);
- Logger::get()->doLog(_level, buffer.str());
+ LoggerImpl::get()->doLog(_level, buffer.str());
}
#else
(void)_level;
@@ -144,11 +128,6 @@ public:
COMMONAPI_EXPORT static void init(bool, const std::string &, bool, const std::string &);
private:
- COMMONAPI_EXPORT static inline Logger *get() {
- static Logger theLogger;
- return &theLogger;
- }
-
COMMONAPI_EXPORT static void log_intern(std::stringstream &_buffer) {
(void)_buffer;
}
@@ -158,35 +137,6 @@ private:
_buffer << _entry;
log_intern(_buffer, _moreEntries...);
}
-
- 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
diff --git a/include/CommonAPI/LoggerImpl.hpp b/include/CommonAPI/LoggerImpl.hpp
new file mode 100644
index 0000000..1491e1b
--- /dev/null
+++ b/include/CommonAPI/LoggerImpl.hpp
@@ -0,0 +1,77 @@
+// Copyright (C) 2015 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/Runtime.hpp b/include/CommonAPI/Runtime.hpp
index 5b9254c..626bf4e 100644
--- a/include/CommonAPI/Runtime.hpp
+++ b/include/CommonAPI/Runtime.hpp
@@ -168,6 +168,8 @@ private:
COMMONAPI_EXPORT bool loadLibrary(const std::string &);
private:
+ std::string usedConfig_;
+
std::string defaultBinding_;
std::string defaultFolder_;
std::string defaultConfig_;
diff --git a/include/CommonAPI/Variant.hpp b/include/CommonAPI/Variant.hpp
index 96f283a..b139704 100644
--- a/include/CommonAPI/Variant.hpp
+++ b/include/CommonAPI/Variant.hpp
@@ -3,7 +3,6 @@
// 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 <cassert>
#include <cstdint>
#include <iostream>
#include <memory>
@@ -17,6 +16,8 @@
#include <CommonAPI/Deployable.hpp>
#include <CommonAPI/Deployment.hpp>
+#include <CommonAPI/Logger.hpp>
+
#ifndef COMMONAPI_VARIANT_HPP_
#define COMMONAPI_VARIANT_HPP_
@@ -223,7 +224,7 @@ private:
public:
inline bool hasValue() const {
- return (valueType_ != 0);
+ return (valueType_ != 0 && valueType_ <= TypesTupleSize::value );
}
typename std::aligned_storage<maxSize>::type valueStorage_;
@@ -239,7 +240,7 @@ struct ApplyVoidIndexVisitor<Variant_> {
static
void visit(Variant_ &, uint8_t &) {
- assert(false);
+ COMMONAPI_ERROR("ApplyVoidIndexVisitor<Variant_>::visit type not found");
}
};
@@ -269,12 +270,12 @@ struct ApplyVoidVisitor<Visitor_, Variant_> {
static
void visit(Visitor_ &, Variant_ &) {
- assert(false);
+ COMMONAPI_ERROR("ApplyVoidIndexVisitor<Visitor_, Variant_>::visit - type not found");
}
static
void visit(Visitor_ &, const Variant_ &) {
- assert(false);
+ COMMONAPI_ERROR("ApplyVoidIndexVisitor<Visitor_, Variant_>::visit(const) - type not found");
}
};
@@ -312,7 +313,7 @@ struct ApplyBoolVisitor<Visitor_, Variant_> {
static const uint8_t index = 0;
static bool visit(Visitor_ &, Variant_ &) {
- assert(false);
+ COMMONAPI_ERROR("ApplyBoolVisitor<Visitor_, Variant_>::visit - type not found");
return false;
}
};
@@ -342,12 +343,13 @@ struct ApplyStreamVisitor<Visitor_, Variant_, Deployment_> {
static
void visit(Visitor_ &, Variant_ &, const Deployment_ *) {
- //assert(false);
+ COMMONAPI_ERROR("ApplyStreamVisitor<Visitor_, Variant_, Deployment_>::visit - type not found");
+
}
static
void visit(Visitor_ &, const Variant_ &, const Deployment_ *) {
- //assert(false);
+ COMMONAPI_ERROR("ApplyStreamVisitor<Visitor_, Variant_, Deployment_>::visit(const) - type not found");
}
};
@@ -746,10 +748,8 @@ void Variant<Types_...>::set(U_ &&_value, const bool _clear) {
ApplyVoidVisitor<
DeleteVisitor<maxSize>, Variant<Types_...>, Types_...
>::visit(visitor, *this);
- } else {
- new (&valueStorage_) selected_type_t(std::move(any_container_value));
}
-
+ new (&valueStorage_) selected_type_t(std::move(any_container_value));
valueType_ = TypeIndex<Types_...>::template get<selected_type_t>();
}