acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
_impl_type.h
1//
2// Created by camilo on 23/12/2022 02:48 <3ThomasBorregaardSorensen!!
3// ::platform::type by camilo on 2025-11-29 <3ThomasBorregaardSørensen!!
4//
5#pragma once
6
7
8//inline type_name::type(const ::std::type_info & typeinfo) :
9// m_pszRawName(typeinfo.raw_name())
10//{
11//
12//}
13//
14//
15//inline bool type_name::operator == (const ::platform::type & type) const
16//{
17//
18// return m_pszRawName == type.m_pszRawName
19// || !strcmp(m_pszRawName, type.m_pszRawName)
20// || m_strDemangled == type.m_strDemangled; }
21//inline bool type_name::operator == (const ::atom& atom) const
22//{ return atom.as_string() == m_pszRawName ||
23// m_strDemangled == atom.as_string();}
24//inline type_name::platform::type(const ::quantum * p)
25//{ if(::is_null(p)) {
26// m_pszRawName = void;
27// m_strDemangled.empty();
28//
29// }
30// else
31// {
32//
33// this->operator=(typeid(*(::quantum*)p));
34//
35// }
36//
37//}
38//
39//
40//template < prototype_object_not_type_atom OBJECT_NOT_TYPE_ATOM >
41//type_name::type(OBJECT_NOT_TYPE_ATOM & objectnottypeatom)
42//{
43//
44// this->operator = (typeid(*(&(non_const < OBJECT_NOT_TYPE_ATOM > &)objectnottypeatom)));
45//
46//}
47//
48//
49//template < typename BASE >
50//inline type_name::platform::type(const ::pointer<BASE>& p)
51//{ this->operator = (typeid(*((BASE*)p.m_p))); }
52//template < typename TYPE >
53//inline string __type_name()
54//{ auto pszType = ::type<TYPE>().name();
55// string strName = demangle(scopedstrType);
56// return strName; }
57//template < typename TYPE >
58//inline string __type_name(const TYPE * p)
59//{ auto pszType = typeid(*p).name();
60// string strName = demangle(scopedstrType); return strName;}
61//template < typename TYPE >
62//inline string __type_name(const TYPE & t)
63//{ auto pszType = ::type<t>().name(); string strName = demangle(scopedstrType);
64// return strName;}
65//inline bool type_name::operator == (const ::quantum * p) const
66//{ return operator ==(::platform::type(p));}
67//template < typename TYPE >
68//inline bool type_name::operator == (const ::pointer < TYPE > & p) const
69//{ return this->operator==(p.m_p);}
70
71
72namespace platform
73{
74
75
76 inline type::type(){}
77
78
79 inline type::type(const ::platform::type &type) :
80 m_typeid(type.m_typeid),
81 m_customid(type.m_customid)
82 {
83 }
84
85
86 inline type::type(const ::std::type_info &info) :
87 m_typeid(info)
88 {
89 }
90
91
92 inline type::type(const ::scoped_string &scopedstrTypeName) :
93 m_customid(scopedstrTypeName)
94 {
95 }
96
97
98 inline type::type(const ::type_iptr_pair &ipairId):
99 m_customid(ipairId)
100 {}
101
102
103
104 inline type::type(const ::atom & atom) :
105 m_customid(atom)
106 {
107
108
109
110 }
111
112
113 template<typename TYPE>
114 inline type::type(const TYPE *p) : type(typeid(*(TYPE *)p))
115 {
116 }
117 template<typename TYPE>
118 inline type::type(const TYPE &t)
119 requires (!is_raw_pointer <TYPE>) : type(typeid(t))
120 {
121 }
122 template<typename BASE>
123 inline type::type(const ::pointer<BASE> &p) : type(p.m_p)
124 {
125 }
126
127
128 inline const ::string &type::raw_name() const { return m_typeid.m_strRawTypeName; }
129 inline const ::string &type::name() const { return m_typeid.m_strTypeName; }
130 inline const ::string &type::text() const { return m_typeid.m_strTypeName.has_character() ? m_typeid.m_strTypeName : m_customid.m_strNameId; }
131 inline const_char_pointer type::c_str() const { return m_typeid.m_strTypeName.c_str(); }
132 inline bool type::is_set() const
133 {
134 return m_typeid.is_set() || m_customid.is_set();
135 }
136
137 inline bool type::is_empty() const { return !is_set(); }
138 inline type::operator bool() const { return is_set(); }
139 // explicit operator pointer_key() const { return m_pszRawTypeName; }
140 // explicit operator ::string() const { return m_strTypeName; }
141 // bool boolean_test() const { return !is_empty(); }
142
143
144 inline bool type::operator==(const ::platform::type &type) const
145 {
146
147 if (m_typeid.is_set() && type.m_typeid.is_set())
148 {
149
150 return m_typeid == type.m_typeid;
151
152 }
153 else if (m_customid.is_set() && type.m_customid.is_set())
154 {
155
156 return m_customid == type.m_customid;
157
158 }
159
160 return false;
161
162 }
163
164
165 inline ::std::strong_ordering type::operator<=>(const ::platform::type &type) const
166 {
167
168 if (m_typeid.is_set() && type.m_typeid.is_set())
169 {
170
171 return m_typeid <=> type.m_typeid;
172
173 }
174 else if (m_customid.is_set() && type.m_customid.is_set())
175 {
176
177 return m_customid <=> type.m_customid;
178
179 }
180
181 return ::order(this->is_set(), type.is_set());
182
183 }
184
185
186} // namespace platform
187
188
189
190
191template<typename TYPE>
192inline ::platform::type type()
193{
194 return typeid(TYPE);
195}
196
197
198inline ::platform::type type(const ::std::type_info &info) { return info; }
199
200
201inline ::platform::type type(const ::scoped_string &scopedstrTypeName) { return scopedstrTypeName; }
202
203
204template<typename TYPE>
205inline ::platform::type type(const TYPE *p)
206{
207 return typeid(*(TYPE *)p);
208}
209
210
211template<typename TYPE>
212inline ::platform::type type(const TYPE &t)
213{
214 return typeid(t);
215}
216
217
218template<typename BASE>
219inline ::platform::type type(const ::pointer<BASE> &p)
220{
221 return p.m_p;
222}
223
224
225
226
227
228inline type_custom_id::type_custom_id()
229{
230
231}
232inline type_custom_id::type_custom_id(const_char_pointer pszNameId):
233m_strNameId(pszNameId)
234{
235
236
237}
238
239inline type_custom_id::type_custom_id(const ::string_literal& strliteralNameId) :
240 m_strNameId(strliteralNameId)
241{
242
243
244}
245
246inline type_custom_id::type_custom_id(const ::scoped_string & scopedstrNameId):
247m_strNameId(scopedstrNameId)
248{
249
250
251}
252inline type_custom_id::type_custom_id(const ::type_iptr_pair & ipairId) :
253m_ipairId(ipairId)
254{
255
256}
257inline type_custom_id::type_custom_id(const ::scoped_string & scopedstrNameId, const ::type_iptr_pair & ipairId):
258m_strNameId(scopedstrNameId),
259m_ipairId(ipairId)
260{
261
262
263}
264
265inline type_custom_id::type_custom_id(enum_task_tool etasktool) :
266m_ipairId(etasktool)
267{
268
269
270}
271
272
273inline type_custom_id::type_custom_id(const ::atom & atom)
274{
275
276 if (atom.is_text())
277 {
278 m_strNameId = atom.as_string();
279 }
280 else if (atom.is_integer())
281 {
282 m_ipairId.m_element1 = (::iptr)atom.m_etype;
283 m_ipairId.m_element2 = (::iptr)atom.m_iLargest;
284 }
285
286
287}
288
289
290inline constexpr bool type_custom_id::is_set() const
291{
292 return m_strNameId.has_character() || m_ipairId.is_set();
293}
294
295
296
297type_id::type_id() :m_typeindex(::std::type_index(typeid(void)))
298
299{
300
301
302}
303
304type_id::type_id(const ::type_id &type_id):
305m_typeindex(type_id.m_typeindex),
306m_strRawTypeName(type_id.m_strRawTypeName),
307m_strTypeName(type_id.m_strTypeName)
308{
309
310
311}
312
313type_id::type_id(const ::std::type_info &info) :
314m_typeindex(info),
315m_strRawTypeName(::type_raw_name(info)),
316m_strTypeName(::type_name(info))
317{
318
319
320}
321
322
323
324
325
326inline bool type_id::is_set() const
327{
328
329 return m_typeindex != ::std::type_index(typeid(void)) || m_strRawTypeName.has_character() ||
330 m_strTypeName.has_character();
331
332}
333
334
335bool type_id::operator == (const ::type_id & type_id) const
336{
337
338 if (::is_type_index_set(m_typeindex) && ::is_type_index_set(type_id.m_typeindex))
339 {
340
341 return m_typeindex == type_id.m_typeindex;
342
343 }
344 else if (m_strRawTypeName.has_character() && type_id.m_strRawTypeName.has_character())
345 {
346
347 return m_strRawTypeName == type_id.m_strRawTypeName;
348
349 }
350 else if (m_strTypeName.has_character() && type_id.m_strTypeName.has_character())
351 {
352
353 return m_strTypeName == type_id.m_strTypeName;
354
355 }
356
357 return ::is_equivalent(this->is_set(), type_id.is_set());
358
359}
360
361
362::std::strong_ordering type_id::operator <=> (const ::type_id & type_id) const
363{
364
365 if (::is_type_index_set(m_typeindex) && ::is_type_index_set(type_id.m_typeindex))
366 {
367
368 return m_typeindex <=> type_id.m_typeindex;
369
370 }
371 else if (m_strRawTypeName.has_character() && type_id.m_strRawTypeName.has_character())
372 {
373
374 return m_strRawTypeName <=> type_id.m_strRawTypeName;
375
376 }
377 else if (m_strTypeName.has_character() && type_id.m_strTypeName.has_character())
378 {
379
380 return m_strTypeName <=> type_id.m_strTypeName;
381
382 }
383
384 return ::order(this->is_set(), type_id.is_set());
385
386}
387
388
389inline bool type_custom_id::operator == (const ::type_custom_id & typecustomid) const
390{
391
392 if (m_ipairId.is_set() && typecustomid.m_ipairId.is_set())
393 {
394
395 return m_ipairId == typecustomid.m_ipairId;
396
397 }
398 else if (m_strNameId.has_character() && typecustomid.m_strNameId.has_character())
399 {
400
401 return m_strNameId == typecustomid.m_strNameId;
402
403 }
404
405 return ::is_equivalent(this->is_set(), typecustomid.is_set());
406
407}
408
409
410inline ::std::strong_ordering type_custom_id::operator <=> (const ::type_custom_id & typecustomid) const
411{
412
413 if (m_ipairId.is_set() && typecustomid.m_ipairId.is_set())
414 {
415
416 return m_ipairId <=> typecustomid.m_ipairId;
417
418 }
419 else if (m_strNameId.has_character() && typecustomid.m_strNameId.has_character())
420 {
421
422 return m_strNameId <=> typecustomid.m_strNameId;
423
424 }
425
426 return ::order(this->is_set(), typecustomid.is_set());
427
428}
Definition atom.h:237
Definition type.h:584
::string m_strNameId
Definition type.h:163
::type_iptr_pair m_ipairId
m_ipair isn't empty it can be used as a key
Definition type.h:165
Definition type.h:46
::string m_strTypeName
type name as obtained from demangle(typeid().name())
Definition type.h:55
::std::type_index m_typeindex
type index as obtained from std::type_index(typeid())
Definition type.h:51
::string m_strRawTypeName
raw type name as obtained from typeid().raw_name()
Definition type.h:53
include "thread/AutoLock.h"
Definition _forward_declaration.h:877