VisitorTags.hpp
1 #pragma once
2 #include <score/serialization/IsTemplate.hpp>
3 
4 #include <cinttypes>
5 #include <limits>
6 #include <type_traits>
7 
9 template <typename T>
10 concept abstract_base = std::decay_t<T>::is_abstract_base_tag::value;
11 
13 template <typename T>
14 concept identified_object = T::identified_object_tag;
15 
17 template <typename T>
18 concept identified_entity = T::entity_tag;
19 
21 {
22 };
23 struct has_base
24 {
25 };
26 
27 template <typename T, typename U = void>
28 struct base_kind
29 {
30  using type = has_no_base;
31  static constexpr bool value = false;
32 };
33 
34 template <typename T>
35 struct base_kind<T, std::enable_if_t<!std::is_same_v<T, typename T::score_base_type>>>
36 {
37  using type = has_base;
38  static constexpr bool value = true;
39 };
40 
43 {
44 };
45 
48 {
49 };
50 
54 {
55 };
56 
59 {
60 };
61 
64 {
65 };
66 
69 {
70 };
71 
74 {
75 };
76 
79 {
80 };
81 
82 template <typename T>
84 {
85  using type = visitor_default_tag;
86 };
87 
88 template <typename T>
89  requires(!identified_object<T> && abstract_base<T> && !is_custom_serialized<T>::value)
90 struct serialization_tag<T>
91 {
92  using type = visitor_abstract_tag;
93 };
94 
95 template <typename T>
96  requires(
97  identified_object<T> && !identified_entity<T> && !abstract_base<T>
98  && !is_custom_serialized<T>::value)
99 struct serialization_tag<T>
100 {
101  using type = visitor_object_tag;
102 };
103 
104 template <typename T>
105  requires(
106  identified_object<T> && !identified_entity<T> && abstract_base<T>
107  && !is_custom_serialized<T>::value)
108 struct serialization_tag<T>
109 {
110  using type = visitor_abstract_object_tag;
111 };
112 
113 template <typename T>
114  requires(identified_entity<T> && !abstract_base<T> && !is_custom_serialized<T>::value)
115 struct serialization_tag<T>
116 {
117  using type = visitor_entity_tag;
118 };
119 
120 template <typename T>
121  requires(identified_entity<T> && abstract_base<T> && !is_custom_serialized<T>::value)
122 struct serialization_tag<T>
123 {
124  using type = visitor_abstract_entity_tag;
125 };
126 
127 template <typename T>
128  requires(
129  is_template<T>::value
130  && !abstract_base<T> && !identified_object<T> && !is_custom_serialized<T>::value)
131 struct serialization_tag<T>
132 {
133  using type = visitor_template_tag;
134 };
135 
136 template <typename T>
137  requires(is_custom_serialized<T>::value)
138 struct serialization_tag<T>
139 {
140  using type = visitor_template_tag;
141 };
142 
143 template <typename T>
144  requires(std::is_enum<T>::value)
145 struct serialization_tag<T>
146 {
147  using type = visitor_enum_tag;
148 };
149 
150 template <typename T>
152 {
153  using type_limits = std::numeric_limits<std::underlying_type_t<T>>;
154  using int_limits = std::numeric_limits<int32_t>;
155  static constexpr bool value = type_limits::min() >= int_limits::min()
156  && type_limits::max() <= int_limits::max();
157 };
Definition: VisitorTags.hpp:29
Definition: VisitorTags.hpp:152
Definition: VisitorTags.hpp:24
Definition: VisitorTags.hpp:21
Definition: VisitorTags.hpp:84
Classes that inherit from score::Entity and score::SerializableInterface.
Definition: VisitorTags.hpp:64
Definition: VisitorTags.hpp:54
Classes that only inherit from score::SerializableInterface.
Definition: VisitorTags.hpp:43
All the other types.
Definition: VisitorTags.hpp:79
Classes that only inherit from score::Entity.
Definition: VisitorTags.hpp:59
Enums.
Definition: VisitorTags.hpp:74
Classes that only inherit from score::IdentifiedObject.
Definition: VisitorTags.hpp:48
Template classes.
Definition: VisitorTags.hpp:69