yasmine
create_behavior_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_BEHAVIOR_FUNCTION_AE991E8C_8970_4642_AAAF_983076825DAB
13 #define CREATE_BEHAVIOR_FUNCTION_AE991E8C_8970_4642_AAAF_983076825DAB
14 
15 
16 #include "behavior_fwd.hpp"
17 #include "behavior_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::behavior_function create_behavior_function( const function1& _function1 )
31 {
32  return ( sxy::behavior_function( [_function1]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_caller( _event, _event_collector, _function1 ); } ) );
33 }
34 
35 
36 template< typename function1, typename function2 >
37 sxy::behavior_function create_behavior_function( const function1& _function1, const function2& _function2 )
38 {
39  return ( sxy::behavior_function( [_function1, _function2]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_caller( _event, _event_collector, _function1, _function2 ); } ) );
40 }
41 
42 
43 template< typename function1, typename function2, typename function3 >
44 sxy::behavior_function create_behavior_function( const function1& _function1, const function2& _function2, const function3& _function3 )
45 {
46  return ( sxy::behavior_function( [_function1, _function2, _function3]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_caller( _event, _event_collector, _function1, _function2, _function3 ); } ) );
47 }
48 
49 
50 template< typename function1, typename function2, typename function3, typename function4 >
51 sxy::behavior_function create_behavior_function( const function1& _function1, const function2& _function2, const function3& _function3, const function4& _function4 )
52 {
53  return ( sxy::behavior_function( [_function1, _function2, _function3, _function4]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_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::behavior_function create_behavior_function( const function1& _function1, const function2& _function2, const function3& _function3, const function4& _function4, const function5& _function5 )
59 {
60  return ( sxy::behavior_function( [_function1, _function2, _function3, _function4, _function5]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_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::behavior_function create_behavior_function( const function1& _function1, const function2& _function2, const function3& _function3, const function4& _function4, const function5& _function5, const function6& _function6 )
66 {
67  return ( sxy::behavior_function( [_function1, _function2, _function3, _function4, _function5, _function6]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_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::behavior_function create_behavior_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::behavior_function( [_function1, _function2, _function3, _function4, _function5, _function6, _function7]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_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::behavior_function create_behavior_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::behavior_function( [_function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_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::behavior_function create_behavior_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::behavior_function( [_function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_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::behavior_function create_behavior_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, const function10& _function10 )
94 {
95  return ( sxy::behavior_function( [_function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9, _function10]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_caller( _event, _event_collector, _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9, _function10 ); } ) );
96 }
97 
98 }
99 #else // !SX_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG
100 
101 namespace sxy
102 {
103 
104 
105 template< typename ... Args >
107 {
108  return ( sxy::behavior_function( [args...]( const sxy::event& _event, sxy::event_collector& _event_collector ) { behavior_caller( _event, _event_collector, args... ); } ) );
109 }
110 
111 
112 }
113 
114 
115 #endif // SX_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG
116 
117 
118 #else // C++03 with Boost
119 
120 
121 namespace sxy
122 {
123 
124 
125 sxy::behavior_function create_behavior_function( const sxe::function<void()>& _function );
126 
127 
128 sxy::behavior_function create_behavior_function( const sxe::function<void( sxy::event_collector& )>& _function );
129 
130 
131 template< typename _event_type >
132 sxy::behavior_function create_behavior_function( const sxe::function<void( const _event_type& )>& _function1 )
133 {
134  typedef void( *behavior_caller_selector )( const sxy::event&, sxy::event_collector&, const sxe::function<void( const _event_type& )>& );
135  return( sxy::behavior_function( sxe::bind( static_cast< behavior_caller_selector >( behavior_caller ), sxe::_1, sxe::_2, _function1 ) ) );
136 }
137 
138 
139 template< typename _event_type >
141  const sxe::function<void( const _event_type&, sxy::event_collector& )>& _function1
142  )
143 {
144  typedef void( *behavior_caller_selector )( const sxy::event&, sxy::event_collector&, const sxe::function<void( const _event_type&, sxy::event_collector& )>& );
145  return( sxy::behavior_function( sxe::bind( static_cast< behavior_caller_selector >( behavior_caller ), sxe::_1, sxe::_2, _function1 ) ) );
146 }
147 
148 
149 template< typename _event_type1, typename _event_type2 >
151  const sxe::function<void( const _event_type1&, sxy::event_collector& )>& _function1,
152  const sxe::function<void( const _event_type2&, sxy::event_collector& )>& _function2
153  )
154 {
155  typedef void( *behavior_caller_selector )( const sxy::event&, sxy::event_collector&,
156  const sxe::function<void( const _event_type1&, sxy::event_collector& )>&,
157  const sxe::function<void( const _event_type2&, sxy::event_collector& )>&
158  );
159  return( sxy::behavior_function( sxe::bind( static_cast< behavior_caller_selector >( behavior_caller ), sxe::_1, sxe::_2, _function1, _function2 ) ) );
160 }
161 
162 
163 template< typename _event_type1, typename _event_type2, typename _event_type3 >
165  const sxe::function<void( const _event_type1&, sxy::event_collector& )>& _function1,
166  const sxe::function<void( const _event_type2&, sxy::event_collector& )>& _function2,
167  const sxe::function<void( const _event_type3&, sxy::event_collector& )>& _function3
168 )
169 {
170  typedef void( *behavior_caller_selector )( const sxy::event&, sxy::event_collector&,
171  const sxe::function<void( const _event_type1&, sxy::event_collector& )>&,
172  const sxe::function<void( const _event_type2&, sxy::event_collector& )>&,
173  const sxe::function<void( const _event_type3&, sxy::event_collector& )>&
174  );
175  return( sxy::behavior_function( sxe::bind( static_cast< behavior_caller_selector >( behavior_caller ), sxe::_1, sxe::_2, _function1, _function2, _function3 ) ) );
176 }
177 
178 
179 template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4 >
181  const sxe::function<void( const _event_type1&, sxy::event_collector& )>& _function1,
182  const sxe::function<void( const _event_type2&, sxy::event_collector& )>& _function2,
183  const sxe::function<void( const _event_type3&, sxy::event_collector& )>& _function3,
184  const sxe::function<void( const _event_type4&, sxy::event_collector& )>& _function4
185 )
186 {
187  typedef void( *behavior_caller_selector )( const sxy::event&, sxy::event_collector&,
188  const sxe::function<void( const _event_type1&, sxy::event_collector& )>&,
189  const sxe::function<void( const _event_type2&, sxy::event_collector& )>&,
190  const sxe::function<void( const _event_type3&, sxy::event_collector& )>&,
191  const sxe::function<void( const _event_type4&, sxy::event_collector& )>&
192  );
193  return( sxy::behavior_function( sxe::bind( static_cast< behavior_caller_selector >( behavior_caller ), sxe::_1, sxe::_2, _function1, _function2, _function3, _function4 ) ) );
194 }
195 
196 
197 template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, typename _event_type5 >
199  const sxe::function<void( const _event_type1&, sxy::event_collector& )>& _function1,
200  const sxe::function<void( const _event_type2&, sxy::event_collector& )>& _function2,
201  const sxe::function<void( const _event_type3&, sxy::event_collector& )>& _function3,
202  const sxe::function<void( const _event_type4&, sxy::event_collector& )>& _function4,
203  const sxe::function<void( const _event_type5&, sxy::event_collector& )>& _function5
204 )
205 {
206  typedef void( *behavior_caller_selector )( const sxy::event&, sxy::event_collector&,
207  const sxe::function<void( const _event_type1&, sxy::event_collector& )>&,
208  const sxe::function<void( const _event_type2&, sxy::event_collector& )>&,
209  const sxe::function<void( const _event_type3&, sxy::event_collector& )>&,
210  const sxe::function<void( const _event_type4&, sxy::event_collector& )>&,
211  const sxe::function<void( const _event_type5&, sxy::event_collector& )>&
212  );
213  return( sxy::behavior_function( sxe::bind( static_cast< behavior_caller_selector >( behavior_caller ), sxe::_1, sxe::_2, _function1, _function2, _function3, _function4, _function5 ) ) );
214 }
215 
216 
217 template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, typename _event_type5, typename _event_type6 >
219  const sxe::function<void( const _event_type1&, sxy::event_collector& )>& _function1,
220  const sxe::function<void( const _event_type2&, sxy::event_collector& )>& _function2,
221  const sxe::function<void( const _event_type3&, sxy::event_collector& )>& _function3,
222  const sxe::function<void( const _event_type4&, sxy::event_collector& )>& _function4,
223  const sxe::function<void( const _event_type5&, sxy::event_collector& )>& _function5,
224  const sxe::function<void( const _event_type6&, sxy::event_collector& )>& _function6
225 )
226 {
227  typedef void( *behavior_caller_selector )( const sxy::event&, sxy::event_collector&,
228  const sxe::function<void( const _event_type1&, sxy::event_collector& )>&,
229  const sxe::function<void( const _event_type2&, sxy::event_collector& )>&,
230  const sxe::function<void( const _event_type3&, sxy::event_collector& )>&,
231  const sxe::function<void( const _event_type4&, sxy::event_collector& )>&,
232  const sxe::function<void( const _event_type5&, sxy::event_collector& )>&,
233  const sxe::function<void( const _event_type6&, sxy::event_collector& )>&
234  );
235  return( sxy::behavior_function( sxe::bind( static_cast< behavior_caller_selector >( behavior_caller ), sxe::_1, sxe::_2, _function1, _function2, _function3, _function4, _function5, _function6 ) ) );
236 }
237 
238 
239 template< typename _event_type1, typename _event_type2, typename _event_type3, typename _event_type4, typename _event_type5, typename _event_type6, typename _event_type7 >
241  const sxe::function<void( const _event_type1&, sxy::event_collector& )>& _function1,
242  const sxe::function<void( const _event_type2&, sxy::event_collector& )>& _function2,
243  const sxe::function<void( const _event_type3&, sxy::event_collector& )>& _function3,
244  const sxe::function<void( const _event_type4&, sxy::event_collector& )>& _function4,
245  const sxe::function<void( const _event_type5&, sxy::event_collector& )>& _function5,
246  const sxe::function<void( const _event_type6&, sxy::event_collector& )>& _function6,
247  const sxe::function<void( const _event_type7&, sxy::event_collector& )>& _function7
248 )
249 {
250  typedef void( *behavior_caller_selector )( const sxy::event&, sxy::event_collector&,
251  const sxe::function<void( const _event_type1&, sxy::event_collector& )>&,
252  const sxe::function<void( const _event_type2&, sxy::event_collector& )>&,
253  const sxe::function<void( const _event_type3&, sxy::event_collector& )>&,
254  const sxe::function<void( const _event_type4&, sxy::event_collector& )>&,
255  const sxe::function<void( const _event_type5&, sxy::event_collector& )>&,
256  const sxe::function<void( const _event_type6&, sxy::event_collector& )>&,
257  const sxe::function<void( const _event_type7&, sxy::event_collector& )>&
258  );
259  return( sxy::behavior_function( sxe::bind( static_cast< behavior_caller_selector >( behavior_caller ), sxe::_1, sxe::_2, _function1, _function2, _function3, _function4, _function5, _function6, _function7 ) ) );
260 }
261 
262 
263 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 >
265  const sxe::function<void( const _event_type1&, sxy::event_collector& )>& _function1,
266  const sxe::function<void( const _event_type2&, sxy::event_collector& )>& _function2,
267  const sxe::function<void( const _event_type3&, sxy::event_collector& )>& _function3,
268  const sxe::function<void( const _event_type4&, sxy::event_collector& )>& _function4,
269  const sxe::function<void( const _event_type5&, sxy::event_collector& )>& _function5,
270  const sxe::function<void( const _event_type6&, sxy::event_collector& )>& _function6,
271  const sxe::function<void( const _event_type7&, sxy::event_collector& )>& _function7,
272  const sxe::function<void( const _event_type8&, sxy::event_collector& )>& _function8
273 )
274 {
275  typedef void( *behavior_caller_selector )( const sxy::event&, sxy::event_collector&,
276  const sxe::function<void( const _event_type1&, sxy::event_collector& )>&,
277  const sxe::function<void( const _event_type2&, sxy::event_collector& )>&,
278  const sxe::function<void( const _event_type3&, sxy::event_collector& )>&,
279  const sxe::function<void( const _event_type4&, sxy::event_collector& )>&,
280  const sxe::function<void( const _event_type5&, sxy::event_collector& )>&,
281  const sxe::function<void( const _event_type6&, sxy::event_collector& )>&,
282  const sxe::function<void( const _event_type7&, sxy::event_collector& )>&,
283  const sxe::function<void( const _event_type8&, sxy::event_collector& )>&
284  );
285  return( sxy::behavior_function( sxe::bind( static_cast< behavior_caller_selector >( behavior_caller ), sxe::_1, sxe::_2, _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8 ) ) );
286 }
287 
288 
289 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 >
291  const sxe::function<void( const _event_type1&, sxy::event_collector& )>& _function1,
292  const sxe::function<void( const _event_type2&, sxy::event_collector& )>& _function2,
293  const sxe::function<void( const _event_type3&, sxy::event_collector& )>& _function3,
294  const sxe::function<void( const _event_type4&, sxy::event_collector& )>& _function4,
295  const sxe::function<void( const _event_type5&, sxy::event_collector& )>& _function5,
296  const sxe::function<void( const _event_type6&, sxy::event_collector& )>& _function6,
297  const sxe::function<void( const _event_type7&, sxy::event_collector& )>& _function7,
298  const sxe::function<void( const _event_type8&, sxy::event_collector& )>& _function8,
299  const sxe::function<void( const _event_type9&, sxy::event_collector& )>& _function9
300 )
301 {
302  typedef void( *behavior_caller_selector )( const sxy::event&, sxy::event_collector&,
303  const sxe::function<void( const _event_type1&, sxy::event_collector& )>&,
304  const sxe::function<void( const _event_type2&, sxy::event_collector& )>&,
305  const sxe::function<void( const _event_type3&, sxy::event_collector& )>&,
306  const sxe::function<void( const _event_type4&, sxy::event_collector& )>&,
307  const sxe::function<void( const _event_type5&, sxy::event_collector& )>&,
308  const sxe::function<void( const _event_type6&, sxy::event_collector& )>&,
309  const sxe::function<void( const _event_type7&, sxy::event_collector& )>&,
310  const sxe::function<void( const _event_type8&, sxy::event_collector& )>&,
311  const sxe::function<void( const _event_type9&, sxy::event_collector& )>&
312  );
313  return( sxy::behavior_function( sxe::bind( static_cast< behavior_caller_selector >( behavior_caller ), sxe::_1, sxe::_2, _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9 ) ) );
314 }
315 
316 
317 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 >
319  const sxe::function<void( const _event_type1&, sxy::event_collector& )>& _function1,
320  const sxe::function<void( const _event_type2&, sxy::event_collector& )>& _function2,
321  const sxe::function<void( const _event_type3&, sxy::event_collector& )>& _function3,
322  const sxe::function<void( const _event_type4&, sxy::event_collector& )>& _function4,
323  const sxe::function<void( const _event_type5&, sxy::event_collector& )>& _function5,
324  const sxe::function<void( const _event_type6&, sxy::event_collector& )>& _function6,
325  const sxe::function<void( const _event_type7&, sxy::event_collector& )>& _function7,
326  const sxe::function<void( const _event_type8&, sxy::event_collector& )>& _function8,
327  const sxe::function<void( const _event_type9&, sxy::event_collector& )>& _function9,
328  const sxe::function<void( const _event_type10&, sxy::event_collector& )>& _function10
329 )
330 {
331  typedef void( *behavior_caller_selector )( const sxy::event&, sxy::event_collector&,
332  const sxe::function<void( const _event_type1&, sxy::event_collector& )>&,
333  const sxe::function<void( const _event_type2&, sxy::event_collector& )>&,
334  const sxe::function<void( const _event_type3&, sxy::event_collector& )>&,
335  const sxe::function<void( const _event_type4&, sxy::event_collector& )>&,
336  const sxe::function<void( const _event_type5&, sxy::event_collector& )>&,
337  const sxe::function<void( const _event_type6&, sxy::event_collector& )>&,
338  const sxe::function<void( const _event_type7&, sxy::event_collector& )>&,
339  const sxe::function<void( const _event_type8&, sxy::event_collector& )>&,
340  const sxe::function<void( const _event_type9&, sxy::event_collector& )>&,
341  const sxe::function<void( const _event_type10&, sxy::event_collector& )>&
342  );
343  return( sxy::behavior_function( sxe::bind( static_cast< behavior_caller_selector >( behavior_caller ), sxe::_1, sxe::_2, _function1, _function2, _function3, _function4, _function5, _function6, _function7, _function8, _function9, _function10 ) ) );
344 }
345 
346 
347 }
348 
349 #endif // !SX_CPP03_BOOST
350 
351 
352 
353 #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
void behavior_caller(const sxy::event &_event, sxy::event_collector &_event_collector, const sxe::function< void()> &_function)
Definition: behavior_caller.cpp:18
sxy::behavior_function create_behavior_function(Args...args)
Definition: create_behavior_function.hpp:106
sxe::function< void(const event &, event_collector &) > behavior_function
Definition: behavior_fwd.hpp:29