yasmine
caller_adapter.hpp
Go to the documentation of this file.
1 // //
3 // This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). //
4 // Copyright (C) 2016-2017 Seadex GmbH //
5 // //
6 // Licensing information is available in the folder "license" which is part of this distribution. //
7 // The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. //
8 // //
10 
11 #ifndef CALLER_ADAPTER_031DC27E_9A5F_4D54_A107_310F31977E26
12 #define CALLER_ADAPTER_031DC27E_9A5F_4D54_A107_310F31977E26
13 
14 #ifndef SX_CPP03_BOOST
15 
16 #include "essentials/compatibility/compatibility.hpp"
17 
18 
19 namespace sxy
20 {
21 
22 
23 class event_collector;
24 
25 
26 }
27 
28 
29 template<typename T>
30 sxe::function<void()> adapt( T* _class, void ( T::*method )() )
31 {
32  return( [_class, method]()
33  {
34  ( _class->*method )();
35  }
36  );
37 }
38 
39 
40 template<typename T>
41 sxe::function<void()> adapt( T* _class, void ( T::*method )( ) const )
42 {
43  return( [_class, method]()
44  {
45  ( _class->*method )( );
46  }
47  );
48 }
49 
50 
51 template<typename T, typename _event_type>
52 sxe::function<void( const _event_type& )> adapt( T* _class,
53  void ( T::*method )( const _event_type& ) )
54 {
55  return( [_class, method]( const _event_type& _event)
56  {
57  ( _class->*method )( _event );
58  }
59  );
60 }
61 
62 
63 template<typename T, typename _event_type>
64 sxe::function<void( const _event_type&)> adapt( T* _class,
65  void ( T::*method )( const _event_type& ) const )
66 {
67  return( [_class, method]( const _event_type& _event )
68  {
69  ( _class->*method )( _event );
70  }
71  );
72 }
73 
74 
75 template<typename T>
76 sxe::function<void( sxy::event_collector& )> adapt( T* _class,
77  void ( T::*method )( sxy::event_collector& ) )
78 {
79  return( [_class, method]( sxy::event_collector& _event_collector )
80  {
81  ( _class->*method )( _event_collector );
82  }
83  );
84 }
85 
86 
87 template<typename T>
88 sxe::function<void( sxy::event_collector& )> adapt( T* _class,
89  void ( T::*method )( sxy::event_collector& ) const )
90 {
91  return( [_class, method]( sxy::event_collector& _event_collector )
92  {
93  ( _class->*method )( _event_collector );
94  }
95  );
96 }
97 
98 
99 template<typename T, typename _event_type>
100 sxe::function<void( const _event_type&, sxy::event_collector& )> adapt( T* _class,
101  void ( T::*method )( const _event_type&, sxy::event_collector& ) )
102 {
103  return( [_class, method]( const _event_type& _event, sxy::event_collector& _event_collector )
104  {
105  ( _class->*method )( _event, _event_collector );
106  }
107  );
108 }
109 
110 
111 template<typename T, typename _event_type>
112 sxe::function<void( const _event_type&, sxy::event_collector& )> adapt( T* _class,
113  void ( T::*method )( const _event_type&, sxy::event_collector& ) const )
114 {
115  return( [_class, method]( const _event_type& _event, sxy::event_collector& _event_collector )
116  {
117  ( _class->*method )( _event, _event_collector );
118  }
119  );
120 }
121 
122 
123 sxe::function<void()> adapt_function( void( *_function )() );
124 
125 
126 template< typename _event_type >
127 sxe::function<void( const _event_type& )> adapt_function(
128  void ( *_function )( const _event_type& ) )
129 {
130  return( [ _function ]( const _event_type& _event )
131  {
132  ( *_function )( _event );
133  }
134  );
135 }
136 
137 
138 sxe::function<void( sxy::event_collector& )> adapt_function( void( *_function )( sxy::event_collector& ) );
139 
140 
141 template< typename _event_type >
142 sxe::function<void( const _event_type&, sxy::event_collector& )> adapt_function(
143  void( *_function )( const _event_type&, sxy::event_collector& ) )
144 {
145  return( [ _function ]( const _event_type& _event, sxy::event_collector& _event_collector )
146  {
147  ( *_function )( _event, _event_collector );
148  }
149  );
150 }
151 
152 
153 
154 template<typename T>
155 sxe::function<bool()> adapt( T* _class, bool ( T::*method )() )
156 {
157  return( [_class, method]()
158  {
159  return( ( _class->*method )( ) );
160  }
161  );
162 }
163 
164 
165 template<typename T>
166 sxe::function<bool()> adapt( T* _class, bool ( T::*method )() const )
167 {
168  return( [_class, method]()
169  {
170  return( ( _class->*method )( ) );
171  }
172  );
173 }
174 
175 
176 template<typename T, typename _event_type>
177 sxe::function<bool( const _event_type& )> adapt( T* _class, bool ( T::*method )( const _event_type& ) )
178 {
179  return( [_class, method]( const _event_type& _event )
180  {
181  return( ( _class->*method )( _event ) );
182  }
183  );
184 }
185 
186 
187 template<typename T, typename _event_type>
188 sxe::function<bool( const _event_type& )> adapt( T* _class, bool ( T::*method )( const _event_type& ) const )
189 {
190  return( [_class, method]( const _event_type& _event )
191  {
192  return( ( _class->*method )( _event ) );
193  }
194  );
195 }
196 
197 
198 template<typename T>
199 sxe::function<bool( sxy::event_collector& )> adapt( T* _class,
200  bool ( T::*method )( sxy::event_collector& ) )
201 {
202  return( [_class, method]( sxy::event_collector& _event_collector )
203  {
204  return ( ( _class->*method )( _event_collector ) );
205  }
206  );
207 }
208 
209 
210 template<typename T>
211 sxe::function<bool( sxy::event_collector& )> adapt( T* _class,
212  bool ( T::*method )( sxy::event_collector& ) const )
213 {
214  return( [_class, method]( sxy::event_collector& _event_collector )
215  {
216  return( ( _class->*method )( _event_collector ) );
217  }
218  );
219 }
220 
221 
222 template<typename T, typename _event_type>
223 sxe::function<bool( const _event_type&, sxy::event_collector& )> adapt( T* _class,
224  bool ( T::*method )( const _event_type&, sxy::event_collector& ) )
225 {
226  return( [_class, method]( const _event_type& _event, sxy::event_collector& _event_collector )
227  {
228  return( ( _class->*method )( _event, _event_collector ) );
229  }
230  );
231 }
232 
233 
234 template<typename T, typename _event_type>
235 sxe::function<bool( const _event_type&, sxy::event_collector& )> adapt( T* _class,
236  bool ( T::*method )( const _event_type&, sxy::event_collector& ) const )
237 {
238  return( [_class, method]( const _event_type& _event, sxy::event_collector& _event_collector )
239  {
240  return( ( _class->*method )( _event, _event_collector ) );
241  }
242  );
243 }
244 
245 
246 sxe::function<bool()> adapt_function( bool( *_function )() );
247 
248 
249 template< typename _event_type >
250 sxe::function<bool( const _event_type& )> adapt_function( bool( *_function )( const _event_type& ) )
251 {
252  return( [_function]( const _event_type& _event )
253  {
254  return( ( *_function )( _event ) );
255  }
256  );
257 }
258 
259 
260 sxe::function<bool( sxy::event_collector& )> adapt_function( bool( *_function )( sxy::event_collector& ) );
261 
262 
263 template< typename _event_type >
264 sxe::function<bool( const _event_type&, sxy::event_collector& )> adapt_function(
265  bool( *_function )( const _event_type&, sxy::event_collector& ) )
266 {
267  return( [_function]( const _event_type& _event, sxy::event_collector& _event_collector )
268  {
269  return( ( *_function )( _event, _event_collector ) );
270  }
271  );
272 }
273 
274 
275 #endif
276 
277 #endif
Definition: event_collector.hpp:25
sxe::function< void()> adapt(T *_class, void(T::*method)())
Definition: caller_adapter.hpp:30
Definition: algorithm_parameters.hpp:16
sxe::function< void(sxy::event_collector &)> adapt_function(void(*_function)(sxy::event_collector &))
Definition: caller_adapter.hpp:138