-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmacros.hpp
More file actions
98 lines (79 loc) · 2.87 KB
/
Copy pathmacros.hpp
File metadata and controls
98 lines (79 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* @file macros.hpp
*
* This file contains constant values common for the whole project
*/
#pragma once
#include <type_traits>
namespace eprosima {
namespace utils {
/////////////////////////
// FORMAT
/////////////////////////
/**
* @brief Get string of the argument passed to the macro
*
* @example
* STRINGIFY(value) = "value"
*/
#define STRINGIFY(x) #x
//! Same as \c STRINGIFY but adding a comma "," at the end
#define STRINGIFY_WITH_COMMA(x) #x,
#define COMMA ,
#define CONCATENATE(x, y) x ## y
#define CONCATENATE_COMMA(x) x,
/////////////////////////
// TYPES
/////////////////////////
#define ARE_SAME_TYPE(a, b) (typeid(a) == typeid(b))
#define IS_SAME_TYPE_AS_THIS(a) (ARE_SAME_TYPE(a, this))
/**
* @brief Force the specialization type of a template to be a subclass of a Class.
*
* @example
* FORCE_TEMPLATE_SUBCLASS(A, B) = static assert <=> B not inherit from A
*
* @param base parent class that \c derived must inherit.
* @param derived specialization class.
*/
#define FORCE_TEMPLATE_SUBCLASS(base, derived) \
static_assert(std::is_base_of<base, derived>::value, STRINGIFY(derived) " class not derived from " STRINGIFY(base))
/**
* @brief Get string of the name of the CPP Data Type of the argument
*
* @example
* STRINGIFY(int) = "j"
* STRINGIFY(string) = "NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE"
*/
#define TYPE_NAME(x) typeid(x).name()
#define MAX(x, y) x < y ? y : x
#define MIN(x, y) x > y ? y : x
/**
* @brief Standarize a common way to check if the OS is windows.
*/
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) || \
defined(WIN64) || defined(_WIN64) || defined(__WIN64) || \
defined(_MSC_VER)
#define _EPROSIMA_WINDOWS_PLATFORM 1
#endif // if defined(WIN32) || defined(_WIN32) || defined(__WIN32) || defined(WIN64) || defined(_WIN64) || defined(__WIN64) || defined(_MSC_VER)
#if defined(WIN64) || defined(_WIN64) || defined(__WIN64) || defined(_WIN64) || defined(__x86_64__) || \
defined(__ppc64__) || defined(__aarch64__)
#define _PLATFORM_64BIT 1
#else
#define _PLATFORM_32BIT 1
#endif // if defined(WIN64) || defined(_WIN64) || defined(__WIN64) || defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__) || defined(__aarch64__)
} /* namespace utils */
} /* namespace eprosima */