PdCom  5.0
Process data communication client
details.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * vim:tw=78
3  *
4  * Copyright (C) 2021 Richard Hacker (lerichi at gmx dot net),
5  * Florian Pose (fp at igh dot de),
6  * Bjarne von Horn (vh at igh dot de).
7  *
8  * This file is part of the PdCom library.
9  *
10  * The PdCom library is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or (at your
13  * option) any later version.
14  *
15  * The PdCom library is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18  * License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with the PdCom library. If not, see <http://www.gnu.org/licenses/>.
22  *
23  *****************************************************************************/
24 
25 #ifndef PDCOM5_DETAILS_H
26 #define PDCOM5_DETAILS_H
27 
30 #include "SizeTypeInfo.h"
31 #include "visibility.h"
32 
33 #include <cstddef>
34 #include <cstdint>
35 #include <string>
36 
37 namespace PdCom { namespace details {
38 
39 template <typename T>
41 {};
42 template <>
43 struct TypeInfoTraits<bool>
44 {
45  static constexpr TypeInfo type_info = {
46  TypeInfo::boolean_T, "bool", sizeof(bool)};
47 };
48 template <>
49 struct TypeInfoTraits<uint8_t>
50 {
51  static constexpr TypeInfo type_info = {
52  TypeInfo::uint8_T, "uint8_t", sizeof(uint8_t)};
53 };
54 template <>
55 struct TypeInfoTraits<int8_t>
56 {
57  static constexpr TypeInfo type_info = {
58  TypeInfo::int8_T, "int8_t", sizeof(int8_t)};
59 };
60 template <>
61 struct TypeInfoTraits<uint16_t>
62 {
63  static constexpr TypeInfo type_info = {
64  TypeInfo::uint16_T, "uint16_t", sizeof(uint16_t)};
65 };
66 template <>
67 struct TypeInfoTraits<int16_t>
68 {
69  static constexpr TypeInfo type_info = {
70  TypeInfo::int16_T, "int16_t", sizeof(int16_t)};
71 };
72 template <>
73 struct TypeInfoTraits<uint32_t>
74 {
75  static constexpr TypeInfo type_info = {
76  TypeInfo::uint32_T, "uint32_t", sizeof(uint32_t)};
77 };
78 template <>
79 struct TypeInfoTraits<int32_t>
80 {
81  static constexpr TypeInfo type_info = {
82  TypeInfo::int32_T, "int32_t", sizeof(int32_t)};
83 };
84 template <>
85 struct TypeInfoTraits<uint64_t>
86 {
87  static constexpr TypeInfo type_info = {
88  TypeInfo::uint64_T, "uint64_t", sizeof(uint64_t)};
89 };
90 template <>
91 struct TypeInfoTraits<int64_t>
92 {
93  static constexpr TypeInfo type_info = {
94  TypeInfo::int64_T, "int64_t", sizeof(int64_t)};
95 };
96 template <>
97 struct TypeInfoTraits<double>
98 {
99  static constexpr TypeInfo type_info = {
100  TypeInfo::double_T, "double", sizeof(double)};
101 };
102 template <>
103 struct TypeInfoTraits<float>
104 {
105  static constexpr TypeInfo type_info = {
106  TypeInfo::single_T, "float", sizeof(float)};
107 };
108 
109 template <TypeInfo::DataType dtype>
111 {};
112 template <>
113 struct DataTypeTraits<TypeInfo::boolean_T>
114 {
115  using value_type = bool;
116 };
117 template <>
118 struct DataTypeTraits<TypeInfo::uint8_T>
119 {
120  using value_type = uint8_t;
121 };
122 template <>
123 struct DataTypeTraits<TypeInfo::int8_T>
124 {
125  using value_type = int8_t;
126 };
127 template <>
128 struct DataTypeTraits<TypeInfo::uint16_T>
129 {
130  using value_type = uint16_t;
131 };
132 template <>
133 struct DataTypeTraits<TypeInfo::int16_T>
134 {
135  using value_type = int16_t;
136 };
137 template <>
138 struct DataTypeTraits<TypeInfo::uint32_T>
139 {
140  using value_type = uint32_t;
141 };
142 template <>
143 struct DataTypeTraits<TypeInfo::int32_T>
144 {
145  using value_type = int32_t;
146 };
147 template <>
148 struct DataTypeTraits<TypeInfo::uint64_T>
149 {
150  using value_type = uint32_t;
151 };
152 template <>
153 struct DataTypeTraits<TypeInfo::int64_T>
154 {
155  using value_type = int32_t;
156 };
157 template <>
158 struct DataTypeTraits<TypeInfo::double_T>
159 {
160  using value_type = double;
161 };
162 template <>
163 struct DataTypeTraits<TypeInfo::single_T>
164 {
165  using value_type = float;
166 };
167 
179 void PDCOM5_PUBLIC copyData(
180  void *dst,
181  TypeInfo::DataType dst_type,
182  const void *src,
183  TypeInfo::DataType src_type,
184  size_t nelem,
185  size_t offset = 0);
186 }} // namespace PdCom::details
187 
188 #endif // PDCOM5_DETAILS_H
Type of a Variable.
Definition: SizeTypeInfo.h:33
Definition: details.h:40
void PDCOM5_PUBLIC copyData(void *dst, TypeInfo::DataType dst_type, const void *src, TypeInfo::DataType src_type, size_t nelem, size_t offset=0)
Data Conversion Matrix.
library version string as "major.minor.patch"
Definition: details.h:37
Definition: details.h:110