Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-dev by
Diff: platform/Callback.h
- Revision:
- 167:e84263d55307
- Parent:
- 160:d5399cc887bb
--- a/platform/Callback.h Thu Jun 08 15:02:37 2017 +0100 +++ b/platform/Callback.h Wed Jun 21 17:46:44 2017 +0100 @@ -24,12 +24,12 @@ namespace mbed { /** \addtogroup platform */ -/** @{*/ /** Callback class based on template specialization * - * @Note Synchronization level: Not protected + * @note Synchronization level: Not protected + * @ingroup platform */ template <typename F> class Callback; @@ -58,9 +58,16 @@ }; } +#define MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, M) \ + typename detail::enable_if< \ + detail::is_type<M, &F::operator()>::value && \ + sizeof(F) <= sizeof(uintptr_t) \ + >::type = detail::nil() + /** Callback class based on template specialization * - * @Note Synchronization level: Not protected + * @note Synchronization level: Not protected + * @ingroup platform */ template <typename R> class Callback<R()> { @@ -159,50 +166,38 @@ } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(F f, typename detail::enable_if< - detail::is_type<R (F::*)(), &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)())) { generate(f); } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const F f, typename detail::enable_if< - detail::is_type<R (F::*)() const, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)() const)) { generate(f); } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)() volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)() volatile)) { generate(f); } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)() const volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)() const volatile)) { generate(f); } @@ -403,7 +398,7 @@ } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -411,16 +406,13 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(F f, typename detail::enable_if< - detail::is_type<R (F::*)(), &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)())) { this->~Callback(); new (this) Callback(f); } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -428,16 +420,13 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(const F f, typename detail::enable_if< - detail::is_type<R (F::*)() const, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)() const)) { this->~Callback(); new (this) Callback(f); } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -445,16 +434,13 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)() volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)() volatile)) { this->~Callback(); new (this) Callback(f); } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -462,10 +448,7 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(const volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)() const volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)() const volatile)) { this->~Callback(); new (this) Callback(f); } @@ -570,6 +553,8 @@ /** Static thunk for passing as C-style function * @param func Callback to call passed as void pointer + * @return the value as determined by func which is of + * type and determined by the signiture of func */ static R thunk(void *func) { return static_cast<Callback*>(func)->call(); @@ -655,7 +640,8 @@ /** Callback class based on template specialization * - * @Note Synchronization level: Not protected + * @note Synchronization level: Not protected + * @ingroup platform */ template <typename R, typename A0> class Callback<R(A0)> { @@ -754,50 +740,38 @@ } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0), &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0))) { generate(f); } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0) const, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0) const)) { generate(f); } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0) volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0) volatile)) { generate(f); } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0) const volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0) const volatile)) { generate(f); } @@ -998,7 +972,7 @@ } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -1006,16 +980,13 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0), &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0))) { this->~Callback(); new (this) Callback(f); } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -1023,16 +994,13 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(const F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0) const, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0) const)) { this->~Callback(); new (this) Callback(f); } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -1040,16 +1008,13 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0) volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0) volatile)) { this->~Callback(); new (this) Callback(f); } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -1057,10 +1022,7 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(const volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0) const volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0) const volatile)) { this->~Callback(); new (this) Callback(f); } @@ -1165,6 +1127,9 @@ /** Static thunk for passing as C-style function * @param func Callback to call passed as void pointer + * @param a0 An argument to be called with function func + * @return the value as determined by func which is of + * type and determined by the signiture of func */ static R thunk(void *func, A0 a0) { return static_cast<Callback*>(func)->call(a0); @@ -1250,7 +1215,8 @@ /** Callback class based on template specialization * - * @Note Synchronization level: Not protected + * @note Synchronization level: Not protected + * @ingroup platform */ template <typename R, typename A0, typename A1> class Callback<R(A0, A1)> { @@ -1349,50 +1315,38 @@ } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1), &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1))) { generate(f); } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1) const, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1) const)) { generate(f); } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1) volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1) volatile)) { generate(f); } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1) const volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1) const volatile)) { generate(f); } @@ -1593,7 +1547,7 @@ } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -1601,16 +1555,13 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1), &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1))) { this->~Callback(); new (this) Callback(f); } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -1618,16 +1569,13 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(const F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1) const, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1) const)) { this->~Callback(); new (this) Callback(f); } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -1635,16 +1583,13 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1) volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1) volatile)) { this->~Callback(); new (this) Callback(f); } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -1652,10 +1597,7 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(const volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1) const volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1) const volatile)) { this->~Callback(); new (this) Callback(f); } @@ -1760,6 +1702,10 @@ /** Static thunk for passing as C-style function * @param func Callback to call passed as void pointer + * @param a0 An argument to be called with function func + * @param a1 An argument to be called with function func + * @return the value as determined by func which is of + * type and determined by the signiture of func */ static R thunk(void *func, A0 a0, A1 a1) { return static_cast<Callback*>(func)->call(a0, a1); @@ -1845,7 +1791,8 @@ /** Callback class based on template specialization * - * @Note Synchronization level: Not protected + * @note Synchronization level: Not protected + * @ingroup platform */ template <typename R, typename A0, typename A1, typename A2> class Callback<R(A0, A1, A2)> { @@ -1944,50 +1891,38 @@ } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2), &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2))) { generate(f); } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2) const, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2) const)) { generate(f); } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2) volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2) volatile)) { generate(f); } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2) const volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2) const volatile)) { generate(f); } @@ -2188,7 +2123,7 @@ } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -2196,16 +2131,13 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2), &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2))) { this->~Callback(); new (this) Callback(f); } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -2213,16 +2145,13 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(const F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2) const, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2) const)) { this->~Callback(); new (this) Callback(f); } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -2230,16 +2159,13 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2) volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2) volatile)) { this->~Callback(); new (this) Callback(f); } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -2247,10 +2173,7 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(const volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2) const volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2) const volatile)) { this->~Callback(); new (this) Callback(f); } @@ -2355,6 +2278,11 @@ /** Static thunk for passing as C-style function * @param func Callback to call passed as void pointer + * @param a0 An argument to be called with function func + * @param a1 An argument to be called with function func + * @param a2 An argument to be called with function func + * @return the value as determined by func which is of + * type and determined by the signiture of func */ static R thunk(void *func, A0 a0, A1 a1, A2 a2) { return static_cast<Callback*>(func)->call(a0, a1, a2); @@ -2440,7 +2368,8 @@ /** Callback class based on template specialization * - * @Note Synchronization level: Not protected + * @note Synchronization level: Not protected + * @ingroup platform */ template <typename R, typename A0, typename A1, typename A2, typename A3> class Callback<R(A0, A1, A2, A3)> { @@ -2539,50 +2468,38 @@ } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2, A3), &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3))) { generate(f); } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2, A3) const, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3) const)) { generate(f); } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2, A3) volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3) volatile)) { generate(f); } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2, A3) const volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3) const volatile)) { generate(f); } @@ -2783,7 +2700,7 @@ } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -2791,16 +2708,13 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2, A3), &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3))) { this->~Callback(); new (this) Callback(f); } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -2808,16 +2722,13 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(const F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2, A3) const, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3) const)) { this->~Callback(); new (this) Callback(f); } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -2825,16 +2736,13 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2, A3) volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3) volatile)) { this->~Callback(); new (this) Callback(f); } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -2842,10 +2750,7 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(const volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2, A3) const volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3) const volatile)) { this->~Callback(); new (this) Callback(f); } @@ -2950,6 +2855,12 @@ /** Static thunk for passing as C-style function * @param func Callback to call passed as void pointer + * @param a0 An argument to be called with function func + * @param a1 An argument to be called with function func + * @param a2 An argument to be called with function func + * @param a3 An argument to be called with function func + * @return the value as determined by func which is of + * type and determined by the signiture of func */ static R thunk(void *func, A0 a0, A1 a1, A2 a2, A3 a3) { return static_cast<Callback*>(func)->call(a0, a1, a2, a3); @@ -3035,7 +2946,8 @@ /** Callback class based on template specialization * - * @Note Synchronization level: Not protected + * @note Synchronization level: Not protected + * @ingroup platform */ template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> class Callback<R(A0, A1, A2, A3, A4)> { @@ -3134,50 +3046,38 @@ } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2, A3, A4), &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3, A4))) { generate(f); } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2, A3, A4) const, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3, A4) const)) { generate(f); } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2, A3, A4) volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3, A4) volatile)) { generate(f); } /** Create a Callback with a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage */ template <typename F> - Callback(const volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2, A3, A4) const volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + Callback(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3, A4) const volatile)) { generate(f); } @@ -3378,7 +3278,7 @@ } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -3386,16 +3286,13 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2, A3, A4), &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3, A4))) { this->~Callback(); new (this) Callback(f); } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -3403,16 +3300,13 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(const F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2, A3, A4) const, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(const F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3, A4) const)) { this->~Callback(); new (this) Callback(f); } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -3420,16 +3314,13 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2, A3, A4) volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3, A4) volatile)) { this->~Callback(); new (this) Callback(f); } /** Attach a function object - * @param func Function object to attach + * @param f Function object to attach * @note The function object is limited to a single word of storage * @deprecated * Replaced by simple assignment 'Callback cb = func' @@ -3437,10 +3328,7 @@ template <typename F> MBED_DEPRECATED_SINCE("mbed-os-5.4", "Replaced by simple assignment 'Callback cb = func") - void attach(const volatile F f, typename detail::enable_if< - detail::is_type<R (F::*)(A0, A1, A2, A3, A4) const volatile, &F::operator()>::value && - sizeof(F) <= sizeof(uintptr_t) - >::type = detail::nil()) { + void attach(const volatile F f, MBED_ENABLE_IF_CALLBACK_COMPATIBLE(F, R (F::*)(A0, A1, A2, A3, A4) const volatile)) { this->~Callback(); new (this) Callback(f); } @@ -3545,6 +3433,13 @@ /** Static thunk for passing as C-style function * @param func Callback to call passed as void pointer + * @param a0 An argument to be called with function func + * @param a1 An argument to be called with function func + * @param a2 An argument to be called with function func + * @param a3 An argument to be called with function func + * @param a4 An argument to be called with function func + * @return the value as determined by func which is of + * type and determined by the signiture of func */ static R thunk(void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { return static_cast<Callback*>(func)->call(a0, a1, a2, a3, a4); @@ -4649,6 +4544,3 @@ } // namespace mbed #endif - - -/** @}*/