visitor.h
Go to the documentation of this file.
1/************************************************************************************
2* *
3* Copyright (c) 2014 - 2018 Axel Menzel <info@rttr.org> *
4* *
5* This file is part of RTTR (Run Time Type Reflection) *
6* License: MIT License *
7* *
8* Permission is hereby granted, free of charge, to any person obtaining *
9* a copy of this software and associated documentation files (the "Software"), *
10* to deal in the Software without restriction, including without limitation *
11* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
12* and/or sell copies of the Software, and to permit persons to whom the *
13* Software is furnished to do so, subject to the following conditions: *
14* *
15* The above copyright notice and this permission notice shall be included in *
16* all copies or substantial portions of the Software. *
17* *
18* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
19* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
20* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
21* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
22* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *
23* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *
24* SOFTWARE. *
25* *
26*************************************************************************************/
27
28#ifndef RTTR_VISITOR_H_
29#define RTTR_VISITOR_H_
30
31#include "rttr/detail/base/core_prerequisites.h"
32#include "rttr/rttr_enable.h"
33#include "rttr/type_list.h"
34#include "rttr/detail/visitor/visitor_registration.h"
35
36#include <type_traits>
37#include <functional>
38#include <tuple>
39
40namespace rttr
41{
42
43class property;
44class method;
45class constructor;
46
99{
100public:
106
111 virtual ~visitor();
112
118 void visit(type t);
119
124 void visit(method meth);
125
130 void visit(constructor ctor);
131
140 void visit(property prop);
141
142#ifdef DOXYGEN
147 template<typename T>
149 {
152
155 };
156
161 template<typename T>
163 {
165 using policy = Policy;
167 };
168
173 template<typename T>
181
186 template<typename T>
188 {
190 using policy = Policy;
193 };
194
199 template<typename T>
201 {
203 using policy = Policy;
204 const property property_item;
206 };
207
212 template<typename T>
221#else
222 template<typename T>
223 struct type_info;
224
225 template<typename T, typename...Base_Classes>
227 {
228 using declaring_type = T;
229 using base_classes = type_list<Base_Classes...>;
230 const type& type_item;
231 };
232
233 template<typename T>
234 struct constructor_info;
235
236 template<typename T, typename Policy, typename...Ctor_args>
237 struct constructor_info<type_list<T, Policy, type_list<Ctor_args...>>>
238 {
239 using declaring_type = T;
240 using ctor_args = type_list<Ctor_args...>;
241 using policy = Policy;
242 const constructor& ctor_item;
243 };
244
245 template<typename T>
246 struct constructor_function_info;
247
248 template<typename T, typename Policy, typename Acc>
249 struct constructor_function_info<type_list<T, Policy, Acc>>
250 {
251 using declaring_type = T;
252 using policy = Policy;
253 const constructor ctor_item;
254 Acc function_ptr;
255 };
256
257 template<typename T>
258 struct method_info;
259
260 template<typename T, typename Policy, typename Acc>
261 struct method_info<type_list<T, Policy, Acc>>
262 {
263 using declaring_type = T;
264 using policy = Policy;
265 const method method_item;
266 Acc function_ptr;
267 };
268
269 template<typename T>
270 struct property_info;
271
272 template<typename T, typename Policy, typename Acc>
273 struct property_info<type_list<T, Policy, Acc>>
274 {
275 using declaring_type = T;
276 using policy = Policy;
277 const property property_item;
278 Acc property_accessor;
279 };
280
281 template<typename T>
282 struct property_getter_setter_info;
283
284 template<typename T, typename Policy, typename Getter, typename Setter>
285 struct property_getter_setter_info<type_list<T, Policy, Getter, Setter>>
286 {
287 using declaring_type = T;
288 using policy = Policy;
289 const property property_item;
290 Getter property_getter;
291 Setter property_setter;
292 };
293#endif
294
315 template<typename T, typename...Base_Classes>
317
338 template<typename T, typename...Base_Classes>
340
355 template<typename T, typename...Ctor_Args>
357
371 template<typename T>
373
386 template<typename T>
388
401 template<typename T>
403
416 template<typename T>
418
431 template<typename T>
433
446 template<typename T>
448
461 template<typename T>
463
476 template<typename T>
478
491 template<typename T>
493
494private:
495 void visit_impl(const type& t);
496
497private:
498 RTTR_ENABLE();
499};
500
501} // end namespace rttr
502
503#include "rttr/detail/visitor/visitor_impl.h"
504
505#endif // RTTR_VISITOR_H_
The array_range class provides a view into an underlying data structure with lower and upper limits.
Definition array_range.h:64
array_range()
Default constructor.
The constructor class provides several meta information about a constructor and can be invoked.
Definition constructor.h:90
The method class provides several meta information about a method and can be invoked.
Definition method.h:122
The property class provides several meta information about a property and gives read/write access to ...
Definition property.h:118
The type class holds the type information for any arbitrary object.
Definition type.h:178
The class visitor, is used for visiting your registered accessors of a type at compile time.
Definition visitor.h:99
void visit_constructor(const constructor_info< T > &info)
This function will be called when you visit a constructor via: visit(type) or directlyvisit(construct...
virtual ~visitor()
The destructor of the visitor class.
void visit(method meth)
Calling this function will indirectly call the function visit_method() for the underlying registered ...
void visit_constructor_function(const constructor_function_info< T > &info)
This function will be called when you visit a constructor function via: visit(type) or visit(construc...
void visit(constructor ctor)
Calling this function will indirectly call the function visit_constructor() or visit_constructor_func...
void visit(type t)
Calling this function will indirectly call the visit functions for all registered types members (cons...
void visit_property(const property_info< T > &info)
This function will be called when you visit a property via: visit(property).
visitor()
The constructor of the visitor class.
void visit_global_method(const method_info< T > &info)
This function will be called when you visit a global method via: visit(method).
void visit(property prop)
Calling this function will indirectly call one of the functions:
void visit_global_property(const property_info< T > &info)
This function will be called when you visit a global property via: visit(property).
void visit_getter_setter_property(const property_getter_setter_info< T > &info)
This function will be called when you visit a property via: visit(property).
void visit_readonly_property(const property_info< T > &info)
This function will be called when you visit a read only property via: visit(property).
void visit_type_begin(const type_info< T > &info)
This function will be called when you visit a type via: visit(type) It is the first function that wil...
void visit_type_end(const type_info< T > &info)
This function will be called when you visit a type via: visit(type).
void visit_global_getter_setter_property(const property_getter_setter_info< T > &info)
This function will be called when you visit a global property via: visit(property).
void visit_global_readonly_property(const property_info< T > &info)
This function will be called when you visit a global read only property via: visit(property).
void visit_method(const method_info< T > &info)
This function will be called when you visit a type method via: visit(type) or visit(method).
Definition access_levels.h:34
#define RTTR_ENABLE(...)
This macro is necessary in order to retrieve type information about the inheritance graph of a class.
Definition rttr_enable.h:76
The policy class contains all policies that can be used during the registration of reflection informa...
Definition policy.h:50
Contains a list of template parameters.
Definition type_list.h:41
The constructor_function_info class is used to forward all information during registration of a const...
Definition visitor.h:175
const constructor ctor_item
The constructor object.
Definition visitor.h:178
Acc function_ptr
The function pointer to create object T.
Definition visitor.h:179
The constructor_info class is used to forward all information during registration of a constructor.
Definition visitor.h:163
const constructor & ctor_item
The constructor object.
Definition visitor.h:166
The method_info class is used to forward all information during registration of a method.
Definition visitor.h:188
Acc function_ptr
The function pointer of the method (can be a member- or free function)
Definition visitor.h:192
const method & method_item
The method object.
Definition visitor.h:191
The method_info class is used to forward all information during registration of a property.
Definition visitor.h:214
Getter property_getter
Definition visitor.h:218
const property property_item
Definition visitor.h:217
Setter property_setter
Definition visitor.h:219
The property_info class is used to forward all information during registration of a property.
Definition visitor.h:201
const property property_item
Definition visitor.h:204
Acc property_accessor
Definition visitor.h:205
The type_info class is used to forward all information during registration of a class.
Definition visitor.h:149
const type & type_item
The type object.
Definition visitor.h:154