yasmine
create_guard_function.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 
12 #ifndef CREATE_GUARD_FUNCTION_ACA9A120_8AEC_43B3_8745_DDC573C43D63
13 #define CREATE_GUARD_FUNCTION_ACA9A120_8AEC_43B3_8745_DDC573C43D63
14 
15 
16 #include "constraint_fwd.hpp"
17 #include "guard_caller.hpp"
18 
19 
20 #ifndef SX_CPP03_BOOST // C++11
21 
22 #ifdef SX_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG
23 
24 
25 namespace sxy
26 {
27 
28 
29 template< typename function1 >
30 sxy::constraint_function create_guard_function( const function1& _function1 )
31 {
32  return ( sxy::constraint_function( [_function1]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, _function1 ) ); } ) );
33 }
34 
35 
36 template< typename function1, typename function2 >
37 sxy::constraint_function create_guard_function( const function1& _function1, const function2& _function2 )
38 {
39  return ( sxy::constraint_function( [_function1, _function2]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, _function1, _function2 ) ); } ) );
40 }
41 
42 
43 template< typename function1, typename function2, typename function3 >
44 sxy::constraint_function create_guard_function( const function1& _function1, const function2& _function2, const function3& _function3 )
45 {
46  return ( sxy::constraint_function( [_function1, _function2, _function3]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, _function1, _function2, _function3 ) ); } ) );
47 }
48 
49 
50 template< typename function1, typename function2, typename function3, typename function4 >
51 sxy::constraint_function create_guard_function( const function1& _function1, const function2& _function2, const function3& _function3, const function4& _function4 )
52 {
53  return ( sxy::constraint_function( [_function1, _function2, _function3, _function4]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, _function1, _function2, _function3, _function4 ) ); } ) );
54 }
55 
56 
57 template< typename function1, typename function2, typename function3, typename function4, typename function5 >
58 sxy::constraint_function create_guard_function( const function1& _function1, const function2& _function2, const function3& _function3, const function4& _function4, const function5& _function5 )
59 {
60  return ( sxy::constraint_function( [_function1, _function2, _function3, _function4, _function5]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, _function1, _function2, _function3, _function4, _function5 ) ); } ) );
61 }
62 
63 
64 template< typename function1, typename function2, typename function3, typename function4, typename function5, typename function6 >
65 sxy::constraint_function create_guard_function( const function1& _function1, const function2& _function2, const function3& _function3, const function4& _function4, const function5& _function5, const function6& _function6 )
66 {
67  return ( sxy::constraint_function( [_function1, _function2, _function3, _function4, _function5, _function6]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, _function1, _function2, _function3, _function4, _function5, _function6 ) ); } ) );
68 }
69 
70 
71 template< typename function1, typename function2, typename function3, typename function4, typename function5, typename function6, typename function7 >
72 sxy::constraint_function create_guard_function( const function1& _function1, const function2& _function2, const function3& _function3, const function4& _function4, const function5& _function5, const function6& _function6, const function7& _function7 )
73 {
74  return ( sxy::constraint_function( [_function1, _function2, _function3, _function4, _function5, _function6, _function7]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, _function1, _function2, _function3, _function4, _function5, _function6, _function7 ) ); } ) );
75 }
76 
77 
78 template< typename function1, typename function2, typename function3, typename function4, typename function5, typename function6, typename function7, typename function8 >
79 sxy::constraint_function create_guard_function( const function1& _function1, const function2& _function2, const function3& _function3, const function4& _function4, const function5& _function5, const function6& _function6, const function7& _function7, const function8& _function8 )
80 {
81  return ( sxy::constraint_function( [_function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8 ) ); } ) );
82 }
83 
84 
85 template< typename function1, typename function2, typename function3, typename function4, typename function5, typename function6, typename function7, typename function8, typename function9 >
86 sxy::constraint_function create_guard_function( const function1& _function1, const function2& _function2, const function3& _function3, const function4& _function4, const function5& _function5, const function6& _function6, const function7& _function7, const function8& _function8, const function9& _function9 )
87 {
88  return ( sxy::constraint_function( [_function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9 ) ); } ) );
89 }
90 
91 
92 template< typename function1, typename function2, typename function3, typename function4, typename function5, typename function6, typename function7, typename function8, typename function9, typename function10 >
93 sxy::constraint_function create_guard_function( const function1& _function1, const function2& _function2, const function3& _function3, const function4& _function4, const function5& _function5, const function6& _function6, const function7& _function7, const function8& _function8, const function9& _function9, function10 _function10 )
94 {
95  return ( sxy::constraint_function( [_function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9, _function10]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9, _function10 ) ); } ) );
96 }
97 
98 }
99 
100 
101 #else // !SX_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG
102 
103 namespace sxy
104 {
105 
106 
107 template< typename ... Args >
109 {
110  return ( sxy::constraint_function( [args...]( const sxy::event& _event, sxy::event_collector& _event_collector ) { return( guard_caller( _event, _event_collector, args... ) ); } ) );
111 }
112 
113 
114 }
115 
116 
117 #endif // SX_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG
118 
119 
120 #else // C++03 with Boost
121 
122 
123 namespace sxy
124 {
125 
126 
127 sxy::constraint_function create_guard_function( const sxe::function<bool()>& _function );
128 
129 
130 sxy::constraint_function create_guard_function( const sxe::function<bool( sxy::event_collector& )>& _function );
131 
132 
133 template< typename _event_type >
134 sxy::constraint_function create_guard_function( const sxe::function<bool( const _event_type& )>& _function1 )
135 {
136  typedef bool( *guard_caller_selector )( const sxy::event&, sxy::event_collector&, const sxe::function<bool( const _event_type& )>& );
137  return( sxy::constraint_function( sxe::bind( static_cast< guard_caller_selector >( guard_caller ), sxe::_1, sxe::_2, _function1 ) ) );
138 }
139 
140 
141 template< typename _event_type1 >
143  const sxe::function<bool( const _event_type1&, sxy::event_collector& )>& _function1
144 )
145 {
146  typedef bool( *guard_caller_selector )( const sxy::event&, sxy::event_collector&,
147  const sxe::function<bool( const _event_type1&, sxy::event_collector& )>&
148  );
149  return( sxy::constraint_function( sxe::bind( static_cast< guard_caller_selector >( guard_caller ), sxe::_1, sxe::_2, _function1 ) ) );
150 }
151 
152 
153 template< typename _event_type1, typename _event_type2 >
155  const sxe::function<bool( const _event_type1&, sxy::event_collector& )>& _function1,
156  const sxe::function<bool( const _event_type2&, sxy::event_collector& )>& _function2
157 )
158 {
159  typedef bool( *guard_caller_selector )( const sxy::event&, sxy::event_collector&,
160  const sxe::function<bool( const _event_type1&, sxy::event_collector& )>&,
161  const sxe::function<bool( const _event_type2&, sxy::event_collector& )>&
162  );
163  return( sxy::constraint_function( sxe::bind( static_cast< guard_caller_selector >( guard_caller ), sxe::_1, sxe::_2, _function1, _function2 ) ) );
164 }
165 
166 
167 template< typename _event_type1, typename _event_type2, typename _event_type3 >
169  const sxe::function<bool( const _event_type1&, sxy::event_collector& )>& _function1,
170  const sxe::function<bool( const _event_type2&, sxy::event_collector& )>& _function2,
171  const sxe::function<bool( const _event_type3&, sxy::event_collector& )>& _function3
172 )
173 {
174  typedef bool( *guard_caller_selector )( const sxy::event&, sxy::event_collector&,
175  const sxe::function<bool( const _event_type1&, sxy::event_collector& )>&,
176  const sxe::function<bool( const _event_type2&, sxy::event_collector& )>&,
177  const sxe::function<bool( const _event_type3&, sxy::event_collector& )>&
178  );
179  return( sxy::constraint_function( sxe::bind( static_cast< guard_caller_selector >( guard_caller ), sxe::_1, sxe::_2, _function1, _function2, _function3 ) ) );
180 }
181 
182 
183 template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4 >
185  const sxe::function<bool( const _event_type1&, sxy::event_collector& )>& _function1,
186  const sxe::function<bool( const _event_type2&, sxy::event_collector& )>& _function2,
187  const sxe::function<bool( const _event_type3&, sxy::event_collector& )>& _function3,
188  const sxe::function<bool( const _event_type4&, sxy::event_collector& )>& _function4
189 )
190 {
191  typedef bool( *guard_caller_selector )( const sxy::event&, sxy::event_collector&,
192  const sxe::function<bool( const _event_type1&, sxy::event_collector& )>&,
193  const sxe::function<bool( const _event_type2&, sxy::event_collector& )>&,
194  const sxe::function<bool( const _event_type3&, sxy::event_collector& )>&,
195  const sxe::function<bool( const _event_type4&, sxy::event_collector& )>&
196  );
197  return( sxy::constraint_function( sxe::bind( static_cast< guard_caller_selector >( guard_caller ), sxe::_1, sxe::_2, _function1, _function2, _function3, _function4 ) ) );
198 }
199 
200 
201 template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, typename _event_type5 >
203  const sxe::function<bool( const _event_type1&, sxy::event_collector& )>& _function1,
204  const sxe::function<bool( const _event_type2&, sxy::event_collector& )>& _function2,
205  const sxe::function<bool( const _event_type3&, sxy::event_collector& )>& _function3,
206  const sxe::function<bool( const _event_type4&, sxy::event_collector& )>& _function4,
207  const sxe::function<bool( const _event_type5&, sxy::event_collector& )>& _function5
208 )
209 {
210  typedef bool( *guard_caller_selector )( const sxy::event&, sxy::event_collector&,
211  const sxe::function<bool( const _event_type1&, sxy::event_collector& )>&,
212  const sxe::function<bool( const _event_type2&, sxy::event_collector& )>&,
213  const sxe::function<bool( const _event_type3&, sxy::event_collector& )>&,
214  const sxe::function<bool( const _event_type4&, sxy::event_collector& )>&,
215  const sxe::function<bool( const _event_type5&, sxy::event_collector& )>&
216  );
217  return( sxy::constraint_function( sxe::bind( static_cast< guard_caller_selector >( guard_caller ), sxe::_1, sxe::_2, _function1, _function2, _function3, _function4, _function5 ) ) );
218 }
219 
220 
221 template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, typename _event_type5, typename _event_type6 >
223  const sxe::function<bool( const _event_type1&, sxy::event_collector& )>& _function1,
224  const sxe::function<bool( const _event_type2&, sxy::event_collector& )>& _function2,
225  const sxe::function<bool( const _event_type3&, sxy::event_collector& )>& _function3,
226  const sxe::function<bool( const _event_type4&, sxy::event_collector& )>& _function4,
227  const sxe::function<bool( const _event_type5&, sxy::event_collector& )>& _function5,
228  const sxe::function<bool( const _event_type6&, sxy::event_collector& )>& _function6
229 )
230 {
231  typedef bool( *guard_caller_selector )( const sxy::event&, sxy::event_collector&,
232  const sxe::function<bool( const _event_type1&, sxy::event_collector& )>&,
233  const sxe::function<bool( const _event_type2&, sxy::event_collector& )>&,
234  const sxe::function<bool( const _event_type3&, sxy::event_collector& )>&,
235  const sxe::function<bool( const _event_type4&, sxy::event_collector& )>&,
236  const sxe::function<bool( const _event_type5&, sxy::event_collector& )>&,
237  const sxe::function<bool( const _event_type6&, sxy::event_collector& )>&
238  );
239  return( sxy::constraint_function( sxe::bind( static_cast< guard_caller_selector >( guard_caller ), sxe::_1, sxe::_2, _function1, _function2, _function3, _function4, _function5, _function6 ) ) );
240 }
241 
242 
243 template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, typename _event_type5, typename _event_type6, typename _event_type7 >
245  const sxe::function<bool( const _event_type1&, sxy::event_collector& )>& _function1,
246  const sxe::function<bool( const _event_type2&, sxy::event_collector& )>& _function2,
247  const sxe::function<bool( const _event_type3&, sxy::event_collector& )>& _function3,
248  const sxe::function<bool( const _event_type4&, sxy::event_collector& )>& _function4,
249  const sxe::function<bool( const _event_type5&, sxy::event_collector& )>& _function5,
250  const sxe::function<bool( const _event_type6&, sxy::event_collector& )>& _function6,
251  const sxe::function<bool( const _event_type7&, sxy::event_collector& )>& _function7
252 )
253 {
254  typedef bool( *guard_caller_selector )( const sxy::event&, sxy::event_collector&,
255  const sxe::function<bool( const _event_type1&, sxy::event_collector& )>&,
256  const sxe::function<bool( const _event_type2&, sxy::event_collector& )>&,
257  const sxe::function<bool( const _event_type3&, sxy::event_collector& )>&,
258  const sxe::function<bool( const _event_type4&, sxy::event_collector& )>&,
259  const sxe::function<bool( const _event_type5&, sxy::event_collector& )>&,
260  const sxe::function<bool( const _event_type6&, sxy::event_collector& )>&,
261  const sxe::function<bool( const _event_type7&, sxy::event_collector& )>&
262  );
263  return( sxy::constraint_function( sxe::bind( static_cast< guard_caller_selector >( guard_caller ), sxe::_1, sxe::_2, _function1, _function2, _function3, _function4, _function5, _function6, _function7 ) ) );
264 }
265 
266 
267 template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, typename _event_type5, typename _event_type6, typename _event_type7, typename _event_type8 >
269  const sxe::function<bool( const _event_type1&, sxy::event_collector& )>& _function1,
270  const sxe::function<bool( const _event_type2&, sxy::event_collector& )>& _function2,
271  const sxe::function<bool( const _event_type3&, sxy::event_collector& )>& _function3,
272  const sxe::function<bool( const _event_type4&, sxy::event_collector& )>& _function4,
273  const sxe::function<bool( const _event_type5&, sxy::event_collector& )>& _function5,
274  const sxe::function<bool( const _event_type6&, sxy::event_collector& )>& _function6,
275  const sxe::function<bool( const _event_type7&, sxy::event_collector& )>& _function7,
276  const sxe::function<bool( const _event_type8&, sxy::event_collector& )>& _function8
277 )
278 {
279  typedef bool( *guard_caller_selector )( const sxy::event&, sxy::event_collector&,
280  const sxe::function<bool( const _event_type1&, sxy::event_collector& )>&,
281  const sxe::function<bool( const _event_type2&, sxy::event_collector& )>&,
282  const sxe::function<bool( const _event_type3&, sxy::event_collector& )>&,
283  const sxe::function<bool( const _event_type4&, sxy::event_collector& )>&,
284  const sxe::function<bool( const _event_type5&, sxy::event_collector& )>&,
285  const sxe::function<bool( const _event_type6&, sxy::event_collector& )>&,
286  const sxe::function<bool( const _event_type7&, sxy::event_collector& )>&,
287  const sxe::function<bool( const _event_type8&, sxy::event_collector& )>&
288  );
289  return( sxy::constraint_function( sxe::bind( static_cast< guard_caller_selector >( guard_caller ), sxe::_1, sxe::_2, _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8 ) ) );
290 }
291 
292 
293 template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, typename _event_type5, typename _event_type6, typename _event_type7, typename _event_type8, typename _event_type9 >
295  const sxe::function<bool( const _event_type1&, sxy::event_collector& )>& _function1,
296  const sxe::function<bool( const _event_type2&, sxy::event_collector& )>& _function2,
297  const sxe::function<bool( const _event_type3&, sxy::event_collector& )>& _function3,
298  const sxe::function<bool( const _event_type4&, sxy::event_collector& )>& _function4,
299  const sxe::function<bool( const _event_type5&, sxy::event_collector& )>& _function5,
300  const sxe::function<bool( const _event_type6&, sxy::event_collector& )>& _function6,
301  const sxe::function<bool( const _event_type7&, sxy::event_collector& )>& _function7,
302  const sxe::function<bool( const _event_type8&, sxy::event_collector& )>& _function8,
303  const sxe::function<bool( const _event_type9&, sxy::event_collector& )>& _function9
304 )
305 {
306  typedef bool( *guard_caller_selector )( const sxy::event&, sxy::event_collector&,
307  const sxe::function<bool( const _event_type1&, sxy::event_collector& )>&,
308  const sxe::function<bool( const _event_type2&, sxy::event_collector& )>&,
309  const sxe::function<bool( const _event_type3&, sxy::event_collector& )>&,
310  const sxe::function<bool( const _event_type4&, sxy::event_collector& )>&,
311  const sxe::function<bool( const _event_type5&, sxy::event_collector& )>&,
312  const sxe::function<bool( const _event_type6&, sxy::event_collector& )>&,
313  const sxe::function<bool( const _event_type7&, sxy::event_collector& )>&,
314  const sxe::function<bool( const _event_type8&, sxy::event_collector& )>&,
315  const sxe::function<bool( const _event_type9&, sxy::event_collector& )>&
316  );
317  return( sxy::constraint_function( sxe::bind( static_cast< guard_caller_selector >( guard_caller ), sxe::_1, sxe::_2, _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9 ) ) );
318 }
319 
320 
321 template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, typename _event_type5, typename _event_type6, typename _event_type7, typename _event_type8, typename _event_type9, typename _event_type10 >
323  const sxe::function<bool( const _event_type1&, sxy::event_collector& )>& _function1,
324  const sxe::function<bool( const _event_type2&, sxy::event_collector& )>& _function2,
325  const sxe::function<bool( const _event_type3&, sxy::event_collector& )>& _function3,
326  const sxe::function<bool( const _event_type4&, sxy::event_collector& )>& _function4,
327  const sxe::function<bool( const _event_type5&, sxy::event_collector& )>& _function5,
328  const sxe::function<bool( const _event_type6&, sxy::event_collector& )>& _function6,
329  const sxe::function<bool( const _event_type7&, sxy::event_collector& )>& _function7,
330  const sxe::function<bool( const _event_type8&, sxy::event_collector& )>& _function8,
331  const sxe::function<bool( const _event_type9&, sxy::event_collector& )>& _function9,
332  const sxe::function<bool( const _event_type10&, sxy::event_collector& )>& _function10
333 )
334 {
335  typedef bool( *guard_caller_selector )( const sxy::event&, sxy::event_collector&,
336  const sxe::function<bool( const _event_type1&, sxy::event_collector& )>&,
337  const sxe::function<bool( const _event_type2&, sxy::event_collector& )>&,
338  const sxe::function<bool( const _event_type3&, sxy::event_collector& )>&,
339  const sxe::function<bool( const _event_type4&, sxy::event_collector& )>&,
340  const sxe::function<bool( const _event_type5&, sxy::event_collector& )>&,
341  const sxe::function<bool( const _event_type6&, sxy::event_collector& )>&,
342  const sxe::function<bool( const _event_type7&, sxy::event_collector& )>&,
343  const sxe::function<bool( const _event_type8&, sxy::event_collector& )>&,
344  const sxe::function<bool( const _event_type9&, sxy::event_collector& )>&,
345  const sxe::function<bool( const _event_type10&, sxy::event_collector& )>&
346  );
347  return( sxy::constraint_function( sxe::bind( static_cast< guard_caller_selector >( guard_caller ), sxe::_1, sxe::_2, _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9, _function10 ) ) );
348 }
349 
350 }
351 
352 #endif // !SX_CPP03_BOOST
353 
354 
355 #endif
Definition: event_collector.hpp:25
Interface of an event. An event has an ID, a name and a priority (for processing by the async state m...
Definition: event.hpp:28
Definition: adapter_cpp11.hpp:21
sxy::constraint_function create_guard_function(Args...args)
Definition: create_guard_function.hpp:108
bool guard_caller(const sxy::event &_event, sxy::event_collector &_event_collector, const sxe::function< bool()> &_function)
Definition: guard_caller.cpp:18
sxe::function< bool(const event &, event_collector &) > constraint_function
Definition: constraint_fwd.hpp:28