- Aldebaran documentation |
- C++ Libraries |
- index

libqi-api 2.8.7.4

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
structtypeinterface.hxx
Go to the documentation of this file.
1 #pragma once
2 /*
3 ** Copyright (C) 2013 Aldebaran Robotics
4 ** See COPYING for the license
5 */
6
7 #ifndef _QITYPE_DETAIL_TYPETUPLE_HXX_
8 #define _QITYPE_DETAIL_TYPETUPLE_HXX_
9
10 #include <map>
11 #include <boost/type_traits.hpp>
12 #include <boost/utility/enable_if.hpp>
13 #include <qi/api.hpp>
14 #include <qi/type/fwd.hpp>
15 #include <qi/type/detail/accessor.hxx>
16 #include <qi/type/typeinterface.hpp>
17 #include <qi/preproc.hpp>
18
19 namespace qi
20 {
21 namespace detail {
22
23 bool QI_API fillMissingFieldsWithDefaultValues(
24 std::map<std::string, ::qi::AnyValue>& fields,
25 const std::vector<std::tuple<std::string, TypeInterface*>>& missing,
26 const char** which=0, int whichLength=0);
27
28 template <typename T>
29 struct StructVersioningDelegateAddFields
30 {
31 static bool convertFrom(StructTypeInterface* type,
32 std::map<std::string, qi::AnyValue>& fields,
33 const std::vector<std::tuple<std::string, TypeInterface*>>& missing)
34 {
35 return missing.empty();
36 }
37 static bool convertTo(const std::map<std::string, qi::AnyReference>& dropFields)
38 {
39 return dropFields.empty();
40 }
41 };
42 template <typename T>
43 struct StructVersioningDelegateDropFields
44 {
45 static bool convertTo(StructTypeInterface* type,
46 std::map<std::string, ::qi::AnyValue>& fields,
47 const std::vector<std::tuple<std::string, TypeInterface*>>& missing)
48 {
49 return missing.empty();
50 }
51 static bool convertFrom(const std::map<std::string, qi::AnyReference>& dropFields)
52 {
53 return dropFields.empty();
54 }
55 };
56
57 template <typename T>
58 struct StructVersioningDelegate
59 {
60 static bool convertFrom(StructTypeInterface* type,
61 std::map<std::string, qi::AnyValue>& fields,
62 const std::vector<std::tuple<std::string, TypeInterface*>>& missing,
63 const std::map<std::string, qi::AnyReference>& dropfields)
64 {
65 return StructVersioningDelegateDropFields<T>::convertFrom(dropfields) &&
66 StructVersioningDelegateAddFields<T>::convertFrom(type, fields, missing);
67 }
68 static bool convertTo(StructTypeInterface* type,
69 std::map<std::string, ::qi::AnyValue>& fields,
70 const std::vector<std::tuple<std::string, TypeInterface*>>& missing,
71 const std::map<std::string, ::qi::AnyReference>& dropfields)
72 {
73 return StructVersioningDelegateAddFields<T>::convertTo(dropfields) &&
74 StructVersioningDelegateDropFields<T>::convertTo(type, fields, missing);
75 }
76 };
77
81 #define QI_TYPE_STRUCT_EXTENSION_ADDED_FIELDS(name, ...) \
82 namespace qi \
83 { \
84 namespace detail \
85 { \
86 template <> \
87 struct StructVersioningDelegateAddFields<name> \
88 { \
89 static bool convertFrom(StructTypeInterface* type, \
90 std::map<std::string, ::qi::AnyValue>& fields, \
91 const std::vector<std::tuple<std::string, TypeInterface*>>& missing) \
92 { \
93 static const char* which[] = {__VA_ARGS__}; \
94 const int count = sizeof(which) / sizeof(char*); \
95 return fillMissingFieldsWithDefaultValues(fields, missing, which, count); \
96 } \
97 static bool convertTo(const std::map<std::string, ::qi::AnyReference>& todrop) \
98 { \
99 static const char* which[] = {__VA_ARGS__}; \
100 const int count = sizeof(which) / sizeof(char*); \
101 for (const auto& field : todrop) \
102 if (std::find(which, which + count, field.first) == which + count) \
103 return false; \
104 return true; \
105 } \
106 }; \
107 } \
108 }
109
112 #define QI_TYPE_STRUCT_EXTENSION_DROPPED_FIELDS(name, ...) \
113 namespace qi \
114 { \
115 namespace detail \
116 { \
117 template <> \
118 struct StructVersioningDelegateDropFields<name> \
119 { \
120 static bool convertTo(StructTypeInterface* type, \
121 std::map<std::string, ::qi::AnyValue>& fields, \
122 const std::vector<std::tuple<std::string, TypeInterface*>>& missing) \
123 { \
124 static const char* which[] = {__VA_ARGS__}; \
125 const int count = sizeof(which) / sizeof(char*); \
126 return fillMissingFieldsWithDefaultValues(fields, missing, which, count); \
127 } \
128 static bool convertFrom(const std::map<std::string, ::qi::AnyReference>& todrop) \
129 { \
130 static const char* which[] = {__VA_ARGS__}; \
131 const int count = sizeof(which) / sizeof(char*); \
132 for (const auto& field : todrop) \
133 if (std::find(which, which + count, field.first) == which + count) \
134 return false; \
135 return true; \
136 } \
137 }; \
138 } \
139 }
140
155 #define QI_TYPE_STRUCT_EXTENSION_CONVERT_HANDLERS(name, fromHandler, toHandler) \
156 namespace qi \
157 { \
158 namespace detail \
159 { \
160 template <> \
161 struct StructVersioningDelegate<name> \
162 { \
163 static bool convertFrom(StructTypeInterface* type, \
164 std::map<std::string, ::qi::AnyValue>& fields, \
165 const std::vector<std::tuple<std::string, TypeInterface*>>& missing, \
166 const std::map<std::string, ::qi::AnyReference>& dropfields) \
167 { \
168 return fromHandler(fields, missing, dropfields); \
169 } \
170 static bool convertTo(StructTypeInterface* type, \
171 std::map<std::string, ::qi::AnyValue>& fields, \
172 const std::vector<std::tuple<std::string, TypeInterface*>>& missing, \
173 const std::map<std::string, ::qi::AnyReference>& dropfields) \
174 { \
175 return toHandler(fields, missing, dropfields); \
176 } \
177 }; \
178 } \
179 }
180
181 //keep only the class name. (remove :: and namespaces)
182 QI_API std::string normalizeClassName(const std::string &name);
183
184 template<typename T> void setFromStorage(T& ref, void* storage)
185 {
186 ref = *(T*)typeOf<T>()->ptrFromStorage(&storage);
187 }
188
189 /* Helpers around accessors
190 */
191 template<typename A> TypeInterface* fieldType(A)
192 {
193 static TypeInterface* res = 0;
194 QI_ONCE(res = qi::typeOf<typename detail::Accessor<A>::value_type>());
195 return res;
196 }
197
198 template<typename C, typename A> void* fieldStorage(C* inst, A accessor)
199 {
200 return fieldType(accessor)->initializeStorage(
201 (void*)&detail::Accessor<A>::access(inst, accessor));
202 }
203
204 template<typename C, typename A>
205 typename detail::Accessor<A>::value_type&
206 fieldValue(C* instance, A accessor, void** data)
207 {
208 using T = typename detail::Accessor<A>::value_type;
209 return *(T*)fieldType(accessor)->ptrFromStorage(data);
210 }
211 }
212 }
213
214 #define __QI_TYPE_STRUCT_DECLARE(name, extra) \
215 namespace qi \
216 { \
217 template <> \
218 struct TypeImpl<name> : public ::qi::StructTypeInterface \
219 { \
220 public: \
221 using ClassType = name; \
222 TypeImpl(); \
223 std::vector<::qi::TypeInterface*> memberTypes() override; \
224 std::vector<std::string> elementsName() override; \
225 std::string className() override; \
226 void* get(void* storage, unsigned int index) override; \
227 void set(void** storage, unsigned int index, void* valStorage) override; \
228 virtual bool convertFrom(std::map<std::string, ::qi::AnyValue>& fields, \
229 const std::vector<std::tuple<std::string, TypeInterface*>>& missing, \
230 const std::map<std::string, ::qi::AnyReference>& dropfields) override; \
231 virtual bool convertTo(std::map<std::string, ::qi::AnyValue>& fields, \
232 const std::vector<std::tuple<std::string, TypeInterface*>>& missing, \
233 const std::map<std::string, ::qi::AnyReference>& dropfields) override; \
234 extra using Impl = ::qi::DefaultTypeImplMethods<name, ::qi::TypeByPointerPOD<name>>; \
235 _QI_BOUNCE_TYPE_METHODS(Impl); \
236 }; \
237 }
238
239 #define __QI_TUPLE_TYPE(_, what, field) res.push_back(::qi::typeOf(ptr->field));
240 #define __QI_TUPLE_GET(_, what, field) if (i == index) return ::qi::typeOf(ptr->field)->initializeStorage(&ptr->field); i++;
241 #define __QI_TUPLE_SET(_, what, field) if (i == index) ::qi::detail::setFromStorage(ptr->field, valueStorage); i++;
242 #define __QI_TUPLE_FIELD_NAME(_, what, field) res.push_back(BOOST_PP_STRINGIZE(QI_DELAY(field)));
243 #define __QI_TYPE_STRUCT_IMPLEMENT(name, inl, onSet, ...) \
244 namespace qi \
245 { \
246 inl TypeImpl<name>::TypeImpl() \
247 { \
248 ::qi::registerStruct(this); \
249 } \
250 inl std::vector<::qi::TypeInterface*> TypeImpl<name>::memberTypes() \
251 { \
252 name* ptr = 0; \
253 std::vector<::qi::TypeInterface*> res; \
254 QI_VAARGS_APPLY(__QI_TUPLE_TYPE, _, __VA_ARGS__); \
255 return res; \
256 } \
257 inl void* TypeImpl<name>::get(void* storage, unsigned int index) \
258 { \
259 unsigned int i = 0; \
260 name* ptr = (name*)ptrFromStorage(&storage); \
261 QI_VAARGS_APPLY(__QI_TUPLE_GET, _, __VA_ARGS__); \
262 return 0; \
263 } \
264 inl void TypeImpl<name>::set(void** storage, unsigned int index, void* valueStorage) \
265 { \
266 unsigned int i = 0; \
267 name* ptr = (name*)ptrFromStorage(storage); \
268 QI_VAARGS_APPLY(__QI_TUPLE_SET, _, __VA_ARGS__); \
269 onSet \
270 } \
271 inl std::vector<std::string> TypeImpl<name>::elementsName() \
272 { \
273 std::vector<std::string> res; \
274 QI_VAARGS_APPLY(__QI_TUPLE_FIELD_NAME, _, __VA_ARGS__); \
275 return res; \
276 } \
277 inl std::string TypeImpl<name>::className() \
278 { \
279 return ::qi::detail::normalizeClassName(BOOST_PP_STRINGIZE(name)); \
280 } \
281 inl bool TypeImpl<name>::convertFrom(std::map<std::string, ::qi::AnyValue>& fields, \
282 const std::vector<std::tuple<std::string, TypeInterface*>>& missing, \
283 const std::map<std::string, ::qi::AnyReference>& dropfields) \
284 { \
285 return ::qi::detail::StructVersioningDelegate<name>::convertFrom(this, fields, missing, dropfields); \
286 } \
287 inl bool TypeImpl<name>::convertTo(std::map<std::string, ::qi::AnyValue>& fields, \
288 const std::vector<std::tuple<std::string, TypeInterface*>>& missing, \
289 const std::map<std::string, ::qi::AnyReference>& dropfields) \
290 { \
291 return ::qi::detail::StructVersioningDelegate<name>::convertTo(this, fields, missing, dropfields); \
292 } \
293 }
294
296 #define QI_STRUCT_HELPER(name, func) (name, func, FUNC)
297 #define QI_STRUCT_FIELD(name, field) (name, field, FIELD)
299
300 // construct pointer-to accessor from free-function
301 #define __QI_STRUCT_ACCESS_FUNC(fname, field) &field
302 // construct pointer-to-accessor from member function/field
303 #define __QI_STRUCT_ACCESS_FIELD(fname, field) &ClassType::field
304
305 // invoke the correct __QI_STRUCT_ACCESS_ macro using type
306 #define __QI_STRUCT_ACCESS_BOUNCE2(name, accessor, type) \
307 QI_CAT(__QI_STRUCT_ACCESS_, type)(name, accessor)
308
309 // bounce with default value FIELD for argument 3
310 #define __QI_STRUCT_ACCESS_BOUNCE1(x, y) \
311 __QI_STRUCT_ACCESS_BOUNCE2(x, y, FIELD)
312
313 // arg-count overload, bounce to __QI_STRUCT_ACCESS_BOUNCE<N>
314 #define __QI_STRUCT_ACCESS_BOUNCE(...) \
315 QI_CAT(__QI_STRUCT_ACCESS_BOUNCE, QI_LIST_VASIZE((__VA_ARGS__)))(__VA_ARGS__)
316
317 // accept (name, accessor, type) and (name, accessor) defaulting type to field
318 #define __QI_STRUCT_ACCESS(tuple) QI_DELAY(__QI_STRUCT_ACCESS_BOUNCE)tuple
319
320
321 #define __QI_ATUPLE_TYPE(_, what, field) res.push_back(::qi::detail::fieldType(__QI_STRUCT_ACCESS(field)));
322 #define __QI_ATUPLE_GET(_, what, field) if (i == index) return ::qi::detail::fieldStorage(ptr, __QI_STRUCT_ACCESS(field)); i++;
323 #define __QI_ATUPLE_FIELD_NAME(_, what, field) res.push_back(QI_PAIR_FIRST(field));
324 #define __QI_ATUPLE_FROMDATA(idx, what, field) ::qi::detail::fieldValue(ptr, __QI_STRUCT_ACCESS(field), const_cast<void**>(&data[idx]))
325 #define __QI_TYPE_STRUCT_AGREGATE_CONSTRUCTOR_IMPLEMENT(name, inl, onSet, ...) \
326 namespace qi \
327 { \
328 inl TypeImpl<name>::TypeImpl() \
329 { \
330 ::qi::registerStruct(this); \
331 } \
332 inl std::vector<::qi::TypeInterface*> TypeImpl<name>::memberTypes() \
333 { \
334 std::vector<::qi::TypeInterface*> res; \
335 QI_VAARGS_APPLY(__QI_ATUPLE_TYPE, name, __VA_ARGS__); \
336 return res; \
337 } \
338 \
339 inl void* TypeImpl<name>::get(void* storage, unsigned int index) \
340 { \
341 unsigned int i = 0; \
342 name* ptr = (name*)ptrFromStorage(&storage); \
343 QI_VAARGS_APPLY(__QI_ATUPLE_GET, name, __VA_ARGS__); \
344 return 0; \
345 } \
346 \
347 inl void TypeImpl<name>::set(void** storage, unsigned int index, void* valueStorage) \
348 { \
349 throw std::runtime_error("single-field set not implemented"); \
350 } \
351 \
352 inl void TypeImpl<name>::set(void** storage, const std::vector<void*>& data) \
353 { \
354 name* ptr = (name*)ptrFromStorage(storage); \
355 *ptr = name(QI_VAARGS_MAP(__QI_ATUPLE_FROMDATA, name, __VA_ARGS__)); \
356 } \
357 \
358 inl std::vector<std::string> TypeImpl<name>::elementsName() \
359 { \
360 std::vector<std::string> res; \
361 QI_VAARGS_APPLY(__QI_ATUPLE_FIELD_NAME, _, __VA_ARGS__); \
362 return res; \
363 } \
364 inl std::string TypeImpl<name>::className() \
365 \
366 { \
367 return ::qi::detail::normalizeClassName(BOOST_PP_STRINGIZE(name)); \
368 } \
369 inl bool TypeImpl<name>::convertFrom(std::map<std::string, ::qi::AnyValue>& fields, \
370 const std::vector<std::tuple<std::string, TypeInterface*>>& missing, \
371 const std::map<std::string, ::qi::AnyReference>& dropfields) \
372 { \
373 return false; \
374 } \
375 inl bool TypeImpl<name>::convertTo(std::map<std::string, ::qi::AnyValue>& fields, \
376 const std::vector<std::tuple<std::string, TypeInterface*>>& missing, \
377 const std::map<std::string, ::qi::AnyReference>& dropfields) \
378 { \
379 return false; \
380 } \
381 }
382
384 #define QI_TYPE_STRUCT_PRIVATE_ACCESS(name) \
385 friend class qi::TypeImpl<name>;
386
396 #define QI_TYPE_STRUCT(name, ...) \
397 QI_TYPE_STRUCT_DECLARE(name) \
398 __QI_TYPE_STRUCT_IMPLEMENT(name, inline, , __VA_ARGS__)
399
403 #define QI_TYPE_STRUCT_EX(name, onSet, ...) \
404 QI_TYPE_STRUCT_DECLARE(name) \
405 __QI_TYPE_STRUCT_IMPLEMENT(name, inline, onSet, __VA_ARGS__)
406
407 #define QI_TYPE_STRUCT_IMPLEMENT(name, ...) \
408 __QI_TYPE_STRUCT_IMPLEMENT(name, , , __VA_ARGS__)
409
432 #define QI_TYPE_STRUCT_AGREGATE_CONSTRUCTOR(name, ...) \
433 __QI_TYPE_STRUCT_DECLARE(name, \
434 void set(void** storage, const std::vector<void*>&) override;) \
435 __QI_TYPE_STRUCT_AGREGATE_CONSTRUCTOR_IMPLEMENT(name, inline, , __VA_ARGS__)
436
443 #define QI_TYPE_STRUCT_REGISTER(name, ...) \
444 namespace _qi_ { \
445 QI_TYPE_STRUCT(name, __VA_ARGS__) \
446 } \
447 QI_TYPE_REGISTER_CUSTOM(name, _qi_::qi::TypeImpl<name>)
448
454 #define QI_TYPE_STRUCT_AGREGATE_CONSTRUCTOR_REGISTER(name, ...) \
455 namespace _qi_ { \
456 QI_TYPE_STRUCT_AGREGATE_CONSTRUCTOR(name, __VA_ARGS__); \
457 } \
458 QI_TYPE_REGISTER_CUSTOM(name, _qi_::qi::TypeImpl<name>)
459
467 #define QI_TYPE_STRUCT_BOUNCE(name, bounceTo, conversion) \
468 namespace qi { \
469 template<> class TypeImpl<name>: public ::qi::StructTypeInterfaceBouncer<name, bounceTo> \
470 { \
471 public: \
472 void adaptStorage(void** storage, void** adapted) \
473 { \
474 name* ptr = (name*)ptrFromStorage(storage); \
475 bounceTo * tptr = conversion(ptr); \
476 *adapted = bounceType()->initializeStorage(tptr); \
477 } \
478 std::string className() \
479 { \
480 return ::qi::detail::normalizeClassName(BOOST_PP_STRINGIZE(name)); \
481 } \
482 };}
483
487 #define QI_TYPE_STRUCT_BOUNCE_REGISTER(name, bounceTo, conversion) \
488 namespace _qi_ { \
489 QI_TYPE_STRUCT_BOUNCE(name, bounceTo, conversion); \
490 } \
491 QI_TYPE_REGISTER_CUSTOM(name, _qi_::qi::TypeImpl<name>)
492
493
494
495 namespace qi {
496 template<typename T, typename TO>
497 class StructTypeInterfaceBouncer: public StructTypeInterface
498 {
499 public:
500 StructTypeInterface* bounceType()
501 {
502 static TypeInterface* result = 0;
503 if (!result)
504 result = typeOf<TO>();
505 return static_cast<StructTypeInterface*>(result);
506 }
507
508 virtual void adaptStorage(void** storage, void** adapted) = 0;
509
510 using Methods = DefaultTypeImplMethods<T, TypeByPointerPOD<T>>;
511 std::vector<TypeInterface*> memberTypes() override
512 {
513 return bounceType()->memberTypes();
514 }
515
516 void* get(void* storage, unsigned int index) override
517 {
518 void* astorage;
519 adaptStorage(&storage, &astorage);
520 return bounceType()->get(astorage, index);
521 }
522
523 std::vector<void*> get(void* storage) override
524 {
525 void* astorage;
526 adaptStorage(&storage, &astorage);
527 return bounceType()->get(astorage);
528 }
529
530 void set(void** storage, const std::vector<void*>& vals) override
531 {
532 void* astorage;
533 adaptStorage(storage, &astorage);
534 bounceType()->set(&astorage, vals);
535 }
536
537 void set(void** storage, unsigned int index, void* valStorage) override
538 {
539 void* astorage;
540 adaptStorage(storage, &astorage);
541 bounceType()->set(&astorage, index, valStorage);
542 }
543
544 std::vector<std::string> elementsName() override
545 {
546 return bounceType()->elementsName();
547 }
548
549 virtual bool convertFrom(std::map<std::string, qi::AnyValue>& fields,
550 const std::vector<std::tuple<std::string, TypeInterface*>>& missing,
551 const std::map<std::string, qi::AnyReference>& dropfields) override
552 {
553 return bounceType()->convertFrom(fields, missing, dropfields);
554 }
555
556 virtual bool convertTo(std::map<std::string, qi::AnyValue>& fields,
557 const std::vector<std::tuple<std::string, TypeInterface*>>& missing,
558 const std::map<std::string, qi::AnyReference>& dropfields) override
559 {
560 return bounceType()->convertTo(fields, missing, dropfields);
561 }
562
563 _QI_BOUNCE_TYPE_METHODS(Methods);
564 };
565
566 template<typename F, typename S>
567 class TypeImpl<std::pair<F, S> >: public StructTypeInterface
568 {
569 public:
570 using Methods = DefaultTypeImplMethods<std::pair<F, S>, TypeByPointerPOD<std::pair<F,S>>>;
571 using BackendType = typename std::pair<F, S>;
572 TypeImpl()
573 {
574 _memberTypes.push_back(typeOf<F>());
575 _memberTypes.push_back(typeOf<S>());
576 }
577 std::vector<TypeInterface*> _memberTypes;
578
579 std::vector<TypeInterface*> memberTypes() override { return _memberTypes;}
580 void* get(void* storage, unsigned int index) override
581 {
582 BackendType* ptr = (BackendType*)ptrFromStorage(&storage);
583 // Will work if F or S are references
584 if (!index)
585 return typeOf<F>()->initializeStorage(const_cast<void*>((void*)&ptr->first));
586 else
587 return typeOf<S>()->initializeStorage(const_cast<void*>((void*)&ptr->second));
588 }
589 void set(void** storage, unsigned int index, void* valStorage) override
590 {
591 BackendType* ptr = (BackendType*)ptrFromStorage(storage);
592 const std::vector<TypeInterface*>& types = _memberTypes;
593
594
595 // FIXME cheating, we do not go through TypeInterface of S and F for copy
596 // because typeerasure does not expose the interface
597 if (!index)
598 detail::TypeTraitCopy<typename boost::remove_const<F>::type, true>::copy(const_cast<void*>((void*)&ptr->first), types[0]->ptrFromStorage(&valStorage));
599 else
600 detail::TypeTraitCopy<typename boost::remove_const<S>::type, true>::copy(const_cast<void*>((void*)&ptr->second), types[1]->ptrFromStorage(&valStorage));
601 }
602 _QI_BOUNCE_TYPE_METHODS(Methods);
603 };
604
605 }
606 #endif // _QITYPE_DETAIL_TYPETUPLE_HXX_
qi::TypeInterface::ptrFromStorage
virtual void * ptrFromStorage(void **)=0
qi::TypeImpl
Definition: typeimpl.hxx:300
qi::StructTypeInterfaceBouncer::set
void set(void **storage, const std::vector< void * > &vals) override
Set all the fields of the struct (copies the values given in the vector)
Definition: structtypeinterface.hxx:530
qi::detail::setFromStorage
void setFromStorage(T &ref, void *storage)
Definition: structtypeinterface.hxx:184
QI_API
#define QI_API
Definition: api.hpp:33
qi::StructTypeInterfaceBouncer::memberTypes
std::vector< TypeInterface * > memberTypes() override
Definition: structtypeinterface.hxx:511
qi::detail::TypeTraitCopy
Definition: typeimpl.hxx:45
qi::StructTypeInterfaceBouncer::Methods
DefaultTypeImplMethods< T, TypeByPointerPOD< T >> Methods
Definition: structtypeinterface.hxx:510
qi::detail::StructVersioningDelegate
Definition: structtypeinterface.hxx:58
qi::detail::StructVersioningDelegate::convertFrom
static bool convertFrom(StructTypeInterface *type, std::map< std::string, qi::AnyValue > &fields, const std::vector< std::tuple< std::string, TypeInterface * >> &missing, const std::map< std::string, qi::AnyReference > &dropfields)
Definition: structtypeinterface.hxx:60
preproc.hpp
fwd.hpp
qi::detail::StructVersioningDelegateDropFields
Definition: structtypeinterface.hxx:43
qi::detail::StructVersioningDelegateDropFields::convertFrom
static bool convertFrom(const std::map< std::string, qi::AnyReference > &dropFields)
Definition: structtypeinterface.hxx:51
api.hpp
dll import/export and compiler message
qi::TypeInterface::initializeStorage
virtual void * initializeStorage(void *ptr=nullptr)=0
qi::StructTypeInterfaceBouncer::convertTo
virtual bool convertTo(std::map< std::string, qi::AnyValue > &fields, const std::vector< std::tuple< std::string, TypeInterface * >> &missing, const std::map< std::string, qi::AnyReference > &dropfields) override
Definition: structtypeinterface.hxx:556
qi::StructTypeInterface::convertFrom
virtual bool convertFrom(std::map< std::string,::qi::AnyValue > &fields, const std::vector< std::tuple< std::string, TypeInterface * >> &missing, const std::map< std::string,::qi::AnyReference > &dropfields)
Fill missing fields caused by conversion from a different struct. Return whether fill succeeded...
Definition: typeinterface.hpp:288
qi::detail::fillMissingFieldsWithDefaultValues
bool fillMissingFieldsWithDefaultValues(std::map< std::string,::qi::AnyValue > &fields, const std::vector< std::tuple< std::string, TypeInterface * >> &missing, const char **which=0, int whichLength=0)
qi::TypeInterface
Definition: typeinterface.hpp:129
qi::StructTypeInterface::memberTypes
virtual std::vector< TypeInterface * > memberTypes()=0
qi::StructTypeInterfaceBouncer::_QI_BOUNCE_TYPE_METHODS
_QI_BOUNCE_TYPE_METHODS(Methods)
qi::detail::fieldValue
detail::Accessor< A >::value_type & fieldValue(C *instance, A accessor, void **data)
Definition: structtypeinterface.hxx:206
qi::detail::StructVersioningDelegateAddFields
Definition: structtypeinterface.hxx:29
qi::TypeImpl< std::pair< F, S > >::memberTypes
std::vector< TypeInterface * > memberTypes() override
Definition: structtypeinterface.hxx:579
_QI_BOUNCE_TYPE_METHODS
#define _QI_BOUNCE_TYPE_METHODS(Bounce)
Implement all methods of Type as bouncers to Bouncer.
Definition: typeimpl.hxx:273
qi::TypeImpl< std::pair< F, S > >::_memberTypes
std::vector< TypeInterface * > _memberTypes
Definition: structtypeinterface.hxx:577
qi::DefaultTypeImpl< T >::ptrFromStorage
void * ptrFromStorage(void **s) override
Definition: typeimpl.hxx:292
qi::DefaultTypeImplMethods
Definition: typeimpl.hxx:228
qi::detail::StructVersioningDelegate::convertTo
static bool convertTo(StructTypeInterface *type, std::map< std::string,::qi::AnyValue > &fields, const std::vector< std::tuple< std::string, TypeInterface * >> &missing, const std::map< std::string,::qi::AnyReference > &dropfields)
Definition: structtypeinterface.hxx:68
QI_ONCE
#define QI_ONCE(code)
Execute code once, parallel calls are blocked until code finishes.
Definition: atomic.hpp:420
qi::StructTypeInterface::get
virtual std::vector< void * > get(void *storage)
Get all the fields storages of the struct (not a copy)
qi::StructTypeInterface::elementsName
virtual std::vector< std::string > elementsName()
Get the names of the fields of the struct.
Definition: typeinterface.hpp:264
qi::StructTypeInterfaceBouncer::set
void set(void **storage, unsigned int index, void *valStorage) override
Set the fields of the struct at index (copies the value given)
Definition: structtypeinterface.hxx:537
qi::DefaultTypeImpl< T >::initializeStorage
void * initializeStorage(void *ptr=0) override
Definition: typeimpl.hxx:292
qi::StructTypeInterfaceBouncer::adaptStorage
virtual void adaptStorage(void **storage, void **adapted)=0
qi::TypeByPointerPOD
Definition: typeimpl.hxx:178
qi::StructTypeInterfaceBouncer::bounceType
StructTypeInterface * bounceType()
Definition: structtypeinterface.hxx:500
qi::TypeImpl< std::pair< F, S > >::TypeImpl
TypeImpl()
Definition: structtypeinterface.hxx:572
accessor.hxx
qi::typeOf
TypeInterface * typeOf()
Definition: type.hxx:94
qi::detail::fieldStorage
void * fieldStorage(C *inst, A accessor)
Definition: structtypeinterface.hxx:198
qi::detail::fieldType
TypeInterface * fieldType(A)
Definition: structtypeinterface.hxx:191
qi::log::env::QI_DEFAULT_LOGHANDLER::name
char const *const name
qi::StructTypeInterface::set
virtual void set(void **storage, const std::vector< void * > &)
Set all the fields of the struct (copies the values given in the vector)
typeinterface.hpp
qi::TypeImpl< std::pair< F, S > >::set
void set(void **storage, unsigned int index, void *valStorage) override
Set the fields of the struct at index (copies the value given)
Definition: structtypeinterface.hxx:589
qi::StructTypeInterface::convertTo
virtual bool convertTo(std::map< std::string,::qi::AnyValue > &fields, const std::vector< std::tuple< std::string, TypeInterface * >> &missing, const std::map< std::string,::qi::AnyReference > &dropfields)
Fill missing fields caused by conversion to a different struct. Return whether fill succeeded...
Definition: typeinterface.hpp:295
qi::detail::StructVersioningDelegateDropFields::convertTo
static bool convertTo(StructTypeInterface *type, std::map< std::string,::qi::AnyValue > &fields, const std::vector< std::tuple< std::string, TypeInterface * >> &missing)
Definition: structtypeinterface.hxx:45
qi::detail::StructVersioningDelegateAddFields::convertFrom
static bool convertFrom(StructTypeInterface *type, std::map< std::string, qi::AnyValue > &fields, const std::vector< std::tuple< std::string, TypeInterface * >> &missing)
Definition: structtypeinterface.hxx:31
qi::detail::normalizeClassName
std::string normalizeClassName(const std::string &name)
qi::StructTypeInterfaceBouncer
Definition: structtypeinterface.hxx:497
qi::TypeImpl< std::pair< F, S > >::BackendType
typename std::pair< F, S > BackendType
Definition: structtypeinterface.hxx:571
qi::StructTypeInterface
Definition: typeinterface.hpp:241
qi::StructTypeInterfaceBouncer::elementsName
std::vector< std::string > elementsName() override
Get the names of the fields of the struct.
Definition: structtypeinterface.hxx:544
qi::StructTypeInterfaceBouncer::convertFrom
virtual bool convertFrom(std::map< std::string, qi::AnyValue > &fields, const std::vector< std::tuple< std::string, TypeInterface * >> &missing, const std::map< std::string, qi::AnyReference > &dropfields) override
Definition: structtypeinterface.hxx:549
qi::detail::StructVersioningDelegateAddFields::convertTo
static bool convertTo(const std::map< std::string, qi::AnyReference > &dropFields)
Definition: structtypeinterface.hxx:37