policy.h Source File - 0.9.0 |RTTR
policy.h
Go to the documentation of this file.
1 /************************************************************************************
2 * *
3 * Copyright (c) 2014 Axel Menzel <info@axelmenzel.de> *
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_POLICY_H__
29 #define __RTTR_POLICY_H__
30 
32 
33 namespace rttr
34 {
35 
36 namespace detail
37 {
38 
39 struct return_as_ptr
40 {};
41 
42 struct set_as_ptr
43 {};
44 
45 struct return_as_copy
46 {};
47 
48 struct read_only
49 {};
50 
51 struct set_value
52 {};
53 
54 struct discard_return
55 {};
56 
57 struct default_invoke
58 {};
59 
61 
62 // default getter policy
63 template<typename T>
64 struct get_getter_policy
65 {
66  typedef return_as_copy type;
67 };
68 
69 // default setter policy
70 template<typename T>
71 struct get_setter_policy
72 {
73  typedef set_value type;
74 };
75 
77 
78 struct bind_property_as_ptr_policy
79 {};
80 
81 struct return_reference_as_ptr_policy
82 {};
83 
84 struct discard_return_value_policy
85 {};
86 
88 
89 template<typename... T>
90 struct policy_list_impl {};
91 
92 using policy_list = policy_list_impl<bind_property_as_ptr_policy,
93  return_reference_as_ptr_policy,
94  discard_return_value_policy>;
95 
97 
98 template<>
99 struct get_getter_policy<bind_property_as_ptr_policy>
100 {
101  typedef return_as_ptr type;
102 };
103 
104 template<>
105 struct get_setter_policy<bind_property_as_ptr_policy>
106 {
107  typedef set_as_ptr type;
108 };
109 
111 
112 // default method policy
113 template<typename T>
114 struct get_method_policy
115 {
116  typedef default_invoke type;
117 };
118 
120 
121 
122 template<>
123 struct get_method_policy<return_reference_as_ptr_policy>
124 {
125  typedef return_as_ptr type;
126 };
127 
129 
130 template<>
131 struct get_method_policy<discard_return_value_policy>
132 {
133  typedef discard_return type;
134 };
135 
137 
138 RTTR_API extern return_as_copy default_property_policy;
139 
140 } // end namespace detail;
141 
145 RTTR_API extern detail::bind_property_as_ptr_policy bind_property_as_ptr;
146 
150 RTTR_API extern detail::return_reference_as_ptr_policy return_reference_as_ptr;
151 
155 RTTR_API extern detail::discard_return_value_policy discard_return_value;
156 
157 
158 } // end namespace rttr
159 
160 #endif // __RTTR_POLICY_H__
The namespace for all rttr components.
Definition: core_prerequisites.h:33
detail::discard_return_value_policy discard_return_value
detail::return_reference_as_ptr_policy return_reference_as_ptr
#define RTTR_API
Definition: core_prerequisites.h:124
detail::bind_property_as_ptr_policy bind_property_as_ptr