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