Photon microGUI widgets library 0.6.0
phproperty.hpp
1#ifndef PH_PROPERTY_HPP
2#define PH_PROPERTY_HPP
3
4#include "property.hpp"
5
6namespace PhWidgets
7{
8 struct IPhWidgetsProperty
9 {
10 template<class ReturnT, class WidgetClassT, class ArgumentT, ArgumentT ArgumentID>
11 inline ReturnT getArgument() const
12 {
13 return static_cast<const WidgetClassT*>(this)->resource.argument[ArgumentID].get();
14 }
15
16 template<class ValueT, class WidgetClassT, class ArgumentT, ArgumentT ArgumentID>
17 inline void setArgument(ValueT val)
18 {
19 static_cast<const WidgetClassT*>(this)->resource.argument[ArgumentID].set(val);
20 }
21 };
22
23 template<class ValueT = void,
24 const cppproperties::detail::property_flag::e_property_flag Flag = (const cppproperties::detail::property_flag::e_property_flag)(cppproperties::detail::flag_chooser<ValueT>::flag)>
25 class phproperty{};
26
27 //phproperty<void>:
28 template<>
29 class phproperty<void, cppproperties::detail::property_flag::ro> :
30 public cppproperties::detail::property_flag
31 {
32 public:
33 typedef cppproperties::detail::property_flag flags;
34 };
35
36 template<>
37 class phproperty<void, cppproperties::detail::property_flag::wo> :
38 public cppproperties::detail::property_flag
39 {
40 public:
41 typedef cppproperties::detail::property_flag flags;
42 };
43
44 template<>
45 class phproperty<void, cppproperties::detail::property_flag::rw> :
46 public cppproperties::detail::property_flag
47 {
48 public:
49 typedef cppproperties::detail::property_flag flags;
50 };
51
52 //phproperty<Value>:
53 template<typename ValueT>
54 class phproperty<ValueT, cppproperties::detail::property_flag::ro>//ValueT == const...
55 {
56 typedef cppproperties::property<ValueT, cppproperties::detail::property_flag::ro> cpp_property_t;
57
58 template<class WidgetClassT, typename cppproperties::detail::property_info<ValueT, WidgetClassT>::getter_t Getter>
59 struct bind_internal :
60 public cpp_property_t::template bind<WidgetClassT, Getter>
61 {
62 explicit bind_internal(WidgetClassT *parent) :
63 cpp_property_t::template bind<WidgetClassT, Getter>(parent)
64 {}
65
66 private:
67 inline bind_internal &operator=(ValueT const &);
68 inline bind_internal &operator=(bind_internal const &);
69 };
70
71 public:
72 template<class WidgetClassT, class ArgumentT, ArgumentT ArgumentID>
73 class bind :
74 public bind_internal<
75 IPhWidgetsProperty,
76 &IPhWidgetsProperty::getArgument<ValueT, WidgetClassT, ArgumentT, ArgumentID>
77 >
78 {
79 typedef bind_internal<
80 IPhWidgetsProperty,
81 &IPhWidgetsProperty::getArgument<ValueT, WidgetClassT, ArgumentT, ArgumentID>
82 > cpp_bind_t;
83
84 public:
85 explicit bind(WidgetClassT *parent) :
86 cpp_bind_t(parent)
87 {}
88
89 private:
90 inline bind &operator=(ValueT const &);
91 inline bind &operator=(bind const &);
92 };
93
94 };
95
96
97 template<typename ValueT>
98 class phproperty<ValueT, cppproperties::detail::property_flag::rw>//ValueT != const...
99 {
100 typedef cppproperties::property<ValueT, cppproperties::detail::property_flag::rw> cpp_property_t;
101
102 template<class WidgetClassT, typename cppproperties::detail::property_info<ValueT, WidgetClassT>::getter_t Getter, typename cppproperties::detail::property_info<ValueT, WidgetClassT>::setter_t Setter>
103 struct bind_internal :
104 public cpp_property_t::template bind<WidgetClassT, Getter, Setter>
105 {
106 explicit bind_internal(WidgetClassT *parent) :
107 cpp_property_t::template bind<WidgetClassT, Getter, Setter>(parent)
108 {}
109
110 using cpp_property_t::template bind<WidgetClassT, Getter, Setter>::operator=;
111 };
112
113 public:
114
115 template<class WidgetClassT, class ArgumentT, ArgumentT ArgumentID>
116 class bind :
117 public bind_internal<
118 IPhWidgetsProperty,
119 &IPhWidgetsProperty::getArgument<ValueT, WidgetClassT, ArgumentT, ArgumentID>,
120 &IPhWidgetsProperty::setArgument<ValueT, WidgetClassT, ArgumentT, ArgumentID>
121 >
122 {
123 typedef bind_internal<
124 IPhWidgetsProperty,
125 &IPhWidgetsProperty::getArgument<ValueT, WidgetClassT, ArgumentT, ArgumentID>,
126 &IPhWidgetsProperty::setArgument<ValueT, WidgetClassT, ArgumentT, ArgumentID>
127 > cpp_bind_t;
128
129 public:
130 explicit bind(WidgetClassT *parent) :
131 cpp_bind_t(parent)
132 {}
133
134 using cpp_bind_t::operator=;
135 };
136
137 };
138
139 template<typename ValueT>
140 class phproperty<ValueT, cppproperties::detail::property_flag::wo>//ValueT != const...
141 {
142 typedef cppproperties::property<ValueT, cppproperties::detail::property_flag::wo> cpp_property_t;
143
144 template<class WidgetClassT, typename cppproperties::detail::property_info<ValueT, WidgetClassT>::setter_t Setter>
145 struct bind_internal :
146 public cpp_property_t::template bind<WidgetClassT, Setter>
147 {
148 bind_internal(WidgetClassT *parent) :
149 cpp_property_t::template bind<WidgetClassT, Setter>(parent)
150 {}
151
152 using cpp_property_t::template bind<WidgetClassT, Setter>::operator=;
153 };
154
155 public:
156 template<class WidgetClassT, class ArgumentT, ArgumentT ArgumentID>
157 class bind :
158 public bind_internal<
159 IPhWidgetsProperty,
160 &IPhWidgetsProperty::setArgument<ValueT, WidgetClassT, ArgumentT, ArgumentID>
161 >
162 {
163 typedef bind_internal<
164 IPhWidgetsProperty,
165 &IPhWidgetsProperty::setArgument<ValueT, WidgetClassT, ArgumentT, ArgumentID>
166 > cpp_bind_t;
167
168 public:
169 explicit bind(WidgetClassT *parent) :
170 cpp_bind_t(parent)
171 {}
172
173 using cpp_bind_t::operator=;
174 };
175
176 };
177}
178
179#endif
The main namespace for all widgets.
Definition: Basic.h:11