21#include "events/EventQueue.h"
22#include "usb/internal/TaskBase.h"
23#include "platform/mbed_assert.h"
24#include "platform/Callback.h"
32template<
typename F,
typename ARG1 =
void,
typename ARG2 =
void,
typename ARG3 =
void,
typename ARG4 =
void,
typename ARG5 =
void>
40 AllArgs(B0 b0 = B0()): b0(b0) {}
42 template <
typename T,
typename _>
44 static void copy(
void *_dest,
void *_src)
49 static void call(
void *data)
57 typedef Operations<B0, void> ops;
60template<
typename B0,
typename B1>
66 AllArgs(B0 b0 = B0(), B1 b1 = B1()): b0(b0), b1(b1) {}
68 template <
typename T,
typename _>
70 static void copy(
void *_dest,
void *_src)
75 static void call(
void *data)
83 template <
typename T,
typename R,
typename U>
84 struct Operations<T *, R(U::*)()> {
85 static void copy(
void *_dest,
void *_src)
90 static void call(
void *data)
93 ((s->b0)->*(s->b1))();
98 template <
typename T,
typename R,
typename U>
99 struct Operations<T, R(U::*)() const> {
100 static void copy(
void *_dest,
void *_src)
105 static void call(
void *data)
107 Self *s =
static_cast<Self *
>(data);
108 ((s->b0)->*(s->b1))();
113 template <
typename T,
typename R,
typename U>
114 struct Operations<T, R(U::*)() volatile> {
115 static void copy(
void *_dest,
void *_src)
120 static void call(
void *data)
122 Self *s =
static_cast<Self *
>(data);
123 ((s->b0)->*(s->b1))();
128 template <
typename T,
typename R,
typename U>
129 struct Operations<T, R(U::*)() const volatile> {
130 static void copy(
void *_dest,
void *_src)
135 static void call(
void *data)
137 Self *s =
static_cast<Self *
>(data);
138 ((s->b0)->*(s->b1))();
143 typedef Operations<B0, B1> ops;
146template<
typename B0,
typename B1,
typename B2>
154 AllArgs(B0 b0 = B0(), B1 b1 = B1(), B2 b2 = B2()): b0(b0), b1(b1), b2(b2) {}
156 template <
typename T,
typename _>
158 static void copy(
void *_dest,
void *_src)
163 static void call(
void *data)
165 Self *s =
static_cast<Self *
>(data);
171 template <
typename T,
typename R,
typename U>
172 struct Operations<T *, R(U::*)(B2)> {
173 static void copy(
void *_dest,
void *_src)
178 static void call(
void *data)
180 Self *s =
static_cast<Self *
>(data);
181 ((s->b0)->*(s->b1))(s->b2);
186 template <
typename T,
typename R,
typename U>
187 struct Operations<T, R(U::*)(B2) const> {
188 static void copy(
void *_dest,
void *_src)
193 static void call(
void *data)
195 Self *s =
static_cast<Self *
>(data);
196 ((s->b0)->*(s->b1))(s->b2);
201 template <
typename T,
typename R,
typename U>
202 struct Operations<T, R(U::*)(B2) volatile> {
203 static void copy(
void *_dest,
void *_src)
208 static void call(
void *data)
210 Self *s =
static_cast<Self *
>(data);
211 ((s->b0)->*(s->b1))(s->b2);
216 template <
typename T,
typename R,
typename U>
217 struct Operations<T, R(U::*)(B2) const volatile> {
218 static void copy(
void *_dest,
void *_src)
223 static void call(
void *data)
225 Self *s =
static_cast<Self *
>(data);
226 ((s->b0)->*(s->b1))(s->b2);
231 typedef Operations<B0, B1> ops;
234template<
typename B0,
typename B1,
typename B2,
typename B3>
243 AllArgs(B0 b0 = B0(), B1 b1 = B1(), B2 b2 = B2(), B3 b3 = B3()): b0(b0), b1(b1), b2(b2), b3(b3) {}
245 template <
typename T,
typename _>
247 static void copy(
void *_dest,
void *_src)
252 static void call(
void *data)
254 Self *s =
static_cast<Self *
>(data);
255 s->b0(s->b1, s->b2, s->b3);
260 template <
typename T,
typename R,
typename U>
261 struct Operations<T *, R(U::*)(B2, B3)> {
262 static void copy(
void *_dest,
void *_src)
267 static void call(
void *data)
269 Self *s =
static_cast<Self *
>(data);
270 ((s->b0)->*(s->b1))(s->b2, s->b3);
275 template <
typename T,
typename R,
typename U>
276 struct Operations<T, R(U::*)(B2, B3) const> {
277 static void copy(
void *_dest,
void *_src)
282 static void call(
void *data)
284 Self *s =
static_cast<Self *
>(data);
285 ((s->b0)->*(s->b1))(s->b2, s->b3);
290 template <
typename T,
typename R,
typename U>
291 struct Operations<T, R(U::*)(B2, B3) volatile> {
292 static void copy(
void *_dest,
void *_src)
297 static void call(
void *data)
299 Self *s =
static_cast<Self *
>(data);
300 ((s->b0)->*(s->b1))(s->b2, s->b3);
305 template <
typename T,
typename R,
typename U>
306 struct Operations<T, R(U::*)(B2, B3) const volatile> {
307 static void copy(
void *_dest,
void *_src)
312 static void call(
void *data)
314 Self *s =
static_cast<Self *
>(data);
315 ((s->b0)->*(s->b1))(s->b2, s->b3);
320 typedef Operations<B0, B1> ops;
323template<
typename B0,
typename B1,
typename B2,
typename B3,
typename B4>
333 AllArgs(B0 b0 = B0(), B1 b1 = B1(), B2 b2 = B2(), B3 b3 = B3(), B4 b4 = B4()): b0(b0), b1(b1), b2(b2), b3(b3), b4(b4) {}
335 template <
typename T,
typename _>
337 static void copy(
void *_dest,
void *_src)
342 static void call(
void *data)
344 Self *s =
static_cast<Self *
>(data);
345 s->b0(s->b1, s->b2, s->b3, s->b4);
350 template <
typename T,
typename R,
typename U>
351 struct Operations<T *, R(U::*)(B2, B3, B4)> {
352 static void copy(
void *_dest,
void *_src)
357 static void call(
void *data)
359 Self *s =
static_cast<Self *
>(data);
360 ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4);
365 template <
typename T,
typename R,
typename U>
366 struct Operations<T, R(U::*)(B2, B3, B4) const> {
367 static void copy(
void *_dest,
void *_src)
372 static void call(
void *data)
374 Self *s =
static_cast<Self *
>(data);
375 ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4);
380 template <
typename T,
typename R,
typename U>
381 struct Operations<T, R(U::*)(B2, B3, B4) volatile> {
382 static void copy(
void *_dest,
void *_src)
387 static void call(
void *data)
389 Self *s =
static_cast<Self *
>(data);
390 ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4);
395 template <
typename T,
typename R,
typename U>
396 struct Operations<T, R(U::*)(B2, B3, B4) const volatile> {
397 static void copy(
void *_dest,
void *_src)
402 static void call(
void *data)
404 Self *s =
static_cast<Self *
>(data);
405 ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4);
410 typedef Operations<B0, B1> ops;
413template<
typename B0,
typename B1,
typename B2,
typename B3,
typename B4,
typename B5>
424 AllArgs(B0 b0 = B0(), B1 b1 = B1(), B2 b2 = B2(), B3 b3 = B3(), B4 b4 = B4(), B5 b5 = B5()): b0(b0), b1(b1), b2(b2), b3(b3), b4(b4), b5(b5) {}
426 template <
typename T,
typename _>
428 static void copy(
void *_dest,
void *_src)
433 static void call(
void *data)
435 Self *s =
static_cast<Self *
>(data);
436 s->b0(s->b1, s->b2, s->b3, s->b4, s->b5);
441 template <
typename T,
typename R,
typename U>
443 static void copy(
void *_dest,
void *_src)
448 static void call(
void *data)
450 Self *s =
static_cast<Self *
>(data);
451 ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4, s->b5);
456 template <
typename T,
typename R,
typename U>
458 static void copy(
void *_dest,
void *_src)
463 static void call(
void *data)
465 Self *s =
static_cast<Self *
>(data);
466 ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4, s->b5);
471 template <
typename T,
typename R,
typename U>
473 static void copy(
void *_dest,
void *_src)
478 static void call(
void *data)
480 Self *s =
static_cast<Self *
>(data);
481 ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4, s->b5);
486 template <
typename T,
typename R,
typename U>
487 struct Operations<T, R(U::*)(B2, B3, B4, B5) const volatile> {
488 static void copy(
void *_dest,
void *_src)
493 static void call(
void *data)
495 Self *s =
static_cast<Self *
>(data);
496 ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4, s->b5);
532 return sizeof(_args);
535 virtual run_callback_t
start(
void *data, uint32_t max_size)
537 All::ops::copy(data, (
void *)&_args);
538 return &All::ops::call;
546template <
typename R,
typename ARG0>
571 return sizeof(_args);
574 virtual run_callback_t
start(
void *data, uint32_t max_size)
576 All::ops::copy(data, (
void *)&_args);
577 return &All::ops::call;
589template <
typename R,
typename ARG0,
typename ARG1>
626 void call(ARG0 arg0, ARG1 arg1)
637 return sizeof(_args);
640 virtual run_callback_t
start(
void *data, uint32_t max_size)
642 All::ops::copy(data, (
void *)&_args);
643 return &All::ops::call;
virtual uint32_t size()
Size of buffer required for TaskBase::start.
virtual run_callback_t start(void *data, uint32_t max_size)
Copy any callback data and return a callback to run.
void call(ARG0 arg0, ARG1 arg1)
Post this task for execution.
virtual uint32_t size()
Size of buffer required for TaskBase::start.
virtual run_callback_t start(void *data, uint32_t max_size)
Copy any callback data and return a callback to run.
Task & operator=(mbed::Callback< R(ARG0, ARG1)> cb)
Set the callback of this task.
Task(TaskQueue *q=NULL, mbed::Callback< R(ARG0, ARG1)> cb=mbed::Callback< R(ARG0, ARG1)>())
Construct a new task.
virtual uint32_t size()
Size of buffer required for TaskBase::start.
virtual run_callback_t start(void *data, uint32_t max_size)
Copy any callback data and return a callback to run.
Callback class based on template specialization.