RMW desert 1.0
Loading...
Searching...
No Matches
macros.h
Go to the documentation of this file.
1/****************************************************************************
2 * Copyright (C) 2024 Davide Costa *
3 * *
4 * This file is part of RMW desert. *
5 * *
6 * RMW desert is free software: you can redistribute it and/or modify it *
7 * under the terms of the GNU General Public License as published by the *
8 * Free Software Foundation, either version 3 of the License, or any *
9 * later version. *
10 * *
11 * RMW desert is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with RMW desert. If not, see <http://www.gnu.org/licenses/>. *
18 ****************************************************************************/
19
32#ifndef MACROS_H_
33#define MACROS_H_
34
37#include "rosidl_runtime_c/primitives_sequence.h"
38#include "rosidl_runtime_c/primitives_sequence_functions.h"
39
42#define SPECIALIZE_GENERIC_C_SEQUENCE(C_NAME, C_TYPE) \
43 template<> \
44 struct GenericCSequence<C_TYPE> \
45 { \
46 using type = rosidl_runtime_c__ ## C_NAME ## __Sequence; \
47 \
48 static void fini(type * sequence) { \
49 rosidl_runtime_c__ ## C_NAME ## __Sequence__fini(sequence); \
50 } \
51 \
52 static bool init(type * sequence, size_t size) { \
53 return rosidl_runtime_c__ ## C_NAME ## __Sequence__init(sequence, size); \
54 } \
55 };
56
57template<typename T>
59
60// multiple definitions of ambiguous primitive types
61SPECIALIZE_GENERIC_C_SEQUENCE(bool, bool)
62SPECIALIZE_GENERIC_C_SEQUENCE(byte, uint8_t)
63SPECIALIZE_GENERIC_C_SEQUENCE(char, char)
64SPECIALIZE_GENERIC_C_SEQUENCE(float32, float)
65SPECIALIZE_GENERIC_C_SEQUENCE(float64, double)
66SPECIALIZE_GENERIC_C_SEQUENCE(int8, int8_t)
67SPECIALIZE_GENERIC_C_SEQUENCE(int16, int16_t)
68SPECIALIZE_GENERIC_C_SEQUENCE(uint16, uint16_t)
69SPECIALIZE_GENERIC_C_SEQUENCE(int32, int32_t)
70SPECIALIZE_GENERIC_C_SEQUENCE(uint32, uint32_t)
71SPECIALIZE_GENERIC_C_SEQUENCE(int64, int64_t)
72SPECIALIZE_GENERIC_C_SEQUENCE(uint64, uint64_t)
73
74#endif // MACROS_HPP_
Definition macros.h:58