GCC Code Coverage Report


Directory: src/gate/
File: src/gate/delegates.hpp
Date: 2026-12-03 19:36:00
Exec Total Coverage
Lines: 263 282 93.3%
Functions: 346 510 67.8%
Branches: 146 300 48.7%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright (c) 2018-2026, Stefan Meislinger <sm@opengate.at> |
4 | All rights reserved. |
5 | |
6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met:|
8 | |
9 | 1. Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. |
11 | 2. Redistributions in binary form must reproduce the above copyright |
12 | notice, this list of conditions and the following disclaimer in the |
13 | documentation and/or other materials provided with the distribution. |
14 | |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"|
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
25 | THE POSSIBILITY OF SUCH DAMAGE. |
26 +----------------------------------------------------------------------------+
27 */
28
29 /** @file
30 * @brief Generic encapsulation of callbacks for functions and objects
31 * @ingroup gatecore_cpp
32 */
33
34 #ifndef GATE_DELEGATES_HPP_INCLUDED
35 #define GATE_DELEGATES_HPP_INCLUDED
36
37 #include "gate/gate_core_api.hpp"
38 #include "gate/gatetypes.hpp"
39 #include "gate/memalloc.hpp"
40 #include "gate/arrays.hpp"
41 #include "gate/typetraits.hpp"
42 #include "gate/debugging.h"
43
44 #include "gate/delegates.h"
45
46 namespace gate
47 {
48
49 typedef gate_delegate_t delegate_t;
50
51 typedef gate_va_list_carrier_t va_list_carrier_t;
52
53 namespace details
54 {
55 #if !defined(GATE_COMPILER_SUPPORTS_CPP_PARTIAL_TEMPLATE_SPECIALIZATION)
56
57 template<class T> struct VaArgGetter
58 {
59 static T get(va_list_carrier_t& args)
60 {
61 if (traits::IsReference<T>::value)
62 {
63 void* ptr = va_arg(args.data, void*);
64 traits::RemoveReference<T>::type_t* ptr_arg = static_cast<traits::RemoveReference<T>::type_t*>(ptr);
65 return *ptr_arg;
66 }
67 else
68 {
69 if (sizeof(T) < sizeof(int))
70 {
71 int intref = va_arg(args.data, int);
72 traits::RemoveReference<T>::type_t* ptr_arg = reinterpret_cast<traits::RemoveReference<T>::type_t*>(&intref);
73 return *ptr_arg;
74 }
75 else
76 {
77 T arg = va_arg(args.data, T);
78 return arg;
79 }
80 }
81 }
82 };
83
84 template<class T> struct VaArgBuilder
85 {
86 static T get(T value)
87 {
88 return value;
89 }
90 };
91
92 #else
93 template<class T, bool use_int, bool is_ref> struct VaArgGetterImpl;
94
95 template<class T> struct VaArgGetterImpl<T, true, false>
96 {
97 12 static T get(va_list_carrier_t& args)
98 {
99 12 int intref = va_arg(args.data, int);
100 12 return *reinterpret_cast<typename traits::RemoveReference<T>::type_t*>(&intref);
101 }
102 };
103
104 template<class T> struct VaArgGetterImpl<T, true, true>
105 {
106 7 static T get(va_list_carrier_t args)
107 {
108 7 T tref = *reinterpret_cast<typename traits::RemoveReference<T>::type_t*>(va_arg(args.data, int*));
109 7 return tref;
110 }
111 };
112
113 template<class T> struct VaArgGetterImpl<T, false, false>
114 {
115 646 static T get(va_list_carrier_t& args)
116 {
117 646 T tref = va_arg(args.data, T);
118 646 return tref;
119 }
120 };
121
122 template<class T> struct VaArgGetterImpl<T, false, true>
123 {
124 186 static T get(va_list_carrier_t& args)
125 {
126 186 T tref = *(va_arg(args.data, typename traits::RemoveReference<T>::type_t*));
127 186 return tref;
128 }
129 };
130
131 template<class T> struct VaArgGetter : public VaArgGetterImpl < T, sizeof(T) < sizeof(int), traits::IsReference<T>::value >
132 {
133 };
134
135 template<class T, bool is_ref> struct VaArgBuilderImpl;
136 template<class T> struct VaArgBuilderImpl<T, true>
137 {
138 207 static typename traits::RemoveReference<T>::type_t* get(T value)
139 {
140 207 return &value;
141 }
142 };
143 template<class T> struct VaArgBuilderImpl<T, false>
144 {
145 658 static T get(T value)
146 {
147 658 return value;
148 }
149 };
150
151 template<class T> struct VaArgBuilder : public VaArgBuilderImpl< T, traits::IsReference<T>::value >
152 {
153 };
154
155 #endif
156
157 951 template<class T> static T next_va_arg(va_list_carrier_t& args)
158 {
159 951 return details::VaArgGetter<T>::get(args);
160 }
161
162 } // end of namespace details
163
164
165 /// @brief
166 class GATE_CORE_CPP_API Delegate : public SafeBoolBase<Delegate>
167 {
168 protected:
169 delegate_t impl;
170
171 Delegate();
172 Delegate(gate_delegate_dispatcher_t dispatcher, void* obj_ptr, void* function_ptr, size_t function_ptr_size);
173
174 void translate_result(result_t result) const;
175
176 public:
177 ~Delegate();
178 delegate_t const* c_impl() const;
179 bool operator!() const;
180 bool operator==(Delegate const& src) const;
181 bool operator!=(Delegate const& src) const;
182
183 };
184
185
186 /// @brief
187 /// @tparam RETTYPE
188 template<class RETTYPE>
189 class GATE_CORE_CPP_TEMPLATE_API TDelegate0 : public Delegate
190 {
191 protected:
192 template<class FUNC>
193 struct function_dispatcher
194 {
195 11 static gate_result_t GATE_CALL impl(gate_delegate_t const* delegate_ptr, gate_va_list_carrier_t* args)
196 {
197 11 FUNC& func = *gate::union_cast<FUNC*>(&delegate_ptr->function_storage);
198
1/2
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
11 ExceptionInfo xcptStatus;
199
5/12
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
13 GATEXX_TRY_CATCHINFO(xcptStatus, {
200 func();
201 });
202 11 return xcptStatus.result_code;
203 }
204 };
205
206 template<class O>
207 struct method_dispatcher
208 {
209 2 static gate_result_t GATE_CALL impl(gate_delegate_t const* delegate_ptr, gate_va_list_carrier_t* args)
210 {
211 typedef RETTYPE(O::* method_t)();
212 2 O* obj = static_cast<O*>(delegate_ptr->object_ptr);
213 2 method_t& method = *gate::union_cast<method_t*>(&delegate_ptr->function_storage);
214
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 ExceptionInfo xcptStatus;
215
3/10
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
2 GATEXX_TRY_CATCHINFO(xcptStatus, {
216 (obj->*method)();
217 });
218 2 return xcptStatus.result_code;
219 }
220 };
221
222 public:
223 1 TDelegate0()
224 1 {
225 1 }
226
227 16 template<class FUNC> TDelegate0(FUNC funcptr)
228 16 : Delegate(&function_dispatcher<FUNC>::impl, NULL, &funcptr, sizeof(funcptr))
229 {
230 16 }
231
232 3 template<class O> TDelegate0(O* obj_ptr, void(O::* method)())
233 3 : Delegate(&method_dispatcher<O>::impl, obj_ptr, &method, sizeof(method))
234 {
235 3 }
236
237 1 VoidResult tryInvoke() const
238 {
239
1/2
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
1 return makeResult(gate_delegate_invoke(this->c_impl()));
240 }
241 9 void invoke() const
242 {
243 9 this->translate_result(gate_delegate_invoke(this->c_impl()));
244 8 }
245 5 void operator()() const
246 {
247 5 this->invoke();
248 4 }
249 };
250 typedef TDelegate0<void> Delegate0;
251
252
253
254 /// @brief
255 /// @tparam A1
256 template<class A1>
257 class GATE_CORE_CPP_TEMPLATE_API Delegate1 : public Delegate
258 {
259 protected:
260 template<class FUNC>
261 struct function_dispatcher
262 {
263 25 static gate_result_t GATE_CALL impl(gate_delegate_t const* delegate_ptr, gate_va_list_carrier_t* args)
264 {
265 25 FUNC& func = *gate::union_cast<FUNC*>(&delegate_ptr->function_storage);
266
1/2
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
25 ExceptionInfo xcptStatus;
267
6/10
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 11 times.
✓ Branch 5 taken 2 times.
✓ Branch 7 taken 11 times.
✗ Branch 8 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 2 times.
✗ Branch 16 not taken.
29 GATEXX_TRY_CATCHINFO(xcptStatus, {
268 A1 arg1 = details::next_va_arg<A1>(*args);
269 func(arg1);
270 });
271 25 return xcptStatus.result_code;
272 }
273 };
274
275 template<class O>
276 struct method_dispatcher
277 {
278 2 static gate_result_t GATE_CALL impl(gate_delegate_t const* delegate_ptr, gate_va_list_carrier_t* args)
279 {
280 typedef void(O::* method_t)(A1);
281 2 O* obj = static_cast<O*>(delegate_ptr->object_ptr);
282 2 method_t& method = *gate::union_cast<method_t*>(&delegate_ptr->function_storage);
283
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 ExceptionInfo xcptStatus;
284
4/12
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
2 GATEXX_TRY_CATCHINFO(xcptStatus, {
285 A1 arg1 = details::next_va_arg<A1>(*args);
286 (obj->*method)(arg1);
287 });
288 2 return xcptStatus.result_code;
289 }
290 };
291
292 public:
293 ✗ Delegate1()
294 ✗ {
295 ✗ }
296
297 29 template<class FUNC> Delegate1(FUNC funcptr)
298 29 : Delegate(&function_dispatcher<FUNC>::impl, NULL, &funcptr, sizeof(funcptr))
299 {
300 29 }
301
302 3 template<class O> Delegate1(O* obj_ptr, void(O::* method)(A1))
303 3 : Delegate(&method_dispatcher<O>::impl, obj_ptr, &method, sizeof(method))
304 {
305 3 }
306
307 1 VoidResult tryInvoke(A1 arg1) const
308 {
309 2 return makeResult(gate_delegate_invoke(this->c_impl(),
310 details::VaArgBuilder<A1>::get(arg1)
311
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 ));
312 }
313 27 void invoke(A1 arg1) const
314 {
315 27 translate_result(gate_delegate_invoke(this->c_impl(),
316 details::VaArgBuilder<A1>::get(arg1)
317 ));
318 25 }
319 8 void operator()(A1 arg1) const
320 {
321 8 this->invoke(arg1);
322 6 }
323 };
324
325
326
327 /// @brief
328 /// @tparam A1
329 /// @tparam A2
330 template<class A1, class A2>
331 class GATE_CORE_CPP_TEMPLATE_API Delegate2 : public Delegate
332 {
333 protected:
334 template<class FUNC>
335 struct function_dispatcher
336 {
337 182 static gate_result_t GATE_CALL impl(gate_delegate_t const* delegate_ptr, gate_va_list_carrier_t* args)
338 {
339 182 FUNC& func = *gate::union_cast<FUNC*>(&delegate_ptr->function_storage);
340
1/2
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
182 ExceptionInfo xcptStatus;
341
7/12
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 94 times.
✓ Branch 8 taken 2 times.
✓ Branch 10 taken 94 times.
✗ Branch 11 not taken.
✓ Branch 15 taken 2 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 2 times.
✗ Branch 19 not taken.
186 GATEXX_TRY_CATCHINFO(xcptStatus, {
342 A1 arg1 = details::next_va_arg<A1>(*args);
343 A2 arg2 = details::next_va_arg<A2>(*args);
344 func(arg1, arg2);
345 });
346 182 return xcptStatus.result_code;
347 }
348 };
349
350 template<class O>
351 struct method_dispatcher
352 {
353 27 static gate_result_t GATE_CALL impl(gate_delegate_t const* delegate_ptr, gate_va_list_carrier_t* args)
354 {
355 typedef void(O::* method_t)(A1, A2);
356 27 O* obj = static_cast<O*>(delegate_ptr->object_ptr);
357 27 method_t& method = *gate::union_cast<method_t*>(&delegate_ptr->function_storage);
358
1/2
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
27 ExceptionInfo xcptStatus;
359
8/14
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 16 times.
✓ Branch 9 taken 14 times.
✓ Branch 10 taken 2 times.
✓ Branch 12 taken 14 times.
✗ Branch 13 not taken.
✓ Branch 17 taken 2 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 2 times.
✗ Branch 21 not taken.
31 GATEXX_TRY_CATCHINFO(xcptStatus, {
360 A1 arg1 = details::next_va_arg<A1>(*args);
361 A2 arg2 = details::next_va_arg<A2>(*args);
362 (obj->*method)(arg1, arg2);
363 });
364 27 return xcptStatus.result_code;
365 }
366 };
367
368 public:
369 ✗ Delegate2()
370 ✗ {
371 ✗ }
372
373 134 template<class FUNC> Delegate2(FUNC funcptr)
374 134 : Delegate(&function_dispatcher<FUNC>::impl, NULL, &funcptr, sizeof(funcptr))
375 {
376 134 }
377
378 24 template<class O> Delegate2(O* obj_ptr, void(O::* method)(A1, A2))
379 24 : Delegate(&method_dispatcher<O>::impl, obj_ptr, &method, sizeof(method))
380 {
381 24 }
382
383 1 VoidResult tryInvoke(A1 arg1, A2 arg2) const
384 {
385 2 return makeResult(gate_delegate_invoke(this->c_impl(),
386 details::VaArgBuilder<A1>::get(arg1),
387 details::VaArgBuilder<A2>::get(arg2)
388
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 ));
389 }
390 203 void invoke(A1 arg1, A2 arg2) const
391 {
392 203 translate_result(gate_delegate_invoke(&this->impl,
393 details::VaArgBuilder<A1>::get(arg1),
394 details::VaArgBuilder<A2>::get(arg2)
395 ));
396 197 }
397 24 void operator()(A1 arg1, A2 arg2) const
398 {
399 24 this->invoke(arg1, arg2);
400 18 }
401 };
402
403
404 /// @brief
405 /// @tparam A1
406 /// @tparam A2
407 /// @tparam A3
408 template<class A1, class A2, class A3>
409 class GATE_CORE_CPP_TEMPLATE_API Delegate3 : public Delegate
410 {
411 protected:
412 template<class FUNC>
413 struct function_dispatcher
414 {
415 86 static gate_result_t GATE_CALL impl(gate_delegate_t const* delegate_ptr, gate_va_list_carrier_t* args)
416 {
417 86 FUNC& func = *gate::union_cast<FUNC*>(&delegate_ptr->function_storage);
418
1/2
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
86 ExceptionInfo xcptStatus;
419
8/14
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 44 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 44 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 42 times.
✓ Branch 11 taken 2 times.
✓ Branch 13 taken 42 times.
✗ Branch 14 not taken.
✓ Branch 18 taken 2 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
90 GATEXX_TRY_CATCHINFO(xcptStatus, {
420 A1 arg1 = details::next_va_arg<A1>(*args);
421 A2 arg2 = details::next_va_arg<A2>(*args);
422 A3 arg3 = details::next_va_arg<A3>(*args);
423 func(arg1, arg2, arg3);
424 });
425 86 return xcptStatus.result_code;
426 }
427 };
428
429 template<class O>
430 struct method_dispatcher
431 {
432 6 static gate_result_t GATE_CALL impl(gate_delegate_t const* delegate_ptr, gate_va_list_carrier_t* args)
433 {
434 typedef void(O::* method_t)(A1, A2, A3);
435 6 O* obj = static_cast<O*>(delegate_ptr->object_ptr);
436 6 method_t& method = *gate::union_cast<method_t*>(&delegate_ptr->function_storage);
437
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
6 ExceptionInfo xcptStatus;
438
6/16
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 12 taken 4 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 4 times.
✗ Branch 16 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
6 GATEXX_TRY_CATCHINFO(xcptStatus, {
439 A1 arg1 = details::next_va_arg<A1>(*args);
440 A2 arg2 = details::next_va_arg<A2>(*args);
441 A3 arg3 = details::next_va_arg<A3>(*args);
442 (obj->*method)(arg1, arg2, arg3);
443 });
444 6 return xcptStatus.result_code;
445 }
446 };
447
448 public:
449 ✗ Delegate3()
450 ✗ {
451 ✗ }
452
453 14 template<class FUNC> Delegate3(FUNC funcptr)
454 14 : Delegate(&function_dispatcher<FUNC>::impl, NULL, &funcptr, sizeof(funcptr))
455 {
456 14 }
457
458 8 template<class O> Delegate3(O* obj_ptr, void(O::* method)(A1, A2, A3))
459 8 : Delegate(&method_dispatcher<O>::impl, obj_ptr, &method, sizeof(method))
460 {
461 8 }
462
463 1 VoidResult tryInvoke(A1 arg1, A2 arg2, A3 arg3) const
464 {
465 2 return makeResult(gate_delegate_invoke(this->c_impl(),
466 details::VaArgBuilder<A1>::get(arg1),
467 details::VaArgBuilder<A2>::get(arg2),
468 details::VaArgBuilder<A3>::get(arg3)
469
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 ));
470 }
471 92 void invoke(A1 arg1, A2 arg2, A3 arg3) const
472 {
473 92 translate_result(gate_delegate_invoke(&this->impl,
474 details::VaArgBuilder<A1>::get(arg1),
475 details::VaArgBuilder<A2>::get(arg2),
476 details::VaArgBuilder<A3>::get(arg3)
477 ));
478 90 }
479 15 void operator()(A1 arg1, A2 arg2, A3 arg3) const
480 {
481 15 this->invoke(arg1, arg2, arg3);
482 13 }
483 };
484
485
486 /// @brief
487 /// @tparam A1
488 /// @tparam A2
489 /// @tparam A3
490 /// @tparam A4
491 template<class A1, class A2, class A3, class A4>
492 class GATE_CORE_CPP_TEMPLATE_API Delegate4 : public Delegate
493 {
494 protected:
495 template<class FUNC>
496 struct function_dispatcher
497 {
498 6 static gate_result_t GATE_CALL impl(gate_delegate_t const* delegate_ptr, gate_va_list_carrier_t* args)
499 {
500 6 FUNC& func = *gate::union_cast<FUNC*>(&delegate_ptr->function_storage);
501
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
6 ExceptionInfo xcptStatus;
502
9/16
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✓ Branch 14 taken 2 times.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 2 times.
✗ Branch 25 not taken.
10 GATEXX_TRY_CATCHINFO(xcptStatus, {
503 A1 arg1 = details::next_va_arg<A1>(*args);
504 A2 arg2 = details::next_va_arg<A2>(*args);
505 A3 arg3 = details::next_va_arg<A3>(*args);
506 A4 arg4 = details::next_va_arg<A4>(*args);
507 func(arg1, arg2, arg3, arg4);
508 });
509 6 return xcptStatus.result_code;
510 }
511 };
512 template<class O>
513 struct method_dispatcher
514 {
515 2 static gate_result_t GATE_CALL impl(gate_delegate_t const* delegate_ptr, gate_va_list_carrier_t* args)
516 {
517 typedef void(O::* method_t)(A1, A2, A3, A4);
518 2 O* obj = static_cast<O*>(delegate_ptr->object_ptr);
519 2 method_t& method = *gate::union_cast<method_t*>(&delegate_ptr->function_storage);
520
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 ExceptionInfo xcptStatus;
521
7/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✓ Branch 15 taken 2 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 2 times.
✗ Branch 19 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
2 GATEXX_TRY_CATCHINFO(xcptStatus, {
522 A1 arg1 = details::next_va_arg<A1>(*args);
523 A2 arg2 = details::next_va_arg<A2>(*args);
524 A3 arg3 = details::next_va_arg<A3>(*args);
525 A4 arg4 = details::next_va_arg<A4>(*args);
526 (obj->*method)(arg1, arg2, arg3, arg4);
527 });
528 2 return xcptStatus.result_code;
529 }
530 };
531
532 public:
533 ✗ Delegate4()
534 ✗ {
535 ✗ }
536
537 4 template<class FUNC> Delegate4(FUNC funcptr)
538 4 : Delegate(&function_dispatcher<FUNC>::impl, NULL, &funcptr, sizeof(funcptr))
539 {
540 4 }
541
542 2 template<class O> Delegate4(O* obj_ptr, void(O::* method)(A1, A2, A3, A4))
543 2 : Delegate(&method_dispatcher<O>::impl, obj_ptr, &method, sizeof(method))
544 {
545 2 }
546
547 1 VoidResult tryInvoke(A1 arg1, A2 arg2, A3 arg3, A4 arg4) const
548 {
549 2 return makeResult(gate_delegate_invoke(this->c_impl(),
550 details::VaArgBuilder<A1>::get(arg1),
551 details::VaArgBuilder<A2>::get(arg2),
552 details::VaArgBuilder<A3>::get(arg3),
553 details::VaArgBuilder<A4>::get(arg4)
554
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 ));
555 }
556 8 void invoke(A1 arg1, A2 arg2, A3 arg3, A4 arg4) const
557 {
558 8 translate_result(gate_delegate_invoke(&this->impl,
559 details::VaArgBuilder<A1>::get(arg1),
560 details::VaArgBuilder<A2>::get(arg2),
561 details::VaArgBuilder<A3>::get(arg3),
562 details::VaArgBuilder<A4>::get(arg4)
563 ));
564 6 }
565 8 void operator()(A1 arg1, A2 arg2, A3 arg3, A4 arg4) const
566 {
567 8 this->invoke(arg1, arg2, arg3, arg4);
568 6 }
569 };
570
571
572 /// @brief
573 /// @tparam A1
574 /// @tparam A2
575 /// @tparam A3
576 /// @tparam A4
577 /// @tparam A5
578 template<class A1, class A2, class A3, class A4, class A5>
579 class GATE_CORE_CPP_TEMPLATE_API Delegate5 : public Delegate
580 {
581 protected:
582 template<class FUNC>
583 struct function_dispatcher
584 {
585 6 static gate_result_t GATE_CALL impl(gate_delegate_t const* delegate_ptr, gate_va_list_carrier_t* args)
586 {
587 6 FUNC& func = *gate::union_cast<FUNC*>(&delegate_ptr->function_storage);
588
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
6 ExceptionInfo xcptStatus;
589
10/18
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 3 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✓ Branch 17 taken 2 times.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 24 taken 2 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 2 times.
✗ Branch 28 not taken.
10 GATEXX_TRY_CATCHINFO(xcptStatus, {
590 A1 arg1 = details::next_va_arg<A1>(*args);
591 A2 arg2 = details::next_va_arg<A2>(*args);
592 A3 arg3 = details::next_va_arg<A3>(*args);
593 A4 arg4 = details::next_va_arg<A4>(*args);
594 A5 arg5 = details::next_va_arg<A5>(*args);
595 func(arg1, arg2, arg3, arg4, arg5);
596 });
597 6 return xcptStatus.result_code;
598 }
599 };
600
601 template<class O>
602 struct method_dispatcher
603 {
604 2 static gate_result_t GATE_CALL impl(gate_delegate_t const* delegate_ptr, gate_va_list_carrier_t* args)
605 {
606 typedef void(O::* method_t)(A1, A2, A3, A4, A5);
607 2 O* obj = static_cast<O*>(delegate_ptr->object_ptr);
608 2 method_t& method = *gate::union_cast<method_t*>(&delegate_ptr->function_storage);
609
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 ExceptionInfo xcptStatus;
610
8/20
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 2 times.
✓ Branch 18 taken 2 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
2 GATEXX_TRY_CATCHINFO(xcptStatus, {
611 A1 arg1 = details::next_va_arg<A1>(*args);
612 A2 arg2 = details::next_va_arg<A2>(*args);
613 A3 arg3 = details::next_va_arg<A3>(*args);
614 A4 arg4 = details::next_va_arg<A4>(*args);
615 A5 arg5 = details::next_va_arg<A5>(*args);
616 (obj->*method)(arg1, arg2, arg3, arg4, arg5);
617 });
618 2 return xcptStatus.result_code;
619 }
620 };
621
622 public:
623 ✗ Delegate5()
624 ✗ {
625 ✗ }
626
627 4 template<class FUNC> Delegate5(FUNC funcptr)
628 4 : Delegate(&function_dispatcher<FUNC>::impl, NULL, &funcptr, sizeof(funcptr))
629 {
630 4 }
631
632 2 template<class O> Delegate5(O* obj_ptr, void(O::* method)(A1, A2, A3, A4, A5))
633 2 : Delegate(&method_dispatcher<O>::impl, obj_ptr, &method, sizeof(method))
634 {
635 2 }
636
637 1 VoidResult tryInvoke(A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5) const
638 {
639 2 return makeResult(gate_delegate_invoke(this->c_impl(),
640 details::VaArgBuilder<A1>::get(arg1),
641 details::VaArgBuilder<A2>::get(arg2),
642 details::VaArgBuilder<A3>::get(arg3),
643 details::VaArgBuilder<A4>::get(arg4),
644 details::VaArgBuilder<A5>::get(arg5)
645
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 ));
646 }
647 8 void invoke(A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5) const
648 {
649 8 translate_result(gate_delegate_invoke(&this->impl,
650 details::VaArgBuilder<A1>::get(arg1),
651 details::VaArgBuilder<A2>::get(arg2),
652 details::VaArgBuilder<A3>::get(arg3),
653 details::VaArgBuilder<A4>::get(arg4),
654 details::VaArgBuilder<A5>::get(arg5)
655 ));
656 6 }
657 8 void operator()(A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5) const
658 {
659 8 this->invoke(arg1, arg2, arg3, arg4, arg5);
660 6 }
661 };
662
663
664
665 /// @brief
666 /// @tparam A1
667 /// @tparam A2
668 /// @tparam A3
669 /// @tparam A4
670 /// @tparam A5
671 /// @tparam A6
672 template<class A1, class A2, class A3, class A4, class A5, class A6>
673 class GATE_CORE_CPP_TEMPLATE_API Delegate6 : public Delegate
674 {
675 protected:
676 template<class FUNC>
677 struct function_dispatcher
678 {
679 12 static gate_result_t GATE_CALL impl(gate_delegate_t const* delegate_ptr, gate_va_list_carrier_t* args)
680 {
681 12 FUNC& func = *gate::union_cast<FUNC*>(&delegate_ptr->function_storage);
682
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
12 ExceptionInfo xcptStatus;
683
11/20
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 6 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 6 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 6 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 4 times.
✓ Branch 20 taken 2 times.
✓ Branch 22 taken 4 times.
✗ Branch 23 not taken.
✓ Branch 27 taken 2 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 2 times.
✗ Branch 31 not taken.
16 GATEXX_TRY_CATCHINFO(xcptStatus, {
684 A1 arg1 = details::next_va_arg<A1>(*args);
685 A2 arg2 = details::next_va_arg<A2>(*args);
686 A3 arg3 = details::next_va_arg<A3>(*args);
687 A4 arg4 = details::next_va_arg<A4>(*args);
688 A5 arg5 = details::next_va_arg<A5>(*args);
689 A6 arg6 = details::next_va_arg<A6>(*args);
690 func(arg1, arg2, arg3, arg4, arg5, arg6);
691 });
692 12 return xcptStatus.result_code;
693 }
694 };
695
696 template<class O>
697 struct method_dispatcher
698 {
699 2 static gate_result_t GATE_CALL impl(gate_delegate_t const* delegate_ptr, gate_va_list_carrier_t* args)
700 {
701 typedef void(O::* method_t)(A1, A2, A3, A4, A5, A6);
702 2 O* obj = static_cast<O*>(delegate_ptr->object_ptr);
703 2 method_t& method = *gate::union_cast<method_t*>(&delegate_ptr->function_storage);
704
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 ExceptionInfo xcptStatus;
705
9/22
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 2 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 2 times.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 2 times.
✗ Branch 25 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
2 GATEXX_TRY_CATCHINFO(xcptStatus, {
706 A1 arg1 = details::next_va_arg<A1>(*args);
707 A2 arg2 = details::next_va_arg<A2>(*args);
708 A3 arg3 = details::next_va_arg<A3>(*args);
709 A4 arg4 = details::next_va_arg<A4>(*args);
710 A5 arg5 = details::next_va_arg<A5>(*args);
711 A6 arg6 = details::next_va_arg<A6>(*args);
712 (obj->*method)(arg1, arg2, arg3, arg4, arg5, arg6);
713 });
714 2 return xcptStatus.result_code;
715 }
716 };
717
718 public:
719 ✗ Delegate6()
720 ✗ {
721 ✗ }
722
723 8 template<class FUNC> Delegate6(FUNC funcptr)
724 8 : Delegate(&function_dispatcher<FUNC>::impl, NULL, &funcptr, sizeof(funcptr))
725 {
726 8 }
727
728 2 template<class O> Delegate6(O* obj_ptr, void(O::* method)(A1, A2, A3, A4, A5, A6))
729 2 : Delegate(&method_dispatcher<O>::impl, obj_ptr, &method, sizeof(method))
730 {
731 2 }
732
733 1 VoidResult tryInvoke(A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6) const
734 {
735 2 return makeResult(gate_delegate_invoke(this->c_impl(),
736 details::VaArgBuilder<A1>::get(arg1),
737 details::VaArgBuilder<A2>::get(arg2),
738 details::VaArgBuilder<A3>::get(arg3),
739 details::VaArgBuilder<A4>::get(arg4),
740 details::VaArgBuilder<A5>::get(arg5),
741 details::VaArgBuilder<A6>::get(arg6)
742
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
2 ));
743 }
744 14 void invoke(A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6) const
745 {
746 20 translate_result(gate_delegate_invoke(&this->impl,
747 details::VaArgBuilder<A1>::get(arg1),
748 6 details::VaArgBuilder<A2>::get(arg2),
749 6 details::VaArgBuilder<A3>::get(arg3),
750 details::VaArgBuilder<A4>::get(arg4),
751 details::VaArgBuilder<A5>::get(arg5),
752 details::VaArgBuilder<A6>::get(arg6)
753 ));
754 12 }
755 14 void operator()(A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5, A6 arg6) const
756 {
757 14 this->invoke(arg1, arg2, arg3, arg4, arg5, arg6);
758 12 }
759 };
760
761
762
763
764 /// @brief
765 class GATE_CORE_CPP_API MulticastDelegateBase
766 {
767 protected:
768
769 35 template<class T> static void addSlot(SlotList<T>& lst, T const& item)
770 {
771 35 lst.add(item);
772 35 }
773 15 template<class T> static bool_t removeSlot(SlotList<T>& lst, T const& item)
774 {
775
1/2
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
15 for (typename SlotList<T>::iterator it(lst.begin()), itend(lst.end()); it != itend; ++it)
776 {
777
2/4
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
15 if ((*it) == item)
778 {
779
1/2
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
15 lst.remove(it);
780 15 return true;
781 }
782 }
783 ✗ return false;
784 }
785 13 template<class T> static void clearSlots(SlotList<T>& lst)
786 {
787 13 lst.clear();
788 13 }
789
790 };
791
792
793
794 /// @brief
795 class GATE_CORE_CPP_API MulticastDelegate0 : protected MulticastDelegateBase
796 {
797 public:
798 typedef MulticastDelegate0 self_t;
799 typedef Delegate0 delegator_t;
800 typedef SlotList<delegator_t> list_t;
801
802 private:
803 list_t impl;
804
805 public:
806 void invoke() const;
807 void operator()() const;
808
809 void clear();
810 self_t& operator+=(delegator_t const& del);
811 self_t& operator-=(delegator_t const& del);
812 };
813
814
815
816 /// @brief
817 /// @tparam A1
818 template<class A1>
819 class GATE_CORE_CPP_TEMPLATE_API MulticastDelegate1 : protected MulticastDelegateBase
820 {
821 public:
822 typedef MulticastDelegate1<A1> self_t;
823 typedef Delegate1<A1> delegator_t;
824 typedef SlotList<delegator_t> list_t;
825
826 private:
827 list_t impl;
828
829 public:
830 1 void invoke(A1 a1) const
831 {
832
2/2
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
2 for (typename list_t::const_iterator it(this->impl.begin()), itend(this->impl.end()); it != itend; ++it)
833 {
834
1/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 GATEXX_TRY_IGNORE({
835 (*it)(a1);
836 })
837 }
838 1 }
839 1 void operator()(A1 a1) const { this->invoke(a1); }
840
841 1 void clear() { clearSlots(this->impl); }
842 1 self_t& operator+=(delegator_t const& del) { addSlot(this->impl, del); return *this; }
843 1 self_t& operator-=(delegator_t const& del) { removeSlot(this->impl, del); return *this; }
844 };
845
846
847
848 /// @brief
849 /// @tparam A1
850 /// @tparam A2
851 template<class A1, class A2>
852 class GATE_CORE_CPP_TEMPLATE_API MulticastDelegate2 : protected MulticastDelegateBase
853 {
854 public:
855 typedef MulticastDelegate2<A1, A2> self_t;
856 typedef Delegate2<A1, A2> delegator_t;
857 typedef SlotList<delegator_t> list_t;
858
859 private:
860 list_t impl;
861
862 public:
863 28 void invoke(A1 a1, A2 a2) const
864 {
865
2/2
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 20 times.
42 for (typename list_t::const_iterator it(this->impl.begin()), itend(this->impl.end()); it != itend; ++it)
866 {
867
3/4
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
18 GATEXX_TRY_IGNORE({
868 (*it)(a1, a2);
869 });
870 }
871 28 }
872 1 void operator()(A1 a1, A2 a2) const { this->invoke(a1, a2); }
873
874 1 void clear() { clearSlots(this->impl); }
875 21 self_t& operator+=(delegator_t const& del) { addSlot(this->impl, del); return *this; }
876 1 self_t& operator-=(delegator_t const& del) { removeSlot(this->impl, del); return *this; }
877 };
878
879
880 /// @brief
881 /// @tparam A1
882 /// @tparam A2
883 /// @tparam A3
884 template<class A1, class A2, class A3>
885 class GATE_CORE_CPP_TEMPLATE_API MulticastDelegate3 : protected MulticastDelegateBase
886 {
887 public:
888 typedef MulticastDelegate3<A1, A2, A3> self_t;
889 typedef Delegate3<A1, A2, A3> delegator_t;
890 typedef SlotList<delegator_t> list_t;
891
892 private:
893 list_t impl;
894
895 public:
896 1 void invoke(A1 a1, A2 a2, A3 a3) const
897 {
898
2/2
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
2 for (typename list_t::const_iterator it(this->impl.begin()), itend(this->impl.end()); it != itend; ++it)
899 {
900
1/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 GATEXX_TRY_IGNORE({
901 (*it)(a1, a2, a3);
902 });
903 }
904 1 }
905 1 void operator()(A1 a1, A2 a2, A3 a3) const { this->invoke(a1, a2, a3); }
906
907 1 void clear() { clearSlots(this->impl); }
908 1 self_t& operator+=(delegator_t const& del) { addSlot(this->impl, del); return *this; }
909 1 self_t& operator-=(delegator_t const& del) { removeSlot(this->impl, del); return *this; }
910 };
911
912
913 /// @brief
914 /// @tparam A1
915 /// @tparam A2
916 /// @tparam A3
917 /// @tparam A4
918 template<class A1, class A2, class A3, class A4>
919 class GATE_CORE_CPP_TEMPLATE_API MulticastDelegate4 : protected MulticastDelegateBase
920 {
921 public:
922 typedef MulticastDelegate4<A1, A2, A3, A4> self_t;
923 typedef Delegate4<A1, A2, A3, A4> delegator_t;
924 typedef SlotList<delegator_t> list_t;
925
926 private:
927 list_t impl;
928
929 public:
930 1 void invoke(A1 a1, A2 a2, A3 a3, A4 a4) const
931 {
932
2/2
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
2 for (typename list_t::const_iterator it(this->impl.begin()), itend(this->impl.end()); it != itend; ++it)
933 {
934
1/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 GATEXX_TRY_IGNORE({
935 (*it)(a1, a2, a3, a4);
936 });
937 }
938 1 }
939 1 void operator()(A1 a1, A2 a2, A3 a3, A4 a4) const { this->invoke(a1, a2, a3, a4); }
940
941 1 void clear() { clearSlots(this->impl); }
942 1 self_t& operator+=(delegator_t const& del) { addSlot(this->impl, del); return *this; }
943 1 self_t& operator-=(delegator_t const& del) { removeSlot(this->impl, del); return *this; }
944 };
945
946
947 /// @brief
948 /// @tparam A1
949 /// @tparam A2
950 /// @tparam A3
951 /// @tparam A4
952 /// @tparam A5
953 template<class A1, class A2, class A3, class A4, class A5>
954 class GATE_CORE_CPP_TEMPLATE_API MulticastDelegate5 : protected MulticastDelegateBase
955 {
956 public:
957 typedef MulticastDelegate5<A1, A2, A3, A4, A5> self_t;
958 typedef Delegate5<A1, A2, A3, A4, A5> delegator_t;
959 typedef SlotList<delegator_t> list_t;
960
961 private:
962 list_t impl;
963
964 public:
965 1 void invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const
966 {
967
2/2
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
2 for (typename list_t::const_iterator it(this->impl.begin()), itend(this->impl.end()); it != itend; ++it)
968 {
969
1/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 GATEXX_TRY_IGNORE({
970 (*it)(a1, a2, a3, a4, a5);
971 });
972 }
973 1 }
974 1 void operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) const { this->invoke(a1, a2, a3, a4, a5); }
975
976 1 void clear() { clearSlots(this->impl); }
977 1 self_t& operator+=(delegator_t const& del) { addSlot(this->impl, del); return *this; }
978 1 self_t& operator-=(delegator_t const& del) { removeSlot(this->impl, del); return *this; }
979 };
980
981
982 /// @brief
983 /// @tparam A1
984 /// @tparam A2
985 /// @tparam A3
986 /// @tparam A4
987 /// @tparam A5
988 /// @tparam A6
989 template<class A1, class A2, class A3, class A4, class A5, class A6>
990 class GATE_CORE_CPP_TEMPLATE_API MulticastDelegate6 : protected MulticastDelegateBase
991 {
992 public:
993 typedef MulticastDelegate6<A1, A2, A3, A4, A5, A6> self_t;
994 typedef Delegate6<A1, A2, A3, A4, A5, A6> delegator_t;
995 typedef SlotList<delegator_t> list_t;
996
997 private:
998 list_t impl;
999
1000 public:
1001 4 void invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const
1002 {
1003
2/2
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
8 for (typename list_t::const_iterator it(this->impl.begin()), itend(this->impl.end()); it != itend; ++it)
1004 {
1005
1/4
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 GATEXX_TRY_IGNORE({
1006 (*it)(a1, a2, a3, a4, a5, a6);
1007 });
1008 }
1009 4 }
1010 4 void operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) const { this->invoke(a1, a2, a3, a4, a5, a6); }
1011
1012 1 void clear() { clearSlots(this->impl); }
1013 4 self_t& operator+=(delegator_t const& del) { addSlot(this->impl, del); return *this; }
1014 4 self_t& operator-=(delegator_t const& del) { removeSlot(this->impl, del); return *this; }
1015 };
1016
1017
1018
1019 } // end of namespace gate
1020
1021 #endif
1022