• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OpenLightingProject / ola / 5334682433

21 Jun 2023 01:54PM UTC coverage: 44.952% (-0.08%) from 45.027%
5334682433

Pull #1801

github

web-flow
Merge 774a8a4ec into e12b0a68b
Pull Request #1801: Remove EPoll delay, add multi-universe throughput example

7602 of 17680 branches covered (43.0%)

79 of 79 new or added lines in 1 file covered. (100.0%)

21411 of 47631 relevant lines covered (44.95%)

56.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

67.24
/include/ola/Callback.h
1
/*
2
 * This library is free software; you can redistribute it and/or
3
 * modify it under the terms of the GNU Lesser General Public
4
 * License as published by the Free Software Foundation; either
5
 * version 2.1 of the License, or (at your option) any later version.
6
 *
7
 * This library is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10
 * Lesser General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU Lesser General Public
13
 * License along with this library; if not, write to the Free Software
14
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
 *
16
 * Callback.h
17
 * @brief Function objects.
18
 * Copyright (C) 2005 Simon Newton
19
 *
20
 * THIS FILE IS AUTOGENERATED!
21
 * Please edit and run gen_callbacks.py if you need to add more types.
22
 */
23

24
/**
25
 * @defgroup callbacks Callbacks
26
 * @brief Function objects.
27
 *
28
 * Callbacks are powerful objects that behave like function pointers. They
29
 * can be constructed with a pointer to a either plain function or member
30
 * function. Arguments can be provided at either creation time or execution
31
 * time.
32
 *
33
 * The SingleUse variant of a Callback automatically delete itself after it
34
 * has been executed.
35
 *
36
 * Callbacks are used throughout OLA to reduce the coupling between classes
37
 * and make for more modular code.
38
 *
39
 * Avoid creating Callbacks by directly calling the constructor. Instead use
40
 * the NewSingleCallback() and NewCallback() helper methods.
41
 *
42
 * @examplepara Simple function pointer replacement.
43
 *   @code
44
 *   // wrap a function that takes no args and returns a bool
45
 *   SingleUseCallback<bool> *callback1 = NewSingleCallback(&Function0);
46
 *
47
 *   // some time later
48
 *   bool result = callback1->Run();
49
 *   // callback1 has deleted itself at this point
50
 *   @endcode
51
 *
52
 * @examplepara Method pointer with a single bound argument
53
 *   @code
54
 *   // Create a Callback for Method1 of the Object class and bind TEST_VALUE
55
 *   // as the first argument.
56
 *   Callback<void> *callback2 = NewCallback(object, &Object::Method1,
57
 *                                           TEST_VALUE);
58
 *
59
 *   // This will call object->Method1(TEST_VALUE)
60
 *   callback2->Run();
61
 *   // this wasn't a SingleUse Callback, so callback is still around and
62
 *   // needs to be deleted manually.
63
 *   delete callback2;
64
 *   @endcode
65
 *
66
 * @examplepara Method pointer that takes a single argument at execution time.
67
 *   @code
68
 *   // Create a Callback for a method that takes 1 argument and returns void.
69
 *   BaseCallback1<void, unsigned int> *callback3 = NewCallback(
70
 *       object, &Object::Method1);
71
 *
72
 *   // Call object->Method1(TEST_VALUE)
73
 *   callback3->Run(TEST_VALUE);
74
 *   // callback3 is still around at this stage
75
 *   delete callback3;
76
 *   @endcode
77
 *
78
 * @examplepara Method pointer with one bound argument and one execution time
79
 * argument.
80
 *   @code
81
 *   // Create a callback for a method that takes 2 args and returns void
82
 *   BaseCallback2<void, int, int> *callback4 = NewSingleCallback(
83
 *       object,
84
 *       &Object::Method2,
85
 *       TEST_VALUE);
86
 *
87
 *   // This calls object->Method2(TEST_VALUE, TEST_VALUE2);
88
 *   callback4->Run(TEST_VALUE2);
89
 *   // callback4 is still around
90
 *   delete callback4;
91
 *   @endcode
92
 *
93
 * @note The code in Callback.h is autogenerated by gen_callbacks.py. Please
94
 * edit and run gen_callbacks.py if you need to add more types.
95
 *
96
 */
97

98
/**
99
 * @addtogroup callbacks
100
 * @{
101
 * @file Callback.h
102
 * @}
103
 */
104

105
#ifndef INCLUDE_OLA_CALLBACK_H_
106
#define INCLUDE_OLA_CALLBACK_H_
107

108
namespace ola {
109

110
/**
111
 * @addtogroup callbacks
112
 * @{
113
 */
114

115
/**
116
 * @brief The base class for all 0 argument callbacks.
117
 */
118
template <typename ReturnType>
119
class BaseCallback0 {
1,341✔
120
 public:
121
  virtual ~BaseCallback0() {}
1✔
122
  virtual ReturnType Run() = 0;
123
};
124

125
/**
126
 * @brief A 0 argument callback which can be called multiple times.
127
 */
128
template <typename ReturnType>
129
class Callback0: public BaseCallback0<ReturnType> {
561✔
130
 public:
131
  virtual ~Callback0() {}
132
  ReturnType Run() { return this->DoRun(); }
1,003✔
133
 private:
134
  virtual ReturnType DoRun() = 0;
135
};
136

137
/**
138
 * @brief A 0 argument callback which deletes itself after it's run.
139
 */
140
template <typename ReturnType>
141
class SingleUseCallback0: public BaseCallback0<ReturnType> {
6✔
142
 public:
143
  virtual ~SingleUseCallback0() {}
144
  ReturnType Run() {
6✔
145
    ReturnType ret = this->DoRun();
6✔
146
    delete this;
6✔
147
    return ret;
6✔
148
  }
149
 private:
150
  virtual ReturnType DoRun() = 0;
151
};
152

153
/**
154
 * @brief A 0 arg, single use callback that returns void.
155
 */
156
template <>
157
class SingleUseCallback0<void>: public BaseCallback0<void> {
774✔
158
 public:
159
  virtual ~SingleUseCallback0() {}
160
  void Run() {
594✔
161
    this->DoRun();
594✔
162
    delete this;
595✔
163
  }
594✔
164
 private:
165
  virtual void DoRun() = 0;
166
};
167

168
/**
169
 * @brief A Function callback with 0 create-time args and 0 exec time args
170
 */
171
template <typename Parent, typename ReturnType>
172
class FunctionCallback0_0: public Parent {
173
 public:
174
  typedef ReturnType (*Function)();
175
  explicit FunctionCallback0_0(Function callback):
4✔
176
    Parent(),
177
    m_callback(callback) {}
4✔
178
  ReturnType DoRun() {
12✔
179
    return m_callback();
12✔
180
  }
181
 private:
182
  Function m_callback;
183
};
184

185

186
/**
187
 * @brief A helper function to create a new SingleUseCallback with 0
188
 * create-time arguments and 0 execution time arguments.
189
 * @tparam ReturnType the return type of the callback.
190
 * @param callback the function pointer to use when executing the callback.
191
 * @returns The same return value as the function.
192
 */
193
template <typename ReturnType>
194
inline SingleUseCallback0<ReturnType>* NewSingleCallback(
2✔
195
  ReturnType (*callback)()) {
196
  return new FunctionCallback0_0<
2✔
197
                                 SingleUseCallback0<ReturnType>,
198
                                 ReturnType>(
199
      callback);
2✔
200
}
201

202

203
/**
204
 * @brief A helper function to create a new Callback with 0
205
 * create-time arguments and 0 execution time arguments.
206
 * @tparam ReturnType the return type of the callback.
207
 * @param callback the function pointer to use when executing the callback.
208
 * @returns The same return value as the function.
209
 */
210
template <typename ReturnType>
211
inline Callback0<ReturnType>* NewCallback(
2✔
212
  ReturnType (*callback)()) {
213
  return new FunctionCallback0_0<
2✔
214
                                 Callback0<ReturnType>,
215
                                 ReturnType>(
216
      callback);
2✔
217
}
218

219

220
/**
221
 * @brief A Method callback with 0 create-time args and 0 exec time args
222
 */
223
template <typename Class, typename Parent, typename ReturnType>
224
class MethodCallback0_0: public Parent {
225
 public:
226
  typedef ReturnType (Class::*Method)();
227
  MethodCallback0_0(Class *object, Method callback):
1,029✔
228
    Parent(),
229
    m_object(object),
1,029✔
230
    m_callback(callback) {}
1,029✔
231
  ReturnType DoRun() {
1,936✔
232
    return (m_object->*m_callback)();
1,936✔
233
  }
234
 private:
235
  Class *m_object;
236
  Method m_callback;
237
};
238

239

240
/**
241
 * @brief A helper function to create a new SingleUseCallback with 0
242
 * create-time arguments and 0 execution time arguments.
243
 * @tparam Class the class with the member function.
244
 * @tparam ReturnType the return type of the callback.
245
 * @param object the object to call the member function on.
246
 * @param method the member function pointer to use when executing the callback.
247
 * @returns The same return value as the member function.
248
 */
249
template <typename Class, typename ReturnType>
250
inline SingleUseCallback0<ReturnType>* NewSingleCallback(
511✔
251
  Class* object,
252
  ReturnType (Class::*method)()) {
253
  return new MethodCallback0_0<Class,
511✔
254
                               SingleUseCallback0<ReturnType>,
255
                               ReturnType>(
256
      object,
257
      method);
511✔
258
}
259

260

261
/**
262
 * @brief A helper function to create a new Callback with 0
263
 * create-time arguments and 0 execution time arguments.
264
 * @tparam Class the class with the member function.
265
 * @tparam ReturnType the return type of the callback.
266
 * @param object the object to call the member function on.
267
 * @param method the member function pointer to use when executing the callback.
268
 * @returns The same return value as the member function.
269
 */
270
template <typename Class, typename ReturnType>
271
inline Callback0<ReturnType>* NewCallback(
513✔
272
  Class* object,
273
  ReturnType (Class::*method)()) {
274
  return new MethodCallback0_0<Class,
517✔
275
                               Callback0<ReturnType>,
276
                               ReturnType>(
277
      object,
278
      method);
517✔
279
}
280

281

282
/**
283
 * @brief A Function callback with 1 create-time args and 0 exec time args
284
 */
285
template <typename Parent, typename ReturnType, typename A0>
286
class FunctionCallback1_0: public Parent {
287
 public:
288
  typedef ReturnType (*Function)(A0);
289
  FunctionCallback1_0(Function callback, A0 a0):
14✔
290
    Parent(),
291
    m_callback(callback),
14✔
292
    m_a0(a0) {}
14✔
293
  ReturnType DoRun() {
22✔
294
    return m_callback(m_a0);
22✔
295
  }
296
 private:
297
  Function m_callback;
298
  A0 m_a0;
299
};
300

301

302
/**
303
 * @brief A helper function to create a new SingleUseCallback with 1
304
 * create-time arguments and 0 execution time arguments.
305
 * @tparam ReturnType the return type of the callback.
306
 * @tparam A0 a create-time argument type.
307
 * @param callback the function pointer to use when executing the callback.
308
 * @param a0 a create-time argument.
309
 * @returns The same return value as the function.
310
 */
311
template <typename ReturnType, typename A0>
312
inline SingleUseCallback0<ReturnType>* NewSingleCallback(
12✔
313
  ReturnType (*callback)(A0),
314
  A0 a0) {
315
  return new FunctionCallback1_0<
12✔
316
                                 SingleUseCallback0<ReturnType>,
317
                                 ReturnType,
318
                                 A0>(
319
      callback,
320
      a0);
12✔
321
}
322

323

324
/**
325
 * @brief A helper function to create a new Callback with 1
326
 * create-time arguments and 0 execution time arguments.
327
 * @tparam ReturnType the return type of the callback.
328
 * @tparam A0 a create-time argument type.
329
 * @param callback the function pointer to use when executing the callback.
330
 * @param a0 a create-time argument.
331
 * @returns The same return value as the function.
332
 */
333
template <typename ReturnType, typename A0>
334
inline Callback0<ReturnType>* NewCallback(
2✔
335
  ReturnType (*callback)(A0),
336
  A0 a0) {
337
  return new FunctionCallback1_0<
2✔
338
                                 Callback0<ReturnType>,
339
                                 ReturnType,
340
                                 A0>(
341
      callback,
342
      a0);
2✔
343
}
344

345

346
/**
347
 * @brief A Method callback with 1 create-time args and 0 exec time args
348
 */
349
template <typename Class, typename Parent, typename ReturnType, typename A0>
350
class MethodCallback1_0: public Parent {
351
 public:
352
  typedef ReturnType (Class::*Method)(A0);
353
  MethodCallback1_0(Class *object, Method callback, A0 a0):
176✔
354
    Parent(),
355
    m_object(object),
176✔
356
    m_callback(callback),
176✔
357
    m_a0(a0) {}
176✔
358
  ReturnType DoRun() {
119✔
359
    return (m_object->*m_callback)(m_a0);
119✔
360
  }
361
 private:
362
  Class *m_object;
363
  Method m_callback;
364
  A0 m_a0;
365
};
366

367

368
/**
369
 * @brief A helper function to create a new SingleUseCallback with 1
370
 * create-time arguments and 0 execution time arguments.
371
 * @tparam Class the class with the member function.
372
 * @tparam ReturnType the return type of the callback.
373
 * @tparam A0 a create-time argument type.
374
 * @param object the object to call the member function on.
375
 * @param method the member function pointer to use when executing the callback.
376
 * @param a0 a create-time argument.
377
 * @returns The same return value as the member function.
378
 */
379
template <typename Class, typename ReturnType, typename A0>
380
inline SingleUseCallback0<ReturnType>* NewSingleCallback(
147✔
381
  Class* object,
382
  ReturnType (Class::*method)(A0),
383
  A0 a0) {
384
  return new MethodCallback1_0<Class,
147✔
385
                               SingleUseCallback0<ReturnType>,
386
                               ReturnType,
387
                               A0>(
388
      object,
389
      method,
390
      a0);
147✔
391
}
392

393

394
/**
395
 * @brief A helper function to create a new Callback with 1
396
 * create-time arguments and 0 execution time arguments.
397
 * @tparam Class the class with the member function.
398
 * @tparam ReturnType the return type of the callback.
399
 * @tparam A0 a create-time argument type.
400
 * @param object the object to call the member function on.
401
 * @param method the member function pointer to use when executing the callback.
402
 * @param a0 a create-time argument.
403
 * @returns The same return value as the member function.
404
 */
405
template <typename Class, typename ReturnType, typename A0>
406
inline Callback0<ReturnType>* NewCallback(
29✔
407
  Class* object,
408
  ReturnType (Class::*method)(A0),
409
  A0 a0) {
410
  return new MethodCallback1_0<Class,
29✔
411
                               Callback0<ReturnType>,
412
                               ReturnType,
413
                               A0>(
414
      object,
415
      method,
416
      a0);
29✔
417
}
418

419

420
/**
421
 * @brief A Function callback with 2 create-time args and 0 exec time args
422
 */
423
template <typename Parent, typename ReturnType, typename A0, typename A1>
424
class FunctionCallback2_0: public Parent {
425
 public:
426
  typedef ReturnType (*Function)(A0, A1);
427
  FunctionCallback2_0(Function callback, A0 a0, A1 a1):
55✔
428
    Parent(),
429
    m_callback(callback),
55✔
430
    m_a0(a0),
55✔
431
    m_a1(a1) {}
55✔
432
  ReturnType DoRun() {
55✔
433
    return m_callback(m_a0, m_a1);
55✔
434
  }
435
 private:
436
  Function m_callback;
437
  A0 m_a0;
438
  A1 m_a1;
439
};
440

441

442
/**
443
 * @brief A helper function to create a new SingleUseCallback with 2
444
 * create-time arguments and 0 execution time arguments.
445
 * @tparam ReturnType the return type of the callback.
446
 * @tparam A0 a create-time argument type.
447
 * @tparam A1 a create-time argument type.
448
 * @param callback the function pointer to use when executing the callback.
449
 * @param a0 a create-time argument.
450
 * @param a1 a create-time argument.
451
 * @returns The same return value as the function.
452
 */
453
template <typename ReturnType, typename A0, typename A1>
454
inline SingleUseCallback0<ReturnType>* NewSingleCallback(
55✔
455
  ReturnType (*callback)(A0, A1),
456
  A0 a0,
457
  A1 a1) {
458
  return new FunctionCallback2_0<
55✔
459
                                 SingleUseCallback0<ReturnType>,
460
                                 ReturnType,
461
                                 A0,
462
                                 A1>(
463
      callback,
464
      a0,
465
      a1);
55✔
466
}
467

468

469
/**
470
 * @brief A helper function to create a new Callback with 2
471
 * create-time arguments and 0 execution time arguments.
472
 * @tparam ReturnType the return type of the callback.
473
 * @tparam A0 a create-time argument type.
474
 * @tparam A1 a create-time argument type.
475
 * @param callback the function pointer to use when executing the callback.
476
 * @param a0 a create-time argument.
477
 * @param a1 a create-time argument.
478
 * @returns The same return value as the function.
479
 */
480
template <typename ReturnType, typename A0, typename A1>
481
inline Callback0<ReturnType>* NewCallback(
×
482
  ReturnType (*callback)(A0, A1),
483
  A0 a0,
484
  A1 a1) {
485
  return new FunctionCallback2_0<
×
486
                                 Callback0<ReturnType>,
487
                                 ReturnType,
488
                                 A0,
489
                                 A1>(
490
      callback,
491
      a0,
492
      a1);
×
493
}
494

495

496
/**
497
 * @brief A Method callback with 2 create-time args and 0 exec time args
498
 */
499
template <typename Class, typename Parent, typename ReturnType, typename A0, typename A1>  // NOLINT(whitespace/line_length)
500
class MethodCallback2_0: public Parent {
501
 public:
502
  typedef ReturnType (Class::*Method)(A0, A1);
503
  MethodCallback2_0(Class *object, Method callback, A0 a0, A1 a1):
54✔
504
    Parent(),
505
    m_object(object),
54✔
506
    m_callback(callback),
54✔
507
    m_a0(a0),
54✔
508
    m_a1(a1) {}
54✔
509
  ReturnType DoRun() {
97✔
510
    return (m_object->*m_callback)(m_a0, m_a1);
97✔
511
  }
512
 private:
513
  Class *m_object;
514
  Method m_callback;
515
  A0 m_a0;
516
  A1 m_a1;
517
};
518

519

520
/**
521
 * @brief A helper function to create a new SingleUseCallback with 2
522
 * create-time arguments and 0 execution time arguments.
523
 * @tparam Class the class with the member function.
524
 * @tparam ReturnType the return type of the callback.
525
 * @tparam A0 a create-time argument type.
526
 * @tparam A1 a create-time argument type.
527
 * @param object the object to call the member function on.
528
 * @param method the member function pointer to use when executing the callback.
529
 * @param a0 a create-time argument.
530
 * @param a1 a create-time argument.
531
 * @returns The same return value as the member function.
532
 */
533
template <typename Class, typename ReturnType, typename A0, typename A1>
534
inline SingleUseCallback0<ReturnType>* NewSingleCallback(
47✔
535
  Class* object,
536
  ReturnType (Class::*method)(A0, A1),
537
  A0 a0,
538
  A1 a1) {
539
  return new MethodCallback2_0<Class,
47✔
540
                               SingleUseCallback0<ReturnType>,
541
                               ReturnType,
542
                               A0,
543
                               A1>(
544
      object,
545
      method,
546
      a0,
547
      a1);
47✔
548
}
549

550

551
/**
552
 * @brief A helper function to create a new Callback with 2
553
 * create-time arguments and 0 execution time arguments.
554
 * @tparam Class the class with the member function.
555
 * @tparam ReturnType the return type of the callback.
556
 * @tparam A0 a create-time argument type.
557
 * @tparam A1 a create-time argument type.
558
 * @param object the object to call the member function on.
559
 * @param method the member function pointer to use when executing the callback.
560
 * @param a0 a create-time argument.
561
 * @param a1 a create-time argument.
562
 * @returns The same return value as the member function.
563
 */
564
template <typename Class, typename ReturnType, typename A0, typename A1>
565
inline Callback0<ReturnType>* NewCallback(
7✔
566
  Class* object,
567
  ReturnType (Class::*method)(A0, A1),
568
  A0 a0,
569
  A1 a1) {
570
  return new MethodCallback2_0<Class,
7✔
571
                               Callback0<ReturnType>,
572
                               ReturnType,
573
                               A0,
574
                               A1>(
575
      object,
576
      method,
577
      a0,
578
      a1);
7✔
579
}
580

581

582
/**
583
 * @brief A Function callback with 3 create-time args and 0 exec time args
584
 */
585
template <typename Parent, typename ReturnType, typename A0, typename A1, typename A2>  // NOLINT(whitespace/line_length)
586
class FunctionCallback3_0: public Parent {
587
 public:
588
  typedef ReturnType (*Function)(A0, A1, A2);
589
  FunctionCallback3_0(Function callback, A0 a0, A1 a1, A2 a2):
×
590
    Parent(),
591
    m_callback(callback),
×
592
    m_a0(a0),
×
593
    m_a1(a1),
×
594
    m_a2(a2) {}
×
595
  ReturnType DoRun() {
×
596
    return m_callback(m_a0, m_a1, m_a2);
×
597
  }
598
 private:
599
  Function m_callback;
600
  A0 m_a0;
601
  A1 m_a1;
602
  A2 m_a2;
603
};
604

605

606
/**
607
 * @brief A helper function to create a new SingleUseCallback with 3
608
 * create-time arguments and 0 execution time arguments.
609
 * @tparam ReturnType the return type of the callback.
610
 * @tparam A0 a create-time argument type.
611
 * @tparam A1 a create-time argument type.
612
 * @tparam A2 a create-time argument type.
613
 * @param callback the function pointer to use when executing the callback.
614
 * @param a0 a create-time argument.
615
 * @param a1 a create-time argument.
616
 * @param a2 a create-time argument.
617
 * @returns The same return value as the function.
618
 */
619
template <typename ReturnType, typename A0, typename A1, typename A2>
620
inline SingleUseCallback0<ReturnType>* NewSingleCallback(
621
  ReturnType (*callback)(A0, A1, A2),
622
  A0 a0,
623
  A1 a1,
624
  A2 a2) {
625
  return new FunctionCallback3_0<
626
                                 SingleUseCallback0<ReturnType>,
627
                                 ReturnType,
628
                                 A0,
629
                                 A1,
630
                                 A2>(
631
      callback,
632
      a0,
633
      a1,
634
      a2);
635
}
636

637

638
/**
639
 * @brief A helper function to create a new Callback with 3
640
 * create-time arguments and 0 execution time arguments.
641
 * @tparam ReturnType the return type of the callback.
642
 * @tparam A0 a create-time argument type.
643
 * @tparam A1 a create-time argument type.
644
 * @tparam A2 a create-time argument type.
645
 * @param callback the function pointer to use when executing the callback.
646
 * @param a0 a create-time argument.
647
 * @param a1 a create-time argument.
648
 * @param a2 a create-time argument.
649
 * @returns The same return value as the function.
650
 */
651
template <typename ReturnType, typename A0, typename A1, typename A2>
652
inline Callback0<ReturnType>* NewCallback(
×
653
  ReturnType (*callback)(A0, A1, A2),
654
  A0 a0,
655
  A1 a1,
656
  A2 a2) {
657
  return new FunctionCallback3_0<
×
658
                                 Callback0<ReturnType>,
659
                                 ReturnType,
660
                                 A0,
661
                                 A1,
662
                                 A2>(
663
      callback,
664
      a0,
665
      a1,
666
      a2);
×
667
}
668

669

670
/**
671
 * @brief A Method callback with 3 create-time args and 0 exec time args
672
 */
673
template <typename Class, typename Parent, typename ReturnType, typename A0, typename A1, typename A2>  // NOLINT(whitespace/line_length)
674
class MethodCallback3_0: public Parent {
675
 public:
676
  typedef ReturnType (Class::*Method)(A0, A1, A2);
677
  MethodCallback3_0(Class *object, Method callback, A0 a0, A1 a1, A2 a2):
14✔
678
    Parent(),
679
    m_object(object),
14✔
680
    m_callback(callback),
14✔
681
    m_a0(a0),
24✔
682
    m_a1(a1),
14✔
683
    m_a2(a2) {}
24✔
684
  ReturnType DoRun() {
22✔
685
    return (m_object->*m_callback)(m_a0, m_a1, m_a2);
32✔
686
  }
687
 private:
688
  Class *m_object;
689
  Method m_callback;
690
  A0 m_a0;
691
  A1 m_a1;
692
  A2 m_a2;
693
};
694

695

696
/**
697
 * @brief A helper function to create a new SingleUseCallback with 3
698
 * create-time arguments and 0 execution time arguments.
699
 * @tparam Class the class with the member function.
700
 * @tparam ReturnType the return type of the callback.
701
 * @tparam A0 a create-time argument type.
702
 * @tparam A1 a create-time argument type.
703
 * @tparam A2 a create-time argument type.
704
 * @param object the object to call the member function on.
705
 * @param method the member function pointer to use when executing the callback.
706
 * @param a0 a create-time argument.
707
 * @param a1 a create-time argument.
708
 * @param a2 a create-time argument.
709
 * @returns The same return value as the member function.
710
 */
711
template <typename Class, typename ReturnType, typename A0, typename A1, typename A2>  // NOLINT(whitespace/line_length)
712
inline SingleUseCallback0<ReturnType>* NewSingleCallback(
6✔
713
  Class* object,
714
  ReturnType (Class::*method)(A0, A1, A2),
715
  A0 a0,
716
  A1 a1,
717
  A2 a2) {
718
  return new MethodCallback3_0<Class,
10✔
719
                               SingleUseCallback0<ReturnType>,
720
                               ReturnType,
721
                               A0,
722
                               A1,
723
                               A2>(
724
      object,
725
      method,
726
      a0,
727
      a1,
728
      a2);
8✔
729
}
730

731

732
/**
733
 * @brief A helper function to create a new Callback with 3
734
 * create-time arguments and 0 execution time arguments.
735
 * @tparam Class the class with the member function.
736
 * @tparam ReturnType the return type of the callback.
737
 * @tparam A0 a create-time argument type.
738
 * @tparam A1 a create-time argument type.
739
 * @tparam A2 a create-time argument type.
740
 * @param object the object to call the member function on.
741
 * @param method the member function pointer to use when executing the callback.
742
 * @param a0 a create-time argument.
743
 * @param a1 a create-time argument.
744
 * @param a2 a create-time argument.
745
 * @returns The same return value as the member function.
746
 */
747
template <typename Class, typename ReturnType, typename A0, typename A1, typename A2>  // NOLINT(whitespace/line_length)
748
inline Callback0<ReturnType>* NewCallback(
3✔
749
  Class* object,
750
  ReturnType (Class::*method)(A0, A1, A2),
751
  A0 a0,
752
  A1 a1,
753
  A2 a2) {
754
  return new MethodCallback3_0<Class,
4✔
755
                               Callback0<ReturnType>,
756
                               ReturnType,
757
                               A0,
758
                               A1,
759
                               A2>(
760
      object,
761
      method,
762
      a0,
763
      a1,
764
      a2);
2✔
765
}
766

767

768
/**
769
 * @brief A Function callback with 4 create-time args and 0 exec time args
770
 */
771
template <typename Parent, typename ReturnType, typename A0, typename A1, typename A2, typename A3>  // NOLINT(whitespace/line_length)
772
class FunctionCallback4_0: public Parent {
773
 public:
774
  typedef ReturnType (*Function)(A0, A1, A2, A3);
775
  FunctionCallback4_0(Function callback, A0 a0, A1 a1, A2 a2, A3 a3):
776
    Parent(),
777
    m_callback(callback),
778
    m_a0(a0),
779
    m_a1(a1),
780
    m_a2(a2),
781
    m_a3(a3) {}
782
  ReturnType DoRun() {
783
    return m_callback(m_a0, m_a1, m_a2, m_a3);
784
  }
785
 private:
786
  Function m_callback;
787
  A0 m_a0;
788
  A1 m_a1;
789
  A2 m_a2;
790
  A3 m_a3;
791
};
792

793

794
/**
795
 * @brief A helper function to create a new SingleUseCallback with 4
796
 * create-time arguments and 0 execution time arguments.
797
 * @tparam ReturnType the return type of the callback.
798
 * @tparam A0 a create-time argument type.
799
 * @tparam A1 a create-time argument type.
800
 * @tparam A2 a create-time argument type.
801
 * @tparam A3 a create-time argument type.
802
 * @param callback the function pointer to use when executing the callback.
803
 * @param a0 a create-time argument.
804
 * @param a1 a create-time argument.
805
 * @param a2 a create-time argument.
806
 * @param a3 a create-time argument.
807
 * @returns The same return value as the function.
808
 */
809
template <typename ReturnType, typename A0, typename A1, typename A2, typename A3>  // NOLINT(whitespace/line_length)
810
inline SingleUseCallback0<ReturnType>* NewSingleCallback(
811
  ReturnType (*callback)(A0, A1, A2, A3),
812
  A0 a0,
813
  A1 a1,
814
  A2 a2,
815
  A3 a3) {
816
  return new FunctionCallback4_0<
817
                                 SingleUseCallback0<ReturnType>,
818
                                 ReturnType,
819
                                 A0,
820
                                 A1,
821
                                 A2,
822
                                 A3>(
823
      callback,
824
      a0,
825
      a1,
826
      a2,
827
      a3);
828
}
829

830

831
/**
832
 * @brief A helper function to create a new Callback with 4
833
 * create-time arguments and 0 execution time arguments.
834
 * @tparam ReturnType the return type of the callback.
835
 * @tparam A0 a create-time argument type.
836
 * @tparam A1 a create-time argument type.
837
 * @tparam A2 a create-time argument type.
838
 * @tparam A3 a create-time argument type.
839
 * @param callback the function pointer to use when executing the callback.
840
 * @param a0 a create-time argument.
841
 * @param a1 a create-time argument.
842
 * @param a2 a create-time argument.
843
 * @param a3 a create-time argument.
844
 * @returns The same return value as the function.
845
 */
846
template <typename ReturnType, typename A0, typename A1, typename A2, typename A3>  // NOLINT(whitespace/line_length)
847
inline Callback0<ReturnType>* NewCallback(
848
  ReturnType (*callback)(A0, A1, A2, A3),
849
  A0 a0,
850
  A1 a1,
851
  A2 a2,
852
  A3 a3) {
853
  return new FunctionCallback4_0<
854
                                 Callback0<ReturnType>,
855
                                 ReturnType,
856
                                 A0,
857
                                 A1,
858
                                 A2,
859
                                 A3>(
860
      callback,
861
      a0,
862
      a1,
863
      a2,
864
      a3);
865
}
866

867

868
/**
869
 * @brief A Method callback with 4 create-time args and 0 exec time args
870
 */
871
template <typename Class, typename Parent, typename ReturnType, typename A0, typename A1, typename A2, typename A3>  // NOLINT(whitespace/line_length)
872
class MethodCallback4_0: public Parent {
873
 public:
874
  typedef ReturnType (Class::*Method)(A0, A1, A2, A3);
875
  MethodCallback4_0(Class *object, Method callback, A0 a0, A1 a1, A2 a2, A3 a3):
×
876
    Parent(),
877
    m_object(object),
×
878
    m_callback(callback),
×
879
    m_a0(a0),
×
880
    m_a1(a1),
×
881
    m_a2(a2),
×
882
    m_a3(a3) {}
×
883
  ReturnType DoRun() {
×
884
    return (m_object->*m_callback)(m_a0, m_a1, m_a2, m_a3);
×
885
  }
886
 private:
887
  Class *m_object;
888
  Method m_callback;
889
  A0 m_a0;
890
  A1 m_a1;
891
  A2 m_a2;
892
  A3 m_a3;
893
};
894

895

896
/**
897
 * @brief A helper function to create a new SingleUseCallback with 4
898
 * create-time arguments and 0 execution time arguments.
899
 * @tparam Class the class with the member function.
900
 * @tparam ReturnType the return type of the callback.
901
 * @tparam A0 a create-time argument type.
902
 * @tparam A1 a create-time argument type.
903
 * @tparam A2 a create-time argument type.
904
 * @tparam A3 a create-time argument type.
905
 * @param object the object to call the member function on.
906
 * @param method the member function pointer to use when executing the callback.
907
 * @param a0 a create-time argument.
908
 * @param a1 a create-time argument.
909
 * @param a2 a create-time argument.
910
 * @param a3 a create-time argument.
911
 * @returns The same return value as the member function.
912
 */
913
template <typename Class, typename ReturnType, typename A0, typename A1, typename A2, typename A3>  // NOLINT(whitespace/line_length)
914
inline SingleUseCallback0<ReturnType>* NewSingleCallback(
×
915
  Class* object,
916
  ReturnType (Class::*method)(A0, A1, A2, A3),
917
  A0 a0,
918
  A1 a1,
919
  A2 a2,
920
  A3 a3) {
921
  return new MethodCallback4_0<Class,
×
922
                               SingleUseCallback0<ReturnType>,
923
                               ReturnType,
924
                               A0,
925
                               A1,
926
                               A2,
927
                               A3>(
928
      object,
929
      method,
930
      a0,
931
      a1,
932
      a2,
933
      a3);
934
}
935

936

937
/**
938
 * @brief A helper function to create a new Callback with 4
939
 * create-time arguments and 0 execution time arguments.
940
 * @tparam Class the class with the member function.
941
 * @tparam ReturnType the return type of the callback.
942
 * @tparam A0 a create-time argument type.
943
 * @tparam A1 a create-time argument type.
944
 * @tparam A2 a create-time argument type.
945
 * @tparam A3 a create-time argument type.
946
 * @param object the object to call the member function on.
947
 * @param method the member function pointer to use when executing the callback.
948
 * @param a0 a create-time argument.
949
 * @param a1 a create-time argument.
950
 * @param a2 a create-time argument.
951
 * @param a3 a create-time argument.
952
 * @returns The same return value as the member function.
953
 */
954
template <typename Class, typename ReturnType, typename A0, typename A1, typename A2, typename A3>  // NOLINT(whitespace/line_length)
955
inline Callback0<ReturnType>* NewCallback(
956
  Class* object,
957
  ReturnType (Class::*method)(A0, A1, A2, A3),
958
  A0 a0,
959
  A1 a1,
960
  A2 a2,
961
  A3 a3) {
962
  return new MethodCallback4_0<Class,
963
                               Callback0<ReturnType>,
964
                               ReturnType,
965
                               A0,
966
                               A1,
967
                               A2,
968
                               A3>(
969
      object,
970
      method,
971
      a0,
972
      a1,
973
      a2,
974
      a3);
975
}
976

977

978
/**
979
 * @brief The base class for all 1 argument callbacks.
980
 */
981
template <typename ReturnType, typename Arg0>
982
class BaseCallback1 {
676✔
983
 public:
984
  virtual ~BaseCallback1() {}
985
  virtual ReturnType Run(Arg0 arg0) = 0;
986
};
987

988
/**
989
 * @brief A 1 argument callback which can be called multiple times.
990
 */
991
template <typename ReturnType, typename Arg0>
992
class Callback1: public BaseCallback1<ReturnType, Arg0> {
286✔
993
 public:
994
  virtual ~Callback1() {}
995
  ReturnType Run(Arg0 arg0) { return this->DoRun(arg0); }
229✔
996
 private:
997
  virtual ReturnType DoRun(Arg0 arg0) = 0;
998
};
999

1000
/**
1001
 * @brief A 1 argument callback which deletes itself after it's run.
1002
 */
1003
template <typename ReturnType, typename Arg0>
1004
class SingleUseCallback1: public BaseCallback1<ReturnType, Arg0> {
5✔
1005
 public:
1006
  virtual ~SingleUseCallback1() {}
1007
  ReturnType Run(Arg0 arg0) {
10✔
1008
    ReturnType ret = this->DoRun(arg0);
10✔
1009
    delete this;
10✔
1010
    return ret;
10✔
1011
  }
1012
 private:
1013
  virtual ReturnType DoRun(Arg0 arg0) = 0;
1014
};
1015

1016
/**
1017
 * @brief A 1 arg, single use callback that returns void.
1018
 */
1019
template <typename Arg0>
1020
class SingleUseCallback1<void, Arg0>: public BaseCallback1<void, Arg0> {
385✔
1021
 public:
1022
  virtual ~SingleUseCallback1() {}
1023
  void Run(Arg0 arg0) {
572✔
1024
    this->DoRun(arg0);
572✔
1025
    delete this;
572✔
1026
  }
572✔
1027
 private:
1028
  virtual void DoRun(Arg0 arg0) = 0;
1029
};
1030

1031
/**
1032
 * @brief A Function callback with 0 create-time args and 1 exec time args
1033
 */
1034
template <typename Parent, typename ReturnType, typename Arg0>
1035
class FunctionCallback0_1: public Parent {
1036
 public:
1037
  typedef ReturnType (*Function)(Arg0);
1038
  explicit FunctionCallback0_1(Function callback):
4✔
1039
    Parent(),
1040
    m_callback(callback) {}
4✔
1041
  ReturnType DoRun(Arg0 arg0) {
12✔
1042
    return m_callback(arg0);
12✔
1043
  }
1044
 private:
1045
  Function m_callback;
1046
};
1047

1048

1049
/**
1050
 * @brief A helper function to create a new SingleUseCallback with 0
1051
 * create-time arguments and 1 execution time arguments.
1052
 * @tparam ReturnType the return type of the callback.
1053
 * @tparam Arg0 an exec-time argument type.
1054
 * @param callback the function pointer to use when executing the callback.
1055
 * @returns The same return value as the function.
1056
 */
1057
template <typename ReturnType, typename Arg0>
1058
inline SingleUseCallback1<ReturnType, Arg0>* NewSingleCallback(
2✔
1059
  ReturnType (*callback)(Arg0)) {
1060
  return new FunctionCallback0_1<
2✔
1061
                                 SingleUseCallback1<ReturnType, Arg0>,
1062
                                 ReturnType,
1063
                                 Arg0>(
1064
      callback);
2✔
1065
}
1066

1067

1068
/**
1069
 * @brief A helper function to create a new Callback with 0
1070
 * create-time arguments and 1 execution time arguments.
1071
 * @tparam ReturnType the return type of the callback.
1072
 * @tparam Arg0 an exec-time argument type.
1073
 * @param callback the function pointer to use when executing the callback.
1074
 * @returns The same return value as the function.
1075
 */
1076
template <typename ReturnType, typename Arg0>
1077
inline Callback1<ReturnType, Arg0>* NewCallback(
2✔
1078
  ReturnType (*callback)(Arg0)) {
1079
  return new FunctionCallback0_1<
2✔
1080
                                 Callback1<ReturnType, Arg0>,
1081
                                 ReturnType,
1082
                                 Arg0>(
1083
      callback);
2✔
1084
}
1085

1086

1087
/**
1088
 * @brief A Method callback with 0 create-time args and 1 exec time args
1089
 */
1090
template <typename Class, typename Parent, typename ReturnType, typename Arg0>
1091
class MethodCallback0_1: public Parent {
1092
 public:
1093
  typedef ReturnType (Class::*Method)(Arg0);
1094
  MethodCallback0_1(Class *object, Method callback):
425✔
1095
    Parent(),
1096
    m_object(object),
425✔
1097
    m_callback(callback) {}
425✔
1098
  ReturnType DoRun(Arg0 arg0) {
509✔
1099
    return (m_object->*m_callback)(arg0);
509✔
1100
  }
1101
 private:
1102
  Class *m_object;
1103
  Method m_callback;
1104
};
1105

1106

1107
/**
1108
 * @brief A helper function to create a new SingleUseCallback with 0
1109
 * create-time arguments and 1 execution time arguments.
1110
 * @tparam Class the class with the member function.
1111
 * @tparam ReturnType the return type of the callback.
1112
 * @tparam Arg0 an exec-time argument type.
1113
 * @param object the object to call the member function on.
1114
 * @param method the member function pointer to use when executing the callback.
1115
 * @returns The same return value as the member function.
1116
 */
1117
template <typename Class, typename ReturnType, typename Arg0>
1118
inline SingleUseCallback1<ReturnType, Arg0>* NewSingleCallback(
150✔
1119
  Class* object,
1120
  ReturnType (Class::*method)(Arg0)) {
1121
  return new MethodCallback0_1<Class,
150✔
1122
                               SingleUseCallback1<ReturnType, Arg0>,
1123
                               ReturnType,
1124
                               Arg0>(
1125
      object,
1126
      method);
150✔
1127
}
1128

1129

1130
/**
1131
 * @brief A helper function to create a new Callback with 0
1132
 * create-time arguments and 1 execution time arguments.
1133
 * @tparam Class the class with the member function.
1134
 * @tparam ReturnType the return type of the callback.
1135
 * @tparam Arg0 an exec-time argument type.
1136
 * @param object the object to call the member function on.
1137
 * @param method the member function pointer to use when executing the callback.
1138
 * @returns The same return value as the member function.
1139
 */
1140
template <typename Class, typename ReturnType, typename Arg0>
1141
inline Callback1<ReturnType, Arg0>* NewCallback(
241✔
1142
  Class* object,
1143
  ReturnType (Class::*method)(Arg0)) {
1144
  return new MethodCallback0_1<Class,
241✔
1145
                               Callback1<ReturnType, Arg0>,
1146
                               ReturnType,
1147
                               Arg0>(
1148
      object,
1149
      method);
241✔
1150
}
1151

1152

1153
/**
1154
 * @brief A Function callback with 1 create-time args and 1 exec time args
1155
 */
1156
template <typename Parent, typename ReturnType, typename A0, typename Arg0>
1157
class FunctionCallback1_1: public Parent {
1158
 public:
1159
  typedef ReturnType (*Function)(A0, Arg0);
1160
  FunctionCallback1_1(Function callback, A0 a0):
2✔
1161
    Parent(),
1162
    m_callback(callback),
2✔
1163
    m_a0(a0) {}
2✔
1164
  ReturnType DoRun(Arg0 arg0) {
6✔
1165
    return m_callback(m_a0, arg0);
6✔
1166
  }
1167
 private:
1168
  Function m_callback;
1169
  A0 m_a0;
1170
};
1171

1172

1173
/**
1174
 * @brief A helper function to create a new SingleUseCallback with 1
1175
 * create-time arguments and 1 execution time arguments.
1176
 * @tparam ReturnType the return type of the callback.
1177
 * @tparam A0 a create-time argument type.
1178
 * @tparam Arg0 an exec-time argument type.
1179
 * @param callback the function pointer to use when executing the callback.
1180
 * @param a0 a create-time argument.
1181
 * @returns The same return value as the function.
1182
 */
1183
template <typename ReturnType, typename A0, typename Arg0>
1184
inline SingleUseCallback1<ReturnType, Arg0>* NewSingleCallback(
1✔
1185
  ReturnType (*callback)(A0, Arg0),
1186
  A0 a0) {
1187
  return new FunctionCallback1_1<
1✔
1188
                                 SingleUseCallback1<ReturnType, Arg0>,
1189
                                 ReturnType,
1190
                                 A0,
1191
                                 Arg0>(
1192
      callback,
1193
      a0);
1✔
1194
}
1195

1196

1197
/**
1198
 * @brief A helper function to create a new Callback with 1
1199
 * create-time arguments and 1 execution time arguments.
1200
 * @tparam ReturnType the return type of the callback.
1201
 * @tparam A0 a create-time argument type.
1202
 * @tparam Arg0 an exec-time argument type.
1203
 * @param callback the function pointer to use when executing the callback.
1204
 * @param a0 a create-time argument.
1205
 * @returns The same return value as the function.
1206
 */
1207
template <typename ReturnType, typename A0, typename Arg0>
1208
inline Callback1<ReturnType, Arg0>* NewCallback(
1✔
1209
  ReturnType (*callback)(A0, Arg0),
1210
  A0 a0) {
1211
  return new FunctionCallback1_1<
1✔
1212
                                 Callback1<ReturnType, Arg0>,
1213
                                 ReturnType,
1214
                                 A0,
1215
                                 Arg0>(
1216
      callback,
1217
      a0);
1✔
1218
}
1219

1220

1221
/**
1222
 * @brief A Method callback with 1 create-time args and 1 exec time args
1223
 */
1224
template <typename Class, typename Parent, typename ReturnType, typename A0, typename Arg0>  // NOLINT(whitespace/line_length)
1225
class MethodCallback1_1: public Parent {
1226
 public:
1227
  typedef ReturnType (Class::*Method)(A0, Arg0);
1228
  MethodCallback1_1(Class *object, Method callback, A0 a0):
186✔
1229
    Parent(),
1230
    m_object(object),
186✔
1231
    m_callback(callback),
186✔
1232
    m_a0(a0) {}
186✔
1233
  ReturnType DoRun(Arg0 arg0) {
216✔
1234
    return (m_object->*m_callback)(m_a0, arg0);
216✔
1235
  }
1236
 private:
1237
  Class *m_object;
1238
  Method m_callback;
1239
  A0 m_a0;
1240
};
1241

1242

1243
/**
1244
 * @brief A helper function to create a new SingleUseCallback with 1
1245
 * create-time arguments and 1 execution time arguments.
1246
 * @tparam Class the class with the member function.
1247
 * @tparam ReturnType the return type of the callback.
1248
 * @tparam A0 a create-time argument type.
1249
 * @tparam Arg0 an exec-time argument type.
1250
 * @param object the object to call the member function on.
1251
 * @param method the member function pointer to use when executing the callback.
1252
 * @param a0 a create-time argument.
1253
 * @returns The same return value as the member function.
1254
 */
1255
template <typename Class, typename ReturnType, typename A0, typename Arg0>
1256
inline SingleUseCallback1<ReturnType, Arg0>* NewSingleCallback(
184✔
1257
  Class* object,
1258
  ReturnType (Class::*method)(A0, Arg0),
1259
  A0 a0) {
1260
  return new MethodCallback1_1<Class,
184✔
1261
                               SingleUseCallback1<ReturnType, Arg0>,
1262
                               ReturnType,
1263
                               A0,
1264
                               Arg0>(
1265
      object,
1266
      method,
1267
      a0);
180✔
1268
}
1269

1270

1271
/**
1272
 * @brief A helper function to create a new Callback with 1
1273
 * create-time arguments and 1 execution time arguments.
1274
 * @tparam Class the class with the member function.
1275
 * @tparam ReturnType the return type of the callback.
1276
 * @tparam A0 a create-time argument type.
1277
 * @tparam Arg0 an exec-time argument type.
1278
 * @param object the object to call the member function on.
1279
 * @param method the member function pointer to use when executing the callback.
1280
 * @param a0 a create-time argument.
1281
 * @returns The same return value as the member function.
1282
 */
1283
template <typename Class, typename ReturnType, typename A0, typename Arg0>
1284
inline Callback1<ReturnType, Arg0>* NewCallback(
2✔
1285
  Class* object,
1286
  ReturnType (Class::*method)(A0, Arg0),
1287
  A0 a0) {
1288
  return new MethodCallback1_1<Class,
2✔
1289
                               Callback1<ReturnType, Arg0>,
1290
                               ReturnType,
1291
                               A0,
1292
                               Arg0>(
1293
      object,
1294
      method,
1295
      a0);
2✔
1296
}
1297

1298

1299
/**
1300
 * @brief A Function callback with 2 create-time args and 1 exec time args
1301
 */
1302
template <typename Parent, typename ReturnType, typename A0, typename A1, typename Arg0>  // NOLINT(whitespace/line_length)
1303
class FunctionCallback2_1: public Parent {
1304
 public:
1305
  typedef ReturnType (*Function)(A0, A1, Arg0);
1306
  FunctionCallback2_1(Function callback, A0 a0, A1 a1):
1✔
1307
    Parent(),
1308
    m_callback(callback),
1✔
1309
    m_a0(a0),
1✔
1310
    m_a1(a1) {}
1✔
1311
  ReturnType DoRun(Arg0 arg0) {
8✔
1312
    return m_callback(m_a0, m_a1, arg0);
8✔
1313
  }
1314
 private:
1315
  Function m_callback;
1316
  A0 m_a0;
1317
  A1 m_a1;
1318
};
1319

1320

1321
/**
1322
 * @brief A helper function to create a new SingleUseCallback with 2
1323
 * create-time arguments and 1 execution time arguments.
1324
 * @tparam ReturnType the return type of the callback.
1325
 * @tparam A0 a create-time argument type.
1326
 * @tparam A1 a create-time argument type.
1327
 * @tparam Arg0 an exec-time argument type.
1328
 * @param callback the function pointer to use when executing the callback.
1329
 * @param a0 a create-time argument.
1330
 * @param a1 a create-time argument.
1331
 * @returns The same return value as the function.
1332
 */
1333
template <typename ReturnType, typename A0, typename A1, typename Arg0>
1334
inline SingleUseCallback1<ReturnType, Arg0>* NewSingleCallback(
1335
  ReturnType (*callback)(A0, A1, Arg0),
1336
  A0 a0,
1337
  A1 a1) {
1338
  return new FunctionCallback2_1<
1339
                                 SingleUseCallback1<ReturnType, Arg0>,
1340
                                 ReturnType,
1341
                                 A0,
1342
                                 A1,
1343
                                 Arg0>(
1344
      callback,
1345
      a0,
1346
      a1);
1347
}
1348

1349

1350
/**
1351
 * @brief A helper function to create a new Callback with 2
1352
 * create-time arguments and 1 execution time arguments.
1353
 * @tparam ReturnType the return type of the callback.
1354
 * @tparam A0 a create-time argument type.
1355
 * @tparam A1 a create-time argument type.
1356
 * @tparam Arg0 an exec-time argument type.
1357
 * @param callback the function pointer to use when executing the callback.
1358
 * @param a0 a create-time argument.
1359
 * @param a1 a create-time argument.
1360
 * @returns The same return value as the function.
1361
 */
1362
template <typename ReturnType, typename A0, typename A1, typename Arg0>
1363
inline Callback1<ReturnType, Arg0>* NewCallback(
1✔
1364
  ReturnType (*callback)(A0, A1, Arg0),
1365
  A0 a0,
1366
  A1 a1) {
1367
  return new FunctionCallback2_1<
1✔
1368
                                 Callback1<ReturnType, Arg0>,
1369
                                 ReturnType,
1370
                                 A0,
1371
                                 A1,
1372
                                 Arg0>(
1373
      callback,
1374
      a0,
1375
      a1);
1✔
1376
}
1377

1378

1379
/**
1380
 * @brief A Method callback with 2 create-time args and 1 exec time args
1381
 */
1382
template <typename Class, typename Parent, typename ReturnType, typename A0, typename A1, typename Arg0>  // NOLINT(whitespace/line_length)
1383
class MethodCallback2_1: public Parent {
1384
 public:
1385
  typedef ReturnType (Class::*Method)(A0, A1, Arg0);
1386
  MethodCallback2_1(Class *object, Method callback, A0 a0, A1 a1):
44✔
1387
    Parent(),
1388
    m_object(object),
44✔
1389
    m_callback(callback),
44✔
1390
    m_a0(a0),
44✔
1391
    m_a1(a1) {}
44✔
1392
  ReturnType DoRun(Arg0 arg0) {
53✔
1393
    return (m_object->*m_callback)(m_a0, m_a1, arg0);
53✔
1394
  }
1395
 private:
1396
  Class *m_object;
1397
  Method m_callback;
1398
  A0 m_a0;
1399
  A1 m_a1;
1400
};
1401

1402

1403
/**
1404
 * @brief A helper function to create a new SingleUseCallback with 2
1405
 * create-time arguments and 1 execution time arguments.
1406
 * @tparam Class the class with the member function.
1407
 * @tparam ReturnType the return type of the callback.
1408
 * @tparam A0 a create-time argument type.
1409
 * @tparam A1 a create-time argument type.
1410
 * @tparam Arg0 an exec-time argument type.
1411
 * @param object the object to call the member function on.
1412
 * @param method the member function pointer to use when executing the callback.
1413
 * @param a0 a create-time argument.
1414
 * @param a1 a create-time argument.
1415
 * @returns The same return value as the member function.
1416
 */
1417
template <typename Class, typename ReturnType, typename A0, typename A1, typename Arg0>  // NOLINT(whitespace/line_length)
1418
inline SingleUseCallback1<ReturnType, Arg0>* NewSingleCallback(
41✔
1419
  Class* object,
1420
  ReturnType (Class::*method)(A0, A1, Arg0),
1421
  A0 a0,
1422
  A1 a1) {
1423
  return new MethodCallback2_1<Class,
67✔
1424
                               SingleUseCallback1<ReturnType, Arg0>,
1425
                               ReturnType,
1426
                               A0,
1427
                               A1,
1428
                               Arg0>(
1429
      object,
1430
      method,
1431
      a0,
1432
      a1);
41✔
1433
}
1434

1435

1436
/**
1437
 * @brief A helper function to create a new Callback with 2
1438
 * create-time arguments and 1 execution time arguments.
1439
 * @tparam Class the class with the member function.
1440
 * @tparam ReturnType the return type of the callback.
1441
 * @tparam A0 a create-time argument type.
1442
 * @tparam A1 a create-time argument type.
1443
 * @tparam Arg0 an exec-time argument type.
1444
 * @param object the object to call the member function on.
1445
 * @param method the member function pointer to use when executing the callback.
1446
 * @param a0 a create-time argument.
1447
 * @param a1 a create-time argument.
1448
 * @returns The same return value as the member function.
1449
 */
1450
template <typename Class, typename ReturnType, typename A0, typename A1, typename Arg0>  // NOLINT(whitespace/line_length)
1451
inline Callback1<ReturnType, Arg0>* NewCallback(
3✔
1452
  Class* object,
1453
  ReturnType (Class::*method)(A0, A1, Arg0),
1454
  A0 a0,
1455
  A1 a1) {
1456
  return new MethodCallback2_1<Class,
3✔
1457
                               Callback1<ReturnType, Arg0>,
1458
                               ReturnType,
1459
                               A0,
1460
                               A1,
1461
                               Arg0>(
1462
      object,
1463
      method,
1464
      a0,
1465
      a1);
3✔
1466
}
1467

1468

1469
/**
1470
 * @brief A Function callback with 3 create-time args and 1 exec time args
1471
 */
1472
template <typename Parent, typename ReturnType, typename A0, typename A1, typename A2, typename Arg0>  // NOLINT(whitespace/line_length)
1473
class FunctionCallback3_1: public Parent {
1474
 public:
1475
  typedef ReturnType (*Function)(A0, A1, A2, Arg0);
1476
  FunctionCallback3_1(Function callback, A0 a0, A1 a1, A2 a2):
1477
    Parent(),
1478
    m_callback(callback),
1479
    m_a0(a0),
1480
    m_a1(a1),
1481
    m_a2(a2) {}
1482
  ReturnType DoRun(Arg0 arg0) {
1483
    return m_callback(m_a0, m_a1, m_a2, arg0);
1484
  }
1485
 private:
1486
  Function m_callback;
1487
  A0 m_a0;
1488
  A1 m_a1;
1489
  A2 m_a2;
1490
};
1491

1492

1493
/**
1494
 * @brief A helper function to create a new SingleUseCallback with 3
1495
 * create-time arguments and 1 execution time arguments.
1496
 * @tparam ReturnType the return type of the callback.
1497
 * @tparam A0 a create-time argument type.
1498
 * @tparam A1 a create-time argument type.
1499
 * @tparam A2 a create-time argument type.
1500
 * @tparam Arg0 an exec-time argument type.
1501
 * @param callback the function pointer to use when executing the callback.
1502
 * @param a0 a create-time argument.
1503
 * @param a1 a create-time argument.
1504
 * @param a2 a create-time argument.
1505
 * @returns The same return value as the function.
1506
 */
1507
template <typename ReturnType, typename A0, typename A1, typename A2, typename Arg0>  // NOLINT(whitespace/line_length)
1508
inline SingleUseCallback1<ReturnType, Arg0>* NewSingleCallback(
1509
  ReturnType (*callback)(A0, A1, A2, Arg0),
1510
  A0 a0,
1511
  A1 a1,
1512
  A2 a2) {
1513
  return new FunctionCallback3_1<
1514
                                 SingleUseCallback1<ReturnType, Arg0>,
1515
                                 ReturnType,
1516
                                 A0,
1517
                                 A1,
1518
                                 A2,
1519
                                 Arg0>(
1520
      callback,
1521
      a0,
1522
      a1,
1523
      a2);
1524
}
1525

1526

1527
/**
1528
 * @brief A helper function to create a new Callback with 3
1529
 * create-time arguments and 1 execution time arguments.
1530
 * @tparam ReturnType the return type of the callback.
1531
 * @tparam A0 a create-time argument type.
1532
 * @tparam A1 a create-time argument type.
1533
 * @tparam A2 a create-time argument type.
1534
 * @tparam Arg0 an exec-time argument type.
1535
 * @param callback the function pointer to use when executing the callback.
1536
 * @param a0 a create-time argument.
1537
 * @param a1 a create-time argument.
1538
 * @param a2 a create-time argument.
1539
 * @returns The same return value as the function.
1540
 */
1541
template <typename ReturnType, typename A0, typename A1, typename A2, typename Arg0>  // NOLINT(whitespace/line_length)
1542
inline Callback1<ReturnType, Arg0>* NewCallback(
1543
  ReturnType (*callback)(A0, A1, A2, Arg0),
1544
  A0 a0,
1545
  A1 a1,
1546
  A2 a2) {
1547
  return new FunctionCallback3_1<
1548
                                 Callback1<ReturnType, Arg0>,
1549
                                 ReturnType,
1550
                                 A0,
1551
                                 A1,
1552
                                 A2,
1553
                                 Arg0>(
1554
      callback,
1555
      a0,
1556
      a1,
1557
      a2);
1558
}
1559

1560

1561
/**
1562
 * @brief A Method callback with 3 create-time args and 1 exec time args
1563
 */
1564
template <typename Class, typename Parent, typename ReturnType, typename A0, typename A1, typename A2, typename Arg0>  // NOLINT(whitespace/line_length)
1565
class MethodCallback3_1: public Parent {
1566
 public:
1567
  typedef ReturnType (Class::*Method)(A0, A1, A2, Arg0);
1568
  MethodCallback3_1(Class *object, Method callback, A0 a0, A1 a1, A2 a2):
14✔
1569
    Parent(),
1570
    m_object(object),
14✔
1571
    m_callback(callback),
14✔
1572
    m_a0(a0),
14✔
1573
    m_a1(a1),
14✔
1574
    m_a2(a2) {}
14✔
1575
  ReturnType DoRun(Arg0 arg0) {
22✔
1576
    return (m_object->*m_callback)(m_a0, m_a1, m_a2, arg0);
22✔
1577
  }
1578
 private:
1579
  Class *m_object;
1580
  Method m_callback;
1581
  A0 m_a0;
1582
  A1 m_a1;
1583
  A2 m_a2;
1584
};
1585

1586

1587
/**
1588
 * @brief A helper function to create a new SingleUseCallback with 3
1589
 * create-time arguments and 1 execution time arguments.
1590
 * @tparam Class the class with the member function.
1591
 * @tparam ReturnType the return type of the callback.
1592
 * @tparam A0 a create-time argument type.
1593
 * @tparam A1 a create-time argument type.
1594
 * @tparam A2 a create-time argument type.
1595
 * @tparam Arg0 an exec-time argument type.
1596
 * @param object the object to call the member function on.
1597
 * @param method the member function pointer to use when executing the callback.
1598
 * @param a0 a create-time argument.
1599
 * @param a1 a create-time argument.
1600
 * @param a2 a create-time argument.
1601
 * @returns The same return value as the member function.
1602
 */
1603
template <typename Class, typename ReturnType, typename A0, typename A1, typename A2, typename Arg0>  // NOLINT(whitespace/line_length)
1604
inline SingleUseCallback1<ReturnType, Arg0>* NewSingleCallback(
12✔
1605
  Class* object,
1606
  ReturnType (Class::*method)(A0, A1, A2, Arg0),
1607
  A0 a0,
1608
  A1 a1,
1609
  A2 a2) {
1610
  return new MethodCallback3_1<Class,
12✔
1611
                               SingleUseCallback1<ReturnType, Arg0>,
1612
                               ReturnType,
1613
                               A0,
1614
                               A1,
1615
                               A2,
1616
                               Arg0>(
1617
      object,
1618
      method,
1619
      a0,
1620
      a1,
1621
      a2);
10✔
1622
}
1623

1624

1625
/**
1626
 * @brief A helper function to create a new Callback with 3
1627
 * create-time arguments and 1 execution time arguments.
1628
 * @tparam Class the class with the member function.
1629
 * @tparam ReturnType the return type of the callback.
1630
 * @tparam A0 a create-time argument type.
1631
 * @tparam A1 a create-time argument type.
1632
 * @tparam A2 a create-time argument type.
1633
 * @tparam Arg0 an exec-time argument type.
1634
 * @param object the object to call the member function on.
1635
 * @param method the member function pointer to use when executing the callback.
1636
 * @param a0 a create-time argument.
1637
 * @param a1 a create-time argument.
1638
 * @param a2 a create-time argument.
1639
 * @returns The same return value as the member function.
1640
 */
1641
template <typename Class, typename ReturnType, typename A0, typename A1, typename A2, typename Arg0>  // NOLINT(whitespace/line_length)
1642
inline Callback1<ReturnType, Arg0>* NewCallback(
2✔
1643
  Class* object,
1644
  ReturnType (Class::*method)(A0, A1, A2, Arg0),
1645
  A0 a0,
1646
  A1 a1,
1647
  A2 a2) {
1648
  return new MethodCallback3_1<Class,
2✔
1649
                               Callback1<ReturnType, Arg0>,
1650
                               ReturnType,
1651
                               A0,
1652
                               A1,
1653
                               A2,
1654
                               Arg0>(
1655
      object,
1656
      method,
1657
      a0,
1658
      a1,
1659
      a2);
1660
}
1661

1662

1663
/**
1664
 * @brief A Function callback with 4 create-time args and 1 exec time args
1665
 */
1666
template <typename Parent, typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0>  // NOLINT(whitespace/line_length)
1667
class FunctionCallback4_1: public Parent {
1668
 public:
1669
  typedef ReturnType (*Function)(A0, A1, A2, A3, Arg0);
1670
  FunctionCallback4_1(Function callback, A0 a0, A1 a1, A2 a2, A3 a3):
1671
    Parent(),
1672
    m_callback(callback),
1673
    m_a0(a0),
1674
    m_a1(a1),
1675
    m_a2(a2),
1676
    m_a3(a3) {}
1677
  ReturnType DoRun(Arg0 arg0) {
1678
    return m_callback(m_a0, m_a1, m_a2, m_a3, arg0);
1679
  }
1680
 private:
1681
  Function m_callback;
1682
  A0 m_a0;
1683
  A1 m_a1;
1684
  A2 m_a2;
1685
  A3 m_a3;
1686
};
1687

1688

1689
/**
1690
 * @brief A helper function to create a new SingleUseCallback with 4
1691
 * create-time arguments and 1 execution time arguments.
1692
 * @tparam ReturnType the return type of the callback.
1693
 * @tparam A0 a create-time argument type.
1694
 * @tparam A1 a create-time argument type.
1695
 * @tparam A2 a create-time argument type.
1696
 * @tparam A3 a create-time argument type.
1697
 * @tparam Arg0 an exec-time argument type.
1698
 * @param callback the function pointer to use when executing the callback.
1699
 * @param a0 a create-time argument.
1700
 * @param a1 a create-time argument.
1701
 * @param a2 a create-time argument.
1702
 * @param a3 a create-time argument.
1703
 * @returns The same return value as the function.
1704
 */
1705
template <typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0>  // NOLINT(whitespace/line_length)
1706
inline SingleUseCallback1<ReturnType, Arg0>* NewSingleCallback(
1707
  ReturnType (*callback)(A0, A1, A2, A3, Arg0),
1708
  A0 a0,
1709
  A1 a1,
1710
  A2 a2,
1711
  A3 a3) {
1712
  return new FunctionCallback4_1<
1713
                                 SingleUseCallback1<ReturnType, Arg0>,
1714
                                 ReturnType,
1715
                                 A0,
1716
                                 A1,
1717
                                 A2,
1718
                                 A3,
1719
                                 Arg0>(
1720
      callback,
1721
      a0,
1722
      a1,
1723
      a2,
1724
      a3);
1725
}
1726

1727

1728
/**
1729
 * @brief A helper function to create a new Callback with 4
1730
 * create-time arguments and 1 execution time arguments.
1731
 * @tparam ReturnType the return type of the callback.
1732
 * @tparam A0 a create-time argument type.
1733
 * @tparam A1 a create-time argument type.
1734
 * @tparam A2 a create-time argument type.
1735
 * @tparam A3 a create-time argument type.
1736
 * @tparam Arg0 an exec-time argument type.
1737
 * @param callback the function pointer to use when executing the callback.
1738
 * @param a0 a create-time argument.
1739
 * @param a1 a create-time argument.
1740
 * @param a2 a create-time argument.
1741
 * @param a3 a create-time argument.
1742
 * @returns The same return value as the function.
1743
 */
1744
template <typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0>  // NOLINT(whitespace/line_length)
1745
inline Callback1<ReturnType, Arg0>* NewCallback(
1746
  ReturnType (*callback)(A0, A1, A2, A3, Arg0),
1747
  A0 a0,
1748
  A1 a1,
1749
  A2 a2,
1750
  A3 a3) {
1751
  return new FunctionCallback4_1<
1752
                                 Callback1<ReturnType, Arg0>,
1753
                                 ReturnType,
1754
                                 A0,
1755
                                 A1,
1756
                                 A2,
1757
                                 A3,
1758
                                 Arg0>(
1759
      callback,
1760
      a0,
1761
      a1,
1762
      a2,
1763
      a3);
1764
}
1765

1766

1767
/**
1768
 * @brief A Method callback with 4 create-time args and 1 exec time args
1769
 */
1770
template <typename Class, typename Parent, typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0>  // NOLINT(whitespace/line_length)
1771
class MethodCallback4_1: public Parent {
1772
 public:
1773
  typedef ReturnType (Class::*Method)(A0, A1, A2, A3, Arg0);
1774
  MethodCallback4_1(Class *object, Method callback, A0 a0, A1 a1, A2 a2, A3 a3):
1775
    Parent(),
1776
    m_object(object),
1777
    m_callback(callback),
1778
    m_a0(a0),
1779
    m_a1(a1),
1780
    m_a2(a2),
1781
    m_a3(a3) {}
1782
  ReturnType DoRun(Arg0 arg0) {
1783
    return (m_object->*m_callback)(m_a0, m_a1, m_a2, m_a3, arg0);
1784
  }
1785
 private:
1786
  Class *m_object;
1787
  Method m_callback;
1788
  A0 m_a0;
1789
  A1 m_a1;
1790
  A2 m_a2;
1791
  A3 m_a3;
1792
};
1793

1794

1795
/**
1796
 * @brief A helper function to create a new SingleUseCallback with 4
1797
 * create-time arguments and 1 execution time arguments.
1798
 * @tparam Class the class with the member function.
1799
 * @tparam ReturnType the return type of the callback.
1800
 * @tparam A0 a create-time argument type.
1801
 * @tparam A1 a create-time argument type.
1802
 * @tparam A2 a create-time argument type.
1803
 * @tparam A3 a create-time argument type.
1804
 * @tparam Arg0 an exec-time argument type.
1805
 * @param object the object to call the member function on.
1806
 * @param method the member function pointer to use when executing the callback.
1807
 * @param a0 a create-time argument.
1808
 * @param a1 a create-time argument.
1809
 * @param a2 a create-time argument.
1810
 * @param a3 a create-time argument.
1811
 * @returns The same return value as the member function.
1812
 */
1813
template <typename Class, typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0>  // NOLINT(whitespace/line_length)
1814
inline SingleUseCallback1<ReturnType, Arg0>* NewSingleCallback(
1815
  Class* object,
1816
  ReturnType (Class::*method)(A0, A1, A2, A3, Arg0),
1817
  A0 a0,
1818
  A1 a1,
1819
  A2 a2,
1820
  A3 a3) {
1821
  return new MethodCallback4_1<Class,
1822
                               SingleUseCallback1<ReturnType, Arg0>,
1823
                               ReturnType,
1824
                               A0,
1825
                               A1,
1826
                               A2,
1827
                               A3,
1828
                               Arg0>(
1829
      object,
1830
      method,
1831
      a0,
1832
      a1,
1833
      a2,
1834
      a3);
1835
}
1836

1837

1838
/**
1839
 * @brief A helper function to create a new Callback with 4
1840
 * create-time arguments and 1 execution time arguments.
1841
 * @tparam Class the class with the member function.
1842
 * @tparam ReturnType the return type of the callback.
1843
 * @tparam A0 a create-time argument type.
1844
 * @tparam A1 a create-time argument type.
1845
 * @tparam A2 a create-time argument type.
1846
 * @tparam A3 a create-time argument type.
1847
 * @tparam Arg0 an exec-time argument type.
1848
 * @param object the object to call the member function on.
1849
 * @param method the member function pointer to use when executing the callback.
1850
 * @param a0 a create-time argument.
1851
 * @param a1 a create-time argument.
1852
 * @param a2 a create-time argument.
1853
 * @param a3 a create-time argument.
1854
 * @returns The same return value as the member function.
1855
 */
1856
template <typename Class, typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0>  // NOLINT(whitespace/line_length)
1857
inline Callback1<ReturnType, Arg0>* NewCallback(
1858
  Class* object,
1859
  ReturnType (Class::*method)(A0, A1, A2, A3, Arg0),
1860
  A0 a0,
1861
  A1 a1,
1862
  A2 a2,
1863
  A3 a3) {
1864
  return new MethodCallback4_1<Class,
1865
                               Callback1<ReturnType, Arg0>,
1866
                               ReturnType,
1867
                               A0,
1868
                               A1,
1869
                               A2,
1870
                               A3,
1871
                               Arg0>(
1872
      object,
1873
      method,
1874
      a0,
1875
      a1,
1876
      a2,
1877
      a3);
1878
}
1879

1880

1881
/**
1882
 * @brief The base class for all 2 argument callbacks.
1883
 */
1884
template <typename ReturnType, typename Arg0, typename Arg1>
1885
class BaseCallback2 {
184✔
1886
 public:
1887
  virtual ~BaseCallback2() {}
1888
  virtual ReturnType Run(Arg0 arg0, Arg1 arg1) = 0;
1889
};
1890

1891
/**
1892
 * @brief A 2 argument callback which can be called multiple times.
1893
 */
1894
template <typename ReturnType, typename Arg0, typename Arg1>
1895
class Callback2: public BaseCallback2<ReturnType, Arg0, Arg1> {
84✔
1896
 public:
1897
  virtual ~Callback2() {}
1898
  ReturnType Run(Arg0 arg0, Arg1 arg1) { return this->DoRun(arg0, arg1); }
1,136✔
1899
 private:
1900
  virtual ReturnType DoRun(Arg0 arg0, Arg1 arg1) = 0;
1901
};
1902

1903
/**
1904
 * @brief A 2 argument callback which deletes itself after it's run.
1905
 */
1906
template <typename ReturnType, typename Arg0, typename Arg1>
1907
class SingleUseCallback2: public BaseCallback2<ReturnType, Arg0, Arg1> {
2✔
1908
 public:
1909
  virtual ~SingleUseCallback2() {}
1910
  ReturnType Run(Arg0 arg0, Arg1 arg1) {
4✔
1911
    ReturnType ret = this->DoRun(arg0, arg1);
4✔
1912
    delete this;
4✔
1913
    return ret;
4✔
1914
  }
1915
 private:
1916
  virtual ReturnType DoRun(Arg0 arg0, Arg1 arg1) = 0;
1917
};
1918

1919
/**
1920
 * @brief A 2 arg, single use callback that returns void.
1921
 */
1922
template <typename Arg0, typename Arg1>
1923
class SingleUseCallback2<void, Arg0, Arg1>: public BaseCallback2<void, Arg0, Arg1> {  // NOLINT(whitespace/line_length)
98✔
1924
 public:
1925
  virtual ~SingleUseCallback2() {}
1926
  void Run(Arg0 arg0, Arg1 arg1) {
117✔
1927
    this->DoRun(arg0, arg1);
117✔
1928
    delete this;
117✔
1929
  }
117✔
1930
 private:
1931
  virtual void DoRun(Arg0 arg0, Arg1 arg1) = 0;
1932
};
1933

1934
/**
1935
 * @brief A Function callback with 0 create-time args and 2 exec time args
1936
 */
1937
template <typename Parent, typename ReturnType, typename Arg0, typename Arg1>
1938
class FunctionCallback0_2: public Parent {
1939
 public:
1940
  typedef ReturnType (*Function)(Arg0, Arg1);
1941
  explicit FunctionCallback0_2(Function callback):
×
1942
    Parent(),
1943
    m_callback(callback) {}
×
1944
  ReturnType DoRun(Arg0 arg0, Arg1 arg1) {
×
1945
    return m_callback(arg0, arg1);
×
1946
  }
1947
 private:
1948
  Function m_callback;
1949
};
1950

1951

1952
/**
1953
 * @brief A helper function to create a new SingleUseCallback with 0
1954
 * create-time arguments and 2 execution time arguments.
1955
 * @tparam ReturnType the return type of the callback.
1956
 * @tparam Arg0 an exec-time argument type.
1957
 * @tparam Arg1 an exec-time argument type.
1958
 * @param callback the function pointer to use when executing the callback.
1959
 * @returns The same return value as the function.
1960
 */
1961
template <typename ReturnType, typename Arg0, typename Arg1>
1962
inline SingleUseCallback2<ReturnType, Arg0, Arg1>* NewSingleCallback(
×
1963
  ReturnType (*callback)(Arg0, Arg1)) {
1964
  return new FunctionCallback0_2<
×
1965
                                 SingleUseCallback2<ReturnType, Arg0, Arg1>,
1966
                                 ReturnType,
1967
                                 Arg0,
1968
                                 Arg1>(
1969
      callback);
×
1970
}
1971

1972

1973
/**
1974
 * @brief A helper function to create a new Callback with 0
1975
 * create-time arguments and 2 execution time arguments.
1976
 * @tparam ReturnType the return type of the callback.
1977
 * @tparam Arg0 an exec-time argument type.
1978
 * @tparam Arg1 an exec-time argument type.
1979
 * @param callback the function pointer to use when executing the callback.
1980
 * @returns The same return value as the function.
1981
 */
1982
template <typename ReturnType, typename Arg0, typename Arg1>
1983
inline Callback2<ReturnType, Arg0, Arg1>* NewCallback(
×
1984
  ReturnType (*callback)(Arg0, Arg1)) {
1985
  return new FunctionCallback0_2<
×
1986
                                 Callback2<ReturnType, Arg0, Arg1>,
1987
                                 ReturnType,
1988
                                 Arg0,
1989
                                 Arg1>(
1990
      callback);
×
1991
}
1992

1993

1994
/**
1995
 * @brief A Method callback with 0 create-time args and 2 exec time args
1996
 */
1997
template <typename Class, typename Parent, typename ReturnType, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
1998
class MethodCallback0_2: public Parent {
1999
 public:
2000
  typedef ReturnType (Class::*Method)(Arg0, Arg1);
2001
  MethodCallback0_2(Class *object, Method callback):
117✔
2002
    Parent(),
2003
    m_object(object),
117✔
2004
    m_callback(callback) {}
117✔
2005
  ReturnType DoRun(Arg0 arg0, Arg1 arg1) {
1,157✔
2006
    return (m_object->*m_callback)(arg0, arg1);
1,157✔
2007
  }
2008
 private:
2009
  Class *m_object;
2010
  Method m_callback;
2011
};
2012

2013

2014
/**
2015
 * @brief A helper function to create a new SingleUseCallback with 0
2016
 * create-time arguments and 2 execution time arguments.
2017
 * @tparam Class the class with the member function.
2018
 * @tparam ReturnType the return type of the callback.
2019
 * @tparam Arg0 an exec-time argument type.
2020
 * @tparam Arg1 an exec-time argument type.
2021
 * @param object the object to call the member function on.
2022
 * @param method the member function pointer to use when executing the callback.
2023
 * @returns The same return value as the member function.
2024
 */
2025
template <typename Class, typename ReturnType, typename Arg0, typename Arg1>
2026
inline SingleUseCallback2<ReturnType, Arg0, Arg1>* NewSingleCallback(
45✔
2027
  Class* object,
2028
  ReturnType (Class::*method)(Arg0, Arg1)) {
2029
  return new MethodCallback0_2<Class,
45✔
2030
                               SingleUseCallback2<ReturnType, Arg0, Arg1>,
2031
                               ReturnType,
2032
                               Arg0,
2033
                               Arg1>(
2034
      object,
2035
      method);
45✔
2036
}
2037

2038

2039
/**
2040
 * @brief A helper function to create a new Callback with 0
2041
 * create-time arguments and 2 execution time arguments.
2042
 * @tparam Class the class with the member function.
2043
 * @tparam ReturnType the return type of the callback.
2044
 * @tparam Arg0 an exec-time argument type.
2045
 * @tparam Arg1 an exec-time argument type.
2046
 * @param object the object to call the member function on.
2047
 * @param method the member function pointer to use when executing the callback.
2048
 * @returns The same return value as the member function.
2049
 */
2050
template <typename Class, typename ReturnType, typename Arg0, typename Arg1>
2051
inline Callback2<ReturnType, Arg0, Arg1>* NewCallback(
72✔
2052
  Class* object,
2053
  ReturnType (Class::*method)(Arg0, Arg1)) {
2054
  return new MethodCallback0_2<Class,
72✔
2055
                               Callback2<ReturnType, Arg0, Arg1>,
2056
                               ReturnType,
2057
                               Arg0,
2058
                               Arg1>(
2059
      object,
2060
      method);
72✔
2061
}
2062

2063

2064
/**
2065
 * @brief A Function callback with 1 create-time args and 2 exec time args
2066
 */
2067
template <typename Parent, typename ReturnType, typename A0, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
2068
class FunctionCallback1_2: public Parent {
2069
 public:
2070
  typedef ReturnType (*Function)(A0, Arg0, Arg1);
2071
  FunctionCallback1_2(Function callback, A0 a0):
×
2072
    Parent(),
2073
    m_callback(callback),
×
2074
    m_a0(a0) {}
×
2075
  ReturnType DoRun(Arg0 arg0, Arg1 arg1) {
×
2076
    return m_callback(m_a0, arg0, arg1);
×
2077
  }
2078
 private:
2079
  Function m_callback;
2080
  A0 m_a0;
2081
};
2082

2083

2084
/**
2085
 * @brief A helper function to create a new SingleUseCallback with 1
2086
 * create-time arguments and 2 execution time arguments.
2087
 * @tparam ReturnType the return type of the callback.
2088
 * @tparam A0 a create-time argument type.
2089
 * @tparam Arg0 an exec-time argument type.
2090
 * @tparam Arg1 an exec-time argument type.
2091
 * @param callback the function pointer to use when executing the callback.
2092
 * @param a0 a create-time argument.
2093
 * @returns The same return value as the function.
2094
 */
2095
template <typename ReturnType, typename A0, typename Arg0, typename Arg1>
2096
inline SingleUseCallback2<ReturnType, Arg0, Arg1>* NewSingleCallback(
×
2097
  ReturnType (*callback)(A0, Arg0, Arg1),
2098
  A0 a0) {
2099
  return new FunctionCallback1_2<
×
2100
                                 SingleUseCallback2<ReturnType, Arg0, Arg1>,
2101
                                 ReturnType,
2102
                                 A0,
2103
                                 Arg0,
2104
                                 Arg1>(
2105
      callback,
2106
      a0);
×
2107
}
2108

2109

2110
/**
2111
 * @brief A helper function to create a new Callback with 1
2112
 * create-time arguments and 2 execution time arguments.
2113
 * @tparam ReturnType the return type of the callback.
2114
 * @tparam A0 a create-time argument type.
2115
 * @tparam Arg0 an exec-time argument type.
2116
 * @tparam Arg1 an exec-time argument type.
2117
 * @param callback the function pointer to use when executing the callback.
2118
 * @param a0 a create-time argument.
2119
 * @returns The same return value as the function.
2120
 */
2121
template <typename ReturnType, typename A0, typename Arg0, typename Arg1>
2122
inline Callback2<ReturnType, Arg0, Arg1>* NewCallback(
2123
  ReturnType (*callback)(A0, Arg0, Arg1),
2124
  A0 a0) {
2125
  return new FunctionCallback1_2<
2126
                                 Callback2<ReturnType, Arg0, Arg1>,
2127
                                 ReturnType,
2128
                                 A0,
2129
                                 Arg0,
2130
                                 Arg1>(
2131
      callback,
2132
      a0);
2133
}
2134

2135

2136
/**
2137
 * @brief A Method callback with 1 create-time args and 2 exec time args
2138
 */
2139
template <typename Class, typename Parent, typename ReturnType, typename A0, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
2140
class MethodCallback1_2: public Parent {
2141
 public:
2142
  typedef ReturnType (Class::*Method)(A0, Arg0, Arg1);
2143
  MethodCallback1_2(Class *object, Method callback, A0 a0):
63✔
2144
    Parent(),
2145
    m_object(object),
63✔
2146
    m_callback(callback),
63✔
2147
    m_a0(a0) {}
63✔
2148
  ReturnType DoRun(Arg0 arg0, Arg1 arg1) {
101✔
2149
    return (m_object->*m_callback)(m_a0, arg0, arg1);
101✔
2150
  }
2151
 private:
2152
  Class *m_object;
2153
  Method m_callback;
2154
  A0 m_a0;
2155
};
2156

2157

2158
/**
2159
 * @brief A helper function to create a new SingleUseCallback with 1
2160
 * create-time arguments and 2 execution time arguments.
2161
 * @tparam Class the class with the member function.
2162
 * @tparam ReturnType the return type of the callback.
2163
 * @tparam A0 a create-time argument type.
2164
 * @tparam Arg0 an exec-time argument type.
2165
 * @tparam Arg1 an exec-time argument type.
2166
 * @param object the object to call the member function on.
2167
 * @param method the member function pointer to use when executing the callback.
2168
 * @param a0 a create-time argument.
2169
 * @returns The same return value as the member function.
2170
 */
2171
template <typename Class, typename ReturnType, typename A0, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
2172
inline SingleUseCallback2<ReturnType, Arg0, Arg1>* NewSingleCallback(
51✔
2173
  Class* object,
2174
  ReturnType (Class::*method)(A0, Arg0, Arg1),
2175
  A0 a0) {
2176
  return new MethodCallback1_2<Class,
51✔
2177
                               SingleUseCallback2<ReturnType, Arg0, Arg1>,
2178
                               ReturnType,
2179
                               A0,
2180
                               Arg0,
2181
                               Arg1>(
2182
      object,
2183
      method,
2184
      a0);
51✔
2185
}
2186

2187

2188
/**
2189
 * @brief A helper function to create a new Callback with 1
2190
 * create-time arguments and 2 execution time arguments.
2191
 * @tparam Class the class with the member function.
2192
 * @tparam ReturnType the return type of the callback.
2193
 * @tparam A0 a create-time argument type.
2194
 * @tparam Arg0 an exec-time argument type.
2195
 * @tparam Arg1 an exec-time argument type.
2196
 * @param object the object to call the member function on.
2197
 * @param method the member function pointer to use when executing the callback.
2198
 * @param a0 a create-time argument.
2199
 * @returns The same return value as the member function.
2200
 */
2201
template <typename Class, typename ReturnType, typename A0, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
2202
inline Callback2<ReturnType, Arg0, Arg1>* NewCallback(
12✔
2203
  Class* object,
2204
  ReturnType (Class::*method)(A0, Arg0, Arg1),
2205
  A0 a0) {
2206
  return new MethodCallback1_2<Class,
12✔
2207
                               Callback2<ReturnType, Arg0, Arg1>,
2208
                               ReturnType,
2209
                               A0,
2210
                               Arg0,
2211
                               Arg1>(
2212
      object,
2213
      method,
2214
      a0);
12✔
2215
}
2216

2217

2218
/**
2219
 * @brief A Function callback with 2 create-time args and 2 exec time args
2220
 */
2221
template <typename Parent, typename ReturnType, typename A0, typename A1, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
2222
class FunctionCallback2_2: public Parent {
2223
 public:
2224
  typedef ReturnType (*Function)(A0, A1, Arg0, Arg1);
2225
  FunctionCallback2_2(Function callback, A0 a0, A1 a1):
×
2226
    Parent(),
2227
    m_callback(callback),
×
2228
    m_a0(a0),
×
2229
    m_a1(a1) {}
×
2230
  ReturnType DoRun(Arg0 arg0, Arg1 arg1) {
×
2231
    return m_callback(m_a0, m_a1, arg0, arg1);
×
2232
  }
2233
 private:
2234
  Function m_callback;
2235
  A0 m_a0;
2236
  A1 m_a1;
2237
};
2238

2239

2240
/**
2241
 * @brief A helper function to create a new SingleUseCallback with 2
2242
 * create-time arguments and 2 execution time arguments.
2243
 * @tparam ReturnType the return type of the callback.
2244
 * @tparam A0 a create-time argument type.
2245
 * @tparam A1 a create-time argument type.
2246
 * @tparam Arg0 an exec-time argument type.
2247
 * @tparam Arg1 an exec-time argument type.
2248
 * @param callback the function pointer to use when executing the callback.
2249
 * @param a0 a create-time argument.
2250
 * @param a1 a create-time argument.
2251
 * @returns The same return value as the function.
2252
 */
2253
template <typename ReturnType, typename A0, typename A1, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
2254
inline SingleUseCallback2<ReturnType, Arg0, Arg1>* NewSingleCallback(
×
2255
  ReturnType (*callback)(A0, A1, Arg0, Arg1),
2256
  A0 a0,
2257
  A1 a1) {
2258
  return new FunctionCallback2_2<
×
2259
                                 SingleUseCallback2<ReturnType, Arg0, Arg1>,
2260
                                 ReturnType,
2261
                                 A0,
2262
                                 A1,
2263
                                 Arg0,
2264
                                 Arg1>(
2265
      callback,
2266
      a0,
2267
      a1);
2268
}
2269

2270

2271
/**
2272
 * @brief A helper function to create a new Callback with 2
2273
 * create-time arguments and 2 execution time arguments.
2274
 * @tparam ReturnType the return type of the callback.
2275
 * @tparam A0 a create-time argument type.
2276
 * @tparam A1 a create-time argument type.
2277
 * @tparam Arg0 an exec-time argument type.
2278
 * @tparam Arg1 an exec-time argument type.
2279
 * @param callback the function pointer to use when executing the callback.
2280
 * @param a0 a create-time argument.
2281
 * @param a1 a create-time argument.
2282
 * @returns The same return value as the function.
2283
 */
2284
template <typename ReturnType, typename A0, typename A1, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
2285
inline Callback2<ReturnType, Arg0, Arg1>* NewCallback(
2286
  ReturnType (*callback)(A0, A1, Arg0, Arg1),
2287
  A0 a0,
2288
  A1 a1) {
2289
  return new FunctionCallback2_2<
2290
                                 Callback2<ReturnType, Arg0, Arg1>,
2291
                                 ReturnType,
2292
                                 A0,
2293
                                 A1,
2294
                                 Arg0,
2295
                                 Arg1>(
2296
      callback,
2297
      a0,
2298
      a1);
2299
}
2300

2301

2302
/**
2303
 * @brief A Method callback with 2 create-time args and 2 exec time args
2304
 */
2305
template <typename Class, typename Parent, typename ReturnType, typename A0, typename A1, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
2306
class MethodCallback2_2: public Parent {
2307
 public:
2308
  typedef ReturnType (Class::*Method)(A0, A1, Arg0, Arg1);
2309
  MethodCallback2_2(Class *object, Method callback, A0 a0, A1 a1):
4✔
2310
    Parent(),
2311
    m_object(object),
4✔
2312
    m_callback(callback),
4✔
2313
    m_a0(a0),
4✔
2314
    m_a1(a1) {}
4✔
2315
  ReturnType DoRun(Arg0 arg0, Arg1 arg1) {
4✔
2316
    return (m_object->*m_callback)(m_a0, m_a1, arg0, arg1);
4✔
2317
  }
2318
 private:
2319
  Class *m_object;
2320
  Method m_callback;
2321
  A0 m_a0;
2322
  A1 m_a1;
2323
};
2324

2325

2326
/**
2327
 * @brief A helper function to create a new SingleUseCallback with 2
2328
 * create-time arguments and 2 execution time arguments.
2329
 * @tparam Class the class with the member function.
2330
 * @tparam ReturnType the return type of the callback.
2331
 * @tparam A0 a create-time argument type.
2332
 * @tparam A1 a create-time argument type.
2333
 * @tparam Arg0 an exec-time argument type.
2334
 * @tparam Arg1 an exec-time argument type.
2335
 * @param object the object to call the member function on.
2336
 * @param method the member function pointer to use when executing the callback.
2337
 * @param a0 a create-time argument.
2338
 * @param a1 a create-time argument.
2339
 * @returns The same return value as the member function.
2340
 */
2341
template <typename Class, typename ReturnType, typename A0, typename A1, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
2342
inline SingleUseCallback2<ReturnType, Arg0, Arg1>* NewSingleCallback(
4✔
2343
  Class* object,
2344
  ReturnType (Class::*method)(A0, A1, Arg0, Arg1),
2345
  A0 a0,
2346
  A1 a1) {
2347
  return new MethodCallback2_2<Class,
4✔
2348
                               SingleUseCallback2<ReturnType, Arg0, Arg1>,
2349
                               ReturnType,
2350
                               A0,
2351
                               A1,
2352
                               Arg0,
2353
                               Arg1>(
2354
      object,
2355
      method,
2356
      a0,
2357
      a1);
4✔
2358
}
2359

2360

2361
/**
2362
 * @brief A helper function to create a new Callback with 2
2363
 * create-time arguments and 2 execution time arguments.
2364
 * @tparam Class the class with the member function.
2365
 * @tparam ReturnType the return type of the callback.
2366
 * @tparam A0 a create-time argument type.
2367
 * @tparam A1 a create-time argument type.
2368
 * @tparam Arg0 an exec-time argument type.
2369
 * @tparam Arg1 an exec-time argument type.
2370
 * @param object the object to call the member function on.
2371
 * @param method the member function pointer to use when executing the callback.
2372
 * @param a0 a create-time argument.
2373
 * @param a1 a create-time argument.
2374
 * @returns The same return value as the member function.
2375
 */
2376
template <typename Class, typename ReturnType, typename A0, typename A1, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
2377
inline Callback2<ReturnType, Arg0, Arg1>* NewCallback(
2378
  Class* object,
2379
  ReturnType (Class::*method)(A0, A1, Arg0, Arg1),
2380
  A0 a0,
2381
  A1 a1) {
2382
  return new MethodCallback2_2<Class,
2383
                               Callback2<ReturnType, Arg0, Arg1>,
2384
                               ReturnType,
2385
                               A0,
2386
                               A1,
2387
                               Arg0,
2388
                               Arg1>(
2389
      object,
2390
      method,
2391
      a0,
2392
      a1);
2393
}
2394

2395

2396
/**
2397
 * @brief A Function callback with 3 create-time args and 2 exec time args
2398
 */
2399
template <typename Parent, typename ReturnType, typename A0, typename A1, typename A2, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
2400
class FunctionCallback3_2: public Parent {
2401
 public:
2402
  typedef ReturnType (*Function)(A0, A1, A2, Arg0, Arg1);
2403
  FunctionCallback3_2(Function callback, A0 a0, A1 a1, A2 a2):
2404
    Parent(),
2405
    m_callback(callback),
2406
    m_a0(a0),
2407
    m_a1(a1),
2408
    m_a2(a2) {}
2409
  ReturnType DoRun(Arg0 arg0, Arg1 arg1) {
2410
    return m_callback(m_a0, m_a1, m_a2, arg0, arg1);
2411
  }
2412
 private:
2413
  Function m_callback;
2414
  A0 m_a0;
2415
  A1 m_a1;
2416
  A2 m_a2;
2417
};
2418

2419

2420
/**
2421
 * @brief A helper function to create a new SingleUseCallback with 3
2422
 * create-time arguments and 2 execution time arguments.
2423
 * @tparam ReturnType the return type of the callback.
2424
 * @tparam A0 a create-time argument type.
2425
 * @tparam A1 a create-time argument type.
2426
 * @tparam A2 a create-time argument type.
2427
 * @tparam Arg0 an exec-time argument type.
2428
 * @tparam Arg1 an exec-time argument type.
2429
 * @param callback the function pointer to use when executing the callback.
2430
 * @param a0 a create-time argument.
2431
 * @param a1 a create-time argument.
2432
 * @param a2 a create-time argument.
2433
 * @returns The same return value as the function.
2434
 */
2435
template <typename ReturnType, typename A0, typename A1, typename A2, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
2436
inline SingleUseCallback2<ReturnType, Arg0, Arg1>* NewSingleCallback(
2437
  ReturnType (*callback)(A0, A1, A2, Arg0, Arg1),
2438
  A0 a0,
2439
  A1 a1,
2440
  A2 a2) {
2441
  return new FunctionCallback3_2<
2442
                                 SingleUseCallback2<ReturnType, Arg0, Arg1>,
2443
                                 ReturnType,
2444
                                 A0,
2445
                                 A1,
2446
                                 A2,
2447
                                 Arg0,
2448
                                 Arg1>(
2449
      callback,
2450
      a0,
2451
      a1,
2452
      a2);
2453
}
2454

2455

2456
/**
2457
 * @brief A helper function to create a new Callback with 3
2458
 * create-time arguments and 2 execution time arguments.
2459
 * @tparam ReturnType the return type of the callback.
2460
 * @tparam A0 a create-time argument type.
2461
 * @tparam A1 a create-time argument type.
2462
 * @tparam A2 a create-time argument type.
2463
 * @tparam Arg0 an exec-time argument type.
2464
 * @tparam Arg1 an exec-time argument type.
2465
 * @param callback the function pointer to use when executing the callback.
2466
 * @param a0 a create-time argument.
2467
 * @param a1 a create-time argument.
2468
 * @param a2 a create-time argument.
2469
 * @returns The same return value as the function.
2470
 */
2471
template <typename ReturnType, typename A0, typename A1, typename A2, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
2472
inline Callback2<ReturnType, Arg0, Arg1>* NewCallback(
2473
  ReturnType (*callback)(A0, A1, A2, Arg0, Arg1),
2474
  A0 a0,
2475
  A1 a1,
2476
  A2 a2) {
2477
  return new FunctionCallback3_2<
2478
                                 Callback2<ReturnType, Arg0, Arg1>,
2479
                                 ReturnType,
2480
                                 A0,
2481
                                 A1,
2482
                                 A2,
2483
                                 Arg0,
2484
                                 Arg1>(
2485
      callback,
2486
      a0,
2487
      a1,
2488
      a2);
2489
}
2490

2491

2492
/**
2493
 * @brief A Method callback with 3 create-time args and 2 exec time args
2494
 */
2495
template <typename Class, typename Parent, typename ReturnType, typename A0, typename A1, typename A2, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
2496
class MethodCallback3_2: public Parent {
2497
 public:
2498
  typedef ReturnType (Class::*Method)(A0, A1, A2, Arg0, Arg1);
2499
  MethodCallback3_2(Class *object, Method callback, A0 a0, A1 a1, A2 a2):
×
2500
    Parent(),
2501
    m_object(object),
×
2502
    m_callback(callback),
×
2503
    m_a0(a0),
×
2504
    m_a1(a1),
×
2505
    m_a2(a2) {}
×
2506
  ReturnType DoRun(Arg0 arg0, Arg1 arg1) {
×
2507
    return (m_object->*m_callback)(m_a0, m_a1, m_a2, arg0, arg1);
×
2508
  }
2509
 private:
2510
  Class *m_object;
2511
  Method m_callback;
2512
  A0 m_a0;
2513
  A1 m_a1;
2514
  A2 m_a2;
2515
};
2516

2517

2518
/**
2519
 * @brief A helper function to create a new SingleUseCallback with 3
2520
 * create-time arguments and 2 execution time arguments.
2521
 * @tparam Class the class with the member function.
2522
 * @tparam ReturnType the return type of the callback.
2523
 * @tparam A0 a create-time argument type.
2524
 * @tparam A1 a create-time argument type.
2525
 * @tparam A2 a create-time argument type.
2526
 * @tparam Arg0 an exec-time argument type.
2527
 * @tparam Arg1 an exec-time argument type.
2528
 * @param object the object to call the member function on.
2529
 * @param method the member function pointer to use when executing the callback.
2530
 * @param a0 a create-time argument.
2531
 * @param a1 a create-time argument.
2532
 * @param a2 a create-time argument.
2533
 * @returns The same return value as the member function.
2534
 */
2535
template <typename Class, typename ReturnType, typename A0, typename A1, typename A2, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
2536
inline SingleUseCallback2<ReturnType, Arg0, Arg1>* NewSingleCallback(
×
2537
  Class* object,
2538
  ReturnType (Class::*method)(A0, A1, A2, Arg0, Arg1),
2539
  A0 a0,
2540
  A1 a1,
2541
  A2 a2) {
2542
  return new MethodCallback3_2<Class,
×
2543
                               SingleUseCallback2<ReturnType, Arg0, Arg1>,
2544
                               ReturnType,
2545
                               A0,
2546
                               A1,
2547
                               A2,
2548
                               Arg0,
2549
                               Arg1>(
2550
      object,
2551
      method,
2552
      a0,
2553
      a1,
2554
      a2);
×
2555
}
2556

2557

2558
/**
2559
 * @brief A helper function to create a new Callback with 3
2560
 * create-time arguments and 2 execution time arguments.
2561
 * @tparam Class the class with the member function.
2562
 * @tparam ReturnType the return type of the callback.
2563
 * @tparam A0 a create-time argument type.
2564
 * @tparam A1 a create-time argument type.
2565
 * @tparam A2 a create-time argument type.
2566
 * @tparam Arg0 an exec-time argument type.
2567
 * @tparam Arg1 an exec-time argument type.
2568
 * @param object the object to call the member function on.
2569
 * @param method the member function pointer to use when executing the callback.
2570
 * @param a0 a create-time argument.
2571
 * @param a1 a create-time argument.
2572
 * @param a2 a create-time argument.
2573
 * @returns The same return value as the member function.
2574
 */
2575
template <typename Class, typename ReturnType, typename A0, typename A1, typename A2, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
2576
inline Callback2<ReturnType, Arg0, Arg1>* NewCallback(
2577
  Class* object,
2578
  ReturnType (Class::*method)(A0, A1, A2, Arg0, Arg1),
2579
  A0 a0,
2580
  A1 a1,
2581
  A2 a2) {
2582
  return new MethodCallback3_2<Class,
2583
                               Callback2<ReturnType, Arg0, Arg1>,
2584
                               ReturnType,
2585
                               A0,
2586
                               A1,
2587
                               A2,
2588
                               Arg0,
2589
                               Arg1>(
2590
      object,
2591
      method,
2592
      a0,
2593
      a1,
2594
      a2);
2595
}
2596

2597

2598
/**
2599
 * @brief A Function callback with 4 create-time args and 2 exec time args
2600
 */
2601
template <typename Parent, typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
2602
class FunctionCallback4_2: public Parent {
2603
 public:
2604
  typedef ReturnType (*Function)(A0, A1, A2, A3, Arg0, Arg1);
2605
  FunctionCallback4_2(Function callback, A0 a0, A1 a1, A2 a2, A3 a3):
2606
    Parent(),
2607
    m_callback(callback),
2608
    m_a0(a0),
2609
    m_a1(a1),
2610
    m_a2(a2),
2611
    m_a3(a3) {}
2612
  ReturnType DoRun(Arg0 arg0, Arg1 arg1) {
2613
    return m_callback(m_a0, m_a1, m_a2, m_a3, arg0, arg1);
2614
  }
2615
 private:
2616
  Function m_callback;
2617
  A0 m_a0;
2618
  A1 m_a1;
2619
  A2 m_a2;
2620
  A3 m_a3;
2621
};
2622

2623

2624
/**
2625
 * @brief A helper function to create a new SingleUseCallback with 4
2626
 * create-time arguments and 2 execution time arguments.
2627
 * @tparam ReturnType the return type of the callback.
2628
 * @tparam A0 a create-time argument type.
2629
 * @tparam A1 a create-time argument type.
2630
 * @tparam A2 a create-time argument type.
2631
 * @tparam A3 a create-time argument type.
2632
 * @tparam Arg0 an exec-time argument type.
2633
 * @tparam Arg1 an exec-time argument type.
2634
 * @param callback the function pointer to use when executing the callback.
2635
 * @param a0 a create-time argument.
2636
 * @param a1 a create-time argument.
2637
 * @param a2 a create-time argument.
2638
 * @param a3 a create-time argument.
2639
 * @returns The same return value as the function.
2640
 */
2641
template <typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
2642
inline SingleUseCallback2<ReturnType, Arg0, Arg1>* NewSingleCallback(
2643
  ReturnType (*callback)(A0, A1, A2, A3, Arg0, Arg1),
2644
  A0 a0,
2645
  A1 a1,
2646
  A2 a2,
2647
  A3 a3) {
2648
  return new FunctionCallback4_2<
2649
                                 SingleUseCallback2<ReturnType, Arg0, Arg1>,
2650
                                 ReturnType,
2651
                                 A0,
2652
                                 A1,
2653
                                 A2,
2654
                                 A3,
2655
                                 Arg0,
2656
                                 Arg1>(
2657
      callback,
2658
      a0,
2659
      a1,
2660
      a2,
2661
      a3);
2662
}
2663

2664

2665
/**
2666
 * @brief A helper function to create a new Callback with 4
2667
 * create-time arguments and 2 execution time arguments.
2668
 * @tparam ReturnType the return type of the callback.
2669
 * @tparam A0 a create-time argument type.
2670
 * @tparam A1 a create-time argument type.
2671
 * @tparam A2 a create-time argument type.
2672
 * @tparam A3 a create-time argument type.
2673
 * @tparam Arg0 an exec-time argument type.
2674
 * @tparam Arg1 an exec-time argument type.
2675
 * @param callback the function pointer to use when executing the callback.
2676
 * @param a0 a create-time argument.
2677
 * @param a1 a create-time argument.
2678
 * @param a2 a create-time argument.
2679
 * @param a3 a create-time argument.
2680
 * @returns The same return value as the function.
2681
 */
2682
template <typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
2683
inline Callback2<ReturnType, Arg0, Arg1>* NewCallback(
2684
  ReturnType (*callback)(A0, A1, A2, A3, Arg0, Arg1),
2685
  A0 a0,
2686
  A1 a1,
2687
  A2 a2,
2688
  A3 a3) {
2689
  return new FunctionCallback4_2<
2690
                                 Callback2<ReturnType, Arg0, Arg1>,
2691
                                 ReturnType,
2692
                                 A0,
2693
                                 A1,
2694
                                 A2,
2695
                                 A3,
2696
                                 Arg0,
2697
                                 Arg1>(
2698
      callback,
2699
      a0,
2700
      a1,
2701
      a2,
2702
      a3);
2703
}
2704

2705

2706
/**
2707
 * @brief A Method callback with 4 create-time args and 2 exec time args
2708
 */
2709
template <typename Class, typename Parent, typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
2710
class MethodCallback4_2: public Parent {
2711
 public:
2712
  typedef ReturnType (Class::*Method)(A0, A1, A2, A3, Arg0, Arg1);
2713
  MethodCallback4_2(Class *object, Method callback, A0 a0, A1 a1, A2 a2, A3 a3):
×
2714
    Parent(),
2715
    m_object(object),
×
2716
    m_callback(callback),
×
2717
    m_a0(a0),
×
2718
    m_a1(a1),
×
2719
    m_a2(a2),
×
2720
    m_a3(a3) {}
×
2721
  ReturnType DoRun(Arg0 arg0, Arg1 arg1) {
×
2722
    return (m_object->*m_callback)(m_a0, m_a1, m_a2, m_a3, arg0, arg1);
×
2723
  }
2724
 private:
2725
  Class *m_object;
2726
  Method m_callback;
2727
  A0 m_a0;
2728
  A1 m_a1;
2729
  A2 m_a2;
2730
  A3 m_a3;
2731
};
2732

2733

2734
/**
2735
 * @brief A helper function to create a new SingleUseCallback with 4
2736
 * create-time arguments and 2 execution time arguments.
2737
 * @tparam Class the class with the member function.
2738
 * @tparam ReturnType the return type of the callback.
2739
 * @tparam A0 a create-time argument type.
2740
 * @tparam A1 a create-time argument type.
2741
 * @tparam A2 a create-time argument type.
2742
 * @tparam A3 a create-time argument type.
2743
 * @tparam Arg0 an exec-time argument type.
2744
 * @tparam Arg1 an exec-time argument type.
2745
 * @param object the object to call the member function on.
2746
 * @param method the member function pointer to use when executing the callback.
2747
 * @param a0 a create-time argument.
2748
 * @param a1 a create-time argument.
2749
 * @param a2 a create-time argument.
2750
 * @param a3 a create-time argument.
2751
 * @returns The same return value as the member function.
2752
 */
2753
template <typename Class, typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
2754
inline SingleUseCallback2<ReturnType, Arg0, Arg1>* NewSingleCallback(
×
2755
  Class* object,
2756
  ReturnType (Class::*method)(A0, A1, A2, A3, Arg0, Arg1),
2757
  A0 a0,
2758
  A1 a1,
2759
  A2 a2,
2760
  A3 a3) {
2761
  return new MethodCallback4_2<Class,
×
2762
                               SingleUseCallback2<ReturnType, Arg0, Arg1>,
2763
                               ReturnType,
2764
                               A0,
2765
                               A1,
2766
                               A2,
2767
                               A3,
2768
                               Arg0,
2769
                               Arg1>(
2770
      object,
2771
      method,
2772
      a0,
2773
      a1,
2774
      a2,
2775
      a3);
×
2776
}
2777

2778

2779
/**
2780
 * @brief A helper function to create a new Callback with 4
2781
 * create-time arguments and 2 execution time arguments.
2782
 * @tparam Class the class with the member function.
2783
 * @tparam ReturnType the return type of the callback.
2784
 * @tparam A0 a create-time argument type.
2785
 * @tparam A1 a create-time argument type.
2786
 * @tparam A2 a create-time argument type.
2787
 * @tparam A3 a create-time argument type.
2788
 * @tparam Arg0 an exec-time argument type.
2789
 * @tparam Arg1 an exec-time argument type.
2790
 * @param object the object to call the member function on.
2791
 * @param method the member function pointer to use when executing the callback.
2792
 * @param a0 a create-time argument.
2793
 * @param a1 a create-time argument.
2794
 * @param a2 a create-time argument.
2795
 * @param a3 a create-time argument.
2796
 * @returns The same return value as the member function.
2797
 */
2798
template <typename Class, typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0, typename Arg1>  // NOLINT(whitespace/line_length)
2799
inline Callback2<ReturnType, Arg0, Arg1>* NewCallback(
2800
  Class* object,
2801
  ReturnType (Class::*method)(A0, A1, A2, A3, Arg0, Arg1),
2802
  A0 a0,
2803
  A1 a1,
2804
  A2 a2,
2805
  A3 a3) {
2806
  return new MethodCallback4_2<Class,
2807
                               Callback2<ReturnType, Arg0, Arg1>,
2808
                               ReturnType,
2809
                               A0,
2810
                               A1,
2811
                               A2,
2812
                               A3,
2813
                               Arg0,
2814
                               Arg1>(
2815
      object,
2816
      method,
2817
      a0,
2818
      a1,
2819
      a2,
2820
      a3);
2821
}
2822

2823

2824
/**
2825
 * @brief The base class for all 3 argument callbacks.
2826
 */
2827
template <typename ReturnType, typename Arg0, typename Arg1, typename Arg2>
2828
class BaseCallback3 {
49✔
2829
 public:
2830
  virtual ~BaseCallback3() {}
2831
  virtual ReturnType Run(Arg0 arg0, Arg1 arg1, Arg2 arg2) = 0;
2832
};
2833

2834
/**
2835
 * @brief A 3 argument callback which can be called multiple times.
2836
 */
2837
template <typename ReturnType, typename Arg0, typename Arg1, typename Arg2>
2838
class Callback3: public BaseCallback3<ReturnType, Arg0, Arg1, Arg2> {
46✔
2839
 public:
2840
  virtual ~Callback3() {}
2841
  ReturnType Run(Arg0 arg0, Arg1 arg1, Arg2 arg2) { return this->DoRun(arg0, arg1, arg2); }  // NOLINT(whitespace/line_length)
66✔
2842
 private:
2843
  virtual ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2) = 0;
2844
};
2845

2846
/**
2847
 * @brief A 3 argument callback which deletes itself after it's run.
2848
 */
2849
template <typename ReturnType, typename Arg0, typename Arg1, typename Arg2>
2850
class SingleUseCallback3: public BaseCallback3<ReturnType, Arg0, Arg1, Arg2> {
2851
 public:
2852
  virtual ~SingleUseCallback3() {}
2853
  ReturnType Run(Arg0 arg0, Arg1 arg1, Arg2 arg2) {
2854
    ReturnType ret = this->DoRun(arg0, arg1, arg2);
2855
    delete this;
2856
    return ret;
2857
  }
2858
 private:
2859
  virtual ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2) = 0;
2860
};
2861

2862
/**
2863
 * @brief A 3 arg, single use callback that returns void.
2864
 */
2865
template <typename Arg0, typename Arg1, typename Arg2>
2866
class SingleUseCallback3<void, Arg0, Arg1, Arg2>: public BaseCallback3<void, Arg0, Arg1, Arg2> {  // NOLINT(whitespace/line_length)
3✔
2867
 public:
2868
  virtual ~SingleUseCallback3() {}
2869
  void Run(Arg0 arg0, Arg1 arg1, Arg2 arg2) {
2✔
2870
    this->DoRun(arg0, arg1, arg2);
2✔
2871
    delete this;
2✔
2872
  }
2✔
2873
 private:
2874
  virtual void DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2) = 0;
2875
};
2876

2877
/**
2878
 * @brief A Function callback with 0 create-time args and 3 exec time args
2879
 */
2880
template <typename Parent, typename ReturnType, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
2881
class FunctionCallback0_3: public Parent {
2882
 public:
2883
  typedef ReturnType (*Function)(Arg0, Arg1, Arg2);
2884
  explicit FunctionCallback0_3(Function callback):
2885
    Parent(),
2886
    m_callback(callback) {}
2887
  ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2) {
2888
    return m_callback(arg0, arg1, arg2);
2889
  }
2890
 private:
2891
  Function m_callback;
2892
};
2893

2894

2895
/**
2896
 * @brief A helper function to create a new SingleUseCallback with 0
2897
 * create-time arguments and 3 execution time arguments.
2898
 * @tparam ReturnType the return type of the callback.
2899
 * @tparam Arg0 an exec-time argument type.
2900
 * @tparam Arg1 an exec-time argument type.
2901
 * @tparam Arg2 an exec-time argument type.
2902
 * @param callback the function pointer to use when executing the callback.
2903
 * @returns The same return value as the function.
2904
 */
2905
template <typename ReturnType, typename Arg0, typename Arg1, typename Arg2>
2906
inline SingleUseCallback3<ReturnType, Arg0, Arg1, Arg2>* NewSingleCallback(
2907
  ReturnType (*callback)(Arg0, Arg1, Arg2)) {
2908
  return new FunctionCallback0_3<
2909
                                 SingleUseCallback3<ReturnType, Arg0, Arg1, Arg2>,  // NOLINT(whitespace/line_length)
2910
                                 ReturnType,
2911
                                 Arg0,
2912
                                 Arg1,
2913
                                 Arg2>(
2914
      callback);
2915
}
2916

2917

2918
/**
2919
 * @brief A helper function to create a new Callback with 0
2920
 * create-time arguments and 3 execution time arguments.
2921
 * @tparam ReturnType the return type of the callback.
2922
 * @tparam Arg0 an exec-time argument type.
2923
 * @tparam Arg1 an exec-time argument type.
2924
 * @tparam Arg2 an exec-time argument type.
2925
 * @param callback the function pointer to use when executing the callback.
2926
 * @returns The same return value as the function.
2927
 */
2928
template <typename ReturnType, typename Arg0, typename Arg1, typename Arg2>
2929
inline Callback3<ReturnType, Arg0, Arg1, Arg2>* NewCallback(
2930
  ReturnType (*callback)(Arg0, Arg1, Arg2)) {
2931
  return new FunctionCallback0_3<
2932
                                 Callback3<ReturnType, Arg0, Arg1, Arg2>,
2933
                                 ReturnType,
2934
                                 Arg0,
2935
                                 Arg1,
2936
                                 Arg2>(
2937
      callback);
2938
}
2939

2940

2941
/**
2942
 * @brief A Method callback with 0 create-time args and 3 exec time args
2943
 */
2944
template <typename Class, typename Parent, typename ReturnType, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
2945
class MethodCallback0_3: public Parent {
2946
 public:
2947
  typedef ReturnType (Class::*Method)(Arg0, Arg1, Arg2);
2948
  MethodCallback0_3(Class *object, Method callback):
27✔
2949
    Parent(),
2950
    m_object(object),
27✔
2951
    m_callback(callback) {}
27✔
2952
  ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2) {
27✔
2953
    return (m_object->*m_callback)(arg0, arg1, arg2);
27✔
2954
  }
2955
 private:
2956
  Class *m_object;
2957
  Method m_callback;
2958
};
2959

2960

2961
/**
2962
 * @brief A helper function to create a new SingleUseCallback with 0
2963
 * create-time arguments and 3 execution time arguments.
2964
 * @tparam Class the class with the member function.
2965
 * @tparam ReturnType the return type of the callback.
2966
 * @tparam Arg0 an exec-time argument type.
2967
 * @tparam Arg1 an exec-time argument type.
2968
 * @tparam Arg2 an exec-time argument type.
2969
 * @param object the object to call the member function on.
2970
 * @param method the member function pointer to use when executing the callback.
2971
 * @returns The same return value as the member function.
2972
 */
2973
template <typename Class, typename ReturnType, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
2974
inline SingleUseCallback3<ReturnType, Arg0, Arg1, Arg2>* NewSingleCallback(
3✔
2975
  Class* object,
2976
  ReturnType (Class::*method)(Arg0, Arg1, Arg2)) {
2977
  return new MethodCallback0_3<Class,
3✔
2978
                               SingleUseCallback3<ReturnType, Arg0, Arg1, Arg2>,
2979
                               ReturnType,
2980
                               Arg0,
2981
                               Arg1,
2982
                               Arg2>(
2983
      object,
2984
      method);
3✔
2985
}
2986

2987

2988
/**
2989
 * @brief A helper function to create a new Callback with 0
2990
 * create-time arguments and 3 execution time arguments.
2991
 * @tparam Class the class with the member function.
2992
 * @tparam ReturnType the return type of the callback.
2993
 * @tparam Arg0 an exec-time argument type.
2994
 * @tparam Arg1 an exec-time argument type.
2995
 * @tparam Arg2 an exec-time argument type.
2996
 * @param object the object to call the member function on.
2997
 * @param method the member function pointer to use when executing the callback.
2998
 * @returns The same return value as the member function.
2999
 */
3000
template <typename Class, typename ReturnType, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3001
inline Callback3<ReturnType, Arg0, Arg1, Arg2>* NewCallback(
24✔
3002
  Class* object,
3003
  ReturnType (Class::*method)(Arg0, Arg1, Arg2)) {
3004
  return new MethodCallback0_3<Class,
24✔
3005
                               Callback3<ReturnType, Arg0, Arg1, Arg2>,
3006
                               ReturnType,
3007
                               Arg0,
3008
                               Arg1,
3009
                               Arg2>(
3010
      object,
3011
      method);
24✔
3012
}
3013

3014

3015
/**
3016
 * @brief A Function callback with 1 create-time args and 3 exec time args
3017
 */
3018
template <typename Parent, typename ReturnType, typename A0, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3019
class FunctionCallback1_3: public Parent {
3020
 public:
3021
  typedef ReturnType (*Function)(A0, Arg0, Arg1, Arg2);
3022
  FunctionCallback1_3(Function callback, A0 a0):
3023
    Parent(),
3024
    m_callback(callback),
3025
    m_a0(a0) {}
3026
  ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2) {
3027
    return m_callback(m_a0, arg0, arg1, arg2);
3028
  }
3029
 private:
3030
  Function m_callback;
3031
  A0 m_a0;
3032
};
3033

3034

3035
/**
3036
 * @brief A helper function to create a new SingleUseCallback with 1
3037
 * create-time arguments and 3 execution time arguments.
3038
 * @tparam ReturnType the return type of the callback.
3039
 * @tparam A0 a create-time argument type.
3040
 * @tparam Arg0 an exec-time argument type.
3041
 * @tparam Arg1 an exec-time argument type.
3042
 * @tparam Arg2 an exec-time argument type.
3043
 * @param callback the function pointer to use when executing the callback.
3044
 * @param a0 a create-time argument.
3045
 * @returns The same return value as the function.
3046
 */
3047
template <typename ReturnType, typename A0, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3048
inline SingleUseCallback3<ReturnType, Arg0, Arg1, Arg2>* NewSingleCallback(
3049
  ReturnType (*callback)(A0, Arg0, Arg1, Arg2),
3050
  A0 a0) {
3051
  return new FunctionCallback1_3<
3052
                                 SingleUseCallback3<ReturnType, Arg0, Arg1, Arg2>,  // NOLINT(whitespace/line_length)
3053
                                 ReturnType,
3054
                                 A0,
3055
                                 Arg0,
3056
                                 Arg1,
3057
                                 Arg2>(
3058
      callback,
3059
      a0);
3060
}
3061

3062

3063
/**
3064
 * @brief A helper function to create a new Callback with 1
3065
 * create-time arguments and 3 execution time arguments.
3066
 * @tparam ReturnType the return type of the callback.
3067
 * @tparam A0 a create-time argument type.
3068
 * @tparam Arg0 an exec-time argument type.
3069
 * @tparam Arg1 an exec-time argument type.
3070
 * @tparam Arg2 an exec-time argument type.
3071
 * @param callback the function pointer to use when executing the callback.
3072
 * @param a0 a create-time argument.
3073
 * @returns The same return value as the function.
3074
 */
3075
template <typename ReturnType, typename A0, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3076
inline Callback3<ReturnType, Arg0, Arg1, Arg2>* NewCallback(
3077
  ReturnType (*callback)(A0, Arg0, Arg1, Arg2),
3078
  A0 a0) {
3079
  return new FunctionCallback1_3<
3080
                                 Callback3<ReturnType, Arg0, Arg1, Arg2>,
3081
                                 ReturnType,
3082
                                 A0,
3083
                                 Arg0,
3084
                                 Arg1,
3085
                                 Arg2>(
3086
      callback,
3087
      a0);
3088
}
3089

3090

3091
/**
3092
 * @brief A Method callback with 1 create-time args and 3 exec time args
3093
 */
3094
template <typename Class, typename Parent, typename ReturnType, typename A0, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3095
class MethodCallback1_3: public Parent {
3096
 public:
3097
  typedef ReturnType (Class::*Method)(A0, Arg0, Arg1, Arg2);
3098
  MethodCallback1_3(Class *object, Method callback, A0 a0):
22✔
3099
    Parent(),
3100
    m_object(object),
22✔
3101
    m_callback(callback),
22✔
3102
    m_a0(a0) {}
22✔
3103
  ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2) {
40✔
3104
    return (m_object->*m_callback)(m_a0, arg0, arg1, arg2);
40✔
3105
  }
3106
 private:
3107
  Class *m_object;
3108
  Method m_callback;
3109
  A0 m_a0;
3110
};
3111

3112

3113
/**
3114
 * @brief A helper function to create a new SingleUseCallback with 1
3115
 * create-time arguments and 3 execution time arguments.
3116
 * @tparam Class the class with the member function.
3117
 * @tparam ReturnType the return type of the callback.
3118
 * @tparam A0 a create-time argument type.
3119
 * @tparam Arg0 an exec-time argument type.
3120
 * @tparam Arg1 an exec-time argument type.
3121
 * @tparam Arg2 an exec-time argument type.
3122
 * @param object the object to call the member function on.
3123
 * @param method the member function pointer to use when executing the callback.
3124
 * @param a0 a create-time argument.
3125
 * @returns The same return value as the member function.
3126
 */
3127
template <typename Class, typename ReturnType, typename A0, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3128
inline SingleUseCallback3<ReturnType, Arg0, Arg1, Arg2>* NewSingleCallback(
×
3129
  Class* object,
3130
  ReturnType (Class::*method)(A0, Arg0, Arg1, Arg2),
3131
  A0 a0) {
3132
  return new MethodCallback1_3<Class,
×
3133
                               SingleUseCallback3<ReturnType, Arg0, Arg1, Arg2>,
3134
                               ReturnType,
3135
                               A0,
3136
                               Arg0,
3137
                               Arg1,
3138
                               Arg2>(
3139
      object,
3140
      method,
3141
      a0);
×
3142
}
3143

3144

3145
/**
3146
 * @brief A helper function to create a new Callback with 1
3147
 * create-time arguments and 3 execution time arguments.
3148
 * @tparam Class the class with the member function.
3149
 * @tparam ReturnType the return type of the callback.
3150
 * @tparam A0 a create-time argument type.
3151
 * @tparam Arg0 an exec-time argument type.
3152
 * @tparam Arg1 an exec-time argument type.
3153
 * @tparam Arg2 an exec-time argument type.
3154
 * @param object the object to call the member function on.
3155
 * @param method the member function pointer to use when executing the callback.
3156
 * @param a0 a create-time argument.
3157
 * @returns The same return value as the member function.
3158
 */
3159
template <typename Class, typename ReturnType, typename A0, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3160
inline Callback3<ReturnType, Arg0, Arg1, Arg2>* NewCallback(
22✔
3161
  Class* object,
3162
  ReturnType (Class::*method)(A0, Arg0, Arg1, Arg2),
3163
  A0 a0) {
3164
  return new MethodCallback1_3<Class,
22✔
3165
                               Callback3<ReturnType, Arg0, Arg1, Arg2>,
3166
                               ReturnType,
3167
                               A0,
3168
                               Arg0,
3169
                               Arg1,
3170
                               Arg2>(
3171
      object,
3172
      method,
3173
      a0);
22✔
3174
}
3175

3176

3177
/**
3178
 * @brief A Function callback with 2 create-time args and 3 exec time args
3179
 */
3180
template <typename Parent, typename ReturnType, typename A0, typename A1, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3181
class FunctionCallback2_3: public Parent {
3182
 public:
3183
  typedef ReturnType (*Function)(A0, A1, Arg0, Arg1, Arg2);
3184
  FunctionCallback2_3(Function callback, A0 a0, A1 a1):
×
3185
    Parent(),
3186
    m_callback(callback),
×
3187
    m_a0(a0),
×
3188
    m_a1(a1) {}
×
3189
  ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2) {
×
3190
    return m_callback(m_a0, m_a1, arg0, arg1, arg2);
×
3191
  }
3192
 private:
3193
  Function m_callback;
3194
  A0 m_a0;
3195
  A1 m_a1;
3196
};
3197

3198

3199
/**
3200
 * @brief A helper function to create a new SingleUseCallback with 2
3201
 * create-time arguments and 3 execution time arguments.
3202
 * @tparam ReturnType the return type of the callback.
3203
 * @tparam A0 a create-time argument type.
3204
 * @tparam A1 a create-time argument type.
3205
 * @tparam Arg0 an exec-time argument type.
3206
 * @tparam Arg1 an exec-time argument type.
3207
 * @tparam Arg2 an exec-time argument type.
3208
 * @param callback the function pointer to use when executing the callback.
3209
 * @param a0 a create-time argument.
3210
 * @param a1 a create-time argument.
3211
 * @returns The same return value as the function.
3212
 */
3213
template <typename ReturnType, typename A0, typename A1, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3214
inline SingleUseCallback3<ReturnType, Arg0, Arg1, Arg2>* NewSingleCallback(
3215
  ReturnType (*callback)(A0, A1, Arg0, Arg1, Arg2),
3216
  A0 a0,
3217
  A1 a1) {
3218
  return new FunctionCallback2_3<
3219
                                 SingleUseCallback3<ReturnType, Arg0, Arg1, Arg2>,  // NOLINT(whitespace/line_length)
3220
                                 ReturnType,
3221
                                 A0,
3222
                                 A1,
3223
                                 Arg0,
3224
                                 Arg1,
3225
                                 Arg2>(
3226
      callback,
3227
      a0,
3228
      a1);
3229
}
3230

3231

3232
/**
3233
 * @brief A helper function to create a new Callback with 2
3234
 * create-time arguments and 3 execution time arguments.
3235
 * @tparam ReturnType the return type of the callback.
3236
 * @tparam A0 a create-time argument type.
3237
 * @tparam A1 a create-time argument type.
3238
 * @tparam Arg0 an exec-time argument type.
3239
 * @tparam Arg1 an exec-time argument type.
3240
 * @tparam Arg2 an exec-time argument type.
3241
 * @param callback the function pointer to use when executing the callback.
3242
 * @param a0 a create-time argument.
3243
 * @param a1 a create-time argument.
3244
 * @returns The same return value as the function.
3245
 */
3246
template <typename ReturnType, typename A0, typename A1, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3247
inline Callback3<ReturnType, Arg0, Arg1, Arg2>* NewCallback(
×
3248
  ReturnType (*callback)(A0, A1, Arg0, Arg1, Arg2),
3249
  A0 a0,
3250
  A1 a1) {
3251
  return new FunctionCallback2_3<
×
3252
                                 Callback3<ReturnType, Arg0, Arg1, Arg2>,
3253
                                 ReturnType,
3254
                                 A0,
3255
                                 A1,
3256
                                 Arg0,
3257
                                 Arg1,
3258
                                 Arg2>(
3259
      callback,
3260
      a0,
3261
      a1);
×
3262
}
3263

3264

3265
/**
3266
 * @brief A Method callback with 2 create-time args and 3 exec time args
3267
 */
3268
template <typename Class, typename Parent, typename ReturnType, typename A0, typename A1, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3269
class MethodCallback2_3: public Parent {
3270
 public:
3271
  typedef ReturnType (Class::*Method)(A0, A1, Arg0, Arg1, Arg2);
3272
  MethodCallback2_3(Class *object, Method callback, A0 a0, A1 a1):
×
3273
    Parent(),
3274
    m_object(object),
×
3275
    m_callback(callback),
×
3276
    m_a0(a0),
×
3277
    m_a1(a1) {}
×
3278
  ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2) {
×
3279
    return (m_object->*m_callback)(m_a0, m_a1, arg0, arg1, arg2);
×
3280
  }
3281
 private:
3282
  Class *m_object;
3283
  Method m_callback;
3284
  A0 m_a0;
3285
  A1 m_a1;
3286
};
3287

3288

3289
/**
3290
 * @brief A helper function to create a new SingleUseCallback with 2
3291
 * create-time arguments and 3 execution time arguments.
3292
 * @tparam Class the class with the member function.
3293
 * @tparam ReturnType the return type of the callback.
3294
 * @tparam A0 a create-time argument type.
3295
 * @tparam A1 a create-time argument type.
3296
 * @tparam Arg0 an exec-time argument type.
3297
 * @tparam Arg1 an exec-time argument type.
3298
 * @tparam Arg2 an exec-time argument type.
3299
 * @param object the object to call the member function on.
3300
 * @param method the member function pointer to use when executing the callback.
3301
 * @param a0 a create-time argument.
3302
 * @param a1 a create-time argument.
3303
 * @returns The same return value as the member function.
3304
 */
3305
template <typename Class, typename ReturnType, typename A0, typename A1, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3306
inline SingleUseCallback3<ReturnType, Arg0, Arg1, Arg2>* NewSingleCallback(
×
3307
  Class* object,
3308
  ReturnType (Class::*method)(A0, A1, Arg0, Arg1, Arg2),
3309
  A0 a0,
3310
  A1 a1) {
3311
  return new MethodCallback2_3<Class,
×
3312
                               SingleUseCallback3<ReturnType, Arg0, Arg1, Arg2>,
3313
                               ReturnType,
3314
                               A0,
3315
                               A1,
3316
                               Arg0,
3317
                               Arg1,
3318
                               Arg2>(
3319
      object,
3320
      method,
3321
      a0,
3322
      a1);
×
3323
}
3324

3325

3326
/**
3327
 * @brief A helper function to create a new Callback with 2
3328
 * create-time arguments and 3 execution time arguments.
3329
 * @tparam Class the class with the member function.
3330
 * @tparam ReturnType the return type of the callback.
3331
 * @tparam A0 a create-time argument type.
3332
 * @tparam A1 a create-time argument type.
3333
 * @tparam Arg0 an exec-time argument type.
3334
 * @tparam Arg1 an exec-time argument type.
3335
 * @tparam Arg2 an exec-time argument type.
3336
 * @param object the object to call the member function on.
3337
 * @param method the member function pointer to use when executing the callback.
3338
 * @param a0 a create-time argument.
3339
 * @param a1 a create-time argument.
3340
 * @returns The same return value as the member function.
3341
 */
3342
template <typename Class, typename ReturnType, typename A0, typename A1, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3343
inline Callback3<ReturnType, Arg0, Arg1, Arg2>* NewCallback(
3344
  Class* object,
3345
  ReturnType (Class::*method)(A0, A1, Arg0, Arg1, Arg2),
3346
  A0 a0,
3347
  A1 a1) {
3348
  return new MethodCallback2_3<Class,
3349
                               Callback3<ReturnType, Arg0, Arg1, Arg2>,
3350
                               ReturnType,
3351
                               A0,
3352
                               A1,
3353
                               Arg0,
3354
                               Arg1,
3355
                               Arg2>(
3356
      object,
3357
      method,
3358
      a0,
3359
      a1);
3360
}
3361

3362

3363
/**
3364
 * @brief A Function callback with 3 create-time args and 3 exec time args
3365
 */
3366
template <typename Parent, typename ReturnType, typename A0, typename A1, typename A2, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3367
class FunctionCallback3_3: public Parent {
3368
 public:
3369
  typedef ReturnType (*Function)(A0, A1, A2, Arg0, Arg1, Arg2);
3370
  FunctionCallback3_3(Function callback, A0 a0, A1 a1, A2 a2):
3371
    Parent(),
3372
    m_callback(callback),
3373
    m_a0(a0),
3374
    m_a1(a1),
3375
    m_a2(a2) {}
3376
  ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2) {
3377
    return m_callback(m_a0, m_a1, m_a2, arg0, arg1, arg2);
3378
  }
3379
 private:
3380
  Function m_callback;
3381
  A0 m_a0;
3382
  A1 m_a1;
3383
  A2 m_a2;
3384
};
3385

3386

3387
/**
3388
 * @brief A helper function to create a new SingleUseCallback with 3
3389
 * create-time arguments and 3 execution time arguments.
3390
 * @tparam ReturnType the return type of the callback.
3391
 * @tparam A0 a create-time argument type.
3392
 * @tparam A1 a create-time argument type.
3393
 * @tparam A2 a create-time argument type.
3394
 * @tparam Arg0 an exec-time argument type.
3395
 * @tparam Arg1 an exec-time argument type.
3396
 * @tparam Arg2 an exec-time argument type.
3397
 * @param callback the function pointer to use when executing the callback.
3398
 * @param a0 a create-time argument.
3399
 * @param a1 a create-time argument.
3400
 * @param a2 a create-time argument.
3401
 * @returns The same return value as the function.
3402
 */
3403
template <typename ReturnType, typename A0, typename A1, typename A2, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3404
inline SingleUseCallback3<ReturnType, Arg0, Arg1, Arg2>* NewSingleCallback(
3405
  ReturnType (*callback)(A0, A1, A2, Arg0, Arg1, Arg2),
3406
  A0 a0,
3407
  A1 a1,
3408
  A2 a2) {
3409
  return new FunctionCallback3_3<
3410
                                 SingleUseCallback3<ReturnType, Arg0, Arg1, Arg2>,  // NOLINT(whitespace/line_length)
3411
                                 ReturnType,
3412
                                 A0,
3413
                                 A1,
3414
                                 A2,
3415
                                 Arg0,
3416
                                 Arg1,
3417
                                 Arg2>(
3418
      callback,
3419
      a0,
3420
      a1,
3421
      a2);
3422
}
3423

3424

3425
/**
3426
 * @brief A helper function to create a new Callback with 3
3427
 * create-time arguments and 3 execution time arguments.
3428
 * @tparam ReturnType the return type of the callback.
3429
 * @tparam A0 a create-time argument type.
3430
 * @tparam A1 a create-time argument type.
3431
 * @tparam A2 a create-time argument type.
3432
 * @tparam Arg0 an exec-time argument type.
3433
 * @tparam Arg1 an exec-time argument type.
3434
 * @tparam Arg2 an exec-time argument type.
3435
 * @param callback the function pointer to use when executing the callback.
3436
 * @param a0 a create-time argument.
3437
 * @param a1 a create-time argument.
3438
 * @param a2 a create-time argument.
3439
 * @returns The same return value as the function.
3440
 */
3441
template <typename ReturnType, typename A0, typename A1, typename A2, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3442
inline Callback3<ReturnType, Arg0, Arg1, Arg2>* NewCallback(
3443
  ReturnType (*callback)(A0, A1, A2, Arg0, Arg1, Arg2),
3444
  A0 a0,
3445
  A1 a1,
3446
  A2 a2) {
3447
  return new FunctionCallback3_3<
3448
                                 Callback3<ReturnType, Arg0, Arg1, Arg2>,
3449
                                 ReturnType,
3450
                                 A0,
3451
                                 A1,
3452
                                 A2,
3453
                                 Arg0,
3454
                                 Arg1,
3455
                                 Arg2>(
3456
      callback,
3457
      a0,
3458
      a1,
3459
      a2);
3460
}
3461

3462

3463
/**
3464
 * @brief A Method callback with 3 create-time args and 3 exec time args
3465
 */
3466
template <typename Class, typename Parent, typename ReturnType, typename A0, typename A1, typename A2, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3467
class MethodCallback3_3: public Parent {
3468
 public:
3469
  typedef ReturnType (Class::*Method)(A0, A1, A2, Arg0, Arg1, Arg2);
3470
  MethodCallback3_3(Class *object, Method callback, A0 a0, A1 a1, A2 a2):
×
3471
    Parent(),
3472
    m_object(object),
×
3473
    m_callback(callback),
×
3474
    m_a0(a0),
×
3475
    m_a1(a1),
×
3476
    m_a2(a2) {}
×
3477
  ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2) {
×
3478
    return (m_object->*m_callback)(m_a0, m_a1, m_a2, arg0, arg1, arg2);
×
3479
  }
3480
 private:
3481
  Class *m_object;
3482
  Method m_callback;
3483
  A0 m_a0;
3484
  A1 m_a1;
3485
  A2 m_a2;
3486
};
3487

3488

3489
/**
3490
 * @brief A helper function to create a new SingleUseCallback with 3
3491
 * create-time arguments and 3 execution time arguments.
3492
 * @tparam Class the class with the member function.
3493
 * @tparam ReturnType the return type of the callback.
3494
 * @tparam A0 a create-time argument type.
3495
 * @tparam A1 a create-time argument type.
3496
 * @tparam A2 a create-time argument type.
3497
 * @tparam Arg0 an exec-time argument type.
3498
 * @tparam Arg1 an exec-time argument type.
3499
 * @tparam Arg2 an exec-time argument type.
3500
 * @param object the object to call the member function on.
3501
 * @param method the member function pointer to use when executing the callback.
3502
 * @param a0 a create-time argument.
3503
 * @param a1 a create-time argument.
3504
 * @param a2 a create-time argument.
3505
 * @returns The same return value as the member function.
3506
 */
3507
template <typename Class, typename ReturnType, typename A0, typename A1, typename A2, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3508
inline SingleUseCallback3<ReturnType, Arg0, Arg1, Arg2>* NewSingleCallback(
×
3509
  Class* object,
3510
  ReturnType (Class::*method)(A0, A1, A2, Arg0, Arg1, Arg2),
3511
  A0 a0,
3512
  A1 a1,
3513
  A2 a2) {
3514
  return new MethodCallback3_3<Class,
×
3515
                               SingleUseCallback3<ReturnType, Arg0, Arg1, Arg2>,
3516
                               ReturnType,
3517
                               A0,
3518
                               A1,
3519
                               A2,
3520
                               Arg0,
3521
                               Arg1,
3522
                               Arg2>(
3523
      object,
3524
      method,
3525
      a0,
3526
      a1,
3527
      a2);
×
3528
}
3529

3530

3531
/**
3532
 * @brief A helper function to create a new Callback with 3
3533
 * create-time arguments and 3 execution time arguments.
3534
 * @tparam Class the class with the member function.
3535
 * @tparam ReturnType the return type of the callback.
3536
 * @tparam A0 a create-time argument type.
3537
 * @tparam A1 a create-time argument type.
3538
 * @tparam A2 a create-time argument type.
3539
 * @tparam Arg0 an exec-time argument type.
3540
 * @tparam Arg1 an exec-time argument type.
3541
 * @tparam Arg2 an exec-time argument type.
3542
 * @param object the object to call the member function on.
3543
 * @param method the member function pointer to use when executing the callback.
3544
 * @param a0 a create-time argument.
3545
 * @param a1 a create-time argument.
3546
 * @param a2 a create-time argument.
3547
 * @returns The same return value as the member function.
3548
 */
3549
template <typename Class, typename ReturnType, typename A0, typename A1, typename A2, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3550
inline Callback3<ReturnType, Arg0, Arg1, Arg2>* NewCallback(
3551
  Class* object,
3552
  ReturnType (Class::*method)(A0, A1, A2, Arg0, Arg1, Arg2),
3553
  A0 a0,
3554
  A1 a1,
3555
  A2 a2) {
3556
  return new MethodCallback3_3<Class,
3557
                               Callback3<ReturnType, Arg0, Arg1, Arg2>,
3558
                               ReturnType,
3559
                               A0,
3560
                               A1,
3561
                               A2,
3562
                               Arg0,
3563
                               Arg1,
3564
                               Arg2>(
3565
      object,
3566
      method,
3567
      a0,
3568
      a1,
3569
      a2);
3570
}
3571

3572

3573
/**
3574
 * @brief A Function callback with 4 create-time args and 3 exec time args
3575
 */
3576
template <typename Parent, typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3577
class FunctionCallback4_3: public Parent {
3578
 public:
3579
  typedef ReturnType (*Function)(A0, A1, A2, A3, Arg0, Arg1, Arg2);
3580
  FunctionCallback4_3(Function callback, A0 a0, A1 a1, A2 a2, A3 a3):
3581
    Parent(),
3582
    m_callback(callback),
3583
    m_a0(a0),
3584
    m_a1(a1),
3585
    m_a2(a2),
3586
    m_a3(a3) {}
3587
  ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2) {
3588
    return m_callback(m_a0, m_a1, m_a2, m_a3, arg0, arg1, arg2);
3589
  }
3590
 private:
3591
  Function m_callback;
3592
  A0 m_a0;
3593
  A1 m_a1;
3594
  A2 m_a2;
3595
  A3 m_a3;
3596
};
3597

3598

3599
/**
3600
 * @brief A helper function to create a new SingleUseCallback with 4
3601
 * create-time arguments and 3 execution time arguments.
3602
 * @tparam ReturnType the return type of the callback.
3603
 * @tparam A0 a create-time argument type.
3604
 * @tparam A1 a create-time argument type.
3605
 * @tparam A2 a create-time argument type.
3606
 * @tparam A3 a create-time argument type.
3607
 * @tparam Arg0 an exec-time argument type.
3608
 * @tparam Arg1 an exec-time argument type.
3609
 * @tparam Arg2 an exec-time argument type.
3610
 * @param callback the function pointer to use when executing the callback.
3611
 * @param a0 a create-time argument.
3612
 * @param a1 a create-time argument.
3613
 * @param a2 a create-time argument.
3614
 * @param a3 a create-time argument.
3615
 * @returns The same return value as the function.
3616
 */
3617
template <typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3618
inline SingleUseCallback3<ReturnType, Arg0, Arg1, Arg2>* NewSingleCallback(
3619
  ReturnType (*callback)(A0, A1, A2, A3, Arg0, Arg1, Arg2),
3620
  A0 a0,
3621
  A1 a1,
3622
  A2 a2,
3623
  A3 a3) {
3624
  return new FunctionCallback4_3<
3625
                                 SingleUseCallback3<ReturnType, Arg0, Arg1, Arg2>,  // NOLINT(whitespace/line_length)
3626
                                 ReturnType,
3627
                                 A0,
3628
                                 A1,
3629
                                 A2,
3630
                                 A3,
3631
                                 Arg0,
3632
                                 Arg1,
3633
                                 Arg2>(
3634
      callback,
3635
      a0,
3636
      a1,
3637
      a2,
3638
      a3);
3639
}
3640

3641

3642
/**
3643
 * @brief A helper function to create a new Callback with 4
3644
 * create-time arguments and 3 execution time arguments.
3645
 * @tparam ReturnType the return type of the callback.
3646
 * @tparam A0 a create-time argument type.
3647
 * @tparam A1 a create-time argument type.
3648
 * @tparam A2 a create-time argument type.
3649
 * @tparam A3 a create-time argument type.
3650
 * @tparam Arg0 an exec-time argument type.
3651
 * @tparam Arg1 an exec-time argument type.
3652
 * @tparam Arg2 an exec-time argument type.
3653
 * @param callback the function pointer to use when executing the callback.
3654
 * @param a0 a create-time argument.
3655
 * @param a1 a create-time argument.
3656
 * @param a2 a create-time argument.
3657
 * @param a3 a create-time argument.
3658
 * @returns The same return value as the function.
3659
 */
3660
template <typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3661
inline Callback3<ReturnType, Arg0, Arg1, Arg2>* NewCallback(
3662
  ReturnType (*callback)(A0, A1, A2, A3, Arg0, Arg1, Arg2),
3663
  A0 a0,
3664
  A1 a1,
3665
  A2 a2,
3666
  A3 a3) {
3667
  return new FunctionCallback4_3<
3668
                                 Callback3<ReturnType, Arg0, Arg1, Arg2>,
3669
                                 ReturnType,
3670
                                 A0,
3671
                                 A1,
3672
                                 A2,
3673
                                 A3,
3674
                                 Arg0,
3675
                                 Arg1,
3676
                                 Arg2>(
3677
      callback,
3678
      a0,
3679
      a1,
3680
      a2,
3681
      a3);
3682
}
3683

3684

3685
/**
3686
 * @brief A Method callback with 4 create-time args and 3 exec time args
3687
 */
3688
template <typename Class, typename Parent, typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3689
class MethodCallback4_3: public Parent {
3690
 public:
3691
  typedef ReturnType (Class::*Method)(A0, A1, A2, A3, Arg0, Arg1, Arg2);
3692
  MethodCallback4_3(Class *object, Method callback, A0 a0, A1 a1, A2 a2, A3 a3):
3693
    Parent(),
3694
    m_object(object),
3695
    m_callback(callback),
3696
    m_a0(a0),
3697
    m_a1(a1),
3698
    m_a2(a2),
3699
    m_a3(a3) {}
3700
  ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2) {
3701
    return (m_object->*m_callback)(m_a0, m_a1, m_a2, m_a3, arg0, arg1, arg2);
3702
  }
3703
 private:
3704
  Class *m_object;
3705
  Method m_callback;
3706
  A0 m_a0;
3707
  A1 m_a1;
3708
  A2 m_a2;
3709
  A3 m_a3;
3710
};
3711

3712

3713
/**
3714
 * @brief A helper function to create a new SingleUseCallback with 4
3715
 * create-time arguments and 3 execution time arguments.
3716
 * @tparam Class the class with the member function.
3717
 * @tparam ReturnType the return type of the callback.
3718
 * @tparam A0 a create-time argument type.
3719
 * @tparam A1 a create-time argument type.
3720
 * @tparam A2 a create-time argument type.
3721
 * @tparam A3 a create-time argument type.
3722
 * @tparam Arg0 an exec-time argument type.
3723
 * @tparam Arg1 an exec-time argument type.
3724
 * @tparam Arg2 an exec-time argument type.
3725
 * @param object the object to call the member function on.
3726
 * @param method the member function pointer to use when executing the callback.
3727
 * @param a0 a create-time argument.
3728
 * @param a1 a create-time argument.
3729
 * @param a2 a create-time argument.
3730
 * @param a3 a create-time argument.
3731
 * @returns The same return value as the member function.
3732
 */
3733
template <typename Class, typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3734
inline SingleUseCallback3<ReturnType, Arg0, Arg1, Arg2>* NewSingleCallback(
3735
  Class* object,
3736
  ReturnType (Class::*method)(A0, A1, A2, A3, Arg0, Arg1, Arg2),
3737
  A0 a0,
3738
  A1 a1,
3739
  A2 a2,
3740
  A3 a3) {
3741
  return new MethodCallback4_3<Class,
3742
                               SingleUseCallback3<ReturnType, Arg0, Arg1, Arg2>,
3743
                               ReturnType,
3744
                               A0,
3745
                               A1,
3746
                               A2,
3747
                               A3,
3748
                               Arg0,
3749
                               Arg1,
3750
                               Arg2>(
3751
      object,
3752
      method,
3753
      a0,
3754
      a1,
3755
      a2,
3756
      a3);
3757
}
3758

3759

3760
/**
3761
 * @brief A helper function to create a new Callback with 4
3762
 * create-time arguments and 3 execution time arguments.
3763
 * @tparam Class the class with the member function.
3764
 * @tparam ReturnType the return type of the callback.
3765
 * @tparam A0 a create-time argument type.
3766
 * @tparam A1 a create-time argument type.
3767
 * @tparam A2 a create-time argument type.
3768
 * @tparam A3 a create-time argument type.
3769
 * @tparam Arg0 an exec-time argument type.
3770
 * @tparam Arg1 an exec-time argument type.
3771
 * @tparam Arg2 an exec-time argument type.
3772
 * @param object the object to call the member function on.
3773
 * @param method the member function pointer to use when executing the callback.
3774
 * @param a0 a create-time argument.
3775
 * @param a1 a create-time argument.
3776
 * @param a2 a create-time argument.
3777
 * @param a3 a create-time argument.
3778
 * @returns The same return value as the member function.
3779
 */
3780
template <typename Class, typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0, typename Arg1, typename Arg2>  // NOLINT(whitespace/line_length)
3781
inline Callback3<ReturnType, Arg0, Arg1, Arg2>* NewCallback(
3782
  Class* object,
3783
  ReturnType (Class::*method)(A0, A1, A2, A3, Arg0, Arg1, Arg2),
3784
  A0 a0,
3785
  A1 a1,
3786
  A2 a2,
3787
  A3 a3) {
3788
  return new MethodCallback4_3<Class,
3789
                               Callback3<ReturnType, Arg0, Arg1, Arg2>,
3790
                               ReturnType,
3791
                               A0,
3792
                               A1,
3793
                               A2,
3794
                               A3,
3795
                               Arg0,
3796
                               Arg1,
3797
                               Arg2>(
3798
      object,
3799
      method,
3800
      a0,
3801
      a1,
3802
      a2,
3803
      a3);
3804
}
3805

3806

3807
/**
3808
 * @brief The base class for all 4 argument callbacks.
3809
 */
3810
template <typename ReturnType, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
3811
class BaseCallback4 {
3✔
3812
 public:
3813
  virtual ~BaseCallback4() {}
3814
  virtual ReturnType Run(Arg0 arg0, Arg1 arg1, Arg2 arg2, Arg3 arg3) = 0;
3815
};
3816

3817
/**
3818
 * @brief A 4 argument callback which can be called multiple times.
3819
 */
3820
template <typename ReturnType, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
3821
class Callback4: public BaseCallback4<ReturnType, Arg0, Arg1, Arg2, Arg3> {
×
3822
 public:
3823
  virtual ~Callback4() {}
3824
  ReturnType Run(Arg0 arg0, Arg1 arg1, Arg2 arg2, Arg3 arg3) { return this->DoRun(arg0, arg1, arg2, arg3); }  // NOLINT(whitespace/line_length)
×
3825
 private:
3826
  virtual ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2, Arg3 arg3) = 0;
3827
};
3828

3829
/**
3830
 * @brief A 4 argument callback which deletes itself after it's run.
3831
 */
3832
template <typename ReturnType, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
3833
class SingleUseCallback4: public BaseCallback4<ReturnType, Arg0, Arg1, Arg2, Arg3> {  // NOLINT(whitespace/line_length)
×
3834
 public:
3835
  virtual ~SingleUseCallback4() {}
3836
  ReturnType Run(Arg0 arg0, Arg1 arg1, Arg2 arg2, Arg3 arg3) {
×
3837
    ReturnType ret = this->DoRun(arg0, arg1, arg2, arg3);
×
3838
    delete this;
×
3839
    return ret;
×
3840
  }
3841
 private:
3842
  virtual ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2, Arg3 arg3) = 0;
3843
};
3844

3845
/**
3846
 * @brief A 4 arg, single use callback that returns void.
3847
 */
3848
template <typename Arg0, typename Arg1, typename Arg2, typename Arg3>
3849
class SingleUseCallback4<void, Arg0, Arg1, Arg2, Arg3>: public BaseCallback4<void, Arg0, Arg1, Arg2, Arg3> {  // NOLINT(whitespace/line_length)
3✔
3850
 public:
3851
  virtual ~SingleUseCallback4() {}
3852
  void Run(Arg0 arg0, Arg1 arg1, Arg2 arg2, Arg3 arg3) {
1✔
3853
    this->DoRun(arg0, arg1, arg2, arg3);
1✔
3854
    delete this;
1✔
3855
  }
1✔
3856
 private:
3857
  virtual void DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2, Arg3 arg3) = 0;
3858
};
3859

3860
/**
3861
 * @brief A Function callback with 0 create-time args and 4 exec time args
3862
 */
3863
template <typename Parent, typename ReturnType, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
3864
class FunctionCallback0_4: public Parent {
3865
 public:
3866
  typedef ReturnType (*Function)(Arg0, Arg1, Arg2, Arg3);
3867
  explicit FunctionCallback0_4(Function callback):
×
3868
    Parent(),
3869
    m_callback(callback) {}
×
3870
  ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2, Arg3 arg3) {
×
3871
    return m_callback(arg0, arg1, arg2, arg3);
×
3872
  }
3873
 private:
3874
  Function m_callback;
3875
};
3876

3877

3878
/**
3879
 * @brief A helper function to create a new SingleUseCallback with 0
3880
 * create-time arguments and 4 execution time arguments.
3881
 * @tparam ReturnType the return type of the callback.
3882
 * @tparam Arg0 an exec-time argument type.
3883
 * @tparam Arg1 an exec-time argument type.
3884
 * @tparam Arg2 an exec-time argument type.
3885
 * @tparam Arg3 an exec-time argument type.
3886
 * @param callback the function pointer to use when executing the callback.
3887
 * @returns The same return value as the function.
3888
 */
3889
template <typename ReturnType, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
3890
inline SingleUseCallback4<ReturnType, Arg0, Arg1, Arg2, Arg3>* NewSingleCallback(  // NOLINT(whitespace/line_length)
3891
  ReturnType (*callback)(Arg0, Arg1, Arg2, Arg3)) {
3892
  return new FunctionCallback0_4<
3893
                                 SingleUseCallback4<ReturnType, Arg0, Arg1, Arg2, Arg3>,  // NOLINT(whitespace/line_length)
3894
                                 ReturnType,
3895
                                 Arg0,
3896
                                 Arg1,
3897
                                 Arg2,
3898
                                 Arg3>(
3899
      callback);
3900
}
3901

3902

3903
/**
3904
 * @brief A helper function to create a new Callback with 0
3905
 * create-time arguments and 4 execution time arguments.
3906
 * @tparam ReturnType the return type of the callback.
3907
 * @tparam Arg0 an exec-time argument type.
3908
 * @tparam Arg1 an exec-time argument type.
3909
 * @tparam Arg2 an exec-time argument type.
3910
 * @tparam Arg3 an exec-time argument type.
3911
 * @param callback the function pointer to use when executing the callback.
3912
 * @returns The same return value as the function.
3913
 */
3914
template <typename ReturnType, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
3915
inline Callback4<ReturnType, Arg0, Arg1, Arg2, Arg3>* NewCallback(
×
3916
  ReturnType (*callback)(Arg0, Arg1, Arg2, Arg3)) {
3917
  return new FunctionCallback0_4<
×
3918
                                 Callback4<ReturnType, Arg0, Arg1, Arg2, Arg3>,
3919
                                 ReturnType,
3920
                                 Arg0,
3921
                                 Arg1,
3922
                                 Arg2,
3923
                                 Arg3>(
3924
      callback);
×
3925
}
3926

3927

3928
/**
3929
 * @brief A Method callback with 0 create-time args and 4 exec time args
3930
 */
3931
template <typename Class, typename Parent, typename ReturnType, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
3932
class MethodCallback0_4: public Parent {
3933
 public:
3934
  typedef ReturnType (Class::*Method)(Arg0, Arg1, Arg2, Arg3);
3935
  MethodCallback0_4(Class *object, Method callback):
3✔
3936
    Parent(),
3937
    m_object(object),
3✔
3938
    m_callback(callback) {}
3✔
3939
  ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2, Arg3 arg3) {
1✔
3940
    return (m_object->*m_callback)(arg0, arg1, arg2, arg3);
1✔
3941
  }
3942
 private:
3943
  Class *m_object;
3944
  Method m_callback;
3945
};
3946

3947

3948
/**
3949
 * @brief A helper function to create a new SingleUseCallback with 0
3950
 * create-time arguments and 4 execution time arguments.
3951
 * @tparam Class the class with the member function.
3952
 * @tparam ReturnType the return type of the callback.
3953
 * @tparam Arg0 an exec-time argument type.
3954
 * @tparam Arg1 an exec-time argument type.
3955
 * @tparam Arg2 an exec-time argument type.
3956
 * @tparam Arg3 an exec-time argument type.
3957
 * @param object the object to call the member function on.
3958
 * @param method the member function pointer to use when executing the callback.
3959
 * @returns The same return value as the member function.
3960
 */
3961
template <typename Class, typename ReturnType, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
3962
inline SingleUseCallback4<ReturnType, Arg0, Arg1, Arg2, Arg3>* NewSingleCallback(  // NOLINT(whitespace/line_length)
3✔
3963
  Class* object,
3964
  ReturnType (Class::*method)(Arg0, Arg1, Arg2, Arg3)) {
3965
  return new MethodCallback0_4<Class,
3✔
3966
                               SingleUseCallback4<ReturnType, Arg0, Arg1, Arg2, Arg3>,  // NOLINT(whitespace/line_length)
3967
                               ReturnType,
3968
                               Arg0,
3969
                               Arg1,
3970
                               Arg2,
3971
                               Arg3>(
3972
      object,
3973
      method);
3✔
3974
}
3975

3976

3977
/**
3978
 * @brief A helper function to create a new Callback with 0
3979
 * create-time arguments and 4 execution time arguments.
3980
 * @tparam Class the class with the member function.
3981
 * @tparam ReturnType the return type of the callback.
3982
 * @tparam Arg0 an exec-time argument type.
3983
 * @tparam Arg1 an exec-time argument type.
3984
 * @tparam Arg2 an exec-time argument type.
3985
 * @tparam Arg3 an exec-time argument type.
3986
 * @param object the object to call the member function on.
3987
 * @param method the member function pointer to use when executing the callback.
3988
 * @returns The same return value as the member function.
3989
 */
3990
template <typename Class, typename ReturnType, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
3991
inline Callback4<ReturnType, Arg0, Arg1, Arg2, Arg3>* NewCallback(
×
3992
  Class* object,
3993
  ReturnType (Class::*method)(Arg0, Arg1, Arg2, Arg3)) {
3994
  return new MethodCallback0_4<Class,
×
3995
                               Callback4<ReturnType, Arg0, Arg1, Arg2, Arg3>,
3996
                               ReturnType,
3997
                               Arg0,
3998
                               Arg1,
3999
                               Arg2,
4000
                               Arg3>(
4001
      object,
4002
      method);
×
4003
}
4004

4005

4006
/**
4007
 * @brief A Function callback with 1 create-time args and 4 exec time args
4008
 */
4009
template <typename Parent, typename ReturnType, typename A0, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4010
class FunctionCallback1_4: public Parent {
4011
 public:
4012
  typedef ReturnType (*Function)(A0, Arg0, Arg1, Arg2, Arg3);
4013
  FunctionCallback1_4(Function callback, A0 a0):
4014
    Parent(),
4015
    m_callback(callback),
4016
    m_a0(a0) {}
4017
  ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2, Arg3 arg3) {
4018
    return m_callback(m_a0, arg0, arg1, arg2, arg3);
4019
  }
4020
 private:
4021
  Function m_callback;
4022
  A0 m_a0;
4023
};
4024

4025

4026
/**
4027
 * @brief A helper function to create a new SingleUseCallback with 1
4028
 * create-time arguments and 4 execution time arguments.
4029
 * @tparam ReturnType the return type of the callback.
4030
 * @tparam A0 a create-time argument type.
4031
 * @tparam Arg0 an exec-time argument type.
4032
 * @tparam Arg1 an exec-time argument type.
4033
 * @tparam Arg2 an exec-time argument type.
4034
 * @tparam Arg3 an exec-time argument type.
4035
 * @param callback the function pointer to use when executing the callback.
4036
 * @param a0 a create-time argument.
4037
 * @returns The same return value as the function.
4038
 */
4039
template <typename ReturnType, typename A0, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4040
inline SingleUseCallback4<ReturnType, Arg0, Arg1, Arg2, Arg3>* NewSingleCallback(  // NOLINT(whitespace/line_length)
4041
  ReturnType (*callback)(A0, Arg0, Arg1, Arg2, Arg3),
4042
  A0 a0) {
4043
  return new FunctionCallback1_4<
4044
                                 SingleUseCallback4<ReturnType, Arg0, Arg1, Arg2, Arg3>,  // NOLINT(whitespace/line_length)
4045
                                 ReturnType,
4046
                                 A0,
4047
                                 Arg0,
4048
                                 Arg1,
4049
                                 Arg2,
4050
                                 Arg3>(
4051
      callback,
4052
      a0);
4053
}
4054

4055

4056
/**
4057
 * @brief A helper function to create a new Callback with 1
4058
 * create-time arguments and 4 execution time arguments.
4059
 * @tparam ReturnType the return type of the callback.
4060
 * @tparam A0 a create-time argument type.
4061
 * @tparam Arg0 an exec-time argument type.
4062
 * @tparam Arg1 an exec-time argument type.
4063
 * @tparam Arg2 an exec-time argument type.
4064
 * @tparam Arg3 an exec-time argument type.
4065
 * @param callback the function pointer to use when executing the callback.
4066
 * @param a0 a create-time argument.
4067
 * @returns The same return value as the function.
4068
 */
4069
template <typename ReturnType, typename A0, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4070
inline Callback4<ReturnType, Arg0, Arg1, Arg2, Arg3>* NewCallback(
4071
  ReturnType (*callback)(A0, Arg0, Arg1, Arg2, Arg3),
4072
  A0 a0) {
4073
  return new FunctionCallback1_4<
4074
                                 Callback4<ReturnType, Arg0, Arg1, Arg2, Arg3>,
4075
                                 ReturnType,
4076
                                 A0,
4077
                                 Arg0,
4078
                                 Arg1,
4079
                                 Arg2,
4080
                                 Arg3>(
4081
      callback,
4082
      a0);
4083
}
4084

4085

4086
/**
4087
 * @brief A Method callback with 1 create-time args and 4 exec time args
4088
 */
4089
template <typename Class, typename Parent, typename ReturnType, typename A0, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4090
class MethodCallback1_4: public Parent {
4091
 public:
4092
  typedef ReturnType (Class::*Method)(A0, Arg0, Arg1, Arg2, Arg3);
4093
  MethodCallback1_4(Class *object, Method callback, A0 a0):
×
4094
    Parent(),
4095
    m_object(object),
×
4096
    m_callback(callback),
×
4097
    m_a0(a0) {}
×
4098
  ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2, Arg3 arg3) {
×
4099
    return (m_object->*m_callback)(m_a0, arg0, arg1, arg2, arg3);
×
4100
  }
4101
 private:
4102
  Class *m_object;
4103
  Method m_callback;
4104
  A0 m_a0;
4105
};
4106

4107

4108
/**
4109
 * @brief A helper function to create a new SingleUseCallback with 1
4110
 * create-time arguments and 4 execution time arguments.
4111
 * @tparam Class the class with the member function.
4112
 * @tparam ReturnType the return type of the callback.
4113
 * @tparam A0 a create-time argument type.
4114
 * @tparam Arg0 an exec-time argument type.
4115
 * @tparam Arg1 an exec-time argument type.
4116
 * @tparam Arg2 an exec-time argument type.
4117
 * @tparam Arg3 an exec-time argument type.
4118
 * @param object the object to call the member function on.
4119
 * @param method the member function pointer to use when executing the callback.
4120
 * @param a0 a create-time argument.
4121
 * @returns The same return value as the member function.
4122
 */
4123
template <typename Class, typename ReturnType, typename A0, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4124
inline SingleUseCallback4<ReturnType, Arg0, Arg1, Arg2, Arg3>* NewSingleCallback(  // NOLINT(whitespace/line_length)
×
4125
  Class* object,
4126
  ReturnType (Class::*method)(A0, Arg0, Arg1, Arg2, Arg3),
4127
  A0 a0) {
4128
  return new MethodCallback1_4<Class,
×
4129
                               SingleUseCallback4<ReturnType, Arg0, Arg1, Arg2, Arg3>,  // NOLINT(whitespace/line_length)
4130
                               ReturnType,
4131
                               A0,
4132
                               Arg0,
4133
                               Arg1,
4134
                               Arg2,
4135
                               Arg3>(
4136
      object,
4137
      method,
4138
      a0);
×
4139
}
4140

4141

4142
/**
4143
 * @brief A helper function to create a new Callback with 1
4144
 * create-time arguments and 4 execution time arguments.
4145
 * @tparam Class the class with the member function.
4146
 * @tparam ReturnType the return type of the callback.
4147
 * @tparam A0 a create-time argument type.
4148
 * @tparam Arg0 an exec-time argument type.
4149
 * @tparam Arg1 an exec-time argument type.
4150
 * @tparam Arg2 an exec-time argument type.
4151
 * @tparam Arg3 an exec-time argument type.
4152
 * @param object the object to call the member function on.
4153
 * @param method the member function pointer to use when executing the callback.
4154
 * @param a0 a create-time argument.
4155
 * @returns The same return value as the member function.
4156
 */
4157
template <typename Class, typename ReturnType, typename A0, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4158
inline Callback4<ReturnType, Arg0, Arg1, Arg2, Arg3>* NewCallback(
4159
  Class* object,
4160
  ReturnType (Class::*method)(A0, Arg0, Arg1, Arg2, Arg3),
4161
  A0 a0) {
4162
  return new MethodCallback1_4<Class,
4163
                               Callback4<ReturnType, Arg0, Arg1, Arg2, Arg3>,
4164
                               ReturnType,
4165
                               A0,
4166
                               Arg0,
4167
                               Arg1,
4168
                               Arg2,
4169
                               Arg3>(
4170
      object,
4171
      method,
4172
      a0);
4173
}
4174

4175

4176
/**
4177
 * @brief A Function callback with 2 create-time args and 4 exec time args
4178
 */
4179
template <typename Parent, typename ReturnType, typename A0, typename A1, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4180
class FunctionCallback2_4: public Parent {
4181
 public:
4182
  typedef ReturnType (*Function)(A0, A1, Arg0, Arg1, Arg2, Arg3);
4183
  FunctionCallback2_4(Function callback, A0 a0, A1 a1):
4184
    Parent(),
4185
    m_callback(callback),
4186
    m_a0(a0),
4187
    m_a1(a1) {}
4188
  ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2, Arg3 arg3) {
4189
    return m_callback(m_a0, m_a1, arg0, arg1, arg2, arg3);
4190
  }
4191
 private:
4192
  Function m_callback;
4193
  A0 m_a0;
4194
  A1 m_a1;
4195
};
4196

4197

4198
/**
4199
 * @brief A helper function to create a new SingleUseCallback with 2
4200
 * create-time arguments and 4 execution time arguments.
4201
 * @tparam ReturnType the return type of the callback.
4202
 * @tparam A0 a create-time argument type.
4203
 * @tparam A1 a create-time argument type.
4204
 * @tparam Arg0 an exec-time argument type.
4205
 * @tparam Arg1 an exec-time argument type.
4206
 * @tparam Arg2 an exec-time argument type.
4207
 * @tparam Arg3 an exec-time argument type.
4208
 * @param callback the function pointer to use when executing the callback.
4209
 * @param a0 a create-time argument.
4210
 * @param a1 a create-time argument.
4211
 * @returns The same return value as the function.
4212
 */
4213
template <typename ReturnType, typename A0, typename A1, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4214
inline SingleUseCallback4<ReturnType, Arg0, Arg1, Arg2, Arg3>* NewSingleCallback(  // NOLINT(whitespace/line_length)
4215
  ReturnType (*callback)(A0, A1, Arg0, Arg1, Arg2, Arg3),
4216
  A0 a0,
4217
  A1 a1) {
4218
  return new FunctionCallback2_4<
4219
                                 SingleUseCallback4<ReturnType, Arg0, Arg1, Arg2, Arg3>,  // NOLINT(whitespace/line_length)
4220
                                 ReturnType,
4221
                                 A0,
4222
                                 A1,
4223
                                 Arg0,
4224
                                 Arg1,
4225
                                 Arg2,
4226
                                 Arg3>(
4227
      callback,
4228
      a0,
4229
      a1);
4230
}
4231

4232

4233
/**
4234
 * @brief A helper function to create a new Callback with 2
4235
 * create-time arguments and 4 execution time arguments.
4236
 * @tparam ReturnType the return type of the callback.
4237
 * @tparam A0 a create-time argument type.
4238
 * @tparam A1 a create-time argument type.
4239
 * @tparam Arg0 an exec-time argument type.
4240
 * @tparam Arg1 an exec-time argument type.
4241
 * @tparam Arg2 an exec-time argument type.
4242
 * @tparam Arg3 an exec-time argument type.
4243
 * @param callback the function pointer to use when executing the callback.
4244
 * @param a0 a create-time argument.
4245
 * @param a1 a create-time argument.
4246
 * @returns The same return value as the function.
4247
 */
4248
template <typename ReturnType, typename A0, typename A1, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4249
inline Callback4<ReturnType, Arg0, Arg1, Arg2, Arg3>* NewCallback(
4250
  ReturnType (*callback)(A0, A1, Arg0, Arg1, Arg2, Arg3),
4251
  A0 a0,
4252
  A1 a1) {
4253
  return new FunctionCallback2_4<
4254
                                 Callback4<ReturnType, Arg0, Arg1, Arg2, Arg3>,
4255
                                 ReturnType,
4256
                                 A0,
4257
                                 A1,
4258
                                 Arg0,
4259
                                 Arg1,
4260
                                 Arg2,
4261
                                 Arg3>(
4262
      callback,
4263
      a0,
4264
      a1);
4265
}
4266

4267

4268
/**
4269
 * @brief A Method callback with 2 create-time args and 4 exec time args
4270
 */
4271
template <typename Class, typename Parent, typename ReturnType, typename A0, typename A1, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4272
class MethodCallback2_4: public Parent {
4273
 public:
4274
  typedef ReturnType (Class::*Method)(A0, A1, Arg0, Arg1, Arg2, Arg3);
4275
  MethodCallback2_4(Class *object, Method callback, A0 a0, A1 a1):
×
4276
    Parent(),
4277
    m_object(object),
×
4278
    m_callback(callback),
×
4279
    m_a0(a0),
×
4280
    m_a1(a1) {}
×
4281
  ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2, Arg3 arg3) {
×
4282
    return (m_object->*m_callback)(m_a0, m_a1, arg0, arg1, arg2, arg3);
×
4283
  }
4284
 private:
4285
  Class *m_object;
4286
  Method m_callback;
4287
  A0 m_a0;
4288
  A1 m_a1;
4289
};
4290

4291

4292
/**
4293
 * @brief A helper function to create a new SingleUseCallback with 2
4294
 * create-time arguments and 4 execution time arguments.
4295
 * @tparam Class the class with the member function.
4296
 * @tparam ReturnType the return type of the callback.
4297
 * @tparam A0 a create-time argument type.
4298
 * @tparam A1 a create-time argument type.
4299
 * @tparam Arg0 an exec-time argument type.
4300
 * @tparam Arg1 an exec-time argument type.
4301
 * @tparam Arg2 an exec-time argument type.
4302
 * @tparam Arg3 an exec-time argument type.
4303
 * @param object the object to call the member function on.
4304
 * @param method the member function pointer to use when executing the callback.
4305
 * @param a0 a create-time argument.
4306
 * @param a1 a create-time argument.
4307
 * @returns The same return value as the member function.
4308
 */
4309
template <typename Class, typename ReturnType, typename A0, typename A1, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4310
inline SingleUseCallback4<ReturnType, Arg0, Arg1, Arg2, Arg3>* NewSingleCallback(  // NOLINT(whitespace/line_length)
×
4311
  Class* object,
4312
  ReturnType (Class::*method)(A0, A1, Arg0, Arg1, Arg2, Arg3),
4313
  A0 a0,
4314
  A1 a1) {
4315
  return new MethodCallback2_4<Class,
×
4316
                               SingleUseCallback4<ReturnType, Arg0, Arg1, Arg2, Arg3>,  // NOLINT(whitespace/line_length)
4317
                               ReturnType,
4318
                               A0,
4319
                               A1,
4320
                               Arg0,
4321
                               Arg1,
4322
                               Arg2,
4323
                               Arg3>(
4324
      object,
4325
      method,
4326
      a0,
4327
      a1);
×
4328
}
4329

4330

4331
/**
4332
 * @brief A helper function to create a new Callback with 2
4333
 * create-time arguments and 4 execution time arguments.
4334
 * @tparam Class the class with the member function.
4335
 * @tparam ReturnType the return type of the callback.
4336
 * @tparam A0 a create-time argument type.
4337
 * @tparam A1 a create-time argument type.
4338
 * @tparam Arg0 an exec-time argument type.
4339
 * @tparam Arg1 an exec-time argument type.
4340
 * @tparam Arg2 an exec-time argument type.
4341
 * @tparam Arg3 an exec-time argument type.
4342
 * @param object the object to call the member function on.
4343
 * @param method the member function pointer to use when executing the callback.
4344
 * @param a0 a create-time argument.
4345
 * @param a1 a create-time argument.
4346
 * @returns The same return value as the member function.
4347
 */
4348
template <typename Class, typename ReturnType, typename A0, typename A1, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4349
inline Callback4<ReturnType, Arg0, Arg1, Arg2, Arg3>* NewCallback(
4350
  Class* object,
4351
  ReturnType (Class::*method)(A0, A1, Arg0, Arg1, Arg2, Arg3),
4352
  A0 a0,
4353
  A1 a1) {
4354
  return new MethodCallback2_4<Class,
4355
                               Callback4<ReturnType, Arg0, Arg1, Arg2, Arg3>,
4356
                               ReturnType,
4357
                               A0,
4358
                               A1,
4359
                               Arg0,
4360
                               Arg1,
4361
                               Arg2,
4362
                               Arg3>(
4363
      object,
4364
      method,
4365
      a0,
4366
      a1);
4367
}
4368

4369

4370
/**
4371
 * @brief A Function callback with 3 create-time args and 4 exec time args
4372
 */
4373
template <typename Parent, typename ReturnType, typename A0, typename A1, typename A2, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4374
class FunctionCallback3_4: public Parent {
4375
 public:
4376
  typedef ReturnType (*Function)(A0, A1, A2, Arg0, Arg1, Arg2, Arg3);
4377
  FunctionCallback3_4(Function callback, A0 a0, A1 a1, A2 a2):
4378
    Parent(),
4379
    m_callback(callback),
4380
    m_a0(a0),
4381
    m_a1(a1),
4382
    m_a2(a2) {}
4383
  ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2, Arg3 arg3) {
4384
    return m_callback(m_a0, m_a1, m_a2, arg0, arg1, arg2, arg3);
4385
  }
4386
 private:
4387
  Function m_callback;
4388
  A0 m_a0;
4389
  A1 m_a1;
4390
  A2 m_a2;
4391
};
4392

4393

4394
/**
4395
 * @brief A helper function to create a new SingleUseCallback with 3
4396
 * create-time arguments and 4 execution time arguments.
4397
 * @tparam ReturnType the return type of the callback.
4398
 * @tparam A0 a create-time argument type.
4399
 * @tparam A1 a create-time argument type.
4400
 * @tparam A2 a create-time argument type.
4401
 * @tparam Arg0 an exec-time argument type.
4402
 * @tparam Arg1 an exec-time argument type.
4403
 * @tparam Arg2 an exec-time argument type.
4404
 * @tparam Arg3 an exec-time argument type.
4405
 * @param callback the function pointer to use when executing the callback.
4406
 * @param a0 a create-time argument.
4407
 * @param a1 a create-time argument.
4408
 * @param a2 a create-time argument.
4409
 * @returns The same return value as the function.
4410
 */
4411
template <typename ReturnType, typename A0, typename A1, typename A2, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4412
inline SingleUseCallback4<ReturnType, Arg0, Arg1, Arg2, Arg3>* NewSingleCallback(  // NOLINT(whitespace/line_length)
4413
  ReturnType (*callback)(A0, A1, A2, Arg0, Arg1, Arg2, Arg3),
4414
  A0 a0,
4415
  A1 a1,
4416
  A2 a2) {
4417
  return new FunctionCallback3_4<
4418
                                 SingleUseCallback4<ReturnType, Arg0, Arg1, Arg2, Arg3>,  // NOLINT(whitespace/line_length)
4419
                                 ReturnType,
4420
                                 A0,
4421
                                 A1,
4422
                                 A2,
4423
                                 Arg0,
4424
                                 Arg1,
4425
                                 Arg2,
4426
                                 Arg3>(
4427
      callback,
4428
      a0,
4429
      a1,
4430
      a2);
4431
}
4432

4433

4434
/**
4435
 * @brief A helper function to create a new Callback with 3
4436
 * create-time arguments and 4 execution time arguments.
4437
 * @tparam ReturnType the return type of the callback.
4438
 * @tparam A0 a create-time argument type.
4439
 * @tparam A1 a create-time argument type.
4440
 * @tparam A2 a create-time argument type.
4441
 * @tparam Arg0 an exec-time argument type.
4442
 * @tparam Arg1 an exec-time argument type.
4443
 * @tparam Arg2 an exec-time argument type.
4444
 * @tparam Arg3 an exec-time argument type.
4445
 * @param callback the function pointer to use when executing the callback.
4446
 * @param a0 a create-time argument.
4447
 * @param a1 a create-time argument.
4448
 * @param a2 a create-time argument.
4449
 * @returns The same return value as the function.
4450
 */
4451
template <typename ReturnType, typename A0, typename A1, typename A2, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4452
inline Callback4<ReturnType, Arg0, Arg1, Arg2, Arg3>* NewCallback(
4453
  ReturnType (*callback)(A0, A1, A2, Arg0, Arg1, Arg2, Arg3),
4454
  A0 a0,
4455
  A1 a1,
4456
  A2 a2) {
4457
  return new FunctionCallback3_4<
4458
                                 Callback4<ReturnType, Arg0, Arg1, Arg2, Arg3>,
4459
                                 ReturnType,
4460
                                 A0,
4461
                                 A1,
4462
                                 A2,
4463
                                 Arg0,
4464
                                 Arg1,
4465
                                 Arg2,
4466
                                 Arg3>(
4467
      callback,
4468
      a0,
4469
      a1,
4470
      a2);
4471
}
4472

4473

4474
/**
4475
 * @brief A Method callback with 3 create-time args and 4 exec time args
4476
 */
4477
template <typename Class, typename Parent, typename ReturnType, typename A0, typename A1, typename A2, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4478
class MethodCallback3_4: public Parent {
4479
 public:
4480
  typedef ReturnType (Class::*Method)(A0, A1, A2, Arg0, Arg1, Arg2, Arg3);
4481
  MethodCallback3_4(Class *object, Method callback, A0 a0, A1 a1, A2 a2):
4482
    Parent(),
4483
    m_object(object),
4484
    m_callback(callback),
4485
    m_a0(a0),
4486
    m_a1(a1),
4487
    m_a2(a2) {}
4488
  ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2, Arg3 arg3) {
4489
    return (m_object->*m_callback)(m_a0, m_a1, m_a2, arg0, arg1, arg2, arg3);
4490
  }
4491
 private:
4492
  Class *m_object;
4493
  Method m_callback;
4494
  A0 m_a0;
4495
  A1 m_a1;
4496
  A2 m_a2;
4497
};
4498

4499

4500
/**
4501
 * @brief A helper function to create a new SingleUseCallback with 3
4502
 * create-time arguments and 4 execution time arguments.
4503
 * @tparam Class the class with the member function.
4504
 * @tparam ReturnType the return type of the callback.
4505
 * @tparam A0 a create-time argument type.
4506
 * @tparam A1 a create-time argument type.
4507
 * @tparam A2 a create-time argument type.
4508
 * @tparam Arg0 an exec-time argument type.
4509
 * @tparam Arg1 an exec-time argument type.
4510
 * @tparam Arg2 an exec-time argument type.
4511
 * @tparam Arg3 an exec-time argument type.
4512
 * @param object the object to call the member function on.
4513
 * @param method the member function pointer to use when executing the callback.
4514
 * @param a0 a create-time argument.
4515
 * @param a1 a create-time argument.
4516
 * @param a2 a create-time argument.
4517
 * @returns The same return value as the member function.
4518
 */
4519
template <typename Class, typename ReturnType, typename A0, typename A1, typename A2, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4520
inline SingleUseCallback4<ReturnType, Arg0, Arg1, Arg2, Arg3>* NewSingleCallback(  // NOLINT(whitespace/line_length)
4521
  Class* object,
4522
  ReturnType (Class::*method)(A0, A1, A2, Arg0, Arg1, Arg2, Arg3),
4523
  A0 a0,
4524
  A1 a1,
4525
  A2 a2) {
4526
  return new MethodCallback3_4<Class,
4527
                               SingleUseCallback4<ReturnType, Arg0, Arg1, Arg2, Arg3>,  // NOLINT(whitespace/line_length)
4528
                               ReturnType,
4529
                               A0,
4530
                               A1,
4531
                               A2,
4532
                               Arg0,
4533
                               Arg1,
4534
                               Arg2,
4535
                               Arg3>(
4536
      object,
4537
      method,
4538
      a0,
4539
      a1,
4540
      a2);
4541
}
4542

4543

4544
/**
4545
 * @brief A helper function to create a new Callback with 3
4546
 * create-time arguments and 4 execution time arguments.
4547
 * @tparam Class the class with the member function.
4548
 * @tparam ReturnType the return type of the callback.
4549
 * @tparam A0 a create-time argument type.
4550
 * @tparam A1 a create-time argument type.
4551
 * @tparam A2 a create-time argument type.
4552
 * @tparam Arg0 an exec-time argument type.
4553
 * @tparam Arg1 an exec-time argument type.
4554
 * @tparam Arg2 an exec-time argument type.
4555
 * @tparam Arg3 an exec-time argument type.
4556
 * @param object the object to call the member function on.
4557
 * @param method the member function pointer to use when executing the callback.
4558
 * @param a0 a create-time argument.
4559
 * @param a1 a create-time argument.
4560
 * @param a2 a create-time argument.
4561
 * @returns The same return value as the member function.
4562
 */
4563
template <typename Class, typename ReturnType, typename A0, typename A1, typename A2, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4564
inline Callback4<ReturnType, Arg0, Arg1, Arg2, Arg3>* NewCallback(
4565
  Class* object,
4566
  ReturnType (Class::*method)(A0, A1, A2, Arg0, Arg1, Arg2, Arg3),
4567
  A0 a0,
4568
  A1 a1,
4569
  A2 a2) {
4570
  return new MethodCallback3_4<Class,
4571
                               Callback4<ReturnType, Arg0, Arg1, Arg2, Arg3>,
4572
                               ReturnType,
4573
                               A0,
4574
                               A1,
4575
                               A2,
4576
                               Arg0,
4577
                               Arg1,
4578
                               Arg2,
4579
                               Arg3>(
4580
      object,
4581
      method,
4582
      a0,
4583
      a1,
4584
      a2);
4585
}
4586

4587

4588
/**
4589
 * @brief A Function callback with 4 create-time args and 4 exec time args
4590
 */
4591
template <typename Parent, typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4592
class FunctionCallback4_4: public Parent {
4593
 public:
4594
  typedef ReturnType (*Function)(A0, A1, A2, A3, Arg0, Arg1, Arg2, Arg3);
4595
  FunctionCallback4_4(Function callback, A0 a0, A1 a1, A2 a2, A3 a3):
4596
    Parent(),
4597
    m_callback(callback),
4598
    m_a0(a0),
4599
    m_a1(a1),
4600
    m_a2(a2),
4601
    m_a3(a3) {}
4602
  ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2, Arg3 arg3) {
4603
    return m_callback(m_a0, m_a1, m_a2, m_a3, arg0, arg1, arg2, arg3);
4604
  }
4605
 private:
4606
  Function m_callback;
4607
  A0 m_a0;
4608
  A1 m_a1;
4609
  A2 m_a2;
4610
  A3 m_a3;
4611
};
4612

4613

4614
/**
4615
 * @brief A helper function to create a new SingleUseCallback with 4
4616
 * create-time arguments and 4 execution time arguments.
4617
 * @tparam ReturnType the return type of the callback.
4618
 * @tparam A0 a create-time argument type.
4619
 * @tparam A1 a create-time argument type.
4620
 * @tparam A2 a create-time argument type.
4621
 * @tparam A3 a create-time argument type.
4622
 * @tparam Arg0 an exec-time argument type.
4623
 * @tparam Arg1 an exec-time argument type.
4624
 * @tparam Arg2 an exec-time argument type.
4625
 * @tparam Arg3 an exec-time argument type.
4626
 * @param callback the function pointer to use when executing the callback.
4627
 * @param a0 a create-time argument.
4628
 * @param a1 a create-time argument.
4629
 * @param a2 a create-time argument.
4630
 * @param a3 a create-time argument.
4631
 * @returns The same return value as the function.
4632
 */
4633
template <typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4634
inline SingleUseCallback4<ReturnType, Arg0, Arg1, Arg2, Arg3>* NewSingleCallback(  // NOLINT(whitespace/line_length)
4635
  ReturnType (*callback)(A0, A1, A2, A3, Arg0, Arg1, Arg2, Arg3),
4636
  A0 a0,
4637
  A1 a1,
4638
  A2 a2,
4639
  A3 a3) {
4640
  return new FunctionCallback4_4<
4641
                                 SingleUseCallback4<ReturnType, Arg0, Arg1, Arg2, Arg3>,  // NOLINT(whitespace/line_length)
4642
                                 ReturnType,
4643
                                 A0,
4644
                                 A1,
4645
                                 A2,
4646
                                 A3,
4647
                                 Arg0,
4648
                                 Arg1,
4649
                                 Arg2,
4650
                                 Arg3>(
4651
      callback,
4652
      a0,
4653
      a1,
4654
      a2,
4655
      a3);
4656
}
4657

4658

4659
/**
4660
 * @brief A helper function to create a new Callback with 4
4661
 * create-time arguments and 4 execution time arguments.
4662
 * @tparam ReturnType the return type of the callback.
4663
 * @tparam A0 a create-time argument type.
4664
 * @tparam A1 a create-time argument type.
4665
 * @tparam A2 a create-time argument type.
4666
 * @tparam A3 a create-time argument type.
4667
 * @tparam Arg0 an exec-time argument type.
4668
 * @tparam Arg1 an exec-time argument type.
4669
 * @tparam Arg2 an exec-time argument type.
4670
 * @tparam Arg3 an exec-time argument type.
4671
 * @param callback the function pointer to use when executing the callback.
4672
 * @param a0 a create-time argument.
4673
 * @param a1 a create-time argument.
4674
 * @param a2 a create-time argument.
4675
 * @param a3 a create-time argument.
4676
 * @returns The same return value as the function.
4677
 */
4678
template <typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4679
inline Callback4<ReturnType, Arg0, Arg1, Arg2, Arg3>* NewCallback(
4680
  ReturnType (*callback)(A0, A1, A2, A3, Arg0, Arg1, Arg2, Arg3),
4681
  A0 a0,
4682
  A1 a1,
4683
  A2 a2,
4684
  A3 a3) {
4685
  return new FunctionCallback4_4<
4686
                                 Callback4<ReturnType, Arg0, Arg1, Arg2, Arg3>,
4687
                                 ReturnType,
4688
                                 A0,
4689
                                 A1,
4690
                                 A2,
4691
                                 A3,
4692
                                 Arg0,
4693
                                 Arg1,
4694
                                 Arg2,
4695
                                 Arg3>(
4696
      callback,
4697
      a0,
4698
      a1,
4699
      a2,
4700
      a3);
4701
}
4702

4703

4704
/**
4705
 * @brief A Method callback with 4 create-time args and 4 exec time args
4706
 */
4707
template <typename Class, typename Parent, typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4708
class MethodCallback4_4: public Parent {
4709
 public:
4710
  typedef ReturnType (Class::*Method)(A0, A1, A2, A3, Arg0, Arg1, Arg2, Arg3);
4711
  MethodCallback4_4(Class *object, Method callback, A0 a0, A1 a1, A2 a2, A3 a3):
4712
    Parent(),
4713
    m_object(object),
4714
    m_callback(callback),
4715
    m_a0(a0),
4716
    m_a1(a1),
4717
    m_a2(a2),
4718
    m_a3(a3) {}
4719
  ReturnType DoRun(Arg0 arg0, Arg1 arg1, Arg2 arg2, Arg3 arg3) {
4720
    return (m_object->*m_callback)(m_a0, m_a1, m_a2, m_a3, arg0, arg1, arg2, arg3);  // NOLINT(whitespace/line_length)
4721
  }
4722
 private:
4723
  Class *m_object;
4724
  Method m_callback;
4725
  A0 m_a0;
4726
  A1 m_a1;
4727
  A2 m_a2;
4728
  A3 m_a3;
4729
};
4730

4731

4732
/**
4733
 * @brief A helper function to create a new SingleUseCallback with 4
4734
 * create-time arguments and 4 execution time arguments.
4735
 * @tparam Class the class with the member function.
4736
 * @tparam ReturnType the return type of the callback.
4737
 * @tparam A0 a create-time argument type.
4738
 * @tparam A1 a create-time argument type.
4739
 * @tparam A2 a create-time argument type.
4740
 * @tparam A3 a create-time argument type.
4741
 * @tparam Arg0 an exec-time argument type.
4742
 * @tparam Arg1 an exec-time argument type.
4743
 * @tparam Arg2 an exec-time argument type.
4744
 * @tparam Arg3 an exec-time argument type.
4745
 * @param object the object to call the member function on.
4746
 * @param method the member function pointer to use when executing the callback.
4747
 * @param a0 a create-time argument.
4748
 * @param a1 a create-time argument.
4749
 * @param a2 a create-time argument.
4750
 * @param a3 a create-time argument.
4751
 * @returns The same return value as the member function.
4752
 */
4753
template <typename Class, typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4754
inline SingleUseCallback4<ReturnType, Arg0, Arg1, Arg2, Arg3>* NewSingleCallback(  // NOLINT(whitespace/line_length)
4755
  Class* object,
4756
  ReturnType (Class::*method)(A0, A1, A2, A3, Arg0, Arg1, Arg2, Arg3),
4757
  A0 a0,
4758
  A1 a1,
4759
  A2 a2,
4760
  A3 a3) {
4761
  return new MethodCallback4_4<Class,
4762
                               SingleUseCallback4<ReturnType, Arg0, Arg1, Arg2, Arg3>,  // NOLINT(whitespace/line_length)
4763
                               ReturnType,
4764
                               A0,
4765
                               A1,
4766
                               A2,
4767
                               A3,
4768
                               Arg0,
4769
                               Arg1,
4770
                               Arg2,
4771
                               Arg3>(
4772
      object,
4773
      method,
4774
      a0,
4775
      a1,
4776
      a2,
4777
      a3);
4778
}
4779

4780

4781
/**
4782
 * @brief A helper function to create a new Callback with 4
4783
 * create-time arguments and 4 execution time arguments.
4784
 * @tparam Class the class with the member function.
4785
 * @tparam ReturnType the return type of the callback.
4786
 * @tparam A0 a create-time argument type.
4787
 * @tparam A1 a create-time argument type.
4788
 * @tparam A2 a create-time argument type.
4789
 * @tparam A3 a create-time argument type.
4790
 * @tparam Arg0 an exec-time argument type.
4791
 * @tparam Arg1 an exec-time argument type.
4792
 * @tparam Arg2 an exec-time argument type.
4793
 * @tparam Arg3 an exec-time argument type.
4794
 * @param object the object to call the member function on.
4795
 * @param method the member function pointer to use when executing the callback.
4796
 * @param a0 a create-time argument.
4797
 * @param a1 a create-time argument.
4798
 * @param a2 a create-time argument.
4799
 * @param a3 a create-time argument.
4800
 * @returns The same return value as the member function.
4801
 */
4802
template <typename Class, typename ReturnType, typename A0, typename A1, typename A2, typename A3, typename Arg0, typename Arg1, typename Arg2, typename Arg3>  // NOLINT(whitespace/line_length)
4803
inline Callback4<ReturnType, Arg0, Arg1, Arg2, Arg3>* NewCallback(
4804
  Class* object,
4805
  ReturnType (Class::*method)(A0, A1, A2, A3, Arg0, Arg1, Arg2, Arg3),
4806
  A0 a0,
4807
  A1 a1,
4808
  A2 a2,
4809
  A3 a3) {
4810
  return new MethodCallback4_4<Class,
4811
                               Callback4<ReturnType, Arg0, Arg1, Arg2, Arg3>,
4812
                               ReturnType,
4813
                               A0,
4814
                               A1,
4815
                               A2,
4816
                               A3,
4817
                               Arg0,
4818
                               Arg1,
4819
                               Arg2,
4820
                               Arg3>(
4821
      object,
4822
      method,
4823
      a0,
4824
      a1,
4825
      a2,
4826
      a3);
4827
}
4828

4829

4830
/**
4831
 * @}
4832
 */
4833
}  // namespace ola
4834
#endif  // INCLUDE_OLA_CALLBACK_H_
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc