summaryrefslogtreecommitdiff
path: root/include/CommonAPI/Types.hpp
diff options
context:
space:
mode:
authorJürgen Gehring <juergen.gehring@bmw.de>2015-06-11 06:57:47 -0700
committerJürgen Gehring <juergen.gehring@bmw.de>2015-06-11 06:57:47 -0700
commit6c463fcc3dcee619925f08ea09e19a86b9e581cc (patch)
tree17e765e0623c58778150605d1cd0340c658ce6ab /include/CommonAPI/Types.hpp
parent1d83eb38e546e0165f1ad6821f04445b2b9b19d2 (diff)
downloadgenivi-common-api-runtime-6c463fcc3dcee619925f08ea09e19a86b9e581cc.tar.gz
CommonAPI 3.1.1
Diffstat (limited to 'include/CommonAPI/Types.hpp')
-rw-r--r--include/CommonAPI/Types.hpp116
1 files changed, 116 insertions, 0 deletions
diff --git a/include/CommonAPI/Types.hpp b/include/CommonAPI/Types.hpp
new file mode 100644
index 0000000..de1d85a
--- /dev/null
+++ b/include/CommonAPI/Types.hpp
@@ -0,0 +1,116 @@
+// Copyright (C) 2013-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/.
+
+#if !defined (COMMONAPI_INTERNAL_COMPILATION)
+#error "Only <CommonAPI/CommonAPI.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef COMMONAPI_TYPES_HPP_
+#define COMMONAPI_TYPES_HPP_
+
+#include <cstdint>
+#include <functional>
+#include <unordered_set>
+#include <memory>
+#include <tuple>
+
+#include <CommonAPI/ByteBuffer.hpp>
+#include <CommonAPI/ContainerUtils.hpp>
+#include <CommonAPI/Event.hpp>
+#include <CommonAPI/Export.hpp>
+#include <CommonAPI/Version.hpp>
+
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
+# define COMMONAPI_DEPRECATED __attribute__ ((__deprecated__))
+#elif defined(_MSC_VER) && (_MSC_VER >= 1300)
+# define COMMONAPI_DEPRECATED __declspec(deprecated)
+#else
+# define COMMONAPI_DEPRECATED
+#endif
+
+
+#ifdef WIN32
+#define CCALL __cdecl
+#pragma section(".CRT$XCU",read)
+#define INITIALIZER(f) \
+ static void __cdecl f(void); \
+ __declspec(allocate(".CRT$XCU")) void(__cdecl*f##_)(void) = f; \
+ static void __cdecl f(void)
+#else
+#define CCALL
+#define INITIALIZER(f) \
+ static void f(void) __attribute__((constructor)); \
+ static void f(void)
+#endif
+
+#ifdef WIN32
+#define usleep(micSec) \
+ std::this_thread::sleep_for(std::chrono::microseconds(micSec))
+#endif
+
+namespace CommonAPI {
+
+enum class AvailabilityStatus {
+ UNKNOWN,
+ AVAILABLE,
+ NOT_AVAILABLE
+};
+
+enum class CallStatus {
+ SUCCESS,
+ OUT_OF_MEMORY,
+ NOT_AVAILABLE,
+ CONNECTION_FAILED,
+ REMOTE_ERROR,
+ UNKNOWN
+};
+
+typedef uint32_t CallId_t;
+typedef std::string ConnectionId_t;
+typedef int Timeout_t; // in ms, -1 means "forever"
+typedef uint32_t Sender_t;
+
+/**
+ * \brief Identifies a client sending a call to a stub.
+ *
+ * The ClientId is used to identify the caller within a stub.
+ * The ClientId is supposed to be added by the middleware and can be compared using the == operator.
+ */
+class ClientId {
+public:
+ virtual ~ClientId() { }
+ virtual bool operator==(ClientId& clientIdToCompare) = 0;
+ virtual std::size_t hashCode() = 0;
+};
+
+template <typename ... Args>
+struct SelectiveBroadcastFunctorHelper {
+ typedef std::function<void(Args...)> SelectiveBroadcastFunctor;
+};
+
+typedef std::unordered_set<
+ std::shared_ptr<CommonAPI::ClientId>,
+ SharedPointerClientIdContentHash,
+ SharedPointerClientIdContentEqual
+> ClientIdList;
+
+template<typename _EnumType>
+class EnumHasher {
+public:
+ size_t operator()(const _EnumType& testEnum) const {
+ return static_cast<int32_t>(testEnum);
+ }
+};
+
+// Type identifier for polymorphic structs
+typedef uint32_t Serial;
+
+} // namespace CommonAPI
+
+#endif // COMMONAPI_TYPES_HPP_
+
+#if defined(COMMONAPI_TYPES_LOCAL_INCLUDE)
+#include COMMONAPI_TYPES_LOCAL_INCLUDE
+#endif