Loading...
Searching...
No Matches
reflection.h
Go to the documentation of this file.
1#ifndef _BBM_REFLECTION_CONCEPT_H_
2#define _BBM_REFLECTION_CONCEPT_H_
3
4#include <utility>
5
6/************************************************************************/
7/*! \file refection.h
8
9 \brief attribute and parent class reflection contract. To do: extend to
10 include function and constructor reflection.
11
12*************************************************************************/
13
14namespace bbm {
15
16 namespace reflection {
17 // forward declaration
18 template<typename T> struct bbm_enum;
19 } // end reflection namespace
20
21 namespace concepts {
22 namespace reflection {
23
24 /******************************************************************/
25 /*! \brief attribute reflection allows to enumerate and direct access to
26 the attributes of a class. A class supports reflection if the
27 following typedef and two methods are implemented:
28
29 + typename attribute_tuple_t : a named<tuple> of the types of the attributes (for a non-const struct)
30 + named<std::tuple<...>, ...> attribute_tuple(void) : returns a named<tuple> of references to the attributes
31 + named<std::tuple<...>, ...> attribute_tuple(void) const : returns a named<tuple> of const references to the attributes
32 *******************************************************************/
33 template<typename T>
34 concept attributes = requires(T t)
35 {
36 typename std::decay_t<T>::attribute_tuple_t;
37 { t.attribute_tuple() };
38 { std::as_const(t).attribute_tuple() };
39 };
40
41
42 /******************************************************************/
43 /*! \brief basetypes reflection allows to enumerate all base classes.
44 The class has the following typename:
45
46 + typename reflection_base_t
47 *******************************************************************/
48 template<typename T>
49 concept basetypes = requires
50 {
51 typename std::decay_t<T>::reflection_base_t;
52 };
53
54 /******************************************************************/
55 /*! \brief concept to check if a class supports reflections
56 ******************************************************************/
57 template<typename T>
59
60
61 /******************************************************************/
62 /*! \brief concept to check if a enum supports reflection
63 ******************************************************************/
64 template<typename T>
65 concept enumerate = requires
66 {
68 };
69
70 } // end reflection namespace
71 } // end concepts namespace
72} // end bbm namespace
73
74#endif /* _BBM_REFLECTION_CONCEPT_H_ */
attribute reflection allows to enumerate and direct access to the attributes of a class....
Definition: reflection.h:34
basetypes reflection allows to enumerate all base classes. The class has the following typename:
Definition: reflection.h:49
concept to check if a enum supports reflection
Definition: reflection.h:65
concept to check if a class supports reflections
Definition: reflection.h:58
Definition: reflection.h:18
Definition: aggregatebsdf.h:29