Dawn Framework 1.0
Universal data acquisition framework for embedded systems
objectid.cxx
1// dawn/src/common/objectid.cxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#include "dawn/common/objectid.hxx"
7
8#include "dawn/debug.hxx"
9
10using namespace dawn;
11
13{
14 switch (dtype)
15 {
16#if defined(CONFIG_DAWN_DTYPE_BOOL) || defined(CONFIG_DAWN_DTYPE_INT8) || \
17 defined(CONFIG_DAWN_DTYPE_UINT8) || defined(CONFIG_DAWN_DTYPE_BLOCK)
18# ifdef CONFIG_DAWN_DTYPE_BOOL
19 case DTYPE_BOOL:
20# endif
21# ifdef CONFIG_DAWN_DTYPE_INT8
22 case DTYPE_INT8:
23# endif
24# ifdef CONFIG_DAWN_DTYPE_UINT8
25 case DTYPE_UINT8:
26# endif
27# ifdef CONFIG_DAWN_DTYPE_BLOCK
28 case DTYPE_BLOCK:
29# endif
30 {
31 return 1;
32 }
33#endif
34
35#if defined(CONFIG_DAWN_DTYPE_INT16) || defined(CONFIG_DAWN_DTYPE_UINT16)
36# ifdef CONFIG_DAWN_DTYPE_INT16
37 case DTYPE_INT16:
38# endif
39# ifdef CONFIG_DAWN_DTYPE_UINT16
40 case DTYPE_UINT16:
41# endif
42 {
43 return 2;
44 }
45#endif
46
47#if defined(CONFIG_DAWN_DTYPE_INT32) || defined(CONFIG_DAWN_DTYPE_UINT32) || \
48 defined(CONFIG_DAWN_DTYPE_FLOAT) || defined(CONFIG_DAWN_DTYPE_B16) || \
49 defined(CONFIG_DAWN_DTYPE_UB16)
50# ifdef CONFIG_DAWN_DTYPE_INT32
51 case DTYPE_INT32:
52# endif
53# ifdef CONFIG_DAWN_DTYPE_UINT32
54 case DTYPE_UINT32:
55# endif
56# ifdef CONFIG_DAWN_DTYPE_FLOAT
57 case DTYPE_FLOAT:
58# endif
59# ifdef CONFIG_DAWN_DTYPE_B16
60 case DTYPE_B16:
61# endif
62# ifdef CONFIG_DAWN_DTYPE_UB16
63 case DTYPE_UB16:
64# endif
65 {
66 return 4;
67 }
68#endif
69
70#if defined(CONFIG_DAWN_DTYPE_INT64) || defined(CONFIG_DAWN_DTYPE_DOUBLE) || \
71 defined(CONFIG_DAWN_DTYPE_UINT64)
72# ifdef CONFIG_DAWN_DTYPE_INT64
73 case DTYPE_INT64:
74# endif
75# ifdef CONFIG_DAWN_DTYPE_DOUBLE
76 case DTYPE_DOUBLE:
77# endif
78# ifdef CONFIG_DAWN_DTYPE_UINT64
79 case DTYPE_UINT64:
80# endif
81 {
82 return 8;
83 }
84#endif
85
86 default:
87 {
88 return -1;
89 }
90 }
91
92 return 0;
93}
94
95bool SObjectId::isDtypeSupported(uint8_t dtype)
96{
97 switch (dtype)
98 {
99 case DTYPE_ANY:
100 return true;
101
102#ifdef CONFIG_DAWN_DTYPE_BOOL
103 case DTYPE_BOOL:
104 return true;
105#endif
106#ifdef CONFIG_DAWN_DTYPE_INT8
107 case DTYPE_INT8:
108 return true;
109#endif
110#ifdef CONFIG_DAWN_DTYPE_UINT8
111 case DTYPE_UINT8:
112 return true;
113#endif
114#ifdef CONFIG_DAWN_DTYPE_INT16
115 case DTYPE_INT16:
116 return true;
117#endif
118#ifdef CONFIG_DAWN_DTYPE_UINT16
119 case DTYPE_UINT16:
120 return true;
121#endif
122#ifdef CONFIG_DAWN_DTYPE_INT32
123 case DTYPE_INT32:
124 return true;
125#endif
126#ifdef CONFIG_DAWN_DTYPE_UINT32
127 case DTYPE_UINT32:
128 return true;
129#endif
130#ifdef CONFIG_DAWN_DTYPE_INT64
131 case DTYPE_INT64:
132 return true;
133#endif
134#ifdef CONFIG_DAWN_DTYPE_UINT64
135 case DTYPE_UINT64:
136 return true;
137#endif
138#ifdef CONFIG_DAWN_DTYPE_FLOAT
139 case DTYPE_FLOAT:
140 return true;
141#endif
142#ifdef CONFIG_DAWN_DTYPE_DOUBLE
143 case DTYPE_DOUBLE:
144 return true;
145#endif
146#ifdef CONFIG_DAWN_DTYPE_B16
147 case DTYPE_B16:
148 return true;
149#endif
150#ifdef CONFIG_DAWN_DTYPE_UB16
151 case DTYPE_UB16:
152 return true;
153#endif
154#ifdef CONFIG_DAWN_DTYPE_CHAR
155 case DTYPE_CHAR:
156 return true;
157#endif
158#ifdef CONFIG_DAWN_DTYPE_BLOCK
159 case DTYPE_BLOCK:
160 return true;
161#endif
162 default:
163 return false;
164 }
165}
166
167const char *SObjectId::dtypeToString(uint8_t dtype)
168{
169 switch (dtype)
170 {
171 case DTYPE_ANY:
172 return "any";
173#ifdef CONFIG_DAWN_DTYPE_BOOL
174 case DTYPE_BOOL:
175 return "bool";
176#endif
177#ifdef CONFIG_DAWN_DTYPE_INT8
178 case DTYPE_INT8:
179 return "int8";
180#endif
181#ifdef CONFIG_DAWN_DTYPE_UINT8
182 case DTYPE_UINT8:
183 return "uint8";
184#endif
185#ifdef CONFIG_DAWN_DTYPE_INT16
186 case DTYPE_INT16:
187 return "int16";
188#endif
189#ifdef CONFIG_DAWN_DTYPE_UINT16
190 case DTYPE_UINT16:
191 return "uint16";
192#endif
193#ifdef CONFIG_DAWN_DTYPE_INT32
194 case DTYPE_INT32:
195 return "int32";
196#endif
197#ifdef CONFIG_DAWN_DTYPE_UINT32
198 case DTYPE_UINT32:
199 return "uint32";
200#endif
201#ifdef CONFIG_DAWN_DTYPE_INT64
202 case DTYPE_INT64:
203 return "int64";
204#endif
205#ifdef CONFIG_DAWN_DTYPE_UINT64
206 case DTYPE_UINT64:
207 return "uint64";
208#endif
209#ifdef CONFIG_DAWN_DTYPE_FLOAT
210 case DTYPE_FLOAT:
211 return "float";
212#endif
213#ifdef CONFIG_DAWN_DTYPE_DOUBLE
214 case DTYPE_DOUBLE:
215 return "double";
216#endif
217#ifdef CONFIG_DAWN_DTYPE_B16
218 case DTYPE_B16:
219 return "b16";
220#endif
221#ifdef CONFIG_DAWN_DTYPE_UB16
222 case DTYPE_UB16:
223 return "ub16";
224#endif
225#ifdef CONFIG_DAWN_DTYPE_CHAR
226 case DTYPE_CHAR:
227 return "char";
228#endif
229#ifdef CONFIG_DAWN_DTYPE_BLOCK
230 case DTYPE_BLOCK:
231 return "block";
232#endif
233 default:
234 return "???";
235 }
236}
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13
static const char * dtypeToString(uint8_t dtype)
Convert data type to human-readable string.
Definition objectid.cxx:167
EObjectDataType
Data types supported by Dawn framework.
Definition objectid.hxx:61
@ DTYPE_FLOAT
IEEE 754 single-precision floating point (32-bit).
Definition objectid.hxx:112
@ DTYPE_INT32
Signed 32-bit integer (-2147483648 to 2147483647).
Definition objectid.hxx:92
@ DTYPE_UINT8
Unsigned 8-bit integer (0 to 255).
Definition objectid.hxx:80
@ DTYPE_INT16
Signed 16-bit integer (-32768 to 32767).
Definition objectid.hxx:84
@ DTYPE_INT8
Signed 8-bit integer (-128 to 127).
Definition objectid.hxx:76
@ DTYPE_ANY
Wildcard data type (matches any actual type).
Definition objectid.hxx:68
@ DTYPE_BLOCK
Opaque block/byte-stream data type.
Definition objectid.hxx:153
@ DTYPE_UINT64
Unsigned 64-bit integer.
Definition objectid.hxx:104
@ DTYPE_UINT16
Unsigned 16-bit integer (0 to 65535).
Definition objectid.hxx:88
@ DTYPE_UB16
Unsigned 16.16 fixed-point (32-bit).
Definition objectid.hxx:132
@ DTYPE_DOUBLE
IEEE 754 double-precision floating point (64-bit).
Definition objectid.hxx:120
@ DTYPE_CHAR
Character/string type (null-terminated, 4-byte aligned).
Definition objectid.hxx:144
@ DTYPE_INT64
Signed 64-bit integer.
Definition objectid.hxx:100
@ DTYPE_UINT32
Unsigned 32-bit integer (0 to 4294967295).
Definition objectid.hxx:96
@ DTYPE_BOOL
Boolean data type (stored in 32-bit container).
Definition objectid.hxx:72
@ DTYPE_B16
Signed 16.16 fixed-point (32-bit).
Definition objectid.hxx:128
static bool isDtypeSupported(uint8_t dtype)
Check if a data type is enabled in build configuration.
Definition objectid.cxx:95
static int getDtypeSize_(const EObjectDataType dtype)
Get byte size for a specific data type.
Definition objectid.cxx:12