PdCom  5.3
Process data communication client
Loading...
Searching...
No Matches
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
29
30#include "SizeTypeInfo.h"
31
32#include <array>
33#include <cstddef>
34#include <cstdint>
35#include <pdcom5_export.h>
36#include <string>
37#include <type_traits>
38#include <vector>
39
40namespace PdCom { namespace details {
41
42template <typename T>
44{};
45template <>
46struct TypeInfoTraits<bool>
47{
48 static constexpr TypeInfo type_info = {
49 TypeInfo::boolean_T, "bool", sizeof(bool)};
50};
51template <>
52struct TypeInfoTraits<char>
53{
54 static constexpr TypeInfo type_info = {
55 TypeInfo::char_T, "char", sizeof(char)};
56};
57template <>
58struct TypeInfoTraits<uint8_t>
59{
60 static constexpr TypeInfo type_info = {
61 TypeInfo::uint8_T, "uint8_t", sizeof(uint8_t)};
62};
63template <>
64struct TypeInfoTraits<int8_t>
65{
66 static constexpr TypeInfo type_info = {
67 TypeInfo::int8_T, "int8_t", sizeof(int8_t)};
68};
69template <>
70struct TypeInfoTraits<uint16_t>
71{
72 static constexpr TypeInfo type_info = {
73 TypeInfo::uint16_T, "uint16_t", sizeof(uint16_t)};
74};
75template <>
76struct TypeInfoTraits<int16_t>
77{
78 static constexpr TypeInfo type_info = {
79 TypeInfo::int16_T, "int16_t", sizeof(int16_t)};
80};
81template <>
82struct TypeInfoTraits<uint32_t>
83{
84 static constexpr TypeInfo type_info = {
85 TypeInfo::uint32_T, "uint32_t", sizeof(uint32_t)};
86};
87template <>
88struct TypeInfoTraits<int32_t>
89{
90 static constexpr TypeInfo type_info = {
91 TypeInfo::int32_T, "int32_t", sizeof(int32_t)};
92};
93template <>
94struct TypeInfoTraits<uint64_t>
95{
96 static constexpr TypeInfo type_info = {
97 TypeInfo::uint64_T, "uint64_t", sizeof(uint64_t)};
98};
99template <>
100struct TypeInfoTraits<int64_t>
101{
102 static constexpr TypeInfo type_info = {
103 TypeInfo::int64_T, "int64_t", sizeof(int64_t)};
104};
105template <>
106struct TypeInfoTraits<double>
107{
108 static constexpr TypeInfo type_info = {
109 TypeInfo::double_T, "double", sizeof(double)};
110};
111template <>
112struct TypeInfoTraits<float>
113{
114 static constexpr TypeInfo type_info = {
115 TypeInfo::single_T, "float", sizeof(float)};
116};
117
118template <TypeInfo::DataType dtype>
120{};
121template <>
122struct DataTypeTraits<TypeInfo::boolean_T>
123{
124 using value_type = bool;
125};
126template <>
128{
129 using value_type = char;
130};
131template <>
132struct DataTypeTraits<TypeInfo::uint8_T>
133{
134 using value_type = uint8_t;
135};
136template <>
138{
139 using value_type = int8_t;
140};
141template <>
142struct DataTypeTraits<TypeInfo::uint16_T>
143{
144 using value_type = uint16_t;
145};
146template <>
147struct DataTypeTraits<TypeInfo::int16_T>
148{
149 using value_type = int16_t;
150};
151template <>
152struct DataTypeTraits<TypeInfo::uint32_T>
153{
154 using value_type = uint32_t;
155};
156template <>
157struct DataTypeTraits<TypeInfo::int32_T>
158{
159 using value_type = int32_t;
160};
161template <>
162struct DataTypeTraits<TypeInfo::uint64_T>
163{
164 using value_type = uint64_t;
165};
166template <>
167struct DataTypeTraits<TypeInfo::int64_T>
168{
169 using value_type = int64_t;
170};
171template <>
172struct DataTypeTraits<TypeInfo::double_T>
173{
174 using value_type = double;
175};
176template <>
177struct DataTypeTraits<TypeInfo::single_T>
178{
179 using value_type = float;
180};
181
182template <class T, class /* sfinae */ = void>
183struct is_contiguous : std::false_type
184{};
185
186template <class T>
187struct is_contiguous<std::vector<T>> : std::true_type
188{};
189
190template <>
191struct is_contiguous<std::vector<bool>> : std::false_type
192{};
193
194template <class T, size_t N>
195struct is_contiguous<std::array<T, N>> : std::true_type
196{};
197
198template <class Char, class Alloc, class Traits>
199struct is_contiguous<std::basic_string<Char, Traits, Alloc>> : std::true_type
200{};
201
202
220void PDCOM5_PUBLIC copyData(
221 void *dst,
222 TypeInfo::DataType dst_type,
223 const void *src,
224 TypeInfo::DataType src_type,
225 size_t nelem,
226 size_t offset = 0);
227
228}} // namespace PdCom::details
229
230#endif // PDCOM5_DETAILS_H
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.
Type of a Variable.
Definition SizeTypeInfo.h:34
Definition details.h:120
Definition details.h:44
Definition details.h:184