diff options
Diffstat (limited to 'src/FbTk/MemFun.hh')
-rw-r--r-- | src/FbTk/MemFun.hh | 90 |
1 files changed, 89 insertions, 1 deletions
diff --git a/src/FbTk/MemFun.hh b/src/FbTk/MemFun.hh index 4c834dd..c2c6b20 100644 --- a/src/FbTk/MemFun.hh +++ b/src/FbTk/MemFun.hh | |||
@@ -38,7 +38,9 @@ public: | |||
38 | void operator ()() { | 38 | void operator ()() { |
39 | (m_obj.*m_action)(); | 39 | (m_obj.*m_action)(); |
40 | } | 40 | } |
41 | 41 | void call() { | |
42 | (m_obj.*m_action)(); | ||
43 | } | ||
42 | private: | 44 | private: |
43 | Object& m_obj; | 45 | Object& m_obj; |
44 | Action m_action; | 46 | Action m_action; |
@@ -133,6 +135,92 @@ MemFun( Object& obj, ReturnType (Object:: *action)(Arg1, Arg2, Arg3) ) { | |||
133 | return MemFun3<ReturnType, Object, Arg1, Arg2, Arg3>(obj, action); | 135 | return MemFun3<ReturnType, Object, Arg1, Arg2, Arg3>(obj, action); |
134 | } | 136 | } |
135 | 137 | ||
138 | /// Ignores all arguments | ||
139 | template <typename ReturnType, typename Object> | ||
140 | class MemFun0IgnoreArgs: public MemFun0<ReturnType, Object> { | ||
141 | public: | ||
142 | typedef MemFun0<ReturnType, Object> BaseType; | ||
143 | |||
144 | MemFun0IgnoreArgs(Object& obj, | ||
145 | typename BaseType::Action action): | ||
146 | BaseType(obj, action) { | ||
147 | } | ||
148 | |||
149 | template <typename IgnoreType1, typename IgnoreType2, typename IgnoreType3> | ||
150 | void operator ()(IgnoreType1&, IgnoreType2&, IgnoreType3&) { | ||
151 | BaseType::operator ()(); | ||
152 | } | ||
153 | |||
154 | template <typename IgnoreType1, typename IgnoreType2> | ||
155 | void operator ()(IgnoreType1&, IgnoreType2&) { | ||
156 | BaseType::operator ()(); | ||
157 | } | ||
158 | |||
159 | template <typename IgnoreType1> | ||
160 | void operator ()(IgnoreType1&) { | ||
161 | BaseType::operator ()(); | ||
162 | } | ||
163 | }; | ||
164 | |||
165 | /// Ignores second and third argument | ||
166 | template <typename ReturnType, typename Object, typename Arg1> | ||
167 | class MemFun1IgnoreArgs: public MemFun1<ReturnType, Object, Arg1> { | ||
168 | public: | ||
169 | typedef MemFun1<ReturnType, Object, Arg1> BaseType; | ||
170 | |||
171 | MemFun1IgnoreArgs(Object& obj, typename BaseType::Action& action): | ||
172 | BaseType(obj, action) { | ||
173 | } | ||
174 | |||
175 | template <typename IgnoreType1, typename IgnoreType2> | ||
176 | void operator ()(Arg1 arg1, IgnoreType1&, IgnoreType2&) { | ||
177 | BaseType::operator ()(arg1); | ||
178 | } | ||
179 | |||
180 | template <typename IgnoreType> | ||
181 | void operator ()(Arg1 arg1, IgnoreType&) { | ||
182 | BaseType::operator ()(arg1); | ||
183 | } | ||
184 | }; | ||
185 | |||
186 | /// Takes two arguments but ignores the third | ||
187 | template <typename ReturnType, typename Object, typename Arg1, typename Arg2> | ||
188 | class MemFun2IgnoreArgs: public MemFun2<ReturnType, Object, Arg1, Arg2> { | ||
189 | public: | ||
190 | typedef MemFun2<ReturnType, Object, Arg1, Arg2> BaseType; | ||
191 | |||
192 | MemFun2IgnoreArgs(Object& obj, typename BaseType::Action& action): | ||
193 | BaseType(obj, action) { | ||
194 | } | ||
195 | |||
196 | template < typename IgnoreType > | ||
197 | void operator ()(Arg1 arg1, Arg2 arg2, IgnoreType&) { | ||
198 | BaseType::operator ()(arg1, arg2); | ||
199 | } | ||
200 | }; | ||
201 | |||
202 | /// Creates functor that ignores all arguments. | ||
203 | template <typename ReturnType, typename Object> | ||
204 | MemFun0IgnoreArgs<ReturnType, Object> | ||
205 | MemFunIgnoreArgs( Object& obj, ReturnType (Object:: *action)() ) { | ||
206 | return MemFun0IgnoreArgs<ReturnType, Object>(obj, action); | ||
207 | } | ||
208 | |||
209 | /// Creates functor that ignores second and third argument. | ||
210 | template <typename ReturnType, typename Object, typename Arg1> | ||
211 | MemFun1IgnoreArgs<ReturnType, Object, Arg1> | ||
212 | MemFunIgnoreArgs( Object& obj, ReturnType (Object:: *action)(Arg1) ) { | ||
213 | return MemFun1IgnoreArgs<ReturnType, Object, Arg1>(obj, action); | ||
214 | } | ||
215 | |||
216 | /// Creates functor that ignores third argument. | ||
217 | template <typename ReturnType, typename Object, typename Arg1, typename Arg2> | ||
218 | MemFun2IgnoreArgs<ReturnType, Object, Arg1, Arg2> | ||
219 | MemFunIgnoreArgs( Object& obj, ReturnType (Object:: *action)(Arg1,Arg2) ) { | ||
220 | return MemFun2IgnoreArgs<ReturnType, Object, Arg1, Arg2>(obj, action); | ||
221 | } | ||
222 | |||
223 | |||
136 | } // namespace FbTk | 224 | } // namespace FbTk |
137 | 225 | ||
138 | #endif // FBTK_MEM_FUN_HH | 226 | #endif // FBTK_MEM_FUN_HH |