this hurts
Dependencies: FFT
mbed/platform/Callback.h@0:d6c9b09b4042, 2020-12-02 (annotated)
- Committer:
- annieluo2
- Date:
- Wed Dec 02 18:02:03 2020 +0000
- Revision:
- 0:d6c9b09b4042
boo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
annieluo2 | 0:d6c9b09b4042 | 1 | /* mbed Microcontroller Library |
annieluo2 | 0:d6c9b09b4042 | 2 | * Copyright (c) 2006-2015 ARM Limited |
annieluo2 | 0:d6c9b09b4042 | 3 | * |
annieluo2 | 0:d6c9b09b4042 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
annieluo2 | 0:d6c9b09b4042 | 5 | * you may not use this file except in compliance with the License. |
annieluo2 | 0:d6c9b09b4042 | 6 | * You may obtain a copy of the License at |
annieluo2 | 0:d6c9b09b4042 | 7 | * |
annieluo2 | 0:d6c9b09b4042 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
annieluo2 | 0:d6c9b09b4042 | 9 | * |
annieluo2 | 0:d6c9b09b4042 | 10 | * Unless required by applicable law or agreed to in writing, software |
annieluo2 | 0:d6c9b09b4042 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
annieluo2 | 0:d6c9b09b4042 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
annieluo2 | 0:d6c9b09b4042 | 13 | * See the License for the specific language governing permissions and |
annieluo2 | 0:d6c9b09b4042 | 14 | * limitations under the License. |
annieluo2 | 0:d6c9b09b4042 | 15 | */ |
annieluo2 | 0:d6c9b09b4042 | 16 | #ifndef MBED_CALLBACK_H |
annieluo2 | 0:d6c9b09b4042 | 17 | #define MBED_CALLBACK_H |
annieluo2 | 0:d6c9b09b4042 | 18 | |
annieluo2 | 0:d6c9b09b4042 | 19 | #include <string.h> |
annieluo2 | 0:d6c9b09b4042 | 20 | #include <stdint.h> |
annieluo2 | 0:d6c9b09b4042 | 21 | #include <new> |
annieluo2 | 0:d6c9b09b4042 | 22 | #include "platform/mbed_assert.h" |
annieluo2 | 0:d6c9b09b4042 | 23 | #include "platform/toolchain.h" |
annieluo2 | 0:d6c9b09b4042 | 24 | |
annieluo2 | 0:d6c9b09b4042 | 25 | namespace mbed { |
annieluo2 | 0:d6c9b09b4042 | 26 | /** \addtogroup platform */ |
annieluo2 | 0:d6c9b09b4042 | 27 | /** @{*/ |
annieluo2 | 0:d6c9b09b4042 | 28 | |
annieluo2 | 0:d6c9b09b4042 | 29 | |
annieluo2 | 0:d6c9b09b4042 | 30 | /** Callback class based on template specialization |
annieluo2 | 0:d6c9b09b4042 | 31 | * |
annieluo2 | 0:d6c9b09b4042 | 32 | * @Note Synchronization level: Not protected |
annieluo2 | 0:d6c9b09b4042 | 33 | */ |
annieluo2 | 0:d6c9b09b4042 | 34 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 35 | class Callback; |
annieluo2 | 0:d6c9b09b4042 | 36 | |
annieluo2 | 0:d6c9b09b4042 | 37 | // Internal sfinae declarations |
annieluo2 | 0:d6c9b09b4042 | 38 | // |
annieluo2 | 0:d6c9b09b4042 | 39 | // These are used to eliminate overloads based on type attributes |
annieluo2 | 0:d6c9b09b4042 | 40 | // 1. Does a function object have a call operator |
annieluo2 | 0:d6c9b09b4042 | 41 | // 2. Does a function object fit in the available storage |
annieluo2 | 0:d6c9b09b4042 | 42 | // |
annieluo2 | 0:d6c9b09b4042 | 43 | // These eliminations are handled cleanly by the compiler and avoid |
annieluo2 | 0:d6c9b09b4042 | 44 | // massive and misleading error messages when confronted with an |
annieluo2 | 0:d6c9b09b4042 | 45 | // invalid type (or worse, runtime failures) |
annieluo2 | 0:d6c9b09b4042 | 46 | namespace detail { |
annieluo2 | 0:d6c9b09b4042 | 47 | struct nil {}; |
annieluo2 | 0:d6c9b09b4042 | 48 | |
annieluo2 | 0:d6c9b09b4042 | 49 | template <bool B, typename R = nil> |
annieluo2 | 0:d6c9b09b4042 | 50 | struct enable_if { typedef R type; }; |
annieluo2 | 0:d6c9b09b4042 | 51 | |
annieluo2 | 0:d6c9b09b4042 | 52 | template <typename R> |
annieluo2 | 0:d6c9b09b4042 | 53 | struct enable_if<false, R> {}; |
annieluo2 | 0:d6c9b09b4042 | 54 | |
annieluo2 | 0:d6c9b09b4042 | 55 | template <typename M, M> |
annieluo2 | 0:d6c9b09b4042 | 56 | struct is_type { |
annieluo2 | 0:d6c9b09b4042 | 57 | static const bool value = true; |
annieluo2 | 0:d6c9b09b4042 | 58 | }; |
annieluo2 | 0:d6c9b09b4042 | 59 | } |
annieluo2 | 0:d6c9b09b4042 | 60 | |
annieluo2 | 0:d6c9b09b4042 | 61 | /** Callback class based on template specialization |
annieluo2 | 0:d6c9b09b4042 | 62 | * |
annieluo2 | 0:d6c9b09b4042 | 63 | * @Note Synchronization level: Not protected |
annieluo2 | 0:d6c9b09b4042 | 64 | */ |
annieluo2 | 0:d6c9b09b4042 | 65 | template <typename R> |
annieluo2 | 0:d6c9b09b4042 | 66 | class Callback<R()> { |
annieluo2 | 0:d6c9b09b4042 | 67 | public: |
annieluo2 | 0:d6c9b09b4042 | 68 | /** Create a Callback with a static function |
annieluo2 | 0:d6c9b09b4042 | 69 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 70 | */ |
annieluo2 | 0:d6c9b09b4042 | 71 | Callback(R (*func)() = 0) { |
annieluo2 | 0:d6c9b09b4042 | 72 | if (!func) { |
annieluo2 | 0:d6c9b09b4042 | 73 | _ops = 0; |
annieluo2 | 0:d6c9b09b4042 | 74 | } else { |
annieluo2 | 0:d6c9b09b4042 | 75 | generate(func); |
annieluo2 | 0:d6c9b09b4042 | 76 | } |
annieluo2 | 0:d6c9b09b4042 | 77 | } |
annieluo2 | 0:d6c9b09b4042 | 78 | |
annieluo2 | 0:d6c9b09b4042 | 79 | /** Attach a Callback |
annieluo2 | 0:d6c9b09b4042 | 80 | * @param func The Callback to attach |
annieluo2 | 0:d6c9b09b4042 | 81 | */ |
annieluo2 | 0:d6c9b09b4042 | 82 | Callback(const Callback<R()> &func) { |
annieluo2 | 0:d6c9b09b4042 | 83 | if (func._ops) { |
annieluo2 | 0:d6c9b09b4042 | 84 | func._ops->move(this, &func); |
annieluo2 | 0:d6c9b09b4042 | 85 | } |
annieluo2 | 0:d6c9b09b4042 | 86 | _ops = func._ops; |
annieluo2 | 0:d6c9b09b4042 | 87 | } |
annieluo2 | 0:d6c9b09b4042 | 88 | |
annieluo2 | 0:d6c9b09b4042 | 89 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 90 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 91 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 92 | */ |
annieluo2 | 0:d6c9b09b4042 | 93 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 94 | Callback(T *obj, R (T::*method)()) { |
annieluo2 | 0:d6c9b09b4042 | 95 | generate(method_context<T, R (T::*)()>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 96 | } |
annieluo2 | 0:d6c9b09b4042 | 97 | |
annieluo2 | 0:d6c9b09b4042 | 98 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 99 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 100 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 101 | */ |
annieluo2 | 0:d6c9b09b4042 | 102 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 103 | Callback(const T *obj, R (T::*method)() const) { |
annieluo2 | 0:d6c9b09b4042 | 104 | generate(method_context<const T, R (T::*)() const>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 105 | } |
annieluo2 | 0:d6c9b09b4042 | 106 | |
annieluo2 | 0:d6c9b09b4042 | 107 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 108 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 109 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 110 | */ |
annieluo2 | 0:d6c9b09b4042 | 111 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 112 | Callback(volatile T *obj, R (T::*method)() volatile) { |
annieluo2 | 0:d6c9b09b4042 | 113 | generate(method_context<volatile T, R (T::*)() volatile>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 114 | } |
annieluo2 | 0:d6c9b09b4042 | 115 | |
annieluo2 | 0:d6c9b09b4042 | 116 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 117 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 118 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 119 | */ |
annieluo2 | 0:d6c9b09b4042 | 120 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 121 | Callback(const volatile T *obj, R (T::*method)() const volatile) { |
annieluo2 | 0:d6c9b09b4042 | 122 | generate(method_context<const volatile T, R (T::*)() const volatile>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 123 | } |
annieluo2 | 0:d6c9b09b4042 | 124 | |
annieluo2 | 0:d6c9b09b4042 | 125 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 126 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 127 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 128 | */ |
annieluo2 | 0:d6c9b09b4042 | 129 | Callback(R (*func)(void*), void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 130 | generate(function_context<R (*)(void*), void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 131 | } |
annieluo2 | 0:d6c9b09b4042 | 132 | |
annieluo2 | 0:d6c9b09b4042 | 133 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 134 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 135 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 136 | */ |
annieluo2 | 0:d6c9b09b4042 | 137 | Callback(R (*func)(const void*), const void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 138 | generate(function_context<R (*)(const void*), const void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 139 | } |
annieluo2 | 0:d6c9b09b4042 | 140 | |
annieluo2 | 0:d6c9b09b4042 | 141 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 142 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 143 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 144 | */ |
annieluo2 | 0:d6c9b09b4042 | 145 | Callback(R (*func)(volatile void*), volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 146 | generate(function_context<R (*)(volatile void*), volatile void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 147 | } |
annieluo2 | 0:d6c9b09b4042 | 148 | |
annieluo2 | 0:d6c9b09b4042 | 149 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 150 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 151 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 152 | */ |
annieluo2 | 0:d6c9b09b4042 | 153 | Callback(R (*func)(const volatile void*), const volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 154 | generate(function_context<R (*)(const volatile void*), const volatile void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 155 | } |
annieluo2 | 0:d6c9b09b4042 | 156 | |
annieluo2 | 0:d6c9b09b4042 | 157 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 158 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 159 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 160 | */ |
annieluo2 | 0:d6c9b09b4042 | 161 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 162 | Callback(R (*func)(T*), T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 163 | generate(function_context<R (*)(T*), T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 164 | } |
annieluo2 | 0:d6c9b09b4042 | 165 | |
annieluo2 | 0:d6c9b09b4042 | 166 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 167 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 168 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 169 | */ |
annieluo2 | 0:d6c9b09b4042 | 170 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 171 | Callback(R (*func)(const T*), const T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 172 | generate(function_context<R (*)(const T*), const T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 173 | } |
annieluo2 | 0:d6c9b09b4042 | 174 | |
annieluo2 | 0:d6c9b09b4042 | 175 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 176 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 177 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 178 | */ |
annieluo2 | 0:d6c9b09b4042 | 179 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 180 | Callback(R (*func)(volatile T*), volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 181 | generate(function_context<R (*)(volatile T*), volatile T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 182 | } |
annieluo2 | 0:d6c9b09b4042 | 183 | |
annieluo2 | 0:d6c9b09b4042 | 184 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 185 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 186 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 187 | */ |
annieluo2 | 0:d6c9b09b4042 | 188 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 189 | Callback(R (*func)(const volatile T*), const volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 190 | generate(function_context<R (*)(const volatile T*), const volatile T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 191 | } |
annieluo2 | 0:d6c9b09b4042 | 192 | |
annieluo2 | 0:d6c9b09b4042 | 193 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 194 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 195 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 196 | */ |
annieluo2 | 0:d6c9b09b4042 | 197 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 198 | Callback(F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 199 | detail::is_type<R (F::*)(), &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 200 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 201 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 202 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 203 | } |
annieluo2 | 0:d6c9b09b4042 | 204 | |
annieluo2 | 0:d6c9b09b4042 | 205 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 206 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 207 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 208 | */ |
annieluo2 | 0:d6c9b09b4042 | 209 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 210 | Callback(const F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 211 | detail::is_type<R (F::*)() const, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 212 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 213 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 214 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 215 | } |
annieluo2 | 0:d6c9b09b4042 | 216 | |
annieluo2 | 0:d6c9b09b4042 | 217 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 218 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 219 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 220 | */ |
annieluo2 | 0:d6c9b09b4042 | 221 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 222 | Callback(volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 223 | detail::is_type<R (F::*)() volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 224 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 225 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 226 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 227 | } |
annieluo2 | 0:d6c9b09b4042 | 228 | |
annieluo2 | 0:d6c9b09b4042 | 229 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 230 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 231 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 232 | */ |
annieluo2 | 0:d6c9b09b4042 | 233 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 234 | Callback(const volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 235 | detail::is_type<R (F::*)() const volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 236 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 237 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 238 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 239 | } |
annieluo2 | 0:d6c9b09b4042 | 240 | |
annieluo2 | 0:d6c9b09b4042 | 241 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 242 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 243 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 244 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 245 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 246 | */ |
annieluo2 | 0:d6c9b09b4042 | 247 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 248 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 249 | Callback(void *obj, R (*func)(void*)) { |
annieluo2 | 0:d6c9b09b4042 | 250 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 251 | } |
annieluo2 | 0:d6c9b09b4042 | 252 | |
annieluo2 | 0:d6c9b09b4042 | 253 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 254 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 255 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 256 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 257 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 258 | */ |
annieluo2 | 0:d6c9b09b4042 | 259 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 260 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 261 | Callback(const void *obj, R (*func)(const void*)) { |
annieluo2 | 0:d6c9b09b4042 | 262 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 263 | } |
annieluo2 | 0:d6c9b09b4042 | 264 | |
annieluo2 | 0:d6c9b09b4042 | 265 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 266 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 267 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 268 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 269 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 270 | */ |
annieluo2 | 0:d6c9b09b4042 | 271 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 272 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 273 | Callback(volatile void *obj, R (*func)(volatile void*)) { |
annieluo2 | 0:d6c9b09b4042 | 274 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 275 | } |
annieluo2 | 0:d6c9b09b4042 | 276 | |
annieluo2 | 0:d6c9b09b4042 | 277 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 278 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 279 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 280 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 281 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 282 | */ |
annieluo2 | 0:d6c9b09b4042 | 283 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 284 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 285 | Callback(const volatile void *obj, R (*func)(const volatile void*)) { |
annieluo2 | 0:d6c9b09b4042 | 286 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 287 | } |
annieluo2 | 0:d6c9b09b4042 | 288 | |
annieluo2 | 0:d6c9b09b4042 | 289 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 290 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 291 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 292 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 293 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 294 | */ |
annieluo2 | 0:d6c9b09b4042 | 295 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 296 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 297 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 298 | Callback(T *obj, R (*func)(T*)) { |
annieluo2 | 0:d6c9b09b4042 | 299 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 300 | } |
annieluo2 | 0:d6c9b09b4042 | 301 | |
annieluo2 | 0:d6c9b09b4042 | 302 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 303 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 304 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 305 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 306 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 307 | */ |
annieluo2 | 0:d6c9b09b4042 | 308 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 309 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 310 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 311 | Callback(const T *obj, R (*func)(const T*)) { |
annieluo2 | 0:d6c9b09b4042 | 312 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 313 | } |
annieluo2 | 0:d6c9b09b4042 | 314 | |
annieluo2 | 0:d6c9b09b4042 | 315 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 316 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 317 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 318 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 319 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 320 | */ |
annieluo2 | 0:d6c9b09b4042 | 321 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 322 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 323 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 324 | Callback(volatile T *obj, R (*func)(volatile T*)) { |
annieluo2 | 0:d6c9b09b4042 | 325 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 326 | } |
annieluo2 | 0:d6c9b09b4042 | 327 | |
annieluo2 | 0:d6c9b09b4042 | 328 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 329 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 330 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 331 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 332 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 333 | */ |
annieluo2 | 0:d6c9b09b4042 | 334 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 335 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 336 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 337 | Callback(const volatile T *obj, R (*func)(const volatile T*)) { |
annieluo2 | 0:d6c9b09b4042 | 338 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 339 | } |
annieluo2 | 0:d6c9b09b4042 | 340 | |
annieluo2 | 0:d6c9b09b4042 | 341 | /** Destroy a callback |
annieluo2 | 0:d6c9b09b4042 | 342 | */ |
annieluo2 | 0:d6c9b09b4042 | 343 | ~Callback() { |
annieluo2 | 0:d6c9b09b4042 | 344 | if (_ops) { |
annieluo2 | 0:d6c9b09b4042 | 345 | _ops->dtor(this); |
annieluo2 | 0:d6c9b09b4042 | 346 | } |
annieluo2 | 0:d6c9b09b4042 | 347 | } |
annieluo2 | 0:d6c9b09b4042 | 348 | |
annieluo2 | 0:d6c9b09b4042 | 349 | /** Attach a static function |
annieluo2 | 0:d6c9b09b4042 | 350 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 351 | */ |
annieluo2 | 0:d6c9b09b4042 | 352 | void attach(R (*func)()) { |
annieluo2 | 0:d6c9b09b4042 | 353 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 354 | new (this) Callback(func); |
annieluo2 | 0:d6c9b09b4042 | 355 | } |
annieluo2 | 0:d6c9b09b4042 | 356 | |
annieluo2 | 0:d6c9b09b4042 | 357 | /** Attach a Callback |
annieluo2 | 0:d6c9b09b4042 | 358 | * @param func The Callback to attach |
annieluo2 | 0:d6c9b09b4042 | 359 | */ |
annieluo2 | 0:d6c9b09b4042 | 360 | void attach(const Callback<R()> &func) { |
annieluo2 | 0:d6c9b09b4042 | 361 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 362 | new (this) Callback(func); |
annieluo2 | 0:d6c9b09b4042 | 363 | } |
annieluo2 | 0:d6c9b09b4042 | 364 | |
annieluo2 | 0:d6c9b09b4042 | 365 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 366 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 367 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 368 | */ |
annieluo2 | 0:d6c9b09b4042 | 369 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 370 | void attach(T *obj, R (T::*method)()) { |
annieluo2 | 0:d6c9b09b4042 | 371 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 372 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 373 | } |
annieluo2 | 0:d6c9b09b4042 | 374 | |
annieluo2 | 0:d6c9b09b4042 | 375 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 376 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 377 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 378 | */ |
annieluo2 | 0:d6c9b09b4042 | 379 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 380 | void attach(const T *obj, R (T::*method)() const) { |
annieluo2 | 0:d6c9b09b4042 | 381 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 382 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 383 | } |
annieluo2 | 0:d6c9b09b4042 | 384 | |
annieluo2 | 0:d6c9b09b4042 | 385 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 386 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 387 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 388 | */ |
annieluo2 | 0:d6c9b09b4042 | 389 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 390 | void attach(volatile T *obj, R (T::*method)() volatile) { |
annieluo2 | 0:d6c9b09b4042 | 391 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 392 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 393 | } |
annieluo2 | 0:d6c9b09b4042 | 394 | |
annieluo2 | 0:d6c9b09b4042 | 395 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 396 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 397 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 398 | */ |
annieluo2 | 0:d6c9b09b4042 | 399 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 400 | void attach(const volatile T *obj, R (T::*method)() const volatile) { |
annieluo2 | 0:d6c9b09b4042 | 401 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 402 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 403 | } |
annieluo2 | 0:d6c9b09b4042 | 404 | |
annieluo2 | 0:d6c9b09b4042 | 405 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 406 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 407 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 408 | */ |
annieluo2 | 0:d6c9b09b4042 | 409 | void attach(R (*func)(void*), void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 410 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 411 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 412 | } |
annieluo2 | 0:d6c9b09b4042 | 413 | |
annieluo2 | 0:d6c9b09b4042 | 414 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 415 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 416 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 417 | */ |
annieluo2 | 0:d6c9b09b4042 | 418 | void attach(R (*func)(const void*), const void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 419 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 420 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 421 | } |
annieluo2 | 0:d6c9b09b4042 | 422 | |
annieluo2 | 0:d6c9b09b4042 | 423 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 424 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 425 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 426 | */ |
annieluo2 | 0:d6c9b09b4042 | 427 | void attach(R (*func)(volatile void*), volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 428 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 429 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 430 | } |
annieluo2 | 0:d6c9b09b4042 | 431 | |
annieluo2 | 0:d6c9b09b4042 | 432 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 433 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 434 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 435 | */ |
annieluo2 | 0:d6c9b09b4042 | 436 | void attach(R (*func)(const volatile void*), const volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 437 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 438 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 439 | } |
annieluo2 | 0:d6c9b09b4042 | 440 | |
annieluo2 | 0:d6c9b09b4042 | 441 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 442 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 443 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 444 | */ |
annieluo2 | 0:d6c9b09b4042 | 445 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 446 | void attach(R (*func)(T*), T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 447 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 448 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 449 | } |
annieluo2 | 0:d6c9b09b4042 | 450 | |
annieluo2 | 0:d6c9b09b4042 | 451 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 452 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 453 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 454 | */ |
annieluo2 | 0:d6c9b09b4042 | 455 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 456 | void attach(R (*func)(const T*), const T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 457 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 458 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 459 | } |
annieluo2 | 0:d6c9b09b4042 | 460 | |
annieluo2 | 0:d6c9b09b4042 | 461 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 462 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 463 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 464 | */ |
annieluo2 | 0:d6c9b09b4042 | 465 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 466 | void attach(R (*func)(volatile T*), volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 467 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 468 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 469 | } |
annieluo2 | 0:d6c9b09b4042 | 470 | |
annieluo2 | 0:d6c9b09b4042 | 471 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 472 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 473 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 474 | */ |
annieluo2 | 0:d6c9b09b4042 | 475 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 476 | void attach(R (*func)(const volatile T*), const volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 477 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 478 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 479 | } |
annieluo2 | 0:d6c9b09b4042 | 480 | |
annieluo2 | 0:d6c9b09b4042 | 481 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 482 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 483 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 484 | */ |
annieluo2 | 0:d6c9b09b4042 | 485 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 486 | void attach(F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 487 | detail::is_type<R (F::*)(), &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 488 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 489 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 490 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 491 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 492 | } |
annieluo2 | 0:d6c9b09b4042 | 493 | |
annieluo2 | 0:d6c9b09b4042 | 494 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 495 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 496 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 497 | */ |
annieluo2 | 0:d6c9b09b4042 | 498 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 499 | void attach(const F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 500 | detail::is_type<R (F::*)() const, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 501 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 502 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 503 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 504 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 505 | } |
annieluo2 | 0:d6c9b09b4042 | 506 | |
annieluo2 | 0:d6c9b09b4042 | 507 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 508 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 509 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 510 | */ |
annieluo2 | 0:d6c9b09b4042 | 511 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 512 | void attach(volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 513 | detail::is_type<R (F::*)() volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 514 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 515 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 516 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 517 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 518 | } |
annieluo2 | 0:d6c9b09b4042 | 519 | |
annieluo2 | 0:d6c9b09b4042 | 520 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 521 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 522 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 523 | */ |
annieluo2 | 0:d6c9b09b4042 | 524 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 525 | void attach(const volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 526 | detail::is_type<R (F::*)() const volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 527 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 528 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 529 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 530 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 531 | } |
annieluo2 | 0:d6c9b09b4042 | 532 | |
annieluo2 | 0:d6c9b09b4042 | 533 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 534 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 535 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 536 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 537 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 538 | */ |
annieluo2 | 0:d6c9b09b4042 | 539 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 540 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 541 | void attach(void *obj, R (*func)(void*)) { |
annieluo2 | 0:d6c9b09b4042 | 542 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 543 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 544 | } |
annieluo2 | 0:d6c9b09b4042 | 545 | |
annieluo2 | 0:d6c9b09b4042 | 546 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 547 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 548 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 549 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 550 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 551 | */ |
annieluo2 | 0:d6c9b09b4042 | 552 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 553 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 554 | void attach(const void *obj, R (*func)(const void*)) { |
annieluo2 | 0:d6c9b09b4042 | 555 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 556 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 557 | } |
annieluo2 | 0:d6c9b09b4042 | 558 | |
annieluo2 | 0:d6c9b09b4042 | 559 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 560 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 561 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 562 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 563 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 564 | */ |
annieluo2 | 0:d6c9b09b4042 | 565 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 566 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 567 | void attach(volatile void *obj, R (*func)(volatile void*)) { |
annieluo2 | 0:d6c9b09b4042 | 568 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 569 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 570 | } |
annieluo2 | 0:d6c9b09b4042 | 571 | |
annieluo2 | 0:d6c9b09b4042 | 572 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 573 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 574 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 575 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 576 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 577 | */ |
annieluo2 | 0:d6c9b09b4042 | 578 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 579 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 580 | void attach(const volatile void *obj, R (*func)(const volatile void*)) { |
annieluo2 | 0:d6c9b09b4042 | 581 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 582 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 583 | } |
annieluo2 | 0:d6c9b09b4042 | 584 | |
annieluo2 | 0:d6c9b09b4042 | 585 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 586 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 587 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 588 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 589 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 590 | */ |
annieluo2 | 0:d6c9b09b4042 | 591 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 592 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 593 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 594 | void attach(T *obj, R (*func)(T*)) { |
annieluo2 | 0:d6c9b09b4042 | 595 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 596 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 597 | } |
annieluo2 | 0:d6c9b09b4042 | 598 | |
annieluo2 | 0:d6c9b09b4042 | 599 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 600 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 601 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 602 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 603 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 604 | */ |
annieluo2 | 0:d6c9b09b4042 | 605 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 606 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 607 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 608 | void attach(const T *obj, R (*func)(const T*)) { |
annieluo2 | 0:d6c9b09b4042 | 609 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 610 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 611 | } |
annieluo2 | 0:d6c9b09b4042 | 612 | |
annieluo2 | 0:d6c9b09b4042 | 613 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 614 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 615 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 616 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 617 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 618 | */ |
annieluo2 | 0:d6c9b09b4042 | 619 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 620 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 621 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 622 | void attach(volatile T *obj, R (*func)(volatile T*)) { |
annieluo2 | 0:d6c9b09b4042 | 623 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 624 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 625 | } |
annieluo2 | 0:d6c9b09b4042 | 626 | |
annieluo2 | 0:d6c9b09b4042 | 627 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 628 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 629 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 630 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 631 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 632 | */ |
annieluo2 | 0:d6c9b09b4042 | 633 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 634 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 635 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 636 | void attach(const volatile T *obj, R (*func)(const volatile T*)) { |
annieluo2 | 0:d6c9b09b4042 | 637 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 638 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 639 | } |
annieluo2 | 0:d6c9b09b4042 | 640 | |
annieluo2 | 0:d6c9b09b4042 | 641 | /** Assign a callback |
annieluo2 | 0:d6c9b09b4042 | 642 | */ |
annieluo2 | 0:d6c9b09b4042 | 643 | Callback &operator=(const Callback &that) { |
annieluo2 | 0:d6c9b09b4042 | 644 | if (this != &that) { |
annieluo2 | 0:d6c9b09b4042 | 645 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 646 | new (this) Callback(that); |
annieluo2 | 0:d6c9b09b4042 | 647 | } |
annieluo2 | 0:d6c9b09b4042 | 648 | |
annieluo2 | 0:d6c9b09b4042 | 649 | return *this; |
annieluo2 | 0:d6c9b09b4042 | 650 | } |
annieluo2 | 0:d6c9b09b4042 | 651 | |
annieluo2 | 0:d6c9b09b4042 | 652 | /** Call the attached function |
annieluo2 | 0:d6c9b09b4042 | 653 | */ |
annieluo2 | 0:d6c9b09b4042 | 654 | R call() const { |
annieluo2 | 0:d6c9b09b4042 | 655 | MBED_ASSERT(_ops); |
annieluo2 | 0:d6c9b09b4042 | 656 | return _ops->call(this); |
annieluo2 | 0:d6c9b09b4042 | 657 | } |
annieluo2 | 0:d6c9b09b4042 | 658 | |
annieluo2 | 0:d6c9b09b4042 | 659 | /** Call the attached function |
annieluo2 | 0:d6c9b09b4042 | 660 | */ |
annieluo2 | 0:d6c9b09b4042 | 661 | R operator()() const { |
annieluo2 | 0:d6c9b09b4042 | 662 | return call(); |
annieluo2 | 0:d6c9b09b4042 | 663 | } |
annieluo2 | 0:d6c9b09b4042 | 664 | |
annieluo2 | 0:d6c9b09b4042 | 665 | /** Test if function has been attached |
annieluo2 | 0:d6c9b09b4042 | 666 | */ |
annieluo2 | 0:d6c9b09b4042 | 667 | operator bool() const { |
annieluo2 | 0:d6c9b09b4042 | 668 | return _ops; |
annieluo2 | 0:d6c9b09b4042 | 669 | } |
annieluo2 | 0:d6c9b09b4042 | 670 | |
annieluo2 | 0:d6c9b09b4042 | 671 | /** Test for equality |
annieluo2 | 0:d6c9b09b4042 | 672 | */ |
annieluo2 | 0:d6c9b09b4042 | 673 | friend bool operator==(const Callback &l, const Callback &r) { |
annieluo2 | 0:d6c9b09b4042 | 674 | return memcmp(&l, &r, sizeof(Callback)) == 0; |
annieluo2 | 0:d6c9b09b4042 | 675 | } |
annieluo2 | 0:d6c9b09b4042 | 676 | |
annieluo2 | 0:d6c9b09b4042 | 677 | /** Test for inequality |
annieluo2 | 0:d6c9b09b4042 | 678 | */ |
annieluo2 | 0:d6c9b09b4042 | 679 | friend bool operator!=(const Callback &l, const Callback &r) { |
annieluo2 | 0:d6c9b09b4042 | 680 | return !(l == r); |
annieluo2 | 0:d6c9b09b4042 | 681 | } |
annieluo2 | 0:d6c9b09b4042 | 682 | |
annieluo2 | 0:d6c9b09b4042 | 683 | /** Static thunk for passing as C-style function |
annieluo2 | 0:d6c9b09b4042 | 684 | * @param func Callback to call passed as void pointer |
annieluo2 | 0:d6c9b09b4042 | 685 | */ |
annieluo2 | 0:d6c9b09b4042 | 686 | static R thunk(void *func) { |
annieluo2 | 0:d6c9b09b4042 | 687 | return static_cast<Callback*>(func)->call(); |
annieluo2 | 0:d6c9b09b4042 | 688 | } |
annieluo2 | 0:d6c9b09b4042 | 689 | |
annieluo2 | 0:d6c9b09b4042 | 690 | private: |
annieluo2 | 0:d6c9b09b4042 | 691 | // Stored as pointer to function and pointer to optional object |
annieluo2 | 0:d6c9b09b4042 | 692 | // Function pointer is stored as union of possible function types |
annieluo2 | 0:d6c9b09b4042 | 693 | // to garuntee proper size and alignment |
annieluo2 | 0:d6c9b09b4042 | 694 | struct _class; |
annieluo2 | 0:d6c9b09b4042 | 695 | union { |
annieluo2 | 0:d6c9b09b4042 | 696 | void (*_staticfunc)(); |
annieluo2 | 0:d6c9b09b4042 | 697 | void (*_boundfunc)(_class*); |
annieluo2 | 0:d6c9b09b4042 | 698 | void (_class::*_methodfunc)(); |
annieluo2 | 0:d6c9b09b4042 | 699 | } _func; |
annieluo2 | 0:d6c9b09b4042 | 700 | void *_obj; |
annieluo2 | 0:d6c9b09b4042 | 701 | |
annieluo2 | 0:d6c9b09b4042 | 702 | // Dynamically dispatched operations |
annieluo2 | 0:d6c9b09b4042 | 703 | const struct ops { |
annieluo2 | 0:d6c9b09b4042 | 704 | R (*call)(const void*); |
annieluo2 | 0:d6c9b09b4042 | 705 | void (*move)(void*, const void*); |
annieluo2 | 0:d6c9b09b4042 | 706 | void (*dtor)(void*); |
annieluo2 | 0:d6c9b09b4042 | 707 | } *_ops; |
annieluo2 | 0:d6c9b09b4042 | 708 | |
annieluo2 | 0:d6c9b09b4042 | 709 | // Generate operations for function object |
annieluo2 | 0:d6c9b09b4042 | 710 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 711 | void generate(const F &f) { |
annieluo2 | 0:d6c9b09b4042 | 712 | static const ops ops = { |
annieluo2 | 0:d6c9b09b4042 | 713 | &Callback::function_call<F>, |
annieluo2 | 0:d6c9b09b4042 | 714 | &Callback::function_move<F>, |
annieluo2 | 0:d6c9b09b4042 | 715 | &Callback::function_dtor<F>, |
annieluo2 | 0:d6c9b09b4042 | 716 | }; |
annieluo2 | 0:d6c9b09b4042 | 717 | |
annieluo2 | 0:d6c9b09b4042 | 718 | MBED_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F)); |
annieluo2 | 0:d6c9b09b4042 | 719 | new (this) F(f); |
annieluo2 | 0:d6c9b09b4042 | 720 | _ops = &ops; |
annieluo2 | 0:d6c9b09b4042 | 721 | } |
annieluo2 | 0:d6c9b09b4042 | 722 | |
annieluo2 | 0:d6c9b09b4042 | 723 | // Function attributes |
annieluo2 | 0:d6c9b09b4042 | 724 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 725 | static R function_call(const void *p) { |
annieluo2 | 0:d6c9b09b4042 | 726 | return (*(F*)p)(); |
annieluo2 | 0:d6c9b09b4042 | 727 | } |
annieluo2 | 0:d6c9b09b4042 | 728 | |
annieluo2 | 0:d6c9b09b4042 | 729 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 730 | static void function_move(void *d, const void *p) { |
annieluo2 | 0:d6c9b09b4042 | 731 | new (d) F(*(F*)p); |
annieluo2 | 0:d6c9b09b4042 | 732 | } |
annieluo2 | 0:d6c9b09b4042 | 733 | |
annieluo2 | 0:d6c9b09b4042 | 734 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 735 | static void function_dtor(void *p) { |
annieluo2 | 0:d6c9b09b4042 | 736 | ((F*)p)->~F(); |
annieluo2 | 0:d6c9b09b4042 | 737 | } |
annieluo2 | 0:d6c9b09b4042 | 738 | |
annieluo2 | 0:d6c9b09b4042 | 739 | // Wrappers for functions with context |
annieluo2 | 0:d6c9b09b4042 | 740 | template <typename O, typename M> |
annieluo2 | 0:d6c9b09b4042 | 741 | struct method_context { |
annieluo2 | 0:d6c9b09b4042 | 742 | M method; |
annieluo2 | 0:d6c9b09b4042 | 743 | O *obj; |
annieluo2 | 0:d6c9b09b4042 | 744 | |
annieluo2 | 0:d6c9b09b4042 | 745 | method_context(O *obj, M method) |
annieluo2 | 0:d6c9b09b4042 | 746 | : method(method), obj(obj) {} |
annieluo2 | 0:d6c9b09b4042 | 747 | |
annieluo2 | 0:d6c9b09b4042 | 748 | R operator()() const { |
annieluo2 | 0:d6c9b09b4042 | 749 | return (obj->*method)(); |
annieluo2 | 0:d6c9b09b4042 | 750 | } |
annieluo2 | 0:d6c9b09b4042 | 751 | }; |
annieluo2 | 0:d6c9b09b4042 | 752 | |
annieluo2 | 0:d6c9b09b4042 | 753 | template <typename F, typename A> |
annieluo2 | 0:d6c9b09b4042 | 754 | struct function_context { |
annieluo2 | 0:d6c9b09b4042 | 755 | F func; |
annieluo2 | 0:d6c9b09b4042 | 756 | A *arg; |
annieluo2 | 0:d6c9b09b4042 | 757 | |
annieluo2 | 0:d6c9b09b4042 | 758 | function_context(F func, A *arg) |
annieluo2 | 0:d6c9b09b4042 | 759 | : func(func), arg(arg) {} |
annieluo2 | 0:d6c9b09b4042 | 760 | |
annieluo2 | 0:d6c9b09b4042 | 761 | R operator()() const { |
annieluo2 | 0:d6c9b09b4042 | 762 | return func(arg); |
annieluo2 | 0:d6c9b09b4042 | 763 | } |
annieluo2 | 0:d6c9b09b4042 | 764 | }; |
annieluo2 | 0:d6c9b09b4042 | 765 | }; |
annieluo2 | 0:d6c9b09b4042 | 766 | |
annieluo2 | 0:d6c9b09b4042 | 767 | /** Callback class based on template specialization |
annieluo2 | 0:d6c9b09b4042 | 768 | * |
annieluo2 | 0:d6c9b09b4042 | 769 | * @Note Synchronization level: Not protected |
annieluo2 | 0:d6c9b09b4042 | 770 | */ |
annieluo2 | 0:d6c9b09b4042 | 771 | template <typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 772 | class Callback<R(A0)> { |
annieluo2 | 0:d6c9b09b4042 | 773 | public: |
annieluo2 | 0:d6c9b09b4042 | 774 | /** Create a Callback with a static function |
annieluo2 | 0:d6c9b09b4042 | 775 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 776 | */ |
annieluo2 | 0:d6c9b09b4042 | 777 | Callback(R (*func)(A0) = 0) { |
annieluo2 | 0:d6c9b09b4042 | 778 | if (!func) { |
annieluo2 | 0:d6c9b09b4042 | 779 | _ops = 0; |
annieluo2 | 0:d6c9b09b4042 | 780 | } else { |
annieluo2 | 0:d6c9b09b4042 | 781 | generate(func); |
annieluo2 | 0:d6c9b09b4042 | 782 | } |
annieluo2 | 0:d6c9b09b4042 | 783 | } |
annieluo2 | 0:d6c9b09b4042 | 784 | |
annieluo2 | 0:d6c9b09b4042 | 785 | /** Attach a Callback |
annieluo2 | 0:d6c9b09b4042 | 786 | * @param func The Callback to attach |
annieluo2 | 0:d6c9b09b4042 | 787 | */ |
annieluo2 | 0:d6c9b09b4042 | 788 | Callback(const Callback<R(A0)> &func) { |
annieluo2 | 0:d6c9b09b4042 | 789 | if (func._ops) { |
annieluo2 | 0:d6c9b09b4042 | 790 | func._ops->move(this, &func); |
annieluo2 | 0:d6c9b09b4042 | 791 | } |
annieluo2 | 0:d6c9b09b4042 | 792 | _ops = func._ops; |
annieluo2 | 0:d6c9b09b4042 | 793 | } |
annieluo2 | 0:d6c9b09b4042 | 794 | |
annieluo2 | 0:d6c9b09b4042 | 795 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 796 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 797 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 798 | */ |
annieluo2 | 0:d6c9b09b4042 | 799 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 800 | Callback(T *obj, R (T::*method)(A0)) { |
annieluo2 | 0:d6c9b09b4042 | 801 | generate(method_context<T, R (T::*)(A0)>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 802 | } |
annieluo2 | 0:d6c9b09b4042 | 803 | |
annieluo2 | 0:d6c9b09b4042 | 804 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 805 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 806 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 807 | */ |
annieluo2 | 0:d6c9b09b4042 | 808 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 809 | Callback(const T *obj, R (T::*method)(A0) const) { |
annieluo2 | 0:d6c9b09b4042 | 810 | generate(method_context<const T, R (T::*)(A0) const>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 811 | } |
annieluo2 | 0:d6c9b09b4042 | 812 | |
annieluo2 | 0:d6c9b09b4042 | 813 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 814 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 815 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 816 | */ |
annieluo2 | 0:d6c9b09b4042 | 817 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 818 | Callback(volatile T *obj, R (T::*method)(A0) volatile) { |
annieluo2 | 0:d6c9b09b4042 | 819 | generate(method_context<volatile T, R (T::*)(A0) volatile>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 820 | } |
annieluo2 | 0:d6c9b09b4042 | 821 | |
annieluo2 | 0:d6c9b09b4042 | 822 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 823 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 824 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 825 | */ |
annieluo2 | 0:d6c9b09b4042 | 826 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 827 | Callback(const volatile T *obj, R (T::*method)(A0) const volatile) { |
annieluo2 | 0:d6c9b09b4042 | 828 | generate(method_context<const volatile T, R (T::*)(A0) const volatile>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 829 | } |
annieluo2 | 0:d6c9b09b4042 | 830 | |
annieluo2 | 0:d6c9b09b4042 | 831 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 832 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 833 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 834 | */ |
annieluo2 | 0:d6c9b09b4042 | 835 | Callback(R (*func)(void*, A0), void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 836 | generate(function_context<R (*)(void*, A0), void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 837 | } |
annieluo2 | 0:d6c9b09b4042 | 838 | |
annieluo2 | 0:d6c9b09b4042 | 839 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 840 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 841 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 842 | */ |
annieluo2 | 0:d6c9b09b4042 | 843 | Callback(R (*func)(const void*, A0), const void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 844 | generate(function_context<R (*)(const void*, A0), const void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 845 | } |
annieluo2 | 0:d6c9b09b4042 | 846 | |
annieluo2 | 0:d6c9b09b4042 | 847 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 848 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 849 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 850 | */ |
annieluo2 | 0:d6c9b09b4042 | 851 | Callback(R (*func)(volatile void*, A0), volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 852 | generate(function_context<R (*)(volatile void*, A0), volatile void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 853 | } |
annieluo2 | 0:d6c9b09b4042 | 854 | |
annieluo2 | 0:d6c9b09b4042 | 855 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 856 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 857 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 858 | */ |
annieluo2 | 0:d6c9b09b4042 | 859 | Callback(R (*func)(const volatile void*, A0), const volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 860 | generate(function_context<R (*)(const volatile void*, A0), const volatile void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 861 | } |
annieluo2 | 0:d6c9b09b4042 | 862 | |
annieluo2 | 0:d6c9b09b4042 | 863 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 864 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 865 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 866 | */ |
annieluo2 | 0:d6c9b09b4042 | 867 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 868 | Callback(R (*func)(T*, A0), T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 869 | generate(function_context<R (*)(T*, A0), T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 870 | } |
annieluo2 | 0:d6c9b09b4042 | 871 | |
annieluo2 | 0:d6c9b09b4042 | 872 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 873 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 874 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 875 | */ |
annieluo2 | 0:d6c9b09b4042 | 876 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 877 | Callback(R (*func)(const T*, A0), const T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 878 | generate(function_context<R (*)(const T*, A0), const T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 879 | } |
annieluo2 | 0:d6c9b09b4042 | 880 | |
annieluo2 | 0:d6c9b09b4042 | 881 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 882 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 883 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 884 | */ |
annieluo2 | 0:d6c9b09b4042 | 885 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 886 | Callback(R (*func)(volatile T*, A0), volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 887 | generate(function_context<R (*)(volatile T*, A0), volatile T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 888 | } |
annieluo2 | 0:d6c9b09b4042 | 889 | |
annieluo2 | 0:d6c9b09b4042 | 890 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 891 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 892 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 893 | */ |
annieluo2 | 0:d6c9b09b4042 | 894 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 895 | Callback(R (*func)(const volatile T*, A0), const volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 896 | generate(function_context<R (*)(const volatile T*, A0), const volatile T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 897 | } |
annieluo2 | 0:d6c9b09b4042 | 898 | |
annieluo2 | 0:d6c9b09b4042 | 899 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 900 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 901 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 902 | */ |
annieluo2 | 0:d6c9b09b4042 | 903 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 904 | Callback(F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 905 | detail::is_type<R (F::*)(A0), &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 906 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 907 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 908 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 909 | } |
annieluo2 | 0:d6c9b09b4042 | 910 | |
annieluo2 | 0:d6c9b09b4042 | 911 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 912 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 913 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 914 | */ |
annieluo2 | 0:d6c9b09b4042 | 915 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 916 | Callback(const F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 917 | detail::is_type<R (F::*)(A0) const, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 918 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 919 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 920 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 921 | } |
annieluo2 | 0:d6c9b09b4042 | 922 | |
annieluo2 | 0:d6c9b09b4042 | 923 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 924 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 925 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 926 | */ |
annieluo2 | 0:d6c9b09b4042 | 927 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 928 | Callback(volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 929 | detail::is_type<R (F::*)(A0) volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 930 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 931 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 932 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 933 | } |
annieluo2 | 0:d6c9b09b4042 | 934 | |
annieluo2 | 0:d6c9b09b4042 | 935 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 936 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 937 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 938 | */ |
annieluo2 | 0:d6c9b09b4042 | 939 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 940 | Callback(const volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 941 | detail::is_type<R (F::*)(A0) const volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 942 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 943 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 944 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 945 | } |
annieluo2 | 0:d6c9b09b4042 | 946 | |
annieluo2 | 0:d6c9b09b4042 | 947 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 948 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 949 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 950 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 951 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 952 | */ |
annieluo2 | 0:d6c9b09b4042 | 953 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 954 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 955 | Callback(void *obj, R (*func)(void*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 956 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 957 | } |
annieluo2 | 0:d6c9b09b4042 | 958 | |
annieluo2 | 0:d6c9b09b4042 | 959 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 960 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 961 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 962 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 963 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 964 | */ |
annieluo2 | 0:d6c9b09b4042 | 965 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 966 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 967 | Callback(const void *obj, R (*func)(const void*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 968 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 969 | } |
annieluo2 | 0:d6c9b09b4042 | 970 | |
annieluo2 | 0:d6c9b09b4042 | 971 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 972 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 973 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 974 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 975 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 976 | */ |
annieluo2 | 0:d6c9b09b4042 | 977 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 978 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 979 | Callback(volatile void *obj, R (*func)(volatile void*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 980 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 981 | } |
annieluo2 | 0:d6c9b09b4042 | 982 | |
annieluo2 | 0:d6c9b09b4042 | 983 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 984 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 985 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 986 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 987 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 988 | */ |
annieluo2 | 0:d6c9b09b4042 | 989 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 990 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 991 | Callback(const volatile void *obj, R (*func)(const volatile void*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 992 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 993 | } |
annieluo2 | 0:d6c9b09b4042 | 994 | |
annieluo2 | 0:d6c9b09b4042 | 995 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 996 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 997 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 998 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 999 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1000 | */ |
annieluo2 | 0:d6c9b09b4042 | 1001 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1002 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1003 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1004 | Callback(T *obj, R (*func)(T*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 1005 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1006 | } |
annieluo2 | 0:d6c9b09b4042 | 1007 | |
annieluo2 | 0:d6c9b09b4042 | 1008 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1009 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1010 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1011 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1012 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1013 | */ |
annieluo2 | 0:d6c9b09b4042 | 1014 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1015 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1016 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1017 | Callback(const T *obj, R (*func)(const T*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 1018 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1019 | } |
annieluo2 | 0:d6c9b09b4042 | 1020 | |
annieluo2 | 0:d6c9b09b4042 | 1021 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1022 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1023 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1024 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1025 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1026 | */ |
annieluo2 | 0:d6c9b09b4042 | 1027 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1028 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1029 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1030 | Callback(volatile T *obj, R (*func)(volatile T*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 1031 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1032 | } |
annieluo2 | 0:d6c9b09b4042 | 1033 | |
annieluo2 | 0:d6c9b09b4042 | 1034 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1035 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1036 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1037 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1038 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1039 | */ |
annieluo2 | 0:d6c9b09b4042 | 1040 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1041 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1042 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1043 | Callback(const volatile T *obj, R (*func)(const volatile T*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 1044 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1045 | } |
annieluo2 | 0:d6c9b09b4042 | 1046 | |
annieluo2 | 0:d6c9b09b4042 | 1047 | /** Destroy a callback |
annieluo2 | 0:d6c9b09b4042 | 1048 | */ |
annieluo2 | 0:d6c9b09b4042 | 1049 | ~Callback() { |
annieluo2 | 0:d6c9b09b4042 | 1050 | if (_ops) { |
annieluo2 | 0:d6c9b09b4042 | 1051 | _ops->dtor(this); |
annieluo2 | 0:d6c9b09b4042 | 1052 | } |
annieluo2 | 0:d6c9b09b4042 | 1053 | } |
annieluo2 | 0:d6c9b09b4042 | 1054 | |
annieluo2 | 0:d6c9b09b4042 | 1055 | /** Attach a static function |
annieluo2 | 0:d6c9b09b4042 | 1056 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1057 | */ |
annieluo2 | 0:d6c9b09b4042 | 1058 | void attach(R (*func)(A0)) { |
annieluo2 | 0:d6c9b09b4042 | 1059 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1060 | new (this) Callback(func); |
annieluo2 | 0:d6c9b09b4042 | 1061 | } |
annieluo2 | 0:d6c9b09b4042 | 1062 | |
annieluo2 | 0:d6c9b09b4042 | 1063 | /** Attach a Callback |
annieluo2 | 0:d6c9b09b4042 | 1064 | * @param func The Callback to attach |
annieluo2 | 0:d6c9b09b4042 | 1065 | */ |
annieluo2 | 0:d6c9b09b4042 | 1066 | void attach(const Callback<R(A0)> &func) { |
annieluo2 | 0:d6c9b09b4042 | 1067 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1068 | new (this) Callback(func); |
annieluo2 | 0:d6c9b09b4042 | 1069 | } |
annieluo2 | 0:d6c9b09b4042 | 1070 | |
annieluo2 | 0:d6c9b09b4042 | 1071 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 1072 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 1073 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 1074 | */ |
annieluo2 | 0:d6c9b09b4042 | 1075 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1076 | void attach(T *obj, R (T::*method)(A0)) { |
annieluo2 | 0:d6c9b09b4042 | 1077 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1078 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 1079 | } |
annieluo2 | 0:d6c9b09b4042 | 1080 | |
annieluo2 | 0:d6c9b09b4042 | 1081 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 1082 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 1083 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 1084 | */ |
annieluo2 | 0:d6c9b09b4042 | 1085 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1086 | void attach(const T *obj, R (T::*method)(A0) const) { |
annieluo2 | 0:d6c9b09b4042 | 1087 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1088 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 1089 | } |
annieluo2 | 0:d6c9b09b4042 | 1090 | |
annieluo2 | 0:d6c9b09b4042 | 1091 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 1092 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 1093 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 1094 | */ |
annieluo2 | 0:d6c9b09b4042 | 1095 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1096 | void attach(volatile T *obj, R (T::*method)(A0) volatile) { |
annieluo2 | 0:d6c9b09b4042 | 1097 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1098 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 1099 | } |
annieluo2 | 0:d6c9b09b4042 | 1100 | |
annieluo2 | 0:d6c9b09b4042 | 1101 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 1102 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 1103 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 1104 | */ |
annieluo2 | 0:d6c9b09b4042 | 1105 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1106 | void attach(const volatile T *obj, R (T::*method)(A0) const volatile) { |
annieluo2 | 0:d6c9b09b4042 | 1107 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1108 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 1109 | } |
annieluo2 | 0:d6c9b09b4042 | 1110 | |
annieluo2 | 0:d6c9b09b4042 | 1111 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1112 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1113 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1114 | */ |
annieluo2 | 0:d6c9b09b4042 | 1115 | void attach(R (*func)(void*, A0), void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1116 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1117 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 1118 | } |
annieluo2 | 0:d6c9b09b4042 | 1119 | |
annieluo2 | 0:d6c9b09b4042 | 1120 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1121 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1122 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1123 | */ |
annieluo2 | 0:d6c9b09b4042 | 1124 | void attach(R (*func)(const void*, A0), const void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1125 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1126 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 1127 | } |
annieluo2 | 0:d6c9b09b4042 | 1128 | |
annieluo2 | 0:d6c9b09b4042 | 1129 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1130 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1131 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1132 | */ |
annieluo2 | 0:d6c9b09b4042 | 1133 | void attach(R (*func)(volatile void*, A0), volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1134 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1135 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 1136 | } |
annieluo2 | 0:d6c9b09b4042 | 1137 | |
annieluo2 | 0:d6c9b09b4042 | 1138 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1139 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1140 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1141 | */ |
annieluo2 | 0:d6c9b09b4042 | 1142 | void attach(R (*func)(const volatile void*, A0), const volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1143 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1144 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 1145 | } |
annieluo2 | 0:d6c9b09b4042 | 1146 | |
annieluo2 | 0:d6c9b09b4042 | 1147 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1148 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1149 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1150 | */ |
annieluo2 | 0:d6c9b09b4042 | 1151 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 1152 | void attach(R (*func)(T*, A0), T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1153 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1154 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 1155 | } |
annieluo2 | 0:d6c9b09b4042 | 1156 | |
annieluo2 | 0:d6c9b09b4042 | 1157 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1158 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1159 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1160 | */ |
annieluo2 | 0:d6c9b09b4042 | 1161 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 1162 | void attach(R (*func)(const T*, A0), const T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1163 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1164 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 1165 | } |
annieluo2 | 0:d6c9b09b4042 | 1166 | |
annieluo2 | 0:d6c9b09b4042 | 1167 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1168 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1169 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1170 | */ |
annieluo2 | 0:d6c9b09b4042 | 1171 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 1172 | void attach(R (*func)(volatile T*, A0), volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1173 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1174 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 1175 | } |
annieluo2 | 0:d6c9b09b4042 | 1176 | |
annieluo2 | 0:d6c9b09b4042 | 1177 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1178 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1179 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1180 | */ |
annieluo2 | 0:d6c9b09b4042 | 1181 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 1182 | void attach(R (*func)(const volatile T*, A0), const volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1183 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1184 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 1185 | } |
annieluo2 | 0:d6c9b09b4042 | 1186 | |
annieluo2 | 0:d6c9b09b4042 | 1187 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 1188 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 1189 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 1190 | */ |
annieluo2 | 0:d6c9b09b4042 | 1191 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 1192 | void attach(F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 1193 | detail::is_type<R (F::*)(A0), &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 1194 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 1195 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 1196 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1197 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 1198 | } |
annieluo2 | 0:d6c9b09b4042 | 1199 | |
annieluo2 | 0:d6c9b09b4042 | 1200 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 1201 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 1202 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 1203 | */ |
annieluo2 | 0:d6c9b09b4042 | 1204 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 1205 | void attach(const F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 1206 | detail::is_type<R (F::*)(A0) const, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 1207 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 1208 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 1209 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1210 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 1211 | } |
annieluo2 | 0:d6c9b09b4042 | 1212 | |
annieluo2 | 0:d6c9b09b4042 | 1213 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 1214 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 1215 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 1216 | */ |
annieluo2 | 0:d6c9b09b4042 | 1217 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 1218 | void attach(volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 1219 | detail::is_type<R (F::*)(A0) volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 1220 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 1221 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 1222 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1223 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 1224 | } |
annieluo2 | 0:d6c9b09b4042 | 1225 | |
annieluo2 | 0:d6c9b09b4042 | 1226 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 1227 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 1228 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 1229 | */ |
annieluo2 | 0:d6c9b09b4042 | 1230 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 1231 | void attach(const volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 1232 | detail::is_type<R (F::*)(A0) const volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 1233 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 1234 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 1235 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1236 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 1237 | } |
annieluo2 | 0:d6c9b09b4042 | 1238 | |
annieluo2 | 0:d6c9b09b4042 | 1239 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1240 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1241 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1242 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1243 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1244 | */ |
annieluo2 | 0:d6c9b09b4042 | 1245 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1246 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1247 | void attach(void *obj, R (*func)(void*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 1248 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1249 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1250 | } |
annieluo2 | 0:d6c9b09b4042 | 1251 | |
annieluo2 | 0:d6c9b09b4042 | 1252 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1253 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1254 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1255 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1256 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1257 | */ |
annieluo2 | 0:d6c9b09b4042 | 1258 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1259 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1260 | void attach(const void *obj, R (*func)(const void*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 1261 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1262 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1263 | } |
annieluo2 | 0:d6c9b09b4042 | 1264 | |
annieluo2 | 0:d6c9b09b4042 | 1265 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1266 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1267 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1268 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1269 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1270 | */ |
annieluo2 | 0:d6c9b09b4042 | 1271 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1272 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1273 | void attach(volatile void *obj, R (*func)(volatile void*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 1274 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1275 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1276 | } |
annieluo2 | 0:d6c9b09b4042 | 1277 | |
annieluo2 | 0:d6c9b09b4042 | 1278 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1279 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1280 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1281 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1282 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1283 | */ |
annieluo2 | 0:d6c9b09b4042 | 1284 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1285 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1286 | void attach(const volatile void *obj, R (*func)(const volatile void*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 1287 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1288 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1289 | } |
annieluo2 | 0:d6c9b09b4042 | 1290 | |
annieluo2 | 0:d6c9b09b4042 | 1291 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1292 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1293 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1294 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1295 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1296 | */ |
annieluo2 | 0:d6c9b09b4042 | 1297 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 1298 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1299 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1300 | void attach(T *obj, R (*func)(T*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 1301 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1302 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1303 | } |
annieluo2 | 0:d6c9b09b4042 | 1304 | |
annieluo2 | 0:d6c9b09b4042 | 1305 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1306 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1307 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1308 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1309 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1310 | */ |
annieluo2 | 0:d6c9b09b4042 | 1311 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 1312 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1313 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1314 | void attach(const T *obj, R (*func)(const T*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 1315 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1316 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1317 | } |
annieluo2 | 0:d6c9b09b4042 | 1318 | |
annieluo2 | 0:d6c9b09b4042 | 1319 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1320 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1321 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1322 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1323 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1324 | */ |
annieluo2 | 0:d6c9b09b4042 | 1325 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 1326 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1327 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1328 | void attach(volatile T *obj, R (*func)(volatile T*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 1329 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1330 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1331 | } |
annieluo2 | 0:d6c9b09b4042 | 1332 | |
annieluo2 | 0:d6c9b09b4042 | 1333 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1334 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1335 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1336 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1337 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1338 | */ |
annieluo2 | 0:d6c9b09b4042 | 1339 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 1340 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1341 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1342 | void attach(const volatile T *obj, R (*func)(const volatile T*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 1343 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1344 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1345 | } |
annieluo2 | 0:d6c9b09b4042 | 1346 | |
annieluo2 | 0:d6c9b09b4042 | 1347 | /** Assign a callback |
annieluo2 | 0:d6c9b09b4042 | 1348 | */ |
annieluo2 | 0:d6c9b09b4042 | 1349 | Callback &operator=(const Callback &that) { |
annieluo2 | 0:d6c9b09b4042 | 1350 | if (this != &that) { |
annieluo2 | 0:d6c9b09b4042 | 1351 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1352 | new (this) Callback(that); |
annieluo2 | 0:d6c9b09b4042 | 1353 | } |
annieluo2 | 0:d6c9b09b4042 | 1354 | |
annieluo2 | 0:d6c9b09b4042 | 1355 | return *this; |
annieluo2 | 0:d6c9b09b4042 | 1356 | } |
annieluo2 | 0:d6c9b09b4042 | 1357 | |
annieluo2 | 0:d6c9b09b4042 | 1358 | /** Call the attached function |
annieluo2 | 0:d6c9b09b4042 | 1359 | */ |
annieluo2 | 0:d6c9b09b4042 | 1360 | R call(A0 a0) const { |
annieluo2 | 0:d6c9b09b4042 | 1361 | MBED_ASSERT(_ops); |
annieluo2 | 0:d6c9b09b4042 | 1362 | return _ops->call(this, a0); |
annieluo2 | 0:d6c9b09b4042 | 1363 | } |
annieluo2 | 0:d6c9b09b4042 | 1364 | |
annieluo2 | 0:d6c9b09b4042 | 1365 | /** Call the attached function |
annieluo2 | 0:d6c9b09b4042 | 1366 | */ |
annieluo2 | 0:d6c9b09b4042 | 1367 | R operator()(A0 a0) const { |
annieluo2 | 0:d6c9b09b4042 | 1368 | return call(a0); |
annieluo2 | 0:d6c9b09b4042 | 1369 | } |
annieluo2 | 0:d6c9b09b4042 | 1370 | |
annieluo2 | 0:d6c9b09b4042 | 1371 | /** Test if function has been attached |
annieluo2 | 0:d6c9b09b4042 | 1372 | */ |
annieluo2 | 0:d6c9b09b4042 | 1373 | operator bool() const { |
annieluo2 | 0:d6c9b09b4042 | 1374 | return _ops; |
annieluo2 | 0:d6c9b09b4042 | 1375 | } |
annieluo2 | 0:d6c9b09b4042 | 1376 | |
annieluo2 | 0:d6c9b09b4042 | 1377 | /** Test for equality |
annieluo2 | 0:d6c9b09b4042 | 1378 | */ |
annieluo2 | 0:d6c9b09b4042 | 1379 | friend bool operator==(const Callback &l, const Callback &r) { |
annieluo2 | 0:d6c9b09b4042 | 1380 | return memcmp(&l, &r, sizeof(Callback)) == 0; |
annieluo2 | 0:d6c9b09b4042 | 1381 | } |
annieluo2 | 0:d6c9b09b4042 | 1382 | |
annieluo2 | 0:d6c9b09b4042 | 1383 | /** Test for inequality |
annieluo2 | 0:d6c9b09b4042 | 1384 | */ |
annieluo2 | 0:d6c9b09b4042 | 1385 | friend bool operator!=(const Callback &l, const Callback &r) { |
annieluo2 | 0:d6c9b09b4042 | 1386 | return !(l == r); |
annieluo2 | 0:d6c9b09b4042 | 1387 | } |
annieluo2 | 0:d6c9b09b4042 | 1388 | |
annieluo2 | 0:d6c9b09b4042 | 1389 | /** Static thunk for passing as C-style function |
annieluo2 | 0:d6c9b09b4042 | 1390 | * @param func Callback to call passed as void pointer |
annieluo2 | 0:d6c9b09b4042 | 1391 | */ |
annieluo2 | 0:d6c9b09b4042 | 1392 | static R thunk(void *func, A0 a0) { |
annieluo2 | 0:d6c9b09b4042 | 1393 | return static_cast<Callback*>(func)->call(a0); |
annieluo2 | 0:d6c9b09b4042 | 1394 | } |
annieluo2 | 0:d6c9b09b4042 | 1395 | |
annieluo2 | 0:d6c9b09b4042 | 1396 | private: |
annieluo2 | 0:d6c9b09b4042 | 1397 | // Stored as pointer to function and pointer to optional object |
annieluo2 | 0:d6c9b09b4042 | 1398 | // Function pointer is stored as union of possible function types |
annieluo2 | 0:d6c9b09b4042 | 1399 | // to garuntee proper size and alignment |
annieluo2 | 0:d6c9b09b4042 | 1400 | struct _class; |
annieluo2 | 0:d6c9b09b4042 | 1401 | union { |
annieluo2 | 0:d6c9b09b4042 | 1402 | void (*_staticfunc)(A0); |
annieluo2 | 0:d6c9b09b4042 | 1403 | void (*_boundfunc)(_class*, A0); |
annieluo2 | 0:d6c9b09b4042 | 1404 | void (_class::*_methodfunc)(A0); |
annieluo2 | 0:d6c9b09b4042 | 1405 | } _func; |
annieluo2 | 0:d6c9b09b4042 | 1406 | void *_obj; |
annieluo2 | 0:d6c9b09b4042 | 1407 | |
annieluo2 | 0:d6c9b09b4042 | 1408 | // Dynamically dispatched operations |
annieluo2 | 0:d6c9b09b4042 | 1409 | const struct ops { |
annieluo2 | 0:d6c9b09b4042 | 1410 | R (*call)(const void*, A0); |
annieluo2 | 0:d6c9b09b4042 | 1411 | void (*move)(void*, const void*); |
annieluo2 | 0:d6c9b09b4042 | 1412 | void (*dtor)(void*); |
annieluo2 | 0:d6c9b09b4042 | 1413 | } *_ops; |
annieluo2 | 0:d6c9b09b4042 | 1414 | |
annieluo2 | 0:d6c9b09b4042 | 1415 | // Generate operations for function object |
annieluo2 | 0:d6c9b09b4042 | 1416 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 1417 | void generate(const F &f) { |
annieluo2 | 0:d6c9b09b4042 | 1418 | static const ops ops = { |
annieluo2 | 0:d6c9b09b4042 | 1419 | &Callback::function_call<F>, |
annieluo2 | 0:d6c9b09b4042 | 1420 | &Callback::function_move<F>, |
annieluo2 | 0:d6c9b09b4042 | 1421 | &Callback::function_dtor<F>, |
annieluo2 | 0:d6c9b09b4042 | 1422 | }; |
annieluo2 | 0:d6c9b09b4042 | 1423 | |
annieluo2 | 0:d6c9b09b4042 | 1424 | MBED_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F)); |
annieluo2 | 0:d6c9b09b4042 | 1425 | new (this) F(f); |
annieluo2 | 0:d6c9b09b4042 | 1426 | _ops = &ops; |
annieluo2 | 0:d6c9b09b4042 | 1427 | } |
annieluo2 | 0:d6c9b09b4042 | 1428 | |
annieluo2 | 0:d6c9b09b4042 | 1429 | // Function attributes |
annieluo2 | 0:d6c9b09b4042 | 1430 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 1431 | static R function_call(const void *p, A0 a0) { |
annieluo2 | 0:d6c9b09b4042 | 1432 | return (*(F*)p)(a0); |
annieluo2 | 0:d6c9b09b4042 | 1433 | } |
annieluo2 | 0:d6c9b09b4042 | 1434 | |
annieluo2 | 0:d6c9b09b4042 | 1435 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 1436 | static void function_move(void *d, const void *p) { |
annieluo2 | 0:d6c9b09b4042 | 1437 | new (d) F(*(F*)p); |
annieluo2 | 0:d6c9b09b4042 | 1438 | } |
annieluo2 | 0:d6c9b09b4042 | 1439 | |
annieluo2 | 0:d6c9b09b4042 | 1440 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 1441 | static void function_dtor(void *p) { |
annieluo2 | 0:d6c9b09b4042 | 1442 | ((F*)p)->~F(); |
annieluo2 | 0:d6c9b09b4042 | 1443 | } |
annieluo2 | 0:d6c9b09b4042 | 1444 | |
annieluo2 | 0:d6c9b09b4042 | 1445 | // Wrappers for functions with context |
annieluo2 | 0:d6c9b09b4042 | 1446 | template <typename O, typename M> |
annieluo2 | 0:d6c9b09b4042 | 1447 | struct method_context { |
annieluo2 | 0:d6c9b09b4042 | 1448 | M method; |
annieluo2 | 0:d6c9b09b4042 | 1449 | O *obj; |
annieluo2 | 0:d6c9b09b4042 | 1450 | |
annieluo2 | 0:d6c9b09b4042 | 1451 | method_context(O *obj, M method) |
annieluo2 | 0:d6c9b09b4042 | 1452 | : method(method), obj(obj) {} |
annieluo2 | 0:d6c9b09b4042 | 1453 | |
annieluo2 | 0:d6c9b09b4042 | 1454 | R operator()(A0 a0) const { |
annieluo2 | 0:d6c9b09b4042 | 1455 | return (obj->*method)(a0); |
annieluo2 | 0:d6c9b09b4042 | 1456 | } |
annieluo2 | 0:d6c9b09b4042 | 1457 | }; |
annieluo2 | 0:d6c9b09b4042 | 1458 | |
annieluo2 | 0:d6c9b09b4042 | 1459 | template <typename F, typename A> |
annieluo2 | 0:d6c9b09b4042 | 1460 | struct function_context { |
annieluo2 | 0:d6c9b09b4042 | 1461 | F func; |
annieluo2 | 0:d6c9b09b4042 | 1462 | A *arg; |
annieluo2 | 0:d6c9b09b4042 | 1463 | |
annieluo2 | 0:d6c9b09b4042 | 1464 | function_context(F func, A *arg) |
annieluo2 | 0:d6c9b09b4042 | 1465 | : func(func), arg(arg) {} |
annieluo2 | 0:d6c9b09b4042 | 1466 | |
annieluo2 | 0:d6c9b09b4042 | 1467 | R operator()(A0 a0) const { |
annieluo2 | 0:d6c9b09b4042 | 1468 | return func(arg, a0); |
annieluo2 | 0:d6c9b09b4042 | 1469 | } |
annieluo2 | 0:d6c9b09b4042 | 1470 | }; |
annieluo2 | 0:d6c9b09b4042 | 1471 | }; |
annieluo2 | 0:d6c9b09b4042 | 1472 | |
annieluo2 | 0:d6c9b09b4042 | 1473 | /** Callback class based on template specialization |
annieluo2 | 0:d6c9b09b4042 | 1474 | * |
annieluo2 | 0:d6c9b09b4042 | 1475 | * @Note Synchronization level: Not protected |
annieluo2 | 0:d6c9b09b4042 | 1476 | */ |
annieluo2 | 0:d6c9b09b4042 | 1477 | template <typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 1478 | class Callback<R(A0, A1)> { |
annieluo2 | 0:d6c9b09b4042 | 1479 | public: |
annieluo2 | 0:d6c9b09b4042 | 1480 | /** Create a Callback with a static function |
annieluo2 | 0:d6c9b09b4042 | 1481 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1482 | */ |
annieluo2 | 0:d6c9b09b4042 | 1483 | Callback(R (*func)(A0, A1) = 0) { |
annieluo2 | 0:d6c9b09b4042 | 1484 | if (!func) { |
annieluo2 | 0:d6c9b09b4042 | 1485 | _ops = 0; |
annieluo2 | 0:d6c9b09b4042 | 1486 | } else { |
annieluo2 | 0:d6c9b09b4042 | 1487 | generate(func); |
annieluo2 | 0:d6c9b09b4042 | 1488 | } |
annieluo2 | 0:d6c9b09b4042 | 1489 | } |
annieluo2 | 0:d6c9b09b4042 | 1490 | |
annieluo2 | 0:d6c9b09b4042 | 1491 | /** Attach a Callback |
annieluo2 | 0:d6c9b09b4042 | 1492 | * @param func The Callback to attach |
annieluo2 | 0:d6c9b09b4042 | 1493 | */ |
annieluo2 | 0:d6c9b09b4042 | 1494 | Callback(const Callback<R(A0, A1)> &func) { |
annieluo2 | 0:d6c9b09b4042 | 1495 | if (func._ops) { |
annieluo2 | 0:d6c9b09b4042 | 1496 | func._ops->move(this, &func); |
annieluo2 | 0:d6c9b09b4042 | 1497 | } |
annieluo2 | 0:d6c9b09b4042 | 1498 | _ops = func._ops; |
annieluo2 | 0:d6c9b09b4042 | 1499 | } |
annieluo2 | 0:d6c9b09b4042 | 1500 | |
annieluo2 | 0:d6c9b09b4042 | 1501 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 1502 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 1503 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 1504 | */ |
annieluo2 | 0:d6c9b09b4042 | 1505 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1506 | Callback(T *obj, R (T::*method)(A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 1507 | generate(method_context<T, R (T::*)(A0, A1)>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 1508 | } |
annieluo2 | 0:d6c9b09b4042 | 1509 | |
annieluo2 | 0:d6c9b09b4042 | 1510 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 1511 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 1512 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 1513 | */ |
annieluo2 | 0:d6c9b09b4042 | 1514 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1515 | Callback(const T *obj, R (T::*method)(A0, A1) const) { |
annieluo2 | 0:d6c9b09b4042 | 1516 | generate(method_context<const T, R (T::*)(A0, A1) const>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 1517 | } |
annieluo2 | 0:d6c9b09b4042 | 1518 | |
annieluo2 | 0:d6c9b09b4042 | 1519 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 1520 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 1521 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 1522 | */ |
annieluo2 | 0:d6c9b09b4042 | 1523 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1524 | Callback(volatile T *obj, R (T::*method)(A0, A1) volatile) { |
annieluo2 | 0:d6c9b09b4042 | 1525 | generate(method_context<volatile T, R (T::*)(A0, A1) volatile>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 1526 | } |
annieluo2 | 0:d6c9b09b4042 | 1527 | |
annieluo2 | 0:d6c9b09b4042 | 1528 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 1529 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 1530 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 1531 | */ |
annieluo2 | 0:d6c9b09b4042 | 1532 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1533 | Callback(const volatile T *obj, R (T::*method)(A0, A1) const volatile) { |
annieluo2 | 0:d6c9b09b4042 | 1534 | generate(method_context<const volatile T, R (T::*)(A0, A1) const volatile>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 1535 | } |
annieluo2 | 0:d6c9b09b4042 | 1536 | |
annieluo2 | 0:d6c9b09b4042 | 1537 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1538 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1539 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1540 | */ |
annieluo2 | 0:d6c9b09b4042 | 1541 | Callback(R (*func)(void*, A0, A1), void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1542 | generate(function_context<R (*)(void*, A0, A1), void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 1543 | } |
annieluo2 | 0:d6c9b09b4042 | 1544 | |
annieluo2 | 0:d6c9b09b4042 | 1545 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1546 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1547 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1548 | */ |
annieluo2 | 0:d6c9b09b4042 | 1549 | Callback(R (*func)(const void*, A0, A1), const void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1550 | generate(function_context<R (*)(const void*, A0, A1), const void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 1551 | } |
annieluo2 | 0:d6c9b09b4042 | 1552 | |
annieluo2 | 0:d6c9b09b4042 | 1553 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1554 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1555 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1556 | */ |
annieluo2 | 0:d6c9b09b4042 | 1557 | Callback(R (*func)(volatile void*, A0, A1), volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1558 | generate(function_context<R (*)(volatile void*, A0, A1), volatile void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 1559 | } |
annieluo2 | 0:d6c9b09b4042 | 1560 | |
annieluo2 | 0:d6c9b09b4042 | 1561 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1562 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1563 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1564 | */ |
annieluo2 | 0:d6c9b09b4042 | 1565 | Callback(R (*func)(const volatile void*, A0, A1), const volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1566 | generate(function_context<R (*)(const volatile void*, A0, A1), const volatile void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 1567 | } |
annieluo2 | 0:d6c9b09b4042 | 1568 | |
annieluo2 | 0:d6c9b09b4042 | 1569 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1570 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1571 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1572 | */ |
annieluo2 | 0:d6c9b09b4042 | 1573 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1574 | Callback(R (*func)(T*, A0, A1), T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1575 | generate(function_context<R (*)(T*, A0, A1), T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 1576 | } |
annieluo2 | 0:d6c9b09b4042 | 1577 | |
annieluo2 | 0:d6c9b09b4042 | 1578 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1579 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1580 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1581 | */ |
annieluo2 | 0:d6c9b09b4042 | 1582 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1583 | Callback(R (*func)(const T*, A0, A1), const T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1584 | generate(function_context<R (*)(const T*, A0, A1), const T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 1585 | } |
annieluo2 | 0:d6c9b09b4042 | 1586 | |
annieluo2 | 0:d6c9b09b4042 | 1587 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1588 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1589 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1590 | */ |
annieluo2 | 0:d6c9b09b4042 | 1591 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1592 | Callback(R (*func)(volatile T*, A0, A1), volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1593 | generate(function_context<R (*)(volatile T*, A0, A1), volatile T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 1594 | } |
annieluo2 | 0:d6c9b09b4042 | 1595 | |
annieluo2 | 0:d6c9b09b4042 | 1596 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1597 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1598 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1599 | */ |
annieluo2 | 0:d6c9b09b4042 | 1600 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1601 | Callback(R (*func)(const volatile T*, A0, A1), const volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1602 | generate(function_context<R (*)(const volatile T*, A0, A1), const volatile T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 1603 | } |
annieluo2 | 0:d6c9b09b4042 | 1604 | |
annieluo2 | 0:d6c9b09b4042 | 1605 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 1606 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 1607 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 1608 | */ |
annieluo2 | 0:d6c9b09b4042 | 1609 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 1610 | Callback(F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 1611 | detail::is_type<R (F::*)(A0, A1), &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 1612 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 1613 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 1614 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 1615 | } |
annieluo2 | 0:d6c9b09b4042 | 1616 | |
annieluo2 | 0:d6c9b09b4042 | 1617 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 1618 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 1619 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 1620 | */ |
annieluo2 | 0:d6c9b09b4042 | 1621 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 1622 | Callback(const F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 1623 | detail::is_type<R (F::*)(A0, A1) const, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 1624 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 1625 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 1626 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 1627 | } |
annieluo2 | 0:d6c9b09b4042 | 1628 | |
annieluo2 | 0:d6c9b09b4042 | 1629 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 1630 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 1631 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 1632 | */ |
annieluo2 | 0:d6c9b09b4042 | 1633 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 1634 | Callback(volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 1635 | detail::is_type<R (F::*)(A0, A1) volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 1636 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 1637 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 1638 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 1639 | } |
annieluo2 | 0:d6c9b09b4042 | 1640 | |
annieluo2 | 0:d6c9b09b4042 | 1641 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 1642 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 1643 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 1644 | */ |
annieluo2 | 0:d6c9b09b4042 | 1645 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 1646 | Callback(const volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 1647 | detail::is_type<R (F::*)(A0, A1) const volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 1648 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 1649 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 1650 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 1651 | } |
annieluo2 | 0:d6c9b09b4042 | 1652 | |
annieluo2 | 0:d6c9b09b4042 | 1653 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1654 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1655 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1656 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1657 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1658 | */ |
annieluo2 | 0:d6c9b09b4042 | 1659 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1660 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1661 | Callback(void *obj, R (*func)(void*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 1662 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1663 | } |
annieluo2 | 0:d6c9b09b4042 | 1664 | |
annieluo2 | 0:d6c9b09b4042 | 1665 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1666 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1667 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1668 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1669 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1670 | */ |
annieluo2 | 0:d6c9b09b4042 | 1671 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1672 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1673 | Callback(const void *obj, R (*func)(const void*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 1674 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1675 | } |
annieluo2 | 0:d6c9b09b4042 | 1676 | |
annieluo2 | 0:d6c9b09b4042 | 1677 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1678 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1679 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1680 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1681 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1682 | */ |
annieluo2 | 0:d6c9b09b4042 | 1683 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1684 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1685 | Callback(volatile void *obj, R (*func)(volatile void*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 1686 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1687 | } |
annieluo2 | 0:d6c9b09b4042 | 1688 | |
annieluo2 | 0:d6c9b09b4042 | 1689 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1690 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1691 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1692 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1693 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1694 | */ |
annieluo2 | 0:d6c9b09b4042 | 1695 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1696 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1697 | Callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 1698 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1699 | } |
annieluo2 | 0:d6c9b09b4042 | 1700 | |
annieluo2 | 0:d6c9b09b4042 | 1701 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1702 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1703 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1704 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1705 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1706 | */ |
annieluo2 | 0:d6c9b09b4042 | 1707 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1708 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1709 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1710 | Callback(T *obj, R (*func)(T*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 1711 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1712 | } |
annieluo2 | 0:d6c9b09b4042 | 1713 | |
annieluo2 | 0:d6c9b09b4042 | 1714 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1715 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1716 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1717 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1718 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1719 | */ |
annieluo2 | 0:d6c9b09b4042 | 1720 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1721 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1722 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1723 | Callback(const T *obj, R (*func)(const T*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 1724 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1725 | } |
annieluo2 | 0:d6c9b09b4042 | 1726 | |
annieluo2 | 0:d6c9b09b4042 | 1727 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1728 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1729 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1730 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1731 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1732 | */ |
annieluo2 | 0:d6c9b09b4042 | 1733 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1734 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1735 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1736 | Callback(volatile T *obj, R (*func)(volatile T*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 1737 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1738 | } |
annieluo2 | 0:d6c9b09b4042 | 1739 | |
annieluo2 | 0:d6c9b09b4042 | 1740 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1741 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1742 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1743 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1744 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1745 | */ |
annieluo2 | 0:d6c9b09b4042 | 1746 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1747 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1748 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1749 | Callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 1750 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1751 | } |
annieluo2 | 0:d6c9b09b4042 | 1752 | |
annieluo2 | 0:d6c9b09b4042 | 1753 | /** Destroy a callback |
annieluo2 | 0:d6c9b09b4042 | 1754 | */ |
annieluo2 | 0:d6c9b09b4042 | 1755 | ~Callback() { |
annieluo2 | 0:d6c9b09b4042 | 1756 | if (_ops) { |
annieluo2 | 0:d6c9b09b4042 | 1757 | _ops->dtor(this); |
annieluo2 | 0:d6c9b09b4042 | 1758 | } |
annieluo2 | 0:d6c9b09b4042 | 1759 | } |
annieluo2 | 0:d6c9b09b4042 | 1760 | |
annieluo2 | 0:d6c9b09b4042 | 1761 | /** Attach a static function |
annieluo2 | 0:d6c9b09b4042 | 1762 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1763 | */ |
annieluo2 | 0:d6c9b09b4042 | 1764 | void attach(R (*func)(A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 1765 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1766 | new (this) Callback(func); |
annieluo2 | 0:d6c9b09b4042 | 1767 | } |
annieluo2 | 0:d6c9b09b4042 | 1768 | |
annieluo2 | 0:d6c9b09b4042 | 1769 | /** Attach a Callback |
annieluo2 | 0:d6c9b09b4042 | 1770 | * @param func The Callback to attach |
annieluo2 | 0:d6c9b09b4042 | 1771 | */ |
annieluo2 | 0:d6c9b09b4042 | 1772 | void attach(const Callback<R(A0, A1)> &func) { |
annieluo2 | 0:d6c9b09b4042 | 1773 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1774 | new (this) Callback(func); |
annieluo2 | 0:d6c9b09b4042 | 1775 | } |
annieluo2 | 0:d6c9b09b4042 | 1776 | |
annieluo2 | 0:d6c9b09b4042 | 1777 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 1778 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 1779 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 1780 | */ |
annieluo2 | 0:d6c9b09b4042 | 1781 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1782 | void attach(T *obj, R (T::*method)(A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 1783 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1784 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 1785 | } |
annieluo2 | 0:d6c9b09b4042 | 1786 | |
annieluo2 | 0:d6c9b09b4042 | 1787 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 1788 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 1789 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 1790 | */ |
annieluo2 | 0:d6c9b09b4042 | 1791 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1792 | void attach(const T *obj, R (T::*method)(A0, A1) const) { |
annieluo2 | 0:d6c9b09b4042 | 1793 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1794 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 1795 | } |
annieluo2 | 0:d6c9b09b4042 | 1796 | |
annieluo2 | 0:d6c9b09b4042 | 1797 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 1798 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 1799 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 1800 | */ |
annieluo2 | 0:d6c9b09b4042 | 1801 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1802 | void attach(volatile T *obj, R (T::*method)(A0, A1) volatile) { |
annieluo2 | 0:d6c9b09b4042 | 1803 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1804 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 1805 | } |
annieluo2 | 0:d6c9b09b4042 | 1806 | |
annieluo2 | 0:d6c9b09b4042 | 1807 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 1808 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 1809 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 1810 | */ |
annieluo2 | 0:d6c9b09b4042 | 1811 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 1812 | void attach(const volatile T *obj, R (T::*method)(A0, A1) const volatile) { |
annieluo2 | 0:d6c9b09b4042 | 1813 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1814 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 1815 | } |
annieluo2 | 0:d6c9b09b4042 | 1816 | |
annieluo2 | 0:d6c9b09b4042 | 1817 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1818 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1819 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1820 | */ |
annieluo2 | 0:d6c9b09b4042 | 1821 | void attach(R (*func)(void*, A0, A1), void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1822 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1823 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 1824 | } |
annieluo2 | 0:d6c9b09b4042 | 1825 | |
annieluo2 | 0:d6c9b09b4042 | 1826 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1827 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1828 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1829 | */ |
annieluo2 | 0:d6c9b09b4042 | 1830 | void attach(R (*func)(const void*, A0, A1), const void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1831 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1832 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 1833 | } |
annieluo2 | 0:d6c9b09b4042 | 1834 | |
annieluo2 | 0:d6c9b09b4042 | 1835 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1836 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1837 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1838 | */ |
annieluo2 | 0:d6c9b09b4042 | 1839 | void attach(R (*func)(volatile void*, A0, A1), volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1840 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1841 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 1842 | } |
annieluo2 | 0:d6c9b09b4042 | 1843 | |
annieluo2 | 0:d6c9b09b4042 | 1844 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1845 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1846 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1847 | */ |
annieluo2 | 0:d6c9b09b4042 | 1848 | void attach(R (*func)(const volatile void*, A0, A1), const volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1849 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1850 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 1851 | } |
annieluo2 | 0:d6c9b09b4042 | 1852 | |
annieluo2 | 0:d6c9b09b4042 | 1853 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1854 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1855 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1856 | */ |
annieluo2 | 0:d6c9b09b4042 | 1857 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 1858 | void attach(R (*func)(T*, A0, A1), T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1859 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1860 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 1861 | } |
annieluo2 | 0:d6c9b09b4042 | 1862 | |
annieluo2 | 0:d6c9b09b4042 | 1863 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1864 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1865 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1866 | */ |
annieluo2 | 0:d6c9b09b4042 | 1867 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 1868 | void attach(R (*func)(const T*, A0, A1), const T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1869 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1870 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 1871 | } |
annieluo2 | 0:d6c9b09b4042 | 1872 | |
annieluo2 | 0:d6c9b09b4042 | 1873 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1874 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1875 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1876 | */ |
annieluo2 | 0:d6c9b09b4042 | 1877 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 1878 | void attach(R (*func)(volatile T*, A0, A1), volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1879 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1880 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 1881 | } |
annieluo2 | 0:d6c9b09b4042 | 1882 | |
annieluo2 | 0:d6c9b09b4042 | 1883 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1884 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1885 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 1886 | */ |
annieluo2 | 0:d6c9b09b4042 | 1887 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 1888 | void attach(R (*func)(const volatile T*, A0, A1), const volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 1889 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1890 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 1891 | } |
annieluo2 | 0:d6c9b09b4042 | 1892 | |
annieluo2 | 0:d6c9b09b4042 | 1893 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 1894 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 1895 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 1896 | */ |
annieluo2 | 0:d6c9b09b4042 | 1897 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 1898 | void attach(F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 1899 | detail::is_type<R (F::*)(A0, A1), &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 1900 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 1901 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 1902 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1903 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 1904 | } |
annieluo2 | 0:d6c9b09b4042 | 1905 | |
annieluo2 | 0:d6c9b09b4042 | 1906 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 1907 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 1908 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 1909 | */ |
annieluo2 | 0:d6c9b09b4042 | 1910 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 1911 | void attach(const F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 1912 | detail::is_type<R (F::*)(A0, A1) const, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 1913 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 1914 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 1915 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1916 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 1917 | } |
annieluo2 | 0:d6c9b09b4042 | 1918 | |
annieluo2 | 0:d6c9b09b4042 | 1919 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 1920 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 1921 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 1922 | */ |
annieluo2 | 0:d6c9b09b4042 | 1923 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 1924 | void attach(volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 1925 | detail::is_type<R (F::*)(A0, A1) volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 1926 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 1927 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 1928 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1929 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 1930 | } |
annieluo2 | 0:d6c9b09b4042 | 1931 | |
annieluo2 | 0:d6c9b09b4042 | 1932 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 1933 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 1934 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 1935 | */ |
annieluo2 | 0:d6c9b09b4042 | 1936 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 1937 | void attach(const volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 1938 | detail::is_type<R (F::*)(A0, A1) const volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 1939 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 1940 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 1941 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1942 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 1943 | } |
annieluo2 | 0:d6c9b09b4042 | 1944 | |
annieluo2 | 0:d6c9b09b4042 | 1945 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1946 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1947 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1948 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1949 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1950 | */ |
annieluo2 | 0:d6c9b09b4042 | 1951 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1952 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1953 | void attach(void *obj, R (*func)(void*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 1954 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1955 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1956 | } |
annieluo2 | 0:d6c9b09b4042 | 1957 | |
annieluo2 | 0:d6c9b09b4042 | 1958 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1959 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1960 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1961 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1962 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1963 | */ |
annieluo2 | 0:d6c9b09b4042 | 1964 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1965 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1966 | void attach(const void *obj, R (*func)(const void*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 1967 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1968 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1969 | } |
annieluo2 | 0:d6c9b09b4042 | 1970 | |
annieluo2 | 0:d6c9b09b4042 | 1971 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1972 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1973 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1974 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1975 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1976 | */ |
annieluo2 | 0:d6c9b09b4042 | 1977 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1978 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1979 | void attach(volatile void *obj, R (*func)(volatile void*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 1980 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1981 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1982 | } |
annieluo2 | 0:d6c9b09b4042 | 1983 | |
annieluo2 | 0:d6c9b09b4042 | 1984 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1985 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1986 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 1987 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 1988 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 1989 | */ |
annieluo2 | 0:d6c9b09b4042 | 1990 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 1991 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 1992 | void attach(const volatile void *obj, R (*func)(const volatile void*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 1993 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 1994 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 1995 | } |
annieluo2 | 0:d6c9b09b4042 | 1996 | |
annieluo2 | 0:d6c9b09b4042 | 1997 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 1998 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 1999 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2000 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 2001 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 2002 | */ |
annieluo2 | 0:d6c9b09b4042 | 2003 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 2004 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 2005 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 2006 | void attach(T *obj, R (*func)(T*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 2007 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2008 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 2009 | } |
annieluo2 | 0:d6c9b09b4042 | 2010 | |
annieluo2 | 0:d6c9b09b4042 | 2011 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2012 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 2013 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2014 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 2015 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 2016 | */ |
annieluo2 | 0:d6c9b09b4042 | 2017 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 2018 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 2019 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 2020 | void attach(const T *obj, R (*func)(const T*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 2021 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2022 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 2023 | } |
annieluo2 | 0:d6c9b09b4042 | 2024 | |
annieluo2 | 0:d6c9b09b4042 | 2025 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2026 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 2027 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2028 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 2029 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 2030 | */ |
annieluo2 | 0:d6c9b09b4042 | 2031 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 2032 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 2033 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 2034 | void attach(volatile T *obj, R (*func)(volatile T*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 2035 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2036 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 2037 | } |
annieluo2 | 0:d6c9b09b4042 | 2038 | |
annieluo2 | 0:d6c9b09b4042 | 2039 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2040 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 2041 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2042 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 2043 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 2044 | */ |
annieluo2 | 0:d6c9b09b4042 | 2045 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 2046 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 2047 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 2048 | void attach(const volatile T *obj, R (*func)(const volatile T*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 2049 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2050 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 2051 | } |
annieluo2 | 0:d6c9b09b4042 | 2052 | |
annieluo2 | 0:d6c9b09b4042 | 2053 | /** Assign a callback |
annieluo2 | 0:d6c9b09b4042 | 2054 | */ |
annieluo2 | 0:d6c9b09b4042 | 2055 | Callback &operator=(const Callback &that) { |
annieluo2 | 0:d6c9b09b4042 | 2056 | if (this != &that) { |
annieluo2 | 0:d6c9b09b4042 | 2057 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2058 | new (this) Callback(that); |
annieluo2 | 0:d6c9b09b4042 | 2059 | } |
annieluo2 | 0:d6c9b09b4042 | 2060 | |
annieluo2 | 0:d6c9b09b4042 | 2061 | return *this; |
annieluo2 | 0:d6c9b09b4042 | 2062 | } |
annieluo2 | 0:d6c9b09b4042 | 2063 | |
annieluo2 | 0:d6c9b09b4042 | 2064 | /** Call the attached function |
annieluo2 | 0:d6c9b09b4042 | 2065 | */ |
annieluo2 | 0:d6c9b09b4042 | 2066 | R call(A0 a0, A1 a1) const { |
annieluo2 | 0:d6c9b09b4042 | 2067 | MBED_ASSERT(_ops); |
annieluo2 | 0:d6c9b09b4042 | 2068 | return _ops->call(this, a0, a1); |
annieluo2 | 0:d6c9b09b4042 | 2069 | } |
annieluo2 | 0:d6c9b09b4042 | 2070 | |
annieluo2 | 0:d6c9b09b4042 | 2071 | /** Call the attached function |
annieluo2 | 0:d6c9b09b4042 | 2072 | */ |
annieluo2 | 0:d6c9b09b4042 | 2073 | R operator()(A0 a0, A1 a1) const { |
annieluo2 | 0:d6c9b09b4042 | 2074 | return call(a0, a1); |
annieluo2 | 0:d6c9b09b4042 | 2075 | } |
annieluo2 | 0:d6c9b09b4042 | 2076 | |
annieluo2 | 0:d6c9b09b4042 | 2077 | /** Test if function has been attached |
annieluo2 | 0:d6c9b09b4042 | 2078 | */ |
annieluo2 | 0:d6c9b09b4042 | 2079 | operator bool() const { |
annieluo2 | 0:d6c9b09b4042 | 2080 | return _ops; |
annieluo2 | 0:d6c9b09b4042 | 2081 | } |
annieluo2 | 0:d6c9b09b4042 | 2082 | |
annieluo2 | 0:d6c9b09b4042 | 2083 | /** Test for equality |
annieluo2 | 0:d6c9b09b4042 | 2084 | */ |
annieluo2 | 0:d6c9b09b4042 | 2085 | friend bool operator==(const Callback &l, const Callback &r) { |
annieluo2 | 0:d6c9b09b4042 | 2086 | return memcmp(&l, &r, sizeof(Callback)) == 0; |
annieluo2 | 0:d6c9b09b4042 | 2087 | } |
annieluo2 | 0:d6c9b09b4042 | 2088 | |
annieluo2 | 0:d6c9b09b4042 | 2089 | /** Test for inequality |
annieluo2 | 0:d6c9b09b4042 | 2090 | */ |
annieluo2 | 0:d6c9b09b4042 | 2091 | friend bool operator!=(const Callback &l, const Callback &r) { |
annieluo2 | 0:d6c9b09b4042 | 2092 | return !(l == r); |
annieluo2 | 0:d6c9b09b4042 | 2093 | } |
annieluo2 | 0:d6c9b09b4042 | 2094 | |
annieluo2 | 0:d6c9b09b4042 | 2095 | /** Static thunk for passing as C-style function |
annieluo2 | 0:d6c9b09b4042 | 2096 | * @param func Callback to call passed as void pointer |
annieluo2 | 0:d6c9b09b4042 | 2097 | */ |
annieluo2 | 0:d6c9b09b4042 | 2098 | static R thunk(void *func, A0 a0, A1 a1) { |
annieluo2 | 0:d6c9b09b4042 | 2099 | return static_cast<Callback*>(func)->call(a0, a1); |
annieluo2 | 0:d6c9b09b4042 | 2100 | } |
annieluo2 | 0:d6c9b09b4042 | 2101 | |
annieluo2 | 0:d6c9b09b4042 | 2102 | private: |
annieluo2 | 0:d6c9b09b4042 | 2103 | // Stored as pointer to function and pointer to optional object |
annieluo2 | 0:d6c9b09b4042 | 2104 | // Function pointer is stored as union of possible function types |
annieluo2 | 0:d6c9b09b4042 | 2105 | // to garuntee proper size and alignment |
annieluo2 | 0:d6c9b09b4042 | 2106 | struct _class; |
annieluo2 | 0:d6c9b09b4042 | 2107 | union { |
annieluo2 | 0:d6c9b09b4042 | 2108 | void (*_staticfunc)(A0, A1); |
annieluo2 | 0:d6c9b09b4042 | 2109 | void (*_boundfunc)(_class*, A0, A1); |
annieluo2 | 0:d6c9b09b4042 | 2110 | void (_class::*_methodfunc)(A0, A1); |
annieluo2 | 0:d6c9b09b4042 | 2111 | } _func; |
annieluo2 | 0:d6c9b09b4042 | 2112 | void *_obj; |
annieluo2 | 0:d6c9b09b4042 | 2113 | |
annieluo2 | 0:d6c9b09b4042 | 2114 | // Dynamically dispatched operations |
annieluo2 | 0:d6c9b09b4042 | 2115 | const struct ops { |
annieluo2 | 0:d6c9b09b4042 | 2116 | R (*call)(const void*, A0, A1); |
annieluo2 | 0:d6c9b09b4042 | 2117 | void (*move)(void*, const void*); |
annieluo2 | 0:d6c9b09b4042 | 2118 | void (*dtor)(void*); |
annieluo2 | 0:d6c9b09b4042 | 2119 | } *_ops; |
annieluo2 | 0:d6c9b09b4042 | 2120 | |
annieluo2 | 0:d6c9b09b4042 | 2121 | // Generate operations for function object |
annieluo2 | 0:d6c9b09b4042 | 2122 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 2123 | void generate(const F &f) { |
annieluo2 | 0:d6c9b09b4042 | 2124 | static const ops ops = { |
annieluo2 | 0:d6c9b09b4042 | 2125 | &Callback::function_call<F>, |
annieluo2 | 0:d6c9b09b4042 | 2126 | &Callback::function_move<F>, |
annieluo2 | 0:d6c9b09b4042 | 2127 | &Callback::function_dtor<F>, |
annieluo2 | 0:d6c9b09b4042 | 2128 | }; |
annieluo2 | 0:d6c9b09b4042 | 2129 | |
annieluo2 | 0:d6c9b09b4042 | 2130 | MBED_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F)); |
annieluo2 | 0:d6c9b09b4042 | 2131 | new (this) F(f); |
annieluo2 | 0:d6c9b09b4042 | 2132 | _ops = &ops; |
annieluo2 | 0:d6c9b09b4042 | 2133 | } |
annieluo2 | 0:d6c9b09b4042 | 2134 | |
annieluo2 | 0:d6c9b09b4042 | 2135 | // Function attributes |
annieluo2 | 0:d6c9b09b4042 | 2136 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 2137 | static R function_call(const void *p, A0 a0, A1 a1) { |
annieluo2 | 0:d6c9b09b4042 | 2138 | return (*(F*)p)(a0, a1); |
annieluo2 | 0:d6c9b09b4042 | 2139 | } |
annieluo2 | 0:d6c9b09b4042 | 2140 | |
annieluo2 | 0:d6c9b09b4042 | 2141 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 2142 | static void function_move(void *d, const void *p) { |
annieluo2 | 0:d6c9b09b4042 | 2143 | new (d) F(*(F*)p); |
annieluo2 | 0:d6c9b09b4042 | 2144 | } |
annieluo2 | 0:d6c9b09b4042 | 2145 | |
annieluo2 | 0:d6c9b09b4042 | 2146 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 2147 | static void function_dtor(void *p) { |
annieluo2 | 0:d6c9b09b4042 | 2148 | ((F*)p)->~F(); |
annieluo2 | 0:d6c9b09b4042 | 2149 | } |
annieluo2 | 0:d6c9b09b4042 | 2150 | |
annieluo2 | 0:d6c9b09b4042 | 2151 | // Wrappers for functions with context |
annieluo2 | 0:d6c9b09b4042 | 2152 | template <typename O, typename M> |
annieluo2 | 0:d6c9b09b4042 | 2153 | struct method_context { |
annieluo2 | 0:d6c9b09b4042 | 2154 | M method; |
annieluo2 | 0:d6c9b09b4042 | 2155 | O *obj; |
annieluo2 | 0:d6c9b09b4042 | 2156 | |
annieluo2 | 0:d6c9b09b4042 | 2157 | method_context(O *obj, M method) |
annieluo2 | 0:d6c9b09b4042 | 2158 | : method(method), obj(obj) {} |
annieluo2 | 0:d6c9b09b4042 | 2159 | |
annieluo2 | 0:d6c9b09b4042 | 2160 | R operator()(A0 a0, A1 a1) const { |
annieluo2 | 0:d6c9b09b4042 | 2161 | return (obj->*method)(a0, a1); |
annieluo2 | 0:d6c9b09b4042 | 2162 | } |
annieluo2 | 0:d6c9b09b4042 | 2163 | }; |
annieluo2 | 0:d6c9b09b4042 | 2164 | |
annieluo2 | 0:d6c9b09b4042 | 2165 | template <typename F, typename A> |
annieluo2 | 0:d6c9b09b4042 | 2166 | struct function_context { |
annieluo2 | 0:d6c9b09b4042 | 2167 | F func; |
annieluo2 | 0:d6c9b09b4042 | 2168 | A *arg; |
annieluo2 | 0:d6c9b09b4042 | 2169 | |
annieluo2 | 0:d6c9b09b4042 | 2170 | function_context(F func, A *arg) |
annieluo2 | 0:d6c9b09b4042 | 2171 | : func(func), arg(arg) {} |
annieluo2 | 0:d6c9b09b4042 | 2172 | |
annieluo2 | 0:d6c9b09b4042 | 2173 | R operator()(A0 a0, A1 a1) const { |
annieluo2 | 0:d6c9b09b4042 | 2174 | return func(arg, a0, a1); |
annieluo2 | 0:d6c9b09b4042 | 2175 | } |
annieluo2 | 0:d6c9b09b4042 | 2176 | }; |
annieluo2 | 0:d6c9b09b4042 | 2177 | }; |
annieluo2 | 0:d6c9b09b4042 | 2178 | |
annieluo2 | 0:d6c9b09b4042 | 2179 | /** Callback class based on template specialization |
annieluo2 | 0:d6c9b09b4042 | 2180 | * |
annieluo2 | 0:d6c9b09b4042 | 2181 | * @Note Synchronization level: Not protected |
annieluo2 | 0:d6c9b09b4042 | 2182 | */ |
annieluo2 | 0:d6c9b09b4042 | 2183 | template <typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 2184 | class Callback<R(A0, A1, A2)> { |
annieluo2 | 0:d6c9b09b4042 | 2185 | public: |
annieluo2 | 0:d6c9b09b4042 | 2186 | /** Create a Callback with a static function |
annieluo2 | 0:d6c9b09b4042 | 2187 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2188 | */ |
annieluo2 | 0:d6c9b09b4042 | 2189 | Callback(R (*func)(A0, A1, A2) = 0) { |
annieluo2 | 0:d6c9b09b4042 | 2190 | if (!func) { |
annieluo2 | 0:d6c9b09b4042 | 2191 | _ops = 0; |
annieluo2 | 0:d6c9b09b4042 | 2192 | } else { |
annieluo2 | 0:d6c9b09b4042 | 2193 | generate(func); |
annieluo2 | 0:d6c9b09b4042 | 2194 | } |
annieluo2 | 0:d6c9b09b4042 | 2195 | } |
annieluo2 | 0:d6c9b09b4042 | 2196 | |
annieluo2 | 0:d6c9b09b4042 | 2197 | /** Attach a Callback |
annieluo2 | 0:d6c9b09b4042 | 2198 | * @param func The Callback to attach |
annieluo2 | 0:d6c9b09b4042 | 2199 | */ |
annieluo2 | 0:d6c9b09b4042 | 2200 | Callback(const Callback<R(A0, A1, A2)> &func) { |
annieluo2 | 0:d6c9b09b4042 | 2201 | if (func._ops) { |
annieluo2 | 0:d6c9b09b4042 | 2202 | func._ops->move(this, &func); |
annieluo2 | 0:d6c9b09b4042 | 2203 | } |
annieluo2 | 0:d6c9b09b4042 | 2204 | _ops = func._ops; |
annieluo2 | 0:d6c9b09b4042 | 2205 | } |
annieluo2 | 0:d6c9b09b4042 | 2206 | |
annieluo2 | 0:d6c9b09b4042 | 2207 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 2208 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 2209 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 2210 | */ |
annieluo2 | 0:d6c9b09b4042 | 2211 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 2212 | Callback(T *obj, R (T::*method)(A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 2213 | generate(method_context<T, R (T::*)(A0, A1, A2)>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 2214 | } |
annieluo2 | 0:d6c9b09b4042 | 2215 | |
annieluo2 | 0:d6c9b09b4042 | 2216 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 2217 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 2218 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 2219 | */ |
annieluo2 | 0:d6c9b09b4042 | 2220 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 2221 | Callback(const T *obj, R (T::*method)(A0, A1, A2) const) { |
annieluo2 | 0:d6c9b09b4042 | 2222 | generate(method_context<const T, R (T::*)(A0, A1, A2) const>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 2223 | } |
annieluo2 | 0:d6c9b09b4042 | 2224 | |
annieluo2 | 0:d6c9b09b4042 | 2225 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 2226 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 2227 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 2228 | */ |
annieluo2 | 0:d6c9b09b4042 | 2229 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 2230 | Callback(volatile T *obj, R (T::*method)(A0, A1, A2) volatile) { |
annieluo2 | 0:d6c9b09b4042 | 2231 | generate(method_context<volatile T, R (T::*)(A0, A1, A2) volatile>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 2232 | } |
annieluo2 | 0:d6c9b09b4042 | 2233 | |
annieluo2 | 0:d6c9b09b4042 | 2234 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 2235 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 2236 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 2237 | */ |
annieluo2 | 0:d6c9b09b4042 | 2238 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 2239 | Callback(const volatile T *obj, R (T::*method)(A0, A1, A2) const volatile) { |
annieluo2 | 0:d6c9b09b4042 | 2240 | generate(method_context<const volatile T, R (T::*)(A0, A1, A2) const volatile>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 2241 | } |
annieluo2 | 0:d6c9b09b4042 | 2242 | |
annieluo2 | 0:d6c9b09b4042 | 2243 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2244 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2245 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 2246 | */ |
annieluo2 | 0:d6c9b09b4042 | 2247 | Callback(R (*func)(void*, A0, A1, A2), void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 2248 | generate(function_context<R (*)(void*, A0, A1, A2), void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 2249 | } |
annieluo2 | 0:d6c9b09b4042 | 2250 | |
annieluo2 | 0:d6c9b09b4042 | 2251 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2252 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2253 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 2254 | */ |
annieluo2 | 0:d6c9b09b4042 | 2255 | Callback(R (*func)(const void*, A0, A1, A2), const void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 2256 | generate(function_context<R (*)(const void*, A0, A1, A2), const void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 2257 | } |
annieluo2 | 0:d6c9b09b4042 | 2258 | |
annieluo2 | 0:d6c9b09b4042 | 2259 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2260 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2261 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 2262 | */ |
annieluo2 | 0:d6c9b09b4042 | 2263 | Callback(R (*func)(volatile void*, A0, A1, A2), volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 2264 | generate(function_context<R (*)(volatile void*, A0, A1, A2), volatile void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 2265 | } |
annieluo2 | 0:d6c9b09b4042 | 2266 | |
annieluo2 | 0:d6c9b09b4042 | 2267 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2268 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2269 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 2270 | */ |
annieluo2 | 0:d6c9b09b4042 | 2271 | Callback(R (*func)(const volatile void*, A0, A1, A2), const volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 2272 | generate(function_context<R (*)(const volatile void*, A0, A1, A2), const volatile void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 2273 | } |
annieluo2 | 0:d6c9b09b4042 | 2274 | |
annieluo2 | 0:d6c9b09b4042 | 2275 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2276 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2277 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 2278 | */ |
annieluo2 | 0:d6c9b09b4042 | 2279 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 2280 | Callback(R (*func)(T*, A0, A1, A2), T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 2281 | generate(function_context<R (*)(T*, A0, A1, A2), T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 2282 | } |
annieluo2 | 0:d6c9b09b4042 | 2283 | |
annieluo2 | 0:d6c9b09b4042 | 2284 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2285 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2286 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 2287 | */ |
annieluo2 | 0:d6c9b09b4042 | 2288 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 2289 | Callback(R (*func)(const T*, A0, A1, A2), const T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 2290 | generate(function_context<R (*)(const T*, A0, A1, A2), const T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 2291 | } |
annieluo2 | 0:d6c9b09b4042 | 2292 | |
annieluo2 | 0:d6c9b09b4042 | 2293 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2294 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2295 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 2296 | */ |
annieluo2 | 0:d6c9b09b4042 | 2297 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 2298 | Callback(R (*func)(volatile T*, A0, A1, A2), volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 2299 | generate(function_context<R (*)(volatile T*, A0, A1, A2), volatile T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 2300 | } |
annieluo2 | 0:d6c9b09b4042 | 2301 | |
annieluo2 | 0:d6c9b09b4042 | 2302 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2303 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2304 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 2305 | */ |
annieluo2 | 0:d6c9b09b4042 | 2306 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 2307 | Callback(R (*func)(const volatile T*, A0, A1, A2), const volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 2308 | generate(function_context<R (*)(const volatile T*, A0, A1, A2), const volatile T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 2309 | } |
annieluo2 | 0:d6c9b09b4042 | 2310 | |
annieluo2 | 0:d6c9b09b4042 | 2311 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 2312 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 2313 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 2314 | */ |
annieluo2 | 0:d6c9b09b4042 | 2315 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 2316 | Callback(F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 2317 | detail::is_type<R (F::*)(A0, A1, A2), &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 2318 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 2319 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 2320 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 2321 | } |
annieluo2 | 0:d6c9b09b4042 | 2322 | |
annieluo2 | 0:d6c9b09b4042 | 2323 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 2324 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 2325 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 2326 | */ |
annieluo2 | 0:d6c9b09b4042 | 2327 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 2328 | Callback(const F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 2329 | detail::is_type<R (F::*)(A0, A1, A2) const, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 2330 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 2331 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 2332 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 2333 | } |
annieluo2 | 0:d6c9b09b4042 | 2334 | |
annieluo2 | 0:d6c9b09b4042 | 2335 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 2336 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 2337 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 2338 | */ |
annieluo2 | 0:d6c9b09b4042 | 2339 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 2340 | Callback(volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 2341 | detail::is_type<R (F::*)(A0, A1, A2) volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 2342 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 2343 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 2344 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 2345 | } |
annieluo2 | 0:d6c9b09b4042 | 2346 | |
annieluo2 | 0:d6c9b09b4042 | 2347 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 2348 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 2349 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 2350 | */ |
annieluo2 | 0:d6c9b09b4042 | 2351 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 2352 | Callback(const volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 2353 | detail::is_type<R (F::*)(A0, A1, A2) const volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 2354 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 2355 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 2356 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 2357 | } |
annieluo2 | 0:d6c9b09b4042 | 2358 | |
annieluo2 | 0:d6c9b09b4042 | 2359 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2360 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 2361 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2362 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 2363 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 2364 | */ |
annieluo2 | 0:d6c9b09b4042 | 2365 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 2366 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 2367 | Callback(void *obj, R (*func)(void*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 2368 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 2369 | } |
annieluo2 | 0:d6c9b09b4042 | 2370 | |
annieluo2 | 0:d6c9b09b4042 | 2371 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2372 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 2373 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2374 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 2375 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 2376 | */ |
annieluo2 | 0:d6c9b09b4042 | 2377 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 2378 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 2379 | Callback(const void *obj, R (*func)(const void*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 2380 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 2381 | } |
annieluo2 | 0:d6c9b09b4042 | 2382 | |
annieluo2 | 0:d6c9b09b4042 | 2383 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2384 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 2385 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2386 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 2387 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 2388 | */ |
annieluo2 | 0:d6c9b09b4042 | 2389 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 2390 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 2391 | Callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 2392 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 2393 | } |
annieluo2 | 0:d6c9b09b4042 | 2394 | |
annieluo2 | 0:d6c9b09b4042 | 2395 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2396 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 2397 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2398 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 2399 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 2400 | */ |
annieluo2 | 0:d6c9b09b4042 | 2401 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 2402 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 2403 | Callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 2404 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 2405 | } |
annieluo2 | 0:d6c9b09b4042 | 2406 | |
annieluo2 | 0:d6c9b09b4042 | 2407 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2408 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 2409 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2410 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 2411 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 2412 | */ |
annieluo2 | 0:d6c9b09b4042 | 2413 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 2414 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 2415 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 2416 | Callback(T *obj, R (*func)(T*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 2417 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 2418 | } |
annieluo2 | 0:d6c9b09b4042 | 2419 | |
annieluo2 | 0:d6c9b09b4042 | 2420 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2421 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 2422 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2423 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 2424 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 2425 | */ |
annieluo2 | 0:d6c9b09b4042 | 2426 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 2427 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 2428 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 2429 | Callback(const T *obj, R (*func)(const T*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 2430 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 2431 | } |
annieluo2 | 0:d6c9b09b4042 | 2432 | |
annieluo2 | 0:d6c9b09b4042 | 2433 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2434 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 2435 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2436 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 2437 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 2438 | */ |
annieluo2 | 0:d6c9b09b4042 | 2439 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 2440 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 2441 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 2442 | Callback(volatile T *obj, R (*func)(volatile T*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 2443 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 2444 | } |
annieluo2 | 0:d6c9b09b4042 | 2445 | |
annieluo2 | 0:d6c9b09b4042 | 2446 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2447 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 2448 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2449 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 2450 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 2451 | */ |
annieluo2 | 0:d6c9b09b4042 | 2452 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 2453 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 2454 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 2455 | Callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 2456 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 2457 | } |
annieluo2 | 0:d6c9b09b4042 | 2458 | |
annieluo2 | 0:d6c9b09b4042 | 2459 | /** Destroy a callback |
annieluo2 | 0:d6c9b09b4042 | 2460 | */ |
annieluo2 | 0:d6c9b09b4042 | 2461 | ~Callback() { |
annieluo2 | 0:d6c9b09b4042 | 2462 | if (_ops) { |
annieluo2 | 0:d6c9b09b4042 | 2463 | _ops->dtor(this); |
annieluo2 | 0:d6c9b09b4042 | 2464 | } |
annieluo2 | 0:d6c9b09b4042 | 2465 | } |
annieluo2 | 0:d6c9b09b4042 | 2466 | |
annieluo2 | 0:d6c9b09b4042 | 2467 | /** Attach a static function |
annieluo2 | 0:d6c9b09b4042 | 2468 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2469 | */ |
annieluo2 | 0:d6c9b09b4042 | 2470 | void attach(R (*func)(A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 2471 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2472 | new (this) Callback(func); |
annieluo2 | 0:d6c9b09b4042 | 2473 | } |
annieluo2 | 0:d6c9b09b4042 | 2474 | |
annieluo2 | 0:d6c9b09b4042 | 2475 | /** Attach a Callback |
annieluo2 | 0:d6c9b09b4042 | 2476 | * @param func The Callback to attach |
annieluo2 | 0:d6c9b09b4042 | 2477 | */ |
annieluo2 | 0:d6c9b09b4042 | 2478 | void attach(const Callback<R(A0, A1, A2)> &func) { |
annieluo2 | 0:d6c9b09b4042 | 2479 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2480 | new (this) Callback(func); |
annieluo2 | 0:d6c9b09b4042 | 2481 | } |
annieluo2 | 0:d6c9b09b4042 | 2482 | |
annieluo2 | 0:d6c9b09b4042 | 2483 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 2484 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 2485 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 2486 | */ |
annieluo2 | 0:d6c9b09b4042 | 2487 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 2488 | void attach(T *obj, R (T::*method)(A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 2489 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2490 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 2491 | } |
annieluo2 | 0:d6c9b09b4042 | 2492 | |
annieluo2 | 0:d6c9b09b4042 | 2493 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 2494 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 2495 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 2496 | */ |
annieluo2 | 0:d6c9b09b4042 | 2497 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 2498 | void attach(const T *obj, R (T::*method)(A0, A1, A2) const) { |
annieluo2 | 0:d6c9b09b4042 | 2499 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2500 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 2501 | } |
annieluo2 | 0:d6c9b09b4042 | 2502 | |
annieluo2 | 0:d6c9b09b4042 | 2503 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 2504 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 2505 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 2506 | */ |
annieluo2 | 0:d6c9b09b4042 | 2507 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 2508 | void attach(volatile T *obj, R (T::*method)(A0, A1, A2) volatile) { |
annieluo2 | 0:d6c9b09b4042 | 2509 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2510 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 2511 | } |
annieluo2 | 0:d6c9b09b4042 | 2512 | |
annieluo2 | 0:d6c9b09b4042 | 2513 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 2514 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 2515 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 2516 | */ |
annieluo2 | 0:d6c9b09b4042 | 2517 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 2518 | void attach(const volatile T *obj, R (T::*method)(A0, A1, A2) const volatile) { |
annieluo2 | 0:d6c9b09b4042 | 2519 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2520 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 2521 | } |
annieluo2 | 0:d6c9b09b4042 | 2522 | |
annieluo2 | 0:d6c9b09b4042 | 2523 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2524 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2525 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 2526 | */ |
annieluo2 | 0:d6c9b09b4042 | 2527 | void attach(R (*func)(void*, A0, A1, A2), void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 2528 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2529 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 2530 | } |
annieluo2 | 0:d6c9b09b4042 | 2531 | |
annieluo2 | 0:d6c9b09b4042 | 2532 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2533 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2534 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 2535 | */ |
annieluo2 | 0:d6c9b09b4042 | 2536 | void attach(R (*func)(const void*, A0, A1, A2), const void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 2537 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2538 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 2539 | } |
annieluo2 | 0:d6c9b09b4042 | 2540 | |
annieluo2 | 0:d6c9b09b4042 | 2541 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2542 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2543 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 2544 | */ |
annieluo2 | 0:d6c9b09b4042 | 2545 | void attach(R (*func)(volatile void*, A0, A1, A2), volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 2546 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2547 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 2548 | } |
annieluo2 | 0:d6c9b09b4042 | 2549 | |
annieluo2 | 0:d6c9b09b4042 | 2550 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2551 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2552 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 2553 | */ |
annieluo2 | 0:d6c9b09b4042 | 2554 | void attach(R (*func)(const volatile void*, A0, A1, A2), const volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 2555 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2556 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 2557 | } |
annieluo2 | 0:d6c9b09b4042 | 2558 | |
annieluo2 | 0:d6c9b09b4042 | 2559 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2560 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2561 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 2562 | */ |
annieluo2 | 0:d6c9b09b4042 | 2563 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 2564 | void attach(R (*func)(T*, A0, A1, A2), T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 2565 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2566 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 2567 | } |
annieluo2 | 0:d6c9b09b4042 | 2568 | |
annieluo2 | 0:d6c9b09b4042 | 2569 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2570 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2571 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 2572 | */ |
annieluo2 | 0:d6c9b09b4042 | 2573 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 2574 | void attach(R (*func)(const T*, A0, A1, A2), const T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 2575 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2576 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 2577 | } |
annieluo2 | 0:d6c9b09b4042 | 2578 | |
annieluo2 | 0:d6c9b09b4042 | 2579 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2580 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2581 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 2582 | */ |
annieluo2 | 0:d6c9b09b4042 | 2583 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 2584 | void attach(R (*func)(volatile T*, A0, A1, A2), volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 2585 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2586 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 2587 | } |
annieluo2 | 0:d6c9b09b4042 | 2588 | |
annieluo2 | 0:d6c9b09b4042 | 2589 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2590 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2591 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 2592 | */ |
annieluo2 | 0:d6c9b09b4042 | 2593 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 2594 | void attach(R (*func)(const volatile T*, A0, A1, A2), const volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 2595 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2596 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 2597 | } |
annieluo2 | 0:d6c9b09b4042 | 2598 | |
annieluo2 | 0:d6c9b09b4042 | 2599 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 2600 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 2601 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 2602 | */ |
annieluo2 | 0:d6c9b09b4042 | 2603 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 2604 | void attach(F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 2605 | detail::is_type<R (F::*)(A0, A1, A2), &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 2606 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 2607 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 2608 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2609 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 2610 | } |
annieluo2 | 0:d6c9b09b4042 | 2611 | |
annieluo2 | 0:d6c9b09b4042 | 2612 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 2613 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 2614 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 2615 | */ |
annieluo2 | 0:d6c9b09b4042 | 2616 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 2617 | void attach(const F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 2618 | detail::is_type<R (F::*)(A0, A1, A2) const, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 2619 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 2620 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 2621 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2622 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 2623 | } |
annieluo2 | 0:d6c9b09b4042 | 2624 | |
annieluo2 | 0:d6c9b09b4042 | 2625 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 2626 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 2627 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 2628 | */ |
annieluo2 | 0:d6c9b09b4042 | 2629 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 2630 | void attach(volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 2631 | detail::is_type<R (F::*)(A0, A1, A2) volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 2632 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 2633 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 2634 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2635 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 2636 | } |
annieluo2 | 0:d6c9b09b4042 | 2637 | |
annieluo2 | 0:d6c9b09b4042 | 2638 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 2639 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 2640 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 2641 | */ |
annieluo2 | 0:d6c9b09b4042 | 2642 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 2643 | void attach(const volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 2644 | detail::is_type<R (F::*)(A0, A1, A2) const volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 2645 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 2646 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 2647 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2648 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 2649 | } |
annieluo2 | 0:d6c9b09b4042 | 2650 | |
annieluo2 | 0:d6c9b09b4042 | 2651 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2652 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 2653 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2654 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 2655 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 2656 | */ |
annieluo2 | 0:d6c9b09b4042 | 2657 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 2658 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 2659 | void attach(void *obj, R (*func)(void*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 2660 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2661 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 2662 | } |
annieluo2 | 0:d6c9b09b4042 | 2663 | |
annieluo2 | 0:d6c9b09b4042 | 2664 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2665 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 2666 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2667 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 2668 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 2669 | */ |
annieluo2 | 0:d6c9b09b4042 | 2670 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 2671 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 2672 | void attach(const void *obj, R (*func)(const void*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 2673 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2674 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 2675 | } |
annieluo2 | 0:d6c9b09b4042 | 2676 | |
annieluo2 | 0:d6c9b09b4042 | 2677 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2678 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 2679 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2680 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 2681 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 2682 | */ |
annieluo2 | 0:d6c9b09b4042 | 2683 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 2684 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 2685 | void attach(volatile void *obj, R (*func)(volatile void*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 2686 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2687 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 2688 | } |
annieluo2 | 0:d6c9b09b4042 | 2689 | |
annieluo2 | 0:d6c9b09b4042 | 2690 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2691 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 2692 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2693 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 2694 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 2695 | */ |
annieluo2 | 0:d6c9b09b4042 | 2696 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 2697 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 2698 | void attach(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 2699 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2700 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 2701 | } |
annieluo2 | 0:d6c9b09b4042 | 2702 | |
annieluo2 | 0:d6c9b09b4042 | 2703 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2704 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 2705 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2706 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 2707 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 2708 | */ |
annieluo2 | 0:d6c9b09b4042 | 2709 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 2710 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 2711 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 2712 | void attach(T *obj, R (*func)(T*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 2713 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2714 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 2715 | } |
annieluo2 | 0:d6c9b09b4042 | 2716 | |
annieluo2 | 0:d6c9b09b4042 | 2717 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2718 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 2719 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2720 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 2721 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 2722 | */ |
annieluo2 | 0:d6c9b09b4042 | 2723 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 2724 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 2725 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 2726 | void attach(const T *obj, R (*func)(const T*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 2727 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2728 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 2729 | } |
annieluo2 | 0:d6c9b09b4042 | 2730 | |
annieluo2 | 0:d6c9b09b4042 | 2731 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2732 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 2733 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2734 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 2735 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 2736 | */ |
annieluo2 | 0:d6c9b09b4042 | 2737 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 2738 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 2739 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 2740 | void attach(volatile T *obj, R (*func)(volatile T*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 2741 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2742 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 2743 | } |
annieluo2 | 0:d6c9b09b4042 | 2744 | |
annieluo2 | 0:d6c9b09b4042 | 2745 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2746 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 2747 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2748 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 2749 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 2750 | */ |
annieluo2 | 0:d6c9b09b4042 | 2751 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 2752 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 2753 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 2754 | void attach(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 2755 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2756 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 2757 | } |
annieluo2 | 0:d6c9b09b4042 | 2758 | |
annieluo2 | 0:d6c9b09b4042 | 2759 | /** Assign a callback |
annieluo2 | 0:d6c9b09b4042 | 2760 | */ |
annieluo2 | 0:d6c9b09b4042 | 2761 | Callback &operator=(const Callback &that) { |
annieluo2 | 0:d6c9b09b4042 | 2762 | if (this != &that) { |
annieluo2 | 0:d6c9b09b4042 | 2763 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 2764 | new (this) Callback(that); |
annieluo2 | 0:d6c9b09b4042 | 2765 | } |
annieluo2 | 0:d6c9b09b4042 | 2766 | |
annieluo2 | 0:d6c9b09b4042 | 2767 | return *this; |
annieluo2 | 0:d6c9b09b4042 | 2768 | } |
annieluo2 | 0:d6c9b09b4042 | 2769 | |
annieluo2 | 0:d6c9b09b4042 | 2770 | /** Call the attached function |
annieluo2 | 0:d6c9b09b4042 | 2771 | */ |
annieluo2 | 0:d6c9b09b4042 | 2772 | R call(A0 a0, A1 a1, A2 a2) const { |
annieluo2 | 0:d6c9b09b4042 | 2773 | MBED_ASSERT(_ops); |
annieluo2 | 0:d6c9b09b4042 | 2774 | return _ops->call(this, a0, a1, a2); |
annieluo2 | 0:d6c9b09b4042 | 2775 | } |
annieluo2 | 0:d6c9b09b4042 | 2776 | |
annieluo2 | 0:d6c9b09b4042 | 2777 | /** Call the attached function |
annieluo2 | 0:d6c9b09b4042 | 2778 | */ |
annieluo2 | 0:d6c9b09b4042 | 2779 | R operator()(A0 a0, A1 a1, A2 a2) const { |
annieluo2 | 0:d6c9b09b4042 | 2780 | return call(a0, a1, a2); |
annieluo2 | 0:d6c9b09b4042 | 2781 | } |
annieluo2 | 0:d6c9b09b4042 | 2782 | |
annieluo2 | 0:d6c9b09b4042 | 2783 | /** Test if function has been attached |
annieluo2 | 0:d6c9b09b4042 | 2784 | */ |
annieluo2 | 0:d6c9b09b4042 | 2785 | operator bool() const { |
annieluo2 | 0:d6c9b09b4042 | 2786 | return _ops; |
annieluo2 | 0:d6c9b09b4042 | 2787 | } |
annieluo2 | 0:d6c9b09b4042 | 2788 | |
annieluo2 | 0:d6c9b09b4042 | 2789 | /** Test for equality |
annieluo2 | 0:d6c9b09b4042 | 2790 | */ |
annieluo2 | 0:d6c9b09b4042 | 2791 | friend bool operator==(const Callback &l, const Callback &r) { |
annieluo2 | 0:d6c9b09b4042 | 2792 | return memcmp(&l, &r, sizeof(Callback)) == 0; |
annieluo2 | 0:d6c9b09b4042 | 2793 | } |
annieluo2 | 0:d6c9b09b4042 | 2794 | |
annieluo2 | 0:d6c9b09b4042 | 2795 | /** Test for inequality |
annieluo2 | 0:d6c9b09b4042 | 2796 | */ |
annieluo2 | 0:d6c9b09b4042 | 2797 | friend bool operator!=(const Callback &l, const Callback &r) { |
annieluo2 | 0:d6c9b09b4042 | 2798 | return !(l == r); |
annieluo2 | 0:d6c9b09b4042 | 2799 | } |
annieluo2 | 0:d6c9b09b4042 | 2800 | |
annieluo2 | 0:d6c9b09b4042 | 2801 | /** Static thunk for passing as C-style function |
annieluo2 | 0:d6c9b09b4042 | 2802 | * @param func Callback to call passed as void pointer |
annieluo2 | 0:d6c9b09b4042 | 2803 | */ |
annieluo2 | 0:d6c9b09b4042 | 2804 | static R thunk(void *func, A0 a0, A1 a1, A2 a2) { |
annieluo2 | 0:d6c9b09b4042 | 2805 | return static_cast<Callback*>(func)->call(a0, a1, a2); |
annieluo2 | 0:d6c9b09b4042 | 2806 | } |
annieluo2 | 0:d6c9b09b4042 | 2807 | |
annieluo2 | 0:d6c9b09b4042 | 2808 | private: |
annieluo2 | 0:d6c9b09b4042 | 2809 | // Stored as pointer to function and pointer to optional object |
annieluo2 | 0:d6c9b09b4042 | 2810 | // Function pointer is stored as union of possible function types |
annieluo2 | 0:d6c9b09b4042 | 2811 | // to garuntee proper size and alignment |
annieluo2 | 0:d6c9b09b4042 | 2812 | struct _class; |
annieluo2 | 0:d6c9b09b4042 | 2813 | union { |
annieluo2 | 0:d6c9b09b4042 | 2814 | void (*_staticfunc)(A0, A1, A2); |
annieluo2 | 0:d6c9b09b4042 | 2815 | void (*_boundfunc)(_class*, A0, A1, A2); |
annieluo2 | 0:d6c9b09b4042 | 2816 | void (_class::*_methodfunc)(A0, A1, A2); |
annieluo2 | 0:d6c9b09b4042 | 2817 | } _func; |
annieluo2 | 0:d6c9b09b4042 | 2818 | void *_obj; |
annieluo2 | 0:d6c9b09b4042 | 2819 | |
annieluo2 | 0:d6c9b09b4042 | 2820 | // Dynamically dispatched operations |
annieluo2 | 0:d6c9b09b4042 | 2821 | const struct ops { |
annieluo2 | 0:d6c9b09b4042 | 2822 | R (*call)(const void*, A0, A1, A2); |
annieluo2 | 0:d6c9b09b4042 | 2823 | void (*move)(void*, const void*); |
annieluo2 | 0:d6c9b09b4042 | 2824 | void (*dtor)(void*); |
annieluo2 | 0:d6c9b09b4042 | 2825 | } *_ops; |
annieluo2 | 0:d6c9b09b4042 | 2826 | |
annieluo2 | 0:d6c9b09b4042 | 2827 | // Generate operations for function object |
annieluo2 | 0:d6c9b09b4042 | 2828 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 2829 | void generate(const F &f) { |
annieluo2 | 0:d6c9b09b4042 | 2830 | static const ops ops = { |
annieluo2 | 0:d6c9b09b4042 | 2831 | &Callback::function_call<F>, |
annieluo2 | 0:d6c9b09b4042 | 2832 | &Callback::function_move<F>, |
annieluo2 | 0:d6c9b09b4042 | 2833 | &Callback::function_dtor<F>, |
annieluo2 | 0:d6c9b09b4042 | 2834 | }; |
annieluo2 | 0:d6c9b09b4042 | 2835 | |
annieluo2 | 0:d6c9b09b4042 | 2836 | MBED_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F)); |
annieluo2 | 0:d6c9b09b4042 | 2837 | new (this) F(f); |
annieluo2 | 0:d6c9b09b4042 | 2838 | _ops = &ops; |
annieluo2 | 0:d6c9b09b4042 | 2839 | } |
annieluo2 | 0:d6c9b09b4042 | 2840 | |
annieluo2 | 0:d6c9b09b4042 | 2841 | // Function attributes |
annieluo2 | 0:d6c9b09b4042 | 2842 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 2843 | static R function_call(const void *p, A0 a0, A1 a1, A2 a2) { |
annieluo2 | 0:d6c9b09b4042 | 2844 | return (*(F*)p)(a0, a1, a2); |
annieluo2 | 0:d6c9b09b4042 | 2845 | } |
annieluo2 | 0:d6c9b09b4042 | 2846 | |
annieluo2 | 0:d6c9b09b4042 | 2847 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 2848 | static void function_move(void *d, const void *p) { |
annieluo2 | 0:d6c9b09b4042 | 2849 | new (d) F(*(F*)p); |
annieluo2 | 0:d6c9b09b4042 | 2850 | } |
annieluo2 | 0:d6c9b09b4042 | 2851 | |
annieluo2 | 0:d6c9b09b4042 | 2852 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 2853 | static void function_dtor(void *p) { |
annieluo2 | 0:d6c9b09b4042 | 2854 | ((F*)p)->~F(); |
annieluo2 | 0:d6c9b09b4042 | 2855 | } |
annieluo2 | 0:d6c9b09b4042 | 2856 | |
annieluo2 | 0:d6c9b09b4042 | 2857 | // Wrappers for functions with context |
annieluo2 | 0:d6c9b09b4042 | 2858 | template <typename O, typename M> |
annieluo2 | 0:d6c9b09b4042 | 2859 | struct method_context { |
annieluo2 | 0:d6c9b09b4042 | 2860 | M method; |
annieluo2 | 0:d6c9b09b4042 | 2861 | O *obj; |
annieluo2 | 0:d6c9b09b4042 | 2862 | |
annieluo2 | 0:d6c9b09b4042 | 2863 | method_context(O *obj, M method) |
annieluo2 | 0:d6c9b09b4042 | 2864 | : method(method), obj(obj) {} |
annieluo2 | 0:d6c9b09b4042 | 2865 | |
annieluo2 | 0:d6c9b09b4042 | 2866 | R operator()(A0 a0, A1 a1, A2 a2) const { |
annieluo2 | 0:d6c9b09b4042 | 2867 | return (obj->*method)(a0, a1, a2); |
annieluo2 | 0:d6c9b09b4042 | 2868 | } |
annieluo2 | 0:d6c9b09b4042 | 2869 | }; |
annieluo2 | 0:d6c9b09b4042 | 2870 | |
annieluo2 | 0:d6c9b09b4042 | 2871 | template <typename F, typename A> |
annieluo2 | 0:d6c9b09b4042 | 2872 | struct function_context { |
annieluo2 | 0:d6c9b09b4042 | 2873 | F func; |
annieluo2 | 0:d6c9b09b4042 | 2874 | A *arg; |
annieluo2 | 0:d6c9b09b4042 | 2875 | |
annieluo2 | 0:d6c9b09b4042 | 2876 | function_context(F func, A *arg) |
annieluo2 | 0:d6c9b09b4042 | 2877 | : func(func), arg(arg) {} |
annieluo2 | 0:d6c9b09b4042 | 2878 | |
annieluo2 | 0:d6c9b09b4042 | 2879 | R operator()(A0 a0, A1 a1, A2 a2) const { |
annieluo2 | 0:d6c9b09b4042 | 2880 | return func(arg, a0, a1, a2); |
annieluo2 | 0:d6c9b09b4042 | 2881 | } |
annieluo2 | 0:d6c9b09b4042 | 2882 | }; |
annieluo2 | 0:d6c9b09b4042 | 2883 | }; |
annieluo2 | 0:d6c9b09b4042 | 2884 | |
annieluo2 | 0:d6c9b09b4042 | 2885 | /** Callback class based on template specialization |
annieluo2 | 0:d6c9b09b4042 | 2886 | * |
annieluo2 | 0:d6c9b09b4042 | 2887 | * @Note Synchronization level: Not protected |
annieluo2 | 0:d6c9b09b4042 | 2888 | */ |
annieluo2 | 0:d6c9b09b4042 | 2889 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 2890 | class Callback<R(A0, A1, A2, A3)> { |
annieluo2 | 0:d6c9b09b4042 | 2891 | public: |
annieluo2 | 0:d6c9b09b4042 | 2892 | /** Create a Callback with a static function |
annieluo2 | 0:d6c9b09b4042 | 2893 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2894 | */ |
annieluo2 | 0:d6c9b09b4042 | 2895 | Callback(R (*func)(A0, A1, A2, A3) = 0) { |
annieluo2 | 0:d6c9b09b4042 | 2896 | if (!func) { |
annieluo2 | 0:d6c9b09b4042 | 2897 | _ops = 0; |
annieluo2 | 0:d6c9b09b4042 | 2898 | } else { |
annieluo2 | 0:d6c9b09b4042 | 2899 | generate(func); |
annieluo2 | 0:d6c9b09b4042 | 2900 | } |
annieluo2 | 0:d6c9b09b4042 | 2901 | } |
annieluo2 | 0:d6c9b09b4042 | 2902 | |
annieluo2 | 0:d6c9b09b4042 | 2903 | /** Attach a Callback |
annieluo2 | 0:d6c9b09b4042 | 2904 | * @param func The Callback to attach |
annieluo2 | 0:d6c9b09b4042 | 2905 | */ |
annieluo2 | 0:d6c9b09b4042 | 2906 | Callback(const Callback<R(A0, A1, A2, A3)> &func) { |
annieluo2 | 0:d6c9b09b4042 | 2907 | if (func._ops) { |
annieluo2 | 0:d6c9b09b4042 | 2908 | func._ops->move(this, &func); |
annieluo2 | 0:d6c9b09b4042 | 2909 | } |
annieluo2 | 0:d6c9b09b4042 | 2910 | _ops = func._ops; |
annieluo2 | 0:d6c9b09b4042 | 2911 | } |
annieluo2 | 0:d6c9b09b4042 | 2912 | |
annieluo2 | 0:d6c9b09b4042 | 2913 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 2914 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 2915 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 2916 | */ |
annieluo2 | 0:d6c9b09b4042 | 2917 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 2918 | Callback(T *obj, R (T::*method)(A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 2919 | generate(method_context<T, R (T::*)(A0, A1, A2, A3)>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 2920 | } |
annieluo2 | 0:d6c9b09b4042 | 2921 | |
annieluo2 | 0:d6c9b09b4042 | 2922 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 2923 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 2924 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 2925 | */ |
annieluo2 | 0:d6c9b09b4042 | 2926 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 2927 | Callback(const T *obj, R (T::*method)(A0, A1, A2, A3) const) { |
annieluo2 | 0:d6c9b09b4042 | 2928 | generate(method_context<const T, R (T::*)(A0, A1, A2, A3) const>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 2929 | } |
annieluo2 | 0:d6c9b09b4042 | 2930 | |
annieluo2 | 0:d6c9b09b4042 | 2931 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 2932 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 2933 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 2934 | */ |
annieluo2 | 0:d6c9b09b4042 | 2935 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 2936 | Callback(volatile T *obj, R (T::*method)(A0, A1, A2, A3) volatile) { |
annieluo2 | 0:d6c9b09b4042 | 2937 | generate(method_context<volatile T, R (T::*)(A0, A1, A2, A3) volatile>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 2938 | } |
annieluo2 | 0:d6c9b09b4042 | 2939 | |
annieluo2 | 0:d6c9b09b4042 | 2940 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 2941 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 2942 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 2943 | */ |
annieluo2 | 0:d6c9b09b4042 | 2944 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 2945 | Callback(const volatile T *obj, R (T::*method)(A0, A1, A2, A3) const volatile) { |
annieluo2 | 0:d6c9b09b4042 | 2946 | generate(method_context<const volatile T, R (T::*)(A0, A1, A2, A3) const volatile>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 2947 | } |
annieluo2 | 0:d6c9b09b4042 | 2948 | |
annieluo2 | 0:d6c9b09b4042 | 2949 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2950 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2951 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 2952 | */ |
annieluo2 | 0:d6c9b09b4042 | 2953 | Callback(R (*func)(void*, A0, A1, A2, A3), void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 2954 | generate(function_context<R (*)(void*, A0, A1, A2, A3), void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 2955 | } |
annieluo2 | 0:d6c9b09b4042 | 2956 | |
annieluo2 | 0:d6c9b09b4042 | 2957 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2958 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2959 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 2960 | */ |
annieluo2 | 0:d6c9b09b4042 | 2961 | Callback(R (*func)(const void*, A0, A1, A2, A3), const void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 2962 | generate(function_context<R (*)(const void*, A0, A1, A2, A3), const void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 2963 | } |
annieluo2 | 0:d6c9b09b4042 | 2964 | |
annieluo2 | 0:d6c9b09b4042 | 2965 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2966 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2967 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 2968 | */ |
annieluo2 | 0:d6c9b09b4042 | 2969 | Callback(R (*func)(volatile void*, A0, A1, A2, A3), volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 2970 | generate(function_context<R (*)(volatile void*, A0, A1, A2, A3), volatile void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 2971 | } |
annieluo2 | 0:d6c9b09b4042 | 2972 | |
annieluo2 | 0:d6c9b09b4042 | 2973 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2974 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2975 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 2976 | */ |
annieluo2 | 0:d6c9b09b4042 | 2977 | Callback(R (*func)(const volatile void*, A0, A1, A2, A3), const volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 2978 | generate(function_context<R (*)(const volatile void*, A0, A1, A2, A3), const volatile void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 2979 | } |
annieluo2 | 0:d6c9b09b4042 | 2980 | |
annieluo2 | 0:d6c9b09b4042 | 2981 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2982 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2983 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 2984 | */ |
annieluo2 | 0:d6c9b09b4042 | 2985 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 2986 | Callback(R (*func)(T*, A0, A1, A2, A3), T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 2987 | generate(function_context<R (*)(T*, A0, A1, A2, A3), T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 2988 | } |
annieluo2 | 0:d6c9b09b4042 | 2989 | |
annieluo2 | 0:d6c9b09b4042 | 2990 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 2991 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 2992 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 2993 | */ |
annieluo2 | 0:d6c9b09b4042 | 2994 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 2995 | Callback(R (*func)(const T*, A0, A1, A2, A3), const T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 2996 | generate(function_context<R (*)(const T*, A0, A1, A2, A3), const T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 2997 | } |
annieluo2 | 0:d6c9b09b4042 | 2998 | |
annieluo2 | 0:d6c9b09b4042 | 2999 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3000 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3001 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3002 | */ |
annieluo2 | 0:d6c9b09b4042 | 3003 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3004 | Callback(R (*func)(volatile T*, A0, A1, A2, A3), volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3005 | generate(function_context<R (*)(volatile T*, A0, A1, A2, A3), volatile T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 3006 | } |
annieluo2 | 0:d6c9b09b4042 | 3007 | |
annieluo2 | 0:d6c9b09b4042 | 3008 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3009 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3010 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3011 | */ |
annieluo2 | 0:d6c9b09b4042 | 3012 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3013 | Callback(R (*func)(const volatile T*, A0, A1, A2, A3), const volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3014 | generate(function_context<R (*)(const volatile T*, A0, A1, A2, A3), const volatile T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 3015 | } |
annieluo2 | 0:d6c9b09b4042 | 3016 | |
annieluo2 | 0:d6c9b09b4042 | 3017 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 3018 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 3019 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 3020 | */ |
annieluo2 | 0:d6c9b09b4042 | 3021 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 3022 | Callback(F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 3023 | detail::is_type<R (F::*)(A0, A1, A2, A3), &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 3024 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 3025 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 3026 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 3027 | } |
annieluo2 | 0:d6c9b09b4042 | 3028 | |
annieluo2 | 0:d6c9b09b4042 | 3029 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 3030 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 3031 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 3032 | */ |
annieluo2 | 0:d6c9b09b4042 | 3033 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 3034 | Callback(const F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 3035 | detail::is_type<R (F::*)(A0, A1, A2, A3) const, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 3036 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 3037 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 3038 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 3039 | } |
annieluo2 | 0:d6c9b09b4042 | 3040 | |
annieluo2 | 0:d6c9b09b4042 | 3041 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 3042 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 3043 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 3044 | */ |
annieluo2 | 0:d6c9b09b4042 | 3045 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 3046 | Callback(volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 3047 | detail::is_type<R (F::*)(A0, A1, A2, A3) volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 3048 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 3049 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 3050 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 3051 | } |
annieluo2 | 0:d6c9b09b4042 | 3052 | |
annieluo2 | 0:d6c9b09b4042 | 3053 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 3054 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 3055 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 3056 | */ |
annieluo2 | 0:d6c9b09b4042 | 3057 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 3058 | Callback(const volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 3059 | detail::is_type<R (F::*)(A0, A1, A2, A3) const volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 3060 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 3061 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 3062 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 3063 | } |
annieluo2 | 0:d6c9b09b4042 | 3064 | |
annieluo2 | 0:d6c9b09b4042 | 3065 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3066 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3067 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3068 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3069 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3070 | */ |
annieluo2 | 0:d6c9b09b4042 | 3071 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3072 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3073 | Callback(void *obj, R (*func)(void*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 3074 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3075 | } |
annieluo2 | 0:d6c9b09b4042 | 3076 | |
annieluo2 | 0:d6c9b09b4042 | 3077 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3078 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3079 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3080 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3081 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3082 | */ |
annieluo2 | 0:d6c9b09b4042 | 3083 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3084 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3085 | Callback(const void *obj, R (*func)(const void*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 3086 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3087 | } |
annieluo2 | 0:d6c9b09b4042 | 3088 | |
annieluo2 | 0:d6c9b09b4042 | 3089 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3090 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3091 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3092 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3093 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3094 | */ |
annieluo2 | 0:d6c9b09b4042 | 3095 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3096 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3097 | Callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 3098 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3099 | } |
annieluo2 | 0:d6c9b09b4042 | 3100 | |
annieluo2 | 0:d6c9b09b4042 | 3101 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3102 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3103 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3104 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3105 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3106 | */ |
annieluo2 | 0:d6c9b09b4042 | 3107 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3108 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3109 | Callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 3110 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3111 | } |
annieluo2 | 0:d6c9b09b4042 | 3112 | |
annieluo2 | 0:d6c9b09b4042 | 3113 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3114 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3115 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3116 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3117 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3118 | */ |
annieluo2 | 0:d6c9b09b4042 | 3119 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3120 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3121 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3122 | Callback(T *obj, R (*func)(T*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 3123 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3124 | } |
annieluo2 | 0:d6c9b09b4042 | 3125 | |
annieluo2 | 0:d6c9b09b4042 | 3126 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3127 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3128 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3129 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3130 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3131 | */ |
annieluo2 | 0:d6c9b09b4042 | 3132 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3133 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3134 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3135 | Callback(const T *obj, R (*func)(const T*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 3136 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3137 | } |
annieluo2 | 0:d6c9b09b4042 | 3138 | |
annieluo2 | 0:d6c9b09b4042 | 3139 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3140 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3141 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3142 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3143 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3144 | */ |
annieluo2 | 0:d6c9b09b4042 | 3145 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3146 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3147 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3148 | Callback(volatile T *obj, R (*func)(volatile T*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 3149 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3150 | } |
annieluo2 | 0:d6c9b09b4042 | 3151 | |
annieluo2 | 0:d6c9b09b4042 | 3152 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3153 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3154 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3155 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3156 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3157 | */ |
annieluo2 | 0:d6c9b09b4042 | 3158 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3159 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3160 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3161 | Callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 3162 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3163 | } |
annieluo2 | 0:d6c9b09b4042 | 3164 | |
annieluo2 | 0:d6c9b09b4042 | 3165 | /** Destroy a callback |
annieluo2 | 0:d6c9b09b4042 | 3166 | */ |
annieluo2 | 0:d6c9b09b4042 | 3167 | ~Callback() { |
annieluo2 | 0:d6c9b09b4042 | 3168 | if (_ops) { |
annieluo2 | 0:d6c9b09b4042 | 3169 | _ops->dtor(this); |
annieluo2 | 0:d6c9b09b4042 | 3170 | } |
annieluo2 | 0:d6c9b09b4042 | 3171 | } |
annieluo2 | 0:d6c9b09b4042 | 3172 | |
annieluo2 | 0:d6c9b09b4042 | 3173 | /** Attach a static function |
annieluo2 | 0:d6c9b09b4042 | 3174 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3175 | */ |
annieluo2 | 0:d6c9b09b4042 | 3176 | void attach(R (*func)(A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 3177 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3178 | new (this) Callback(func); |
annieluo2 | 0:d6c9b09b4042 | 3179 | } |
annieluo2 | 0:d6c9b09b4042 | 3180 | |
annieluo2 | 0:d6c9b09b4042 | 3181 | /** Attach a Callback |
annieluo2 | 0:d6c9b09b4042 | 3182 | * @param func The Callback to attach |
annieluo2 | 0:d6c9b09b4042 | 3183 | */ |
annieluo2 | 0:d6c9b09b4042 | 3184 | void attach(const Callback<R(A0, A1, A2, A3)> &func) { |
annieluo2 | 0:d6c9b09b4042 | 3185 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3186 | new (this) Callback(func); |
annieluo2 | 0:d6c9b09b4042 | 3187 | } |
annieluo2 | 0:d6c9b09b4042 | 3188 | |
annieluo2 | 0:d6c9b09b4042 | 3189 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 3190 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 3191 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 3192 | */ |
annieluo2 | 0:d6c9b09b4042 | 3193 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3194 | void attach(T *obj, R (T::*method)(A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 3195 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3196 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 3197 | } |
annieluo2 | 0:d6c9b09b4042 | 3198 | |
annieluo2 | 0:d6c9b09b4042 | 3199 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 3200 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 3201 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 3202 | */ |
annieluo2 | 0:d6c9b09b4042 | 3203 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3204 | void attach(const T *obj, R (T::*method)(A0, A1, A2, A3) const) { |
annieluo2 | 0:d6c9b09b4042 | 3205 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3206 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 3207 | } |
annieluo2 | 0:d6c9b09b4042 | 3208 | |
annieluo2 | 0:d6c9b09b4042 | 3209 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 3210 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 3211 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 3212 | */ |
annieluo2 | 0:d6c9b09b4042 | 3213 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3214 | void attach(volatile T *obj, R (T::*method)(A0, A1, A2, A3) volatile) { |
annieluo2 | 0:d6c9b09b4042 | 3215 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3216 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 3217 | } |
annieluo2 | 0:d6c9b09b4042 | 3218 | |
annieluo2 | 0:d6c9b09b4042 | 3219 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 3220 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 3221 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 3222 | */ |
annieluo2 | 0:d6c9b09b4042 | 3223 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3224 | void attach(const volatile T *obj, R (T::*method)(A0, A1, A2, A3) const volatile) { |
annieluo2 | 0:d6c9b09b4042 | 3225 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3226 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 3227 | } |
annieluo2 | 0:d6c9b09b4042 | 3228 | |
annieluo2 | 0:d6c9b09b4042 | 3229 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3230 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3231 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3232 | */ |
annieluo2 | 0:d6c9b09b4042 | 3233 | void attach(R (*func)(void*, A0, A1, A2, A3), void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3234 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3235 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 3236 | } |
annieluo2 | 0:d6c9b09b4042 | 3237 | |
annieluo2 | 0:d6c9b09b4042 | 3238 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3239 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3240 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3241 | */ |
annieluo2 | 0:d6c9b09b4042 | 3242 | void attach(R (*func)(const void*, A0, A1, A2, A3), const void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3243 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3244 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 3245 | } |
annieluo2 | 0:d6c9b09b4042 | 3246 | |
annieluo2 | 0:d6c9b09b4042 | 3247 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3248 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3249 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3250 | */ |
annieluo2 | 0:d6c9b09b4042 | 3251 | void attach(R (*func)(volatile void*, A0, A1, A2, A3), volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3252 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3253 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 3254 | } |
annieluo2 | 0:d6c9b09b4042 | 3255 | |
annieluo2 | 0:d6c9b09b4042 | 3256 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3257 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3258 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3259 | */ |
annieluo2 | 0:d6c9b09b4042 | 3260 | void attach(R (*func)(const volatile void*, A0, A1, A2, A3), const volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3261 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3262 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 3263 | } |
annieluo2 | 0:d6c9b09b4042 | 3264 | |
annieluo2 | 0:d6c9b09b4042 | 3265 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3266 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3267 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3268 | */ |
annieluo2 | 0:d6c9b09b4042 | 3269 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 3270 | void attach(R (*func)(T*, A0, A1, A2, A3), T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3271 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3272 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 3273 | } |
annieluo2 | 0:d6c9b09b4042 | 3274 | |
annieluo2 | 0:d6c9b09b4042 | 3275 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3276 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3277 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3278 | */ |
annieluo2 | 0:d6c9b09b4042 | 3279 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 3280 | void attach(R (*func)(const T*, A0, A1, A2, A3), const T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3281 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3282 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 3283 | } |
annieluo2 | 0:d6c9b09b4042 | 3284 | |
annieluo2 | 0:d6c9b09b4042 | 3285 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3286 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3287 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3288 | */ |
annieluo2 | 0:d6c9b09b4042 | 3289 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 3290 | void attach(R (*func)(volatile T*, A0, A1, A2, A3), volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3291 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3292 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 3293 | } |
annieluo2 | 0:d6c9b09b4042 | 3294 | |
annieluo2 | 0:d6c9b09b4042 | 3295 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3296 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3297 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3298 | */ |
annieluo2 | 0:d6c9b09b4042 | 3299 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 3300 | void attach(R (*func)(const volatile T*, A0, A1, A2, A3), const volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3301 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3302 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 3303 | } |
annieluo2 | 0:d6c9b09b4042 | 3304 | |
annieluo2 | 0:d6c9b09b4042 | 3305 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 3306 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 3307 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 3308 | */ |
annieluo2 | 0:d6c9b09b4042 | 3309 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 3310 | void attach(F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 3311 | detail::is_type<R (F::*)(A0, A1, A2, A3), &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 3312 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 3313 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 3314 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3315 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 3316 | } |
annieluo2 | 0:d6c9b09b4042 | 3317 | |
annieluo2 | 0:d6c9b09b4042 | 3318 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 3319 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 3320 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 3321 | */ |
annieluo2 | 0:d6c9b09b4042 | 3322 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 3323 | void attach(const F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 3324 | detail::is_type<R (F::*)(A0, A1, A2, A3) const, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 3325 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 3326 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 3327 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3328 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 3329 | } |
annieluo2 | 0:d6c9b09b4042 | 3330 | |
annieluo2 | 0:d6c9b09b4042 | 3331 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 3332 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 3333 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 3334 | */ |
annieluo2 | 0:d6c9b09b4042 | 3335 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 3336 | void attach(volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 3337 | detail::is_type<R (F::*)(A0, A1, A2, A3) volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 3338 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 3339 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 3340 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3341 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 3342 | } |
annieluo2 | 0:d6c9b09b4042 | 3343 | |
annieluo2 | 0:d6c9b09b4042 | 3344 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 3345 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 3346 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 3347 | */ |
annieluo2 | 0:d6c9b09b4042 | 3348 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 3349 | void attach(const volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 3350 | detail::is_type<R (F::*)(A0, A1, A2, A3) const volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 3351 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 3352 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 3353 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3354 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 3355 | } |
annieluo2 | 0:d6c9b09b4042 | 3356 | |
annieluo2 | 0:d6c9b09b4042 | 3357 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3358 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3359 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3360 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3361 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3362 | */ |
annieluo2 | 0:d6c9b09b4042 | 3363 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3364 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3365 | void attach(void *obj, R (*func)(void*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 3366 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3367 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3368 | } |
annieluo2 | 0:d6c9b09b4042 | 3369 | |
annieluo2 | 0:d6c9b09b4042 | 3370 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3371 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3372 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3373 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3374 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3375 | */ |
annieluo2 | 0:d6c9b09b4042 | 3376 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3377 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3378 | void attach(const void *obj, R (*func)(const void*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 3379 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3380 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3381 | } |
annieluo2 | 0:d6c9b09b4042 | 3382 | |
annieluo2 | 0:d6c9b09b4042 | 3383 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3384 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3385 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3386 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3387 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3388 | */ |
annieluo2 | 0:d6c9b09b4042 | 3389 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3390 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3391 | void attach(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 3392 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3393 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3394 | } |
annieluo2 | 0:d6c9b09b4042 | 3395 | |
annieluo2 | 0:d6c9b09b4042 | 3396 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3397 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3398 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3399 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3400 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3401 | */ |
annieluo2 | 0:d6c9b09b4042 | 3402 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3403 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3404 | void attach(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 3405 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3406 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3407 | } |
annieluo2 | 0:d6c9b09b4042 | 3408 | |
annieluo2 | 0:d6c9b09b4042 | 3409 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3410 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3411 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3412 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3413 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3414 | */ |
annieluo2 | 0:d6c9b09b4042 | 3415 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 3416 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3417 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3418 | void attach(T *obj, R (*func)(T*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 3419 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3420 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3421 | } |
annieluo2 | 0:d6c9b09b4042 | 3422 | |
annieluo2 | 0:d6c9b09b4042 | 3423 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3424 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3425 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3426 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3427 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3428 | */ |
annieluo2 | 0:d6c9b09b4042 | 3429 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 3430 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3431 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3432 | void attach(const T *obj, R (*func)(const T*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 3433 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3434 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3435 | } |
annieluo2 | 0:d6c9b09b4042 | 3436 | |
annieluo2 | 0:d6c9b09b4042 | 3437 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3438 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3439 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3440 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3441 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3442 | */ |
annieluo2 | 0:d6c9b09b4042 | 3443 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 3444 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3445 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3446 | void attach(volatile T *obj, R (*func)(volatile T*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 3447 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3448 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3449 | } |
annieluo2 | 0:d6c9b09b4042 | 3450 | |
annieluo2 | 0:d6c9b09b4042 | 3451 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3452 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3453 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3454 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3455 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3456 | */ |
annieluo2 | 0:d6c9b09b4042 | 3457 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 3458 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3459 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3460 | void attach(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 3461 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3462 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3463 | } |
annieluo2 | 0:d6c9b09b4042 | 3464 | |
annieluo2 | 0:d6c9b09b4042 | 3465 | /** Assign a callback |
annieluo2 | 0:d6c9b09b4042 | 3466 | */ |
annieluo2 | 0:d6c9b09b4042 | 3467 | Callback &operator=(const Callback &that) { |
annieluo2 | 0:d6c9b09b4042 | 3468 | if (this != &that) { |
annieluo2 | 0:d6c9b09b4042 | 3469 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3470 | new (this) Callback(that); |
annieluo2 | 0:d6c9b09b4042 | 3471 | } |
annieluo2 | 0:d6c9b09b4042 | 3472 | |
annieluo2 | 0:d6c9b09b4042 | 3473 | return *this; |
annieluo2 | 0:d6c9b09b4042 | 3474 | } |
annieluo2 | 0:d6c9b09b4042 | 3475 | |
annieluo2 | 0:d6c9b09b4042 | 3476 | /** Call the attached function |
annieluo2 | 0:d6c9b09b4042 | 3477 | */ |
annieluo2 | 0:d6c9b09b4042 | 3478 | R call(A0 a0, A1 a1, A2 a2, A3 a3) const { |
annieluo2 | 0:d6c9b09b4042 | 3479 | MBED_ASSERT(_ops); |
annieluo2 | 0:d6c9b09b4042 | 3480 | return _ops->call(this, a0, a1, a2, a3); |
annieluo2 | 0:d6c9b09b4042 | 3481 | } |
annieluo2 | 0:d6c9b09b4042 | 3482 | |
annieluo2 | 0:d6c9b09b4042 | 3483 | /** Call the attached function |
annieluo2 | 0:d6c9b09b4042 | 3484 | */ |
annieluo2 | 0:d6c9b09b4042 | 3485 | R operator()(A0 a0, A1 a1, A2 a2, A3 a3) const { |
annieluo2 | 0:d6c9b09b4042 | 3486 | return call(a0, a1, a2, a3); |
annieluo2 | 0:d6c9b09b4042 | 3487 | } |
annieluo2 | 0:d6c9b09b4042 | 3488 | |
annieluo2 | 0:d6c9b09b4042 | 3489 | /** Test if function has been attached |
annieluo2 | 0:d6c9b09b4042 | 3490 | */ |
annieluo2 | 0:d6c9b09b4042 | 3491 | operator bool() const { |
annieluo2 | 0:d6c9b09b4042 | 3492 | return _ops; |
annieluo2 | 0:d6c9b09b4042 | 3493 | } |
annieluo2 | 0:d6c9b09b4042 | 3494 | |
annieluo2 | 0:d6c9b09b4042 | 3495 | /** Test for equality |
annieluo2 | 0:d6c9b09b4042 | 3496 | */ |
annieluo2 | 0:d6c9b09b4042 | 3497 | friend bool operator==(const Callback &l, const Callback &r) { |
annieluo2 | 0:d6c9b09b4042 | 3498 | return memcmp(&l, &r, sizeof(Callback)) == 0; |
annieluo2 | 0:d6c9b09b4042 | 3499 | } |
annieluo2 | 0:d6c9b09b4042 | 3500 | |
annieluo2 | 0:d6c9b09b4042 | 3501 | /** Test for inequality |
annieluo2 | 0:d6c9b09b4042 | 3502 | */ |
annieluo2 | 0:d6c9b09b4042 | 3503 | friend bool operator!=(const Callback &l, const Callback &r) { |
annieluo2 | 0:d6c9b09b4042 | 3504 | return !(l == r); |
annieluo2 | 0:d6c9b09b4042 | 3505 | } |
annieluo2 | 0:d6c9b09b4042 | 3506 | |
annieluo2 | 0:d6c9b09b4042 | 3507 | /** Static thunk for passing as C-style function |
annieluo2 | 0:d6c9b09b4042 | 3508 | * @param func Callback to call passed as void pointer |
annieluo2 | 0:d6c9b09b4042 | 3509 | */ |
annieluo2 | 0:d6c9b09b4042 | 3510 | static R thunk(void *func, A0 a0, A1 a1, A2 a2, A3 a3) { |
annieluo2 | 0:d6c9b09b4042 | 3511 | return static_cast<Callback*>(func)->call(a0, a1, a2, a3); |
annieluo2 | 0:d6c9b09b4042 | 3512 | } |
annieluo2 | 0:d6c9b09b4042 | 3513 | |
annieluo2 | 0:d6c9b09b4042 | 3514 | private: |
annieluo2 | 0:d6c9b09b4042 | 3515 | // Stored as pointer to function and pointer to optional object |
annieluo2 | 0:d6c9b09b4042 | 3516 | // Function pointer is stored as union of possible function types |
annieluo2 | 0:d6c9b09b4042 | 3517 | // to garuntee proper size and alignment |
annieluo2 | 0:d6c9b09b4042 | 3518 | struct _class; |
annieluo2 | 0:d6c9b09b4042 | 3519 | union { |
annieluo2 | 0:d6c9b09b4042 | 3520 | void (*_staticfunc)(A0, A1, A2, A3); |
annieluo2 | 0:d6c9b09b4042 | 3521 | void (*_boundfunc)(_class*, A0, A1, A2, A3); |
annieluo2 | 0:d6c9b09b4042 | 3522 | void (_class::*_methodfunc)(A0, A1, A2, A3); |
annieluo2 | 0:d6c9b09b4042 | 3523 | } _func; |
annieluo2 | 0:d6c9b09b4042 | 3524 | void *_obj; |
annieluo2 | 0:d6c9b09b4042 | 3525 | |
annieluo2 | 0:d6c9b09b4042 | 3526 | // Dynamically dispatched operations |
annieluo2 | 0:d6c9b09b4042 | 3527 | const struct ops { |
annieluo2 | 0:d6c9b09b4042 | 3528 | R (*call)(const void*, A0, A1, A2, A3); |
annieluo2 | 0:d6c9b09b4042 | 3529 | void (*move)(void*, const void*); |
annieluo2 | 0:d6c9b09b4042 | 3530 | void (*dtor)(void*); |
annieluo2 | 0:d6c9b09b4042 | 3531 | } *_ops; |
annieluo2 | 0:d6c9b09b4042 | 3532 | |
annieluo2 | 0:d6c9b09b4042 | 3533 | // Generate operations for function object |
annieluo2 | 0:d6c9b09b4042 | 3534 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 3535 | void generate(const F &f) { |
annieluo2 | 0:d6c9b09b4042 | 3536 | static const ops ops = { |
annieluo2 | 0:d6c9b09b4042 | 3537 | &Callback::function_call<F>, |
annieluo2 | 0:d6c9b09b4042 | 3538 | &Callback::function_move<F>, |
annieluo2 | 0:d6c9b09b4042 | 3539 | &Callback::function_dtor<F>, |
annieluo2 | 0:d6c9b09b4042 | 3540 | }; |
annieluo2 | 0:d6c9b09b4042 | 3541 | |
annieluo2 | 0:d6c9b09b4042 | 3542 | MBED_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F)); |
annieluo2 | 0:d6c9b09b4042 | 3543 | new (this) F(f); |
annieluo2 | 0:d6c9b09b4042 | 3544 | _ops = &ops; |
annieluo2 | 0:d6c9b09b4042 | 3545 | } |
annieluo2 | 0:d6c9b09b4042 | 3546 | |
annieluo2 | 0:d6c9b09b4042 | 3547 | // Function attributes |
annieluo2 | 0:d6c9b09b4042 | 3548 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 3549 | static R function_call(const void *p, A0 a0, A1 a1, A2 a2, A3 a3) { |
annieluo2 | 0:d6c9b09b4042 | 3550 | return (*(F*)p)(a0, a1, a2, a3); |
annieluo2 | 0:d6c9b09b4042 | 3551 | } |
annieluo2 | 0:d6c9b09b4042 | 3552 | |
annieluo2 | 0:d6c9b09b4042 | 3553 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 3554 | static void function_move(void *d, const void *p) { |
annieluo2 | 0:d6c9b09b4042 | 3555 | new (d) F(*(F*)p); |
annieluo2 | 0:d6c9b09b4042 | 3556 | } |
annieluo2 | 0:d6c9b09b4042 | 3557 | |
annieluo2 | 0:d6c9b09b4042 | 3558 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 3559 | static void function_dtor(void *p) { |
annieluo2 | 0:d6c9b09b4042 | 3560 | ((F*)p)->~F(); |
annieluo2 | 0:d6c9b09b4042 | 3561 | } |
annieluo2 | 0:d6c9b09b4042 | 3562 | |
annieluo2 | 0:d6c9b09b4042 | 3563 | // Wrappers for functions with context |
annieluo2 | 0:d6c9b09b4042 | 3564 | template <typename O, typename M> |
annieluo2 | 0:d6c9b09b4042 | 3565 | struct method_context { |
annieluo2 | 0:d6c9b09b4042 | 3566 | M method; |
annieluo2 | 0:d6c9b09b4042 | 3567 | O *obj; |
annieluo2 | 0:d6c9b09b4042 | 3568 | |
annieluo2 | 0:d6c9b09b4042 | 3569 | method_context(O *obj, M method) |
annieluo2 | 0:d6c9b09b4042 | 3570 | : method(method), obj(obj) {} |
annieluo2 | 0:d6c9b09b4042 | 3571 | |
annieluo2 | 0:d6c9b09b4042 | 3572 | R operator()(A0 a0, A1 a1, A2 a2, A3 a3) const { |
annieluo2 | 0:d6c9b09b4042 | 3573 | return (obj->*method)(a0, a1, a2, a3); |
annieluo2 | 0:d6c9b09b4042 | 3574 | } |
annieluo2 | 0:d6c9b09b4042 | 3575 | }; |
annieluo2 | 0:d6c9b09b4042 | 3576 | |
annieluo2 | 0:d6c9b09b4042 | 3577 | template <typename F, typename A> |
annieluo2 | 0:d6c9b09b4042 | 3578 | struct function_context { |
annieluo2 | 0:d6c9b09b4042 | 3579 | F func; |
annieluo2 | 0:d6c9b09b4042 | 3580 | A *arg; |
annieluo2 | 0:d6c9b09b4042 | 3581 | |
annieluo2 | 0:d6c9b09b4042 | 3582 | function_context(F func, A *arg) |
annieluo2 | 0:d6c9b09b4042 | 3583 | : func(func), arg(arg) {} |
annieluo2 | 0:d6c9b09b4042 | 3584 | |
annieluo2 | 0:d6c9b09b4042 | 3585 | R operator()(A0 a0, A1 a1, A2 a2, A3 a3) const { |
annieluo2 | 0:d6c9b09b4042 | 3586 | return func(arg, a0, a1, a2, a3); |
annieluo2 | 0:d6c9b09b4042 | 3587 | } |
annieluo2 | 0:d6c9b09b4042 | 3588 | }; |
annieluo2 | 0:d6c9b09b4042 | 3589 | }; |
annieluo2 | 0:d6c9b09b4042 | 3590 | |
annieluo2 | 0:d6c9b09b4042 | 3591 | /** Callback class based on template specialization |
annieluo2 | 0:d6c9b09b4042 | 3592 | * |
annieluo2 | 0:d6c9b09b4042 | 3593 | * @Note Synchronization level: Not protected |
annieluo2 | 0:d6c9b09b4042 | 3594 | */ |
annieluo2 | 0:d6c9b09b4042 | 3595 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 3596 | class Callback<R(A0, A1, A2, A3, A4)> { |
annieluo2 | 0:d6c9b09b4042 | 3597 | public: |
annieluo2 | 0:d6c9b09b4042 | 3598 | /** Create a Callback with a static function |
annieluo2 | 0:d6c9b09b4042 | 3599 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3600 | */ |
annieluo2 | 0:d6c9b09b4042 | 3601 | Callback(R (*func)(A0, A1, A2, A3, A4) = 0) { |
annieluo2 | 0:d6c9b09b4042 | 3602 | if (!func) { |
annieluo2 | 0:d6c9b09b4042 | 3603 | _ops = 0; |
annieluo2 | 0:d6c9b09b4042 | 3604 | } else { |
annieluo2 | 0:d6c9b09b4042 | 3605 | generate(func); |
annieluo2 | 0:d6c9b09b4042 | 3606 | } |
annieluo2 | 0:d6c9b09b4042 | 3607 | } |
annieluo2 | 0:d6c9b09b4042 | 3608 | |
annieluo2 | 0:d6c9b09b4042 | 3609 | /** Attach a Callback |
annieluo2 | 0:d6c9b09b4042 | 3610 | * @param func The Callback to attach |
annieluo2 | 0:d6c9b09b4042 | 3611 | */ |
annieluo2 | 0:d6c9b09b4042 | 3612 | Callback(const Callback<R(A0, A1, A2, A3, A4)> &func) { |
annieluo2 | 0:d6c9b09b4042 | 3613 | if (func._ops) { |
annieluo2 | 0:d6c9b09b4042 | 3614 | func._ops->move(this, &func); |
annieluo2 | 0:d6c9b09b4042 | 3615 | } |
annieluo2 | 0:d6c9b09b4042 | 3616 | _ops = func._ops; |
annieluo2 | 0:d6c9b09b4042 | 3617 | } |
annieluo2 | 0:d6c9b09b4042 | 3618 | |
annieluo2 | 0:d6c9b09b4042 | 3619 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 3620 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 3621 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 3622 | */ |
annieluo2 | 0:d6c9b09b4042 | 3623 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3624 | Callback(T *obj, R (T::*method)(A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 3625 | generate(method_context<T, R (T::*)(A0, A1, A2, A3, A4)>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 3626 | } |
annieluo2 | 0:d6c9b09b4042 | 3627 | |
annieluo2 | 0:d6c9b09b4042 | 3628 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 3629 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 3630 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 3631 | */ |
annieluo2 | 0:d6c9b09b4042 | 3632 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3633 | Callback(const T *obj, R (T::*method)(A0, A1, A2, A3, A4) const) { |
annieluo2 | 0:d6c9b09b4042 | 3634 | generate(method_context<const T, R (T::*)(A0, A1, A2, A3, A4) const>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 3635 | } |
annieluo2 | 0:d6c9b09b4042 | 3636 | |
annieluo2 | 0:d6c9b09b4042 | 3637 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 3638 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 3639 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 3640 | */ |
annieluo2 | 0:d6c9b09b4042 | 3641 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3642 | Callback(volatile T *obj, R (T::*method)(A0, A1, A2, A3, A4) volatile) { |
annieluo2 | 0:d6c9b09b4042 | 3643 | generate(method_context<volatile T, R (T::*)(A0, A1, A2, A3, A4) volatile>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 3644 | } |
annieluo2 | 0:d6c9b09b4042 | 3645 | |
annieluo2 | 0:d6c9b09b4042 | 3646 | /** Create a Callback with a member function |
annieluo2 | 0:d6c9b09b4042 | 3647 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 3648 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 3649 | */ |
annieluo2 | 0:d6c9b09b4042 | 3650 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3651 | Callback(const volatile T *obj, R (T::*method)(A0, A1, A2, A3, A4) const volatile) { |
annieluo2 | 0:d6c9b09b4042 | 3652 | generate(method_context<const volatile T, R (T::*)(A0, A1, A2, A3, A4) const volatile>(obj, method)); |
annieluo2 | 0:d6c9b09b4042 | 3653 | } |
annieluo2 | 0:d6c9b09b4042 | 3654 | |
annieluo2 | 0:d6c9b09b4042 | 3655 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3656 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3657 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3658 | */ |
annieluo2 | 0:d6c9b09b4042 | 3659 | Callback(R (*func)(void*, A0, A1, A2, A3, A4), void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3660 | generate(function_context<R (*)(void*, A0, A1, A2, A3, A4), void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 3661 | } |
annieluo2 | 0:d6c9b09b4042 | 3662 | |
annieluo2 | 0:d6c9b09b4042 | 3663 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3664 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3665 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3666 | */ |
annieluo2 | 0:d6c9b09b4042 | 3667 | Callback(R (*func)(const void*, A0, A1, A2, A3, A4), const void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3668 | generate(function_context<R (*)(const void*, A0, A1, A2, A3, A4), const void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 3669 | } |
annieluo2 | 0:d6c9b09b4042 | 3670 | |
annieluo2 | 0:d6c9b09b4042 | 3671 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3672 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3673 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3674 | */ |
annieluo2 | 0:d6c9b09b4042 | 3675 | Callback(R (*func)(volatile void*, A0, A1, A2, A3, A4), volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3676 | generate(function_context<R (*)(volatile void*, A0, A1, A2, A3, A4), volatile void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 3677 | } |
annieluo2 | 0:d6c9b09b4042 | 3678 | |
annieluo2 | 0:d6c9b09b4042 | 3679 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3680 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3681 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3682 | */ |
annieluo2 | 0:d6c9b09b4042 | 3683 | Callback(R (*func)(const volatile void*, A0, A1, A2, A3, A4), const volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3684 | generate(function_context<R (*)(const volatile void*, A0, A1, A2, A3, A4), const volatile void>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 3685 | } |
annieluo2 | 0:d6c9b09b4042 | 3686 | |
annieluo2 | 0:d6c9b09b4042 | 3687 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3688 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3689 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3690 | */ |
annieluo2 | 0:d6c9b09b4042 | 3691 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3692 | Callback(R (*func)(T*, A0, A1, A2, A3, A4), T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3693 | generate(function_context<R (*)(T*, A0, A1, A2, A3, A4), T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 3694 | } |
annieluo2 | 0:d6c9b09b4042 | 3695 | |
annieluo2 | 0:d6c9b09b4042 | 3696 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3697 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3698 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3699 | */ |
annieluo2 | 0:d6c9b09b4042 | 3700 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3701 | Callback(R (*func)(const T*, A0, A1, A2, A3, A4), const T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3702 | generate(function_context<R (*)(const T*, A0, A1, A2, A3, A4), const T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 3703 | } |
annieluo2 | 0:d6c9b09b4042 | 3704 | |
annieluo2 | 0:d6c9b09b4042 | 3705 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3706 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3707 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3708 | */ |
annieluo2 | 0:d6c9b09b4042 | 3709 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3710 | Callback(R (*func)(volatile T*, A0, A1, A2, A3, A4), volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3711 | generate(function_context<R (*)(volatile T*, A0, A1, A2, A3, A4), volatile T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 3712 | } |
annieluo2 | 0:d6c9b09b4042 | 3713 | |
annieluo2 | 0:d6c9b09b4042 | 3714 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3715 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3716 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3717 | */ |
annieluo2 | 0:d6c9b09b4042 | 3718 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3719 | Callback(R (*func)(const volatile T*, A0, A1, A2, A3, A4), const volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3720 | generate(function_context<R (*)(const volatile T*, A0, A1, A2, A3, A4), const volatile T>(func, arg)); |
annieluo2 | 0:d6c9b09b4042 | 3721 | } |
annieluo2 | 0:d6c9b09b4042 | 3722 | |
annieluo2 | 0:d6c9b09b4042 | 3723 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 3724 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 3725 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 3726 | */ |
annieluo2 | 0:d6c9b09b4042 | 3727 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 3728 | Callback(F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 3729 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4), &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 3730 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 3731 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 3732 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 3733 | } |
annieluo2 | 0:d6c9b09b4042 | 3734 | |
annieluo2 | 0:d6c9b09b4042 | 3735 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 3736 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 3737 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 3738 | */ |
annieluo2 | 0:d6c9b09b4042 | 3739 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 3740 | Callback(const F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 3741 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4) const, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 3742 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 3743 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 3744 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 3745 | } |
annieluo2 | 0:d6c9b09b4042 | 3746 | |
annieluo2 | 0:d6c9b09b4042 | 3747 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 3748 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 3749 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 3750 | */ |
annieluo2 | 0:d6c9b09b4042 | 3751 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 3752 | Callback(volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 3753 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4) volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 3754 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 3755 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 3756 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 3757 | } |
annieluo2 | 0:d6c9b09b4042 | 3758 | |
annieluo2 | 0:d6c9b09b4042 | 3759 | /** Create a Callback with a function object |
annieluo2 | 0:d6c9b09b4042 | 3760 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 3761 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 3762 | */ |
annieluo2 | 0:d6c9b09b4042 | 3763 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 3764 | Callback(const volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 3765 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4) const volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 3766 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 3767 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 3768 | generate(f); |
annieluo2 | 0:d6c9b09b4042 | 3769 | } |
annieluo2 | 0:d6c9b09b4042 | 3770 | |
annieluo2 | 0:d6c9b09b4042 | 3771 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3772 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3773 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3774 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3775 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3776 | */ |
annieluo2 | 0:d6c9b09b4042 | 3777 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3778 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3779 | Callback(void *obj, R (*func)(void*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 3780 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3781 | } |
annieluo2 | 0:d6c9b09b4042 | 3782 | |
annieluo2 | 0:d6c9b09b4042 | 3783 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3784 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3785 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3786 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3787 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3788 | */ |
annieluo2 | 0:d6c9b09b4042 | 3789 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3790 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3791 | Callback(const void *obj, R (*func)(const void*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 3792 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3793 | } |
annieluo2 | 0:d6c9b09b4042 | 3794 | |
annieluo2 | 0:d6c9b09b4042 | 3795 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3796 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3797 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3798 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3799 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3800 | */ |
annieluo2 | 0:d6c9b09b4042 | 3801 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3802 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3803 | Callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 3804 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3805 | } |
annieluo2 | 0:d6c9b09b4042 | 3806 | |
annieluo2 | 0:d6c9b09b4042 | 3807 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3808 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3809 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3810 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3811 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3812 | */ |
annieluo2 | 0:d6c9b09b4042 | 3813 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3814 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3815 | Callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 3816 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3817 | } |
annieluo2 | 0:d6c9b09b4042 | 3818 | |
annieluo2 | 0:d6c9b09b4042 | 3819 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3820 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3821 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3822 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3823 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3824 | */ |
annieluo2 | 0:d6c9b09b4042 | 3825 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3826 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3827 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3828 | Callback(T *obj, R (*func)(T*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 3829 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3830 | } |
annieluo2 | 0:d6c9b09b4042 | 3831 | |
annieluo2 | 0:d6c9b09b4042 | 3832 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3833 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3834 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3835 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3836 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3837 | */ |
annieluo2 | 0:d6c9b09b4042 | 3838 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3839 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3840 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3841 | Callback(const T *obj, R (*func)(const T*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 3842 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3843 | } |
annieluo2 | 0:d6c9b09b4042 | 3844 | |
annieluo2 | 0:d6c9b09b4042 | 3845 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3846 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3847 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3848 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3849 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3850 | */ |
annieluo2 | 0:d6c9b09b4042 | 3851 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3852 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3853 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3854 | Callback(volatile T *obj, R (*func)(volatile T*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 3855 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3856 | } |
annieluo2 | 0:d6c9b09b4042 | 3857 | |
annieluo2 | 0:d6c9b09b4042 | 3858 | /** Create a Callback with a static function and bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3859 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 3860 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3861 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 3862 | * Arguments to callback have been reordered to Callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 3863 | */ |
annieluo2 | 0:d6c9b09b4042 | 3864 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3865 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 3866 | "Arguments to callback have been reordered to Callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 3867 | Callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 3868 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 3869 | } |
annieluo2 | 0:d6c9b09b4042 | 3870 | |
annieluo2 | 0:d6c9b09b4042 | 3871 | /** Destroy a callback |
annieluo2 | 0:d6c9b09b4042 | 3872 | */ |
annieluo2 | 0:d6c9b09b4042 | 3873 | ~Callback() { |
annieluo2 | 0:d6c9b09b4042 | 3874 | if (_ops) { |
annieluo2 | 0:d6c9b09b4042 | 3875 | _ops->dtor(this); |
annieluo2 | 0:d6c9b09b4042 | 3876 | } |
annieluo2 | 0:d6c9b09b4042 | 3877 | } |
annieluo2 | 0:d6c9b09b4042 | 3878 | |
annieluo2 | 0:d6c9b09b4042 | 3879 | /** Attach a static function |
annieluo2 | 0:d6c9b09b4042 | 3880 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3881 | */ |
annieluo2 | 0:d6c9b09b4042 | 3882 | void attach(R (*func)(A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 3883 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3884 | new (this) Callback(func); |
annieluo2 | 0:d6c9b09b4042 | 3885 | } |
annieluo2 | 0:d6c9b09b4042 | 3886 | |
annieluo2 | 0:d6c9b09b4042 | 3887 | /** Attach a Callback |
annieluo2 | 0:d6c9b09b4042 | 3888 | * @param func The Callback to attach |
annieluo2 | 0:d6c9b09b4042 | 3889 | */ |
annieluo2 | 0:d6c9b09b4042 | 3890 | void attach(const Callback<R(A0, A1, A2, A3, A4)> &func) { |
annieluo2 | 0:d6c9b09b4042 | 3891 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3892 | new (this) Callback(func); |
annieluo2 | 0:d6c9b09b4042 | 3893 | } |
annieluo2 | 0:d6c9b09b4042 | 3894 | |
annieluo2 | 0:d6c9b09b4042 | 3895 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 3896 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 3897 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 3898 | */ |
annieluo2 | 0:d6c9b09b4042 | 3899 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3900 | void attach(T *obj, R (T::*method)(A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 3901 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3902 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 3903 | } |
annieluo2 | 0:d6c9b09b4042 | 3904 | |
annieluo2 | 0:d6c9b09b4042 | 3905 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 3906 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 3907 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 3908 | */ |
annieluo2 | 0:d6c9b09b4042 | 3909 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3910 | void attach(const T *obj, R (T::*method)(A0, A1, A2, A3, A4) const) { |
annieluo2 | 0:d6c9b09b4042 | 3911 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3912 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 3913 | } |
annieluo2 | 0:d6c9b09b4042 | 3914 | |
annieluo2 | 0:d6c9b09b4042 | 3915 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 3916 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 3917 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 3918 | */ |
annieluo2 | 0:d6c9b09b4042 | 3919 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3920 | void attach(volatile T *obj, R (T::*method)(A0, A1, A2, A3, A4) volatile) { |
annieluo2 | 0:d6c9b09b4042 | 3921 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3922 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 3923 | } |
annieluo2 | 0:d6c9b09b4042 | 3924 | |
annieluo2 | 0:d6c9b09b4042 | 3925 | /** Attach a member function |
annieluo2 | 0:d6c9b09b4042 | 3926 | * @param obj Pointer to object to invoke member function on |
annieluo2 | 0:d6c9b09b4042 | 3927 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 3928 | */ |
annieluo2 | 0:d6c9b09b4042 | 3929 | template<typename T> |
annieluo2 | 0:d6c9b09b4042 | 3930 | void attach(const volatile T *obj, R (T::*method)(A0, A1, A2, A3, A4) const volatile) { |
annieluo2 | 0:d6c9b09b4042 | 3931 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3932 | new (this) Callback(obj, method); |
annieluo2 | 0:d6c9b09b4042 | 3933 | } |
annieluo2 | 0:d6c9b09b4042 | 3934 | |
annieluo2 | 0:d6c9b09b4042 | 3935 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3936 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3937 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3938 | */ |
annieluo2 | 0:d6c9b09b4042 | 3939 | void attach(R (*func)(void*, A0, A1, A2, A3, A4), void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3940 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3941 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 3942 | } |
annieluo2 | 0:d6c9b09b4042 | 3943 | |
annieluo2 | 0:d6c9b09b4042 | 3944 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3945 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3946 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3947 | */ |
annieluo2 | 0:d6c9b09b4042 | 3948 | void attach(R (*func)(const void*, A0, A1, A2, A3, A4), const void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3949 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3950 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 3951 | } |
annieluo2 | 0:d6c9b09b4042 | 3952 | |
annieluo2 | 0:d6c9b09b4042 | 3953 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3954 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3955 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3956 | */ |
annieluo2 | 0:d6c9b09b4042 | 3957 | void attach(R (*func)(volatile void*, A0, A1, A2, A3, A4), volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3958 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3959 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 3960 | } |
annieluo2 | 0:d6c9b09b4042 | 3961 | |
annieluo2 | 0:d6c9b09b4042 | 3962 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3963 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3964 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3965 | */ |
annieluo2 | 0:d6c9b09b4042 | 3966 | void attach(R (*func)(const volatile void*, A0, A1, A2, A3, A4), const volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3967 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3968 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 3969 | } |
annieluo2 | 0:d6c9b09b4042 | 3970 | |
annieluo2 | 0:d6c9b09b4042 | 3971 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3972 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3973 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3974 | */ |
annieluo2 | 0:d6c9b09b4042 | 3975 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 3976 | void attach(R (*func)(T*, A0, A1, A2, A3, A4), T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3977 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3978 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 3979 | } |
annieluo2 | 0:d6c9b09b4042 | 3980 | |
annieluo2 | 0:d6c9b09b4042 | 3981 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3982 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3983 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3984 | */ |
annieluo2 | 0:d6c9b09b4042 | 3985 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 3986 | void attach(R (*func)(const T*, A0, A1, A2, A3, A4), const T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3987 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3988 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 3989 | } |
annieluo2 | 0:d6c9b09b4042 | 3990 | |
annieluo2 | 0:d6c9b09b4042 | 3991 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 3992 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 3993 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 3994 | */ |
annieluo2 | 0:d6c9b09b4042 | 3995 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 3996 | void attach(R (*func)(volatile T*, A0, A1, A2, A3, A4), volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 3997 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 3998 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 3999 | } |
annieluo2 | 0:d6c9b09b4042 | 4000 | |
annieluo2 | 0:d6c9b09b4042 | 4001 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 4002 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4003 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4004 | */ |
annieluo2 | 0:d6c9b09b4042 | 4005 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 4006 | void attach(R (*func)(const volatile T*, A0, A1, A2, A3, A4), const volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4007 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 4008 | new (this) Callback(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4009 | } |
annieluo2 | 0:d6c9b09b4042 | 4010 | |
annieluo2 | 0:d6c9b09b4042 | 4011 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 4012 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 4013 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 4014 | */ |
annieluo2 | 0:d6c9b09b4042 | 4015 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 4016 | void attach(F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 4017 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4), &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 4018 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 4019 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 4020 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 4021 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 4022 | } |
annieluo2 | 0:d6c9b09b4042 | 4023 | |
annieluo2 | 0:d6c9b09b4042 | 4024 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 4025 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 4026 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 4027 | */ |
annieluo2 | 0:d6c9b09b4042 | 4028 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 4029 | void attach(const F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 4030 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4) const, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 4031 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 4032 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 4033 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 4034 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 4035 | } |
annieluo2 | 0:d6c9b09b4042 | 4036 | |
annieluo2 | 0:d6c9b09b4042 | 4037 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 4038 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 4039 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 4040 | */ |
annieluo2 | 0:d6c9b09b4042 | 4041 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 4042 | void attach(volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 4043 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4) volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 4044 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 4045 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 4046 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 4047 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 4048 | } |
annieluo2 | 0:d6c9b09b4042 | 4049 | |
annieluo2 | 0:d6c9b09b4042 | 4050 | /** Attach a function object |
annieluo2 | 0:d6c9b09b4042 | 4051 | * @param func Function object to attach |
annieluo2 | 0:d6c9b09b4042 | 4052 | * @note The function object is limited to a single word of storage |
annieluo2 | 0:d6c9b09b4042 | 4053 | */ |
annieluo2 | 0:d6c9b09b4042 | 4054 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 4055 | void attach(const volatile F f, typename detail::enable_if< |
annieluo2 | 0:d6c9b09b4042 | 4056 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4) const volatile, &F::operator()>::value && |
annieluo2 | 0:d6c9b09b4042 | 4057 | sizeof(F) <= sizeof(uintptr_t) |
annieluo2 | 0:d6c9b09b4042 | 4058 | >::type = detail::nil()) { |
annieluo2 | 0:d6c9b09b4042 | 4059 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 4060 | new (this) Callback(f); |
annieluo2 | 0:d6c9b09b4042 | 4061 | } |
annieluo2 | 0:d6c9b09b4042 | 4062 | |
annieluo2 | 0:d6c9b09b4042 | 4063 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 4064 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4065 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4066 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4067 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4068 | */ |
annieluo2 | 0:d6c9b09b4042 | 4069 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4070 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4071 | void attach(void *obj, R (*func)(void*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 4072 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 4073 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4074 | } |
annieluo2 | 0:d6c9b09b4042 | 4075 | |
annieluo2 | 0:d6c9b09b4042 | 4076 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 4077 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4078 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4079 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4080 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4081 | */ |
annieluo2 | 0:d6c9b09b4042 | 4082 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4083 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4084 | void attach(const void *obj, R (*func)(const void*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 4085 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 4086 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4087 | } |
annieluo2 | 0:d6c9b09b4042 | 4088 | |
annieluo2 | 0:d6c9b09b4042 | 4089 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 4090 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4091 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4092 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4093 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4094 | */ |
annieluo2 | 0:d6c9b09b4042 | 4095 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4096 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4097 | void attach(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 4098 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 4099 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4100 | } |
annieluo2 | 0:d6c9b09b4042 | 4101 | |
annieluo2 | 0:d6c9b09b4042 | 4102 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 4103 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4104 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4105 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4106 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4107 | */ |
annieluo2 | 0:d6c9b09b4042 | 4108 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4109 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4110 | void attach(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 4111 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 4112 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4113 | } |
annieluo2 | 0:d6c9b09b4042 | 4114 | |
annieluo2 | 0:d6c9b09b4042 | 4115 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 4116 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4117 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4118 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4119 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4120 | */ |
annieluo2 | 0:d6c9b09b4042 | 4121 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 4122 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4123 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4124 | void attach(T *obj, R (*func)(T*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 4125 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 4126 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4127 | } |
annieluo2 | 0:d6c9b09b4042 | 4128 | |
annieluo2 | 0:d6c9b09b4042 | 4129 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 4130 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4131 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4132 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4133 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4134 | */ |
annieluo2 | 0:d6c9b09b4042 | 4135 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 4136 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4137 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4138 | void attach(const T *obj, R (*func)(const T*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 4139 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 4140 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4141 | } |
annieluo2 | 0:d6c9b09b4042 | 4142 | |
annieluo2 | 0:d6c9b09b4042 | 4143 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 4144 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4145 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4146 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4147 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4148 | */ |
annieluo2 | 0:d6c9b09b4042 | 4149 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 4150 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4151 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4152 | void attach(volatile T *obj, R (*func)(volatile T*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 4153 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 4154 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4155 | } |
annieluo2 | 0:d6c9b09b4042 | 4156 | |
annieluo2 | 0:d6c9b09b4042 | 4157 | /** Attach a static function with a bound pointer |
annieluo2 | 0:d6c9b09b4042 | 4158 | * @param obj Pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4159 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4160 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4161 | * Arguments to callback have been reordered to attach(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4162 | */ |
annieluo2 | 0:d6c9b09b4042 | 4163 | template <typename T> |
annieluo2 | 0:d6c9b09b4042 | 4164 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4165 | "Arguments to callback have been reordered to attach(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4166 | void attach(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 4167 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 4168 | new (this) Callback(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4169 | } |
annieluo2 | 0:d6c9b09b4042 | 4170 | |
annieluo2 | 0:d6c9b09b4042 | 4171 | /** Assign a callback |
annieluo2 | 0:d6c9b09b4042 | 4172 | */ |
annieluo2 | 0:d6c9b09b4042 | 4173 | Callback &operator=(const Callback &that) { |
annieluo2 | 0:d6c9b09b4042 | 4174 | if (this != &that) { |
annieluo2 | 0:d6c9b09b4042 | 4175 | this->~Callback(); |
annieluo2 | 0:d6c9b09b4042 | 4176 | new (this) Callback(that); |
annieluo2 | 0:d6c9b09b4042 | 4177 | } |
annieluo2 | 0:d6c9b09b4042 | 4178 | |
annieluo2 | 0:d6c9b09b4042 | 4179 | return *this; |
annieluo2 | 0:d6c9b09b4042 | 4180 | } |
annieluo2 | 0:d6c9b09b4042 | 4181 | |
annieluo2 | 0:d6c9b09b4042 | 4182 | /** Call the attached function |
annieluo2 | 0:d6c9b09b4042 | 4183 | */ |
annieluo2 | 0:d6c9b09b4042 | 4184 | R call(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const { |
annieluo2 | 0:d6c9b09b4042 | 4185 | MBED_ASSERT(_ops); |
annieluo2 | 0:d6c9b09b4042 | 4186 | return _ops->call(this, a0, a1, a2, a3, a4); |
annieluo2 | 0:d6c9b09b4042 | 4187 | } |
annieluo2 | 0:d6c9b09b4042 | 4188 | |
annieluo2 | 0:d6c9b09b4042 | 4189 | /** Call the attached function |
annieluo2 | 0:d6c9b09b4042 | 4190 | */ |
annieluo2 | 0:d6c9b09b4042 | 4191 | R operator()(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const { |
annieluo2 | 0:d6c9b09b4042 | 4192 | return call(a0, a1, a2, a3, a4); |
annieluo2 | 0:d6c9b09b4042 | 4193 | } |
annieluo2 | 0:d6c9b09b4042 | 4194 | |
annieluo2 | 0:d6c9b09b4042 | 4195 | /** Test if function has been attached |
annieluo2 | 0:d6c9b09b4042 | 4196 | */ |
annieluo2 | 0:d6c9b09b4042 | 4197 | operator bool() const { |
annieluo2 | 0:d6c9b09b4042 | 4198 | return _ops; |
annieluo2 | 0:d6c9b09b4042 | 4199 | } |
annieluo2 | 0:d6c9b09b4042 | 4200 | |
annieluo2 | 0:d6c9b09b4042 | 4201 | /** Test for equality |
annieluo2 | 0:d6c9b09b4042 | 4202 | */ |
annieluo2 | 0:d6c9b09b4042 | 4203 | friend bool operator==(const Callback &l, const Callback &r) { |
annieluo2 | 0:d6c9b09b4042 | 4204 | return memcmp(&l, &r, sizeof(Callback)) == 0; |
annieluo2 | 0:d6c9b09b4042 | 4205 | } |
annieluo2 | 0:d6c9b09b4042 | 4206 | |
annieluo2 | 0:d6c9b09b4042 | 4207 | /** Test for inequality |
annieluo2 | 0:d6c9b09b4042 | 4208 | */ |
annieluo2 | 0:d6c9b09b4042 | 4209 | friend bool operator!=(const Callback &l, const Callback &r) { |
annieluo2 | 0:d6c9b09b4042 | 4210 | return !(l == r); |
annieluo2 | 0:d6c9b09b4042 | 4211 | } |
annieluo2 | 0:d6c9b09b4042 | 4212 | |
annieluo2 | 0:d6c9b09b4042 | 4213 | /** Static thunk for passing as C-style function |
annieluo2 | 0:d6c9b09b4042 | 4214 | * @param func Callback to call passed as void pointer |
annieluo2 | 0:d6c9b09b4042 | 4215 | */ |
annieluo2 | 0:d6c9b09b4042 | 4216 | static R thunk(void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { |
annieluo2 | 0:d6c9b09b4042 | 4217 | return static_cast<Callback*>(func)->call(a0, a1, a2, a3, a4); |
annieluo2 | 0:d6c9b09b4042 | 4218 | } |
annieluo2 | 0:d6c9b09b4042 | 4219 | |
annieluo2 | 0:d6c9b09b4042 | 4220 | private: |
annieluo2 | 0:d6c9b09b4042 | 4221 | // Stored as pointer to function and pointer to optional object |
annieluo2 | 0:d6c9b09b4042 | 4222 | // Function pointer is stored as union of possible function types |
annieluo2 | 0:d6c9b09b4042 | 4223 | // to garuntee proper size and alignment |
annieluo2 | 0:d6c9b09b4042 | 4224 | struct _class; |
annieluo2 | 0:d6c9b09b4042 | 4225 | union { |
annieluo2 | 0:d6c9b09b4042 | 4226 | void (*_staticfunc)(A0, A1, A2, A3, A4); |
annieluo2 | 0:d6c9b09b4042 | 4227 | void (*_boundfunc)(_class*, A0, A1, A2, A3, A4); |
annieluo2 | 0:d6c9b09b4042 | 4228 | void (_class::*_methodfunc)(A0, A1, A2, A3, A4); |
annieluo2 | 0:d6c9b09b4042 | 4229 | } _func; |
annieluo2 | 0:d6c9b09b4042 | 4230 | void *_obj; |
annieluo2 | 0:d6c9b09b4042 | 4231 | |
annieluo2 | 0:d6c9b09b4042 | 4232 | // Dynamically dispatched operations |
annieluo2 | 0:d6c9b09b4042 | 4233 | const struct ops { |
annieluo2 | 0:d6c9b09b4042 | 4234 | R (*call)(const void*, A0, A1, A2, A3, A4); |
annieluo2 | 0:d6c9b09b4042 | 4235 | void (*move)(void*, const void*); |
annieluo2 | 0:d6c9b09b4042 | 4236 | void (*dtor)(void*); |
annieluo2 | 0:d6c9b09b4042 | 4237 | } *_ops; |
annieluo2 | 0:d6c9b09b4042 | 4238 | |
annieluo2 | 0:d6c9b09b4042 | 4239 | // Generate operations for function object |
annieluo2 | 0:d6c9b09b4042 | 4240 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 4241 | void generate(const F &f) { |
annieluo2 | 0:d6c9b09b4042 | 4242 | static const ops ops = { |
annieluo2 | 0:d6c9b09b4042 | 4243 | &Callback::function_call<F>, |
annieluo2 | 0:d6c9b09b4042 | 4244 | &Callback::function_move<F>, |
annieluo2 | 0:d6c9b09b4042 | 4245 | &Callback::function_dtor<F>, |
annieluo2 | 0:d6c9b09b4042 | 4246 | }; |
annieluo2 | 0:d6c9b09b4042 | 4247 | |
annieluo2 | 0:d6c9b09b4042 | 4248 | MBED_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F)); |
annieluo2 | 0:d6c9b09b4042 | 4249 | new (this) F(f); |
annieluo2 | 0:d6c9b09b4042 | 4250 | _ops = &ops; |
annieluo2 | 0:d6c9b09b4042 | 4251 | } |
annieluo2 | 0:d6c9b09b4042 | 4252 | |
annieluo2 | 0:d6c9b09b4042 | 4253 | // Function attributes |
annieluo2 | 0:d6c9b09b4042 | 4254 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 4255 | static R function_call(const void *p, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { |
annieluo2 | 0:d6c9b09b4042 | 4256 | return (*(F*)p)(a0, a1, a2, a3, a4); |
annieluo2 | 0:d6c9b09b4042 | 4257 | } |
annieluo2 | 0:d6c9b09b4042 | 4258 | |
annieluo2 | 0:d6c9b09b4042 | 4259 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 4260 | static void function_move(void *d, const void *p) { |
annieluo2 | 0:d6c9b09b4042 | 4261 | new (d) F(*(F*)p); |
annieluo2 | 0:d6c9b09b4042 | 4262 | } |
annieluo2 | 0:d6c9b09b4042 | 4263 | |
annieluo2 | 0:d6c9b09b4042 | 4264 | template <typename F> |
annieluo2 | 0:d6c9b09b4042 | 4265 | static void function_dtor(void *p) { |
annieluo2 | 0:d6c9b09b4042 | 4266 | ((F*)p)->~F(); |
annieluo2 | 0:d6c9b09b4042 | 4267 | } |
annieluo2 | 0:d6c9b09b4042 | 4268 | |
annieluo2 | 0:d6c9b09b4042 | 4269 | // Wrappers for functions with context |
annieluo2 | 0:d6c9b09b4042 | 4270 | template <typename O, typename M> |
annieluo2 | 0:d6c9b09b4042 | 4271 | struct method_context { |
annieluo2 | 0:d6c9b09b4042 | 4272 | M method; |
annieluo2 | 0:d6c9b09b4042 | 4273 | O *obj; |
annieluo2 | 0:d6c9b09b4042 | 4274 | |
annieluo2 | 0:d6c9b09b4042 | 4275 | method_context(O *obj, M method) |
annieluo2 | 0:d6c9b09b4042 | 4276 | : method(method), obj(obj) {} |
annieluo2 | 0:d6c9b09b4042 | 4277 | |
annieluo2 | 0:d6c9b09b4042 | 4278 | R operator()(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const { |
annieluo2 | 0:d6c9b09b4042 | 4279 | return (obj->*method)(a0, a1, a2, a3, a4); |
annieluo2 | 0:d6c9b09b4042 | 4280 | } |
annieluo2 | 0:d6c9b09b4042 | 4281 | }; |
annieluo2 | 0:d6c9b09b4042 | 4282 | |
annieluo2 | 0:d6c9b09b4042 | 4283 | template <typename F, typename A> |
annieluo2 | 0:d6c9b09b4042 | 4284 | struct function_context { |
annieluo2 | 0:d6c9b09b4042 | 4285 | F func; |
annieluo2 | 0:d6c9b09b4042 | 4286 | A *arg; |
annieluo2 | 0:d6c9b09b4042 | 4287 | |
annieluo2 | 0:d6c9b09b4042 | 4288 | function_context(F func, A *arg) |
annieluo2 | 0:d6c9b09b4042 | 4289 | : func(func), arg(arg) {} |
annieluo2 | 0:d6c9b09b4042 | 4290 | |
annieluo2 | 0:d6c9b09b4042 | 4291 | R operator()(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const { |
annieluo2 | 0:d6c9b09b4042 | 4292 | return func(arg, a0, a1, a2, a3, a4); |
annieluo2 | 0:d6c9b09b4042 | 4293 | } |
annieluo2 | 0:d6c9b09b4042 | 4294 | }; |
annieluo2 | 0:d6c9b09b4042 | 4295 | }; |
annieluo2 | 0:d6c9b09b4042 | 4296 | |
annieluo2 | 0:d6c9b09b4042 | 4297 | // Internally used event type |
annieluo2 | 0:d6c9b09b4042 | 4298 | typedef Callback<void(int)> event_callback_t; |
annieluo2 | 0:d6c9b09b4042 | 4299 | |
annieluo2 | 0:d6c9b09b4042 | 4300 | |
annieluo2 | 0:d6c9b09b4042 | 4301 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4302 | * |
annieluo2 | 0:d6c9b09b4042 | 4303 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4304 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4305 | */ |
annieluo2 | 0:d6c9b09b4042 | 4306 | template <typename R> |
annieluo2 | 0:d6c9b09b4042 | 4307 | Callback<R()> callback(R (*func)() = 0) { |
annieluo2 | 0:d6c9b09b4042 | 4308 | return Callback<R()>(func); |
annieluo2 | 0:d6c9b09b4042 | 4309 | } |
annieluo2 | 0:d6c9b09b4042 | 4310 | |
annieluo2 | 0:d6c9b09b4042 | 4311 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4312 | * |
annieluo2 | 0:d6c9b09b4042 | 4313 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4314 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4315 | */ |
annieluo2 | 0:d6c9b09b4042 | 4316 | template <typename R> |
annieluo2 | 0:d6c9b09b4042 | 4317 | Callback<R()> callback(const Callback<R()> &func) { |
annieluo2 | 0:d6c9b09b4042 | 4318 | return Callback<R()>(func); |
annieluo2 | 0:d6c9b09b4042 | 4319 | } |
annieluo2 | 0:d6c9b09b4042 | 4320 | |
annieluo2 | 0:d6c9b09b4042 | 4321 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4322 | * |
annieluo2 | 0:d6c9b09b4042 | 4323 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4324 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 4325 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4326 | */ |
annieluo2 | 0:d6c9b09b4042 | 4327 | template<typename T, typename R> |
annieluo2 | 0:d6c9b09b4042 | 4328 | Callback<R()> callback(T *obj, R (T::*func)()) { |
annieluo2 | 0:d6c9b09b4042 | 4329 | return Callback<R()>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 4330 | } |
annieluo2 | 0:d6c9b09b4042 | 4331 | |
annieluo2 | 0:d6c9b09b4042 | 4332 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4333 | * |
annieluo2 | 0:d6c9b09b4042 | 4334 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4335 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 4336 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4337 | */ |
annieluo2 | 0:d6c9b09b4042 | 4338 | template<typename T, typename R> |
annieluo2 | 0:d6c9b09b4042 | 4339 | Callback<R()> callback(const T *obj, R (T::*func)() const) { |
annieluo2 | 0:d6c9b09b4042 | 4340 | return Callback<R()>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 4341 | } |
annieluo2 | 0:d6c9b09b4042 | 4342 | |
annieluo2 | 0:d6c9b09b4042 | 4343 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4344 | * |
annieluo2 | 0:d6c9b09b4042 | 4345 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4346 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 4347 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4348 | */ |
annieluo2 | 0:d6c9b09b4042 | 4349 | template<typename T, typename R> |
annieluo2 | 0:d6c9b09b4042 | 4350 | Callback<R()> callback(volatile T *obj, R (T::*func)() volatile) { |
annieluo2 | 0:d6c9b09b4042 | 4351 | return Callback<R()>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 4352 | } |
annieluo2 | 0:d6c9b09b4042 | 4353 | |
annieluo2 | 0:d6c9b09b4042 | 4354 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4355 | * |
annieluo2 | 0:d6c9b09b4042 | 4356 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4357 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 4358 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4359 | */ |
annieluo2 | 0:d6c9b09b4042 | 4360 | template<typename T, typename R> |
annieluo2 | 0:d6c9b09b4042 | 4361 | Callback<R()> callback(const volatile T *obj, R (T::*func)() const volatile) { |
annieluo2 | 0:d6c9b09b4042 | 4362 | return Callback<R()>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 4363 | } |
annieluo2 | 0:d6c9b09b4042 | 4364 | |
annieluo2 | 0:d6c9b09b4042 | 4365 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4366 | * |
annieluo2 | 0:d6c9b09b4042 | 4367 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4368 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4369 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4370 | */ |
annieluo2 | 0:d6c9b09b4042 | 4371 | template <typename R> |
annieluo2 | 0:d6c9b09b4042 | 4372 | Callback<R()> callback(R (*func)(void*), void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4373 | return Callback<R()>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4374 | } |
annieluo2 | 0:d6c9b09b4042 | 4375 | |
annieluo2 | 0:d6c9b09b4042 | 4376 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4377 | * |
annieluo2 | 0:d6c9b09b4042 | 4378 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4379 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4380 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4381 | */ |
annieluo2 | 0:d6c9b09b4042 | 4382 | template <typename R> |
annieluo2 | 0:d6c9b09b4042 | 4383 | Callback<R()> callback(R (*func)(const void*), const void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4384 | return Callback<R()>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4385 | } |
annieluo2 | 0:d6c9b09b4042 | 4386 | |
annieluo2 | 0:d6c9b09b4042 | 4387 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4388 | * |
annieluo2 | 0:d6c9b09b4042 | 4389 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4390 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4391 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4392 | */ |
annieluo2 | 0:d6c9b09b4042 | 4393 | template <typename R> |
annieluo2 | 0:d6c9b09b4042 | 4394 | Callback<R()> callback(R (*func)(volatile void*), volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4395 | return Callback<R()>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4396 | } |
annieluo2 | 0:d6c9b09b4042 | 4397 | |
annieluo2 | 0:d6c9b09b4042 | 4398 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4399 | * |
annieluo2 | 0:d6c9b09b4042 | 4400 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4401 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4402 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4403 | */ |
annieluo2 | 0:d6c9b09b4042 | 4404 | template <typename R> |
annieluo2 | 0:d6c9b09b4042 | 4405 | Callback<R()> callback(R (*func)(const volatile void*), const volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4406 | return Callback<R()>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4407 | } |
annieluo2 | 0:d6c9b09b4042 | 4408 | |
annieluo2 | 0:d6c9b09b4042 | 4409 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4410 | * |
annieluo2 | 0:d6c9b09b4042 | 4411 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4412 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4413 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4414 | */ |
annieluo2 | 0:d6c9b09b4042 | 4415 | template <typename T, typename R> |
annieluo2 | 0:d6c9b09b4042 | 4416 | Callback<R()> callback(R (*func)(T*), T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4417 | return Callback<R()>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4418 | } |
annieluo2 | 0:d6c9b09b4042 | 4419 | |
annieluo2 | 0:d6c9b09b4042 | 4420 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4421 | * |
annieluo2 | 0:d6c9b09b4042 | 4422 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4423 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4424 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4425 | */ |
annieluo2 | 0:d6c9b09b4042 | 4426 | template <typename T, typename R> |
annieluo2 | 0:d6c9b09b4042 | 4427 | Callback<R()> callback(R (*func)(const T*), const T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4428 | return Callback<R()>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4429 | } |
annieluo2 | 0:d6c9b09b4042 | 4430 | |
annieluo2 | 0:d6c9b09b4042 | 4431 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4432 | * |
annieluo2 | 0:d6c9b09b4042 | 4433 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4434 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4435 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4436 | */ |
annieluo2 | 0:d6c9b09b4042 | 4437 | template <typename T, typename R> |
annieluo2 | 0:d6c9b09b4042 | 4438 | Callback<R()> callback(R (*func)(volatile T*), volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4439 | return Callback<R()>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4440 | } |
annieluo2 | 0:d6c9b09b4042 | 4441 | |
annieluo2 | 0:d6c9b09b4042 | 4442 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4443 | * |
annieluo2 | 0:d6c9b09b4042 | 4444 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4445 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4446 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4447 | */ |
annieluo2 | 0:d6c9b09b4042 | 4448 | template <typename T, typename R> |
annieluo2 | 0:d6c9b09b4042 | 4449 | Callback<R()> callback(R (*func)(const volatile T*), const volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4450 | return Callback<R()>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4451 | } |
annieluo2 | 0:d6c9b09b4042 | 4452 | |
annieluo2 | 0:d6c9b09b4042 | 4453 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4454 | * |
annieluo2 | 0:d6c9b09b4042 | 4455 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4456 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4457 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4458 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4459 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4460 | */ |
annieluo2 | 0:d6c9b09b4042 | 4461 | template <typename R> |
annieluo2 | 0:d6c9b09b4042 | 4462 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4463 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4464 | Callback<R()> callback(void *obj, R (*func)(void*)) { |
annieluo2 | 0:d6c9b09b4042 | 4465 | return Callback<R()>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4466 | } |
annieluo2 | 0:d6c9b09b4042 | 4467 | |
annieluo2 | 0:d6c9b09b4042 | 4468 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4469 | * |
annieluo2 | 0:d6c9b09b4042 | 4470 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4471 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4472 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4473 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4474 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4475 | */ |
annieluo2 | 0:d6c9b09b4042 | 4476 | template <typename R> |
annieluo2 | 0:d6c9b09b4042 | 4477 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4478 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4479 | Callback<R()> callback(const void *obj, R (*func)(const void*)) { |
annieluo2 | 0:d6c9b09b4042 | 4480 | return Callback<R()>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4481 | } |
annieluo2 | 0:d6c9b09b4042 | 4482 | |
annieluo2 | 0:d6c9b09b4042 | 4483 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4484 | * |
annieluo2 | 0:d6c9b09b4042 | 4485 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4486 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4487 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4488 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4489 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4490 | */ |
annieluo2 | 0:d6c9b09b4042 | 4491 | template <typename R> |
annieluo2 | 0:d6c9b09b4042 | 4492 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4493 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4494 | Callback<R()> callback(volatile void *obj, R (*func)(volatile void*)) { |
annieluo2 | 0:d6c9b09b4042 | 4495 | return Callback<R()>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4496 | } |
annieluo2 | 0:d6c9b09b4042 | 4497 | |
annieluo2 | 0:d6c9b09b4042 | 4498 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4499 | * |
annieluo2 | 0:d6c9b09b4042 | 4500 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4501 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4502 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4503 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4504 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4505 | */ |
annieluo2 | 0:d6c9b09b4042 | 4506 | template <typename R> |
annieluo2 | 0:d6c9b09b4042 | 4507 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4508 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4509 | Callback<R()> callback(const volatile void *obj, R (*func)(const volatile void*)) { |
annieluo2 | 0:d6c9b09b4042 | 4510 | return Callback<R()>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4511 | } |
annieluo2 | 0:d6c9b09b4042 | 4512 | |
annieluo2 | 0:d6c9b09b4042 | 4513 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4514 | * |
annieluo2 | 0:d6c9b09b4042 | 4515 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4516 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4517 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4518 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4519 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4520 | */ |
annieluo2 | 0:d6c9b09b4042 | 4521 | template <typename T, typename R> |
annieluo2 | 0:d6c9b09b4042 | 4522 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4523 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4524 | Callback<R()> callback(T *obj, R (*func)(T*)) { |
annieluo2 | 0:d6c9b09b4042 | 4525 | return Callback<R()>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4526 | } |
annieluo2 | 0:d6c9b09b4042 | 4527 | |
annieluo2 | 0:d6c9b09b4042 | 4528 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4529 | * |
annieluo2 | 0:d6c9b09b4042 | 4530 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4531 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4532 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4533 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4534 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4535 | */ |
annieluo2 | 0:d6c9b09b4042 | 4536 | template <typename T, typename R> |
annieluo2 | 0:d6c9b09b4042 | 4537 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4538 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4539 | Callback<R()> callback(const T *obj, R (*func)(const T*)) { |
annieluo2 | 0:d6c9b09b4042 | 4540 | return Callback<R()>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4541 | } |
annieluo2 | 0:d6c9b09b4042 | 4542 | |
annieluo2 | 0:d6c9b09b4042 | 4543 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4544 | * |
annieluo2 | 0:d6c9b09b4042 | 4545 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4546 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4547 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4548 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4549 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4550 | */ |
annieluo2 | 0:d6c9b09b4042 | 4551 | template <typename T, typename R> |
annieluo2 | 0:d6c9b09b4042 | 4552 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4553 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4554 | Callback<R()> callback(volatile T *obj, R (*func)(volatile T*)) { |
annieluo2 | 0:d6c9b09b4042 | 4555 | return Callback<R()>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4556 | } |
annieluo2 | 0:d6c9b09b4042 | 4557 | |
annieluo2 | 0:d6c9b09b4042 | 4558 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4559 | * |
annieluo2 | 0:d6c9b09b4042 | 4560 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4561 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4562 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4563 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4564 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4565 | */ |
annieluo2 | 0:d6c9b09b4042 | 4566 | template <typename T, typename R> |
annieluo2 | 0:d6c9b09b4042 | 4567 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4568 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4569 | Callback<R()> callback(const volatile T *obj, R (*func)(const volatile T*)) { |
annieluo2 | 0:d6c9b09b4042 | 4570 | return Callback<R()>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4571 | } |
annieluo2 | 0:d6c9b09b4042 | 4572 | |
annieluo2 | 0:d6c9b09b4042 | 4573 | |
annieluo2 | 0:d6c9b09b4042 | 4574 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4575 | * |
annieluo2 | 0:d6c9b09b4042 | 4576 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4577 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4578 | */ |
annieluo2 | 0:d6c9b09b4042 | 4579 | template <typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 4580 | Callback<R(A0)> callback(R (*func)(A0) = 0) { |
annieluo2 | 0:d6c9b09b4042 | 4581 | return Callback<R(A0)>(func); |
annieluo2 | 0:d6c9b09b4042 | 4582 | } |
annieluo2 | 0:d6c9b09b4042 | 4583 | |
annieluo2 | 0:d6c9b09b4042 | 4584 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4585 | * |
annieluo2 | 0:d6c9b09b4042 | 4586 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4587 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4588 | */ |
annieluo2 | 0:d6c9b09b4042 | 4589 | template <typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 4590 | Callback<R(A0)> callback(const Callback<R(A0)> &func) { |
annieluo2 | 0:d6c9b09b4042 | 4591 | return Callback<R(A0)>(func); |
annieluo2 | 0:d6c9b09b4042 | 4592 | } |
annieluo2 | 0:d6c9b09b4042 | 4593 | |
annieluo2 | 0:d6c9b09b4042 | 4594 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4595 | * |
annieluo2 | 0:d6c9b09b4042 | 4596 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4597 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 4598 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4599 | */ |
annieluo2 | 0:d6c9b09b4042 | 4600 | template<typename T, typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 4601 | Callback<R(A0)> callback(T *obj, R (T::*func)(A0)) { |
annieluo2 | 0:d6c9b09b4042 | 4602 | return Callback<R(A0)>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 4603 | } |
annieluo2 | 0:d6c9b09b4042 | 4604 | |
annieluo2 | 0:d6c9b09b4042 | 4605 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4606 | * |
annieluo2 | 0:d6c9b09b4042 | 4607 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4608 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 4609 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4610 | */ |
annieluo2 | 0:d6c9b09b4042 | 4611 | template<typename T, typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 4612 | Callback<R(A0)> callback(const T *obj, R (T::*func)(A0) const) { |
annieluo2 | 0:d6c9b09b4042 | 4613 | return Callback<R(A0)>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 4614 | } |
annieluo2 | 0:d6c9b09b4042 | 4615 | |
annieluo2 | 0:d6c9b09b4042 | 4616 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4617 | * |
annieluo2 | 0:d6c9b09b4042 | 4618 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4619 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 4620 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4621 | */ |
annieluo2 | 0:d6c9b09b4042 | 4622 | template<typename T, typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 4623 | Callback<R(A0)> callback(volatile T *obj, R (T::*func)(A0) volatile) { |
annieluo2 | 0:d6c9b09b4042 | 4624 | return Callback<R(A0)>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 4625 | } |
annieluo2 | 0:d6c9b09b4042 | 4626 | |
annieluo2 | 0:d6c9b09b4042 | 4627 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4628 | * |
annieluo2 | 0:d6c9b09b4042 | 4629 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4630 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 4631 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4632 | */ |
annieluo2 | 0:d6c9b09b4042 | 4633 | template<typename T, typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 4634 | Callback<R(A0)> callback(const volatile T *obj, R (T::*func)(A0) const volatile) { |
annieluo2 | 0:d6c9b09b4042 | 4635 | return Callback<R(A0)>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 4636 | } |
annieluo2 | 0:d6c9b09b4042 | 4637 | |
annieluo2 | 0:d6c9b09b4042 | 4638 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4639 | * |
annieluo2 | 0:d6c9b09b4042 | 4640 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4641 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4642 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4643 | */ |
annieluo2 | 0:d6c9b09b4042 | 4644 | template <typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 4645 | Callback<R(A0)> callback(R (*func)(void*, A0), void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4646 | return Callback<R(A0)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4647 | } |
annieluo2 | 0:d6c9b09b4042 | 4648 | |
annieluo2 | 0:d6c9b09b4042 | 4649 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4650 | * |
annieluo2 | 0:d6c9b09b4042 | 4651 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4652 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4653 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4654 | */ |
annieluo2 | 0:d6c9b09b4042 | 4655 | template <typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 4656 | Callback<R(A0)> callback(R (*func)(const void*, A0), const void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4657 | return Callback<R(A0)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4658 | } |
annieluo2 | 0:d6c9b09b4042 | 4659 | |
annieluo2 | 0:d6c9b09b4042 | 4660 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4661 | * |
annieluo2 | 0:d6c9b09b4042 | 4662 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4663 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4664 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4665 | */ |
annieluo2 | 0:d6c9b09b4042 | 4666 | template <typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 4667 | Callback<R(A0)> callback(R (*func)(volatile void*, A0), volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4668 | return Callback<R(A0)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4669 | } |
annieluo2 | 0:d6c9b09b4042 | 4670 | |
annieluo2 | 0:d6c9b09b4042 | 4671 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4672 | * |
annieluo2 | 0:d6c9b09b4042 | 4673 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4674 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4675 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4676 | */ |
annieluo2 | 0:d6c9b09b4042 | 4677 | template <typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 4678 | Callback<R(A0)> callback(R (*func)(const volatile void*, A0), const volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4679 | return Callback<R(A0)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4680 | } |
annieluo2 | 0:d6c9b09b4042 | 4681 | |
annieluo2 | 0:d6c9b09b4042 | 4682 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4683 | * |
annieluo2 | 0:d6c9b09b4042 | 4684 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4685 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4686 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4687 | */ |
annieluo2 | 0:d6c9b09b4042 | 4688 | template <typename T, typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 4689 | Callback<R(A0)> callback(R (*func)(T*, A0), T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4690 | return Callback<R(A0)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4691 | } |
annieluo2 | 0:d6c9b09b4042 | 4692 | |
annieluo2 | 0:d6c9b09b4042 | 4693 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4694 | * |
annieluo2 | 0:d6c9b09b4042 | 4695 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4696 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4697 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4698 | */ |
annieluo2 | 0:d6c9b09b4042 | 4699 | template <typename T, typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 4700 | Callback<R(A0)> callback(R (*func)(const T*, A0), const T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4701 | return Callback<R(A0)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4702 | } |
annieluo2 | 0:d6c9b09b4042 | 4703 | |
annieluo2 | 0:d6c9b09b4042 | 4704 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4705 | * |
annieluo2 | 0:d6c9b09b4042 | 4706 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4707 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4708 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4709 | */ |
annieluo2 | 0:d6c9b09b4042 | 4710 | template <typename T, typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 4711 | Callback<R(A0)> callback(R (*func)(volatile T*, A0), volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4712 | return Callback<R(A0)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4713 | } |
annieluo2 | 0:d6c9b09b4042 | 4714 | |
annieluo2 | 0:d6c9b09b4042 | 4715 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4716 | * |
annieluo2 | 0:d6c9b09b4042 | 4717 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4718 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4719 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4720 | */ |
annieluo2 | 0:d6c9b09b4042 | 4721 | template <typename T, typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 4722 | Callback<R(A0)> callback(R (*func)(const volatile T*, A0), const volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4723 | return Callback<R(A0)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4724 | } |
annieluo2 | 0:d6c9b09b4042 | 4725 | |
annieluo2 | 0:d6c9b09b4042 | 4726 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4727 | * |
annieluo2 | 0:d6c9b09b4042 | 4728 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4729 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4730 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4731 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4732 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4733 | */ |
annieluo2 | 0:d6c9b09b4042 | 4734 | template <typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 4735 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4736 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4737 | Callback<R(A0)> callback(void *obj, R (*func)(void*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 4738 | return Callback<R(A0)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4739 | } |
annieluo2 | 0:d6c9b09b4042 | 4740 | |
annieluo2 | 0:d6c9b09b4042 | 4741 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4742 | * |
annieluo2 | 0:d6c9b09b4042 | 4743 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4744 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4745 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4746 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4747 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4748 | */ |
annieluo2 | 0:d6c9b09b4042 | 4749 | template <typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 4750 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4751 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4752 | Callback<R(A0)> callback(const void *obj, R (*func)(const void*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 4753 | return Callback<R(A0)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4754 | } |
annieluo2 | 0:d6c9b09b4042 | 4755 | |
annieluo2 | 0:d6c9b09b4042 | 4756 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4757 | * |
annieluo2 | 0:d6c9b09b4042 | 4758 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4759 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4760 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4761 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4762 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4763 | */ |
annieluo2 | 0:d6c9b09b4042 | 4764 | template <typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 4765 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4766 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4767 | Callback<R(A0)> callback(volatile void *obj, R (*func)(volatile void*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 4768 | return Callback<R(A0)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4769 | } |
annieluo2 | 0:d6c9b09b4042 | 4770 | |
annieluo2 | 0:d6c9b09b4042 | 4771 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4772 | * |
annieluo2 | 0:d6c9b09b4042 | 4773 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4774 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4775 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4776 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4777 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4778 | */ |
annieluo2 | 0:d6c9b09b4042 | 4779 | template <typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 4780 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4781 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4782 | Callback<R(A0)> callback(const volatile void *obj, R (*func)(const volatile void*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 4783 | return Callback<R(A0)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4784 | } |
annieluo2 | 0:d6c9b09b4042 | 4785 | |
annieluo2 | 0:d6c9b09b4042 | 4786 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4787 | * |
annieluo2 | 0:d6c9b09b4042 | 4788 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4789 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4790 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4791 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4792 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4793 | */ |
annieluo2 | 0:d6c9b09b4042 | 4794 | template <typename T, typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 4795 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4796 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4797 | Callback<R(A0)> callback(T *obj, R (*func)(T*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 4798 | return Callback<R(A0)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4799 | } |
annieluo2 | 0:d6c9b09b4042 | 4800 | |
annieluo2 | 0:d6c9b09b4042 | 4801 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4802 | * |
annieluo2 | 0:d6c9b09b4042 | 4803 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4804 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4805 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4806 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4807 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4808 | */ |
annieluo2 | 0:d6c9b09b4042 | 4809 | template <typename T, typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 4810 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4811 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4812 | Callback<R(A0)> callback(const T *obj, R (*func)(const T*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 4813 | return Callback<R(A0)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4814 | } |
annieluo2 | 0:d6c9b09b4042 | 4815 | |
annieluo2 | 0:d6c9b09b4042 | 4816 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4817 | * |
annieluo2 | 0:d6c9b09b4042 | 4818 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4819 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4820 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4821 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4822 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4823 | */ |
annieluo2 | 0:d6c9b09b4042 | 4824 | template <typename T, typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 4825 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4826 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4827 | Callback<R(A0)> callback(volatile T *obj, R (*func)(volatile T*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 4828 | return Callback<R(A0)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4829 | } |
annieluo2 | 0:d6c9b09b4042 | 4830 | |
annieluo2 | 0:d6c9b09b4042 | 4831 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4832 | * |
annieluo2 | 0:d6c9b09b4042 | 4833 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4834 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4835 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4836 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 4837 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 4838 | */ |
annieluo2 | 0:d6c9b09b4042 | 4839 | template <typename T, typename R, typename A0> |
annieluo2 | 0:d6c9b09b4042 | 4840 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 4841 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 4842 | Callback<R(A0)> callback(const volatile T *obj, R (*func)(const volatile T*, A0)) { |
annieluo2 | 0:d6c9b09b4042 | 4843 | return Callback<R(A0)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 4844 | } |
annieluo2 | 0:d6c9b09b4042 | 4845 | |
annieluo2 | 0:d6c9b09b4042 | 4846 | |
annieluo2 | 0:d6c9b09b4042 | 4847 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4848 | * |
annieluo2 | 0:d6c9b09b4042 | 4849 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4850 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4851 | */ |
annieluo2 | 0:d6c9b09b4042 | 4852 | template <typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 4853 | Callback<R(A0, A1)> callback(R (*func)(A0, A1) = 0) { |
annieluo2 | 0:d6c9b09b4042 | 4854 | return Callback<R(A0, A1)>(func); |
annieluo2 | 0:d6c9b09b4042 | 4855 | } |
annieluo2 | 0:d6c9b09b4042 | 4856 | |
annieluo2 | 0:d6c9b09b4042 | 4857 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4858 | * |
annieluo2 | 0:d6c9b09b4042 | 4859 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4860 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4861 | */ |
annieluo2 | 0:d6c9b09b4042 | 4862 | template <typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 4863 | Callback<R(A0, A1)> callback(const Callback<R(A0, A1)> &func) { |
annieluo2 | 0:d6c9b09b4042 | 4864 | return Callback<R(A0, A1)>(func); |
annieluo2 | 0:d6c9b09b4042 | 4865 | } |
annieluo2 | 0:d6c9b09b4042 | 4866 | |
annieluo2 | 0:d6c9b09b4042 | 4867 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4868 | * |
annieluo2 | 0:d6c9b09b4042 | 4869 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4870 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 4871 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4872 | */ |
annieluo2 | 0:d6c9b09b4042 | 4873 | template<typename T, typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 4874 | Callback<R(A0, A1)> callback(T *obj, R (T::*func)(A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 4875 | return Callback<R(A0, A1)>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 4876 | } |
annieluo2 | 0:d6c9b09b4042 | 4877 | |
annieluo2 | 0:d6c9b09b4042 | 4878 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4879 | * |
annieluo2 | 0:d6c9b09b4042 | 4880 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4881 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 4882 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4883 | */ |
annieluo2 | 0:d6c9b09b4042 | 4884 | template<typename T, typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 4885 | Callback<R(A0, A1)> callback(const T *obj, R (T::*func)(A0, A1) const) { |
annieluo2 | 0:d6c9b09b4042 | 4886 | return Callback<R(A0, A1)>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 4887 | } |
annieluo2 | 0:d6c9b09b4042 | 4888 | |
annieluo2 | 0:d6c9b09b4042 | 4889 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4890 | * |
annieluo2 | 0:d6c9b09b4042 | 4891 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4892 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 4893 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4894 | */ |
annieluo2 | 0:d6c9b09b4042 | 4895 | template<typename T, typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 4896 | Callback<R(A0, A1)> callback(volatile T *obj, R (T::*func)(A0, A1) volatile) { |
annieluo2 | 0:d6c9b09b4042 | 4897 | return Callback<R(A0, A1)>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 4898 | } |
annieluo2 | 0:d6c9b09b4042 | 4899 | |
annieluo2 | 0:d6c9b09b4042 | 4900 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4901 | * |
annieluo2 | 0:d6c9b09b4042 | 4902 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 4903 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 4904 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4905 | */ |
annieluo2 | 0:d6c9b09b4042 | 4906 | template<typename T, typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 4907 | Callback<R(A0, A1)> callback(const volatile T *obj, R (T::*func)(A0, A1) const volatile) { |
annieluo2 | 0:d6c9b09b4042 | 4908 | return Callback<R(A0, A1)>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 4909 | } |
annieluo2 | 0:d6c9b09b4042 | 4910 | |
annieluo2 | 0:d6c9b09b4042 | 4911 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4912 | * |
annieluo2 | 0:d6c9b09b4042 | 4913 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4914 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4915 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4916 | */ |
annieluo2 | 0:d6c9b09b4042 | 4917 | template <typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 4918 | Callback<R(A0, A1)> callback(R (*func)(void*, A0, A1), void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4919 | return Callback<R(A0, A1)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4920 | } |
annieluo2 | 0:d6c9b09b4042 | 4921 | |
annieluo2 | 0:d6c9b09b4042 | 4922 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4923 | * |
annieluo2 | 0:d6c9b09b4042 | 4924 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4925 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4926 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4927 | */ |
annieluo2 | 0:d6c9b09b4042 | 4928 | template <typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 4929 | Callback<R(A0, A1)> callback(R (*func)(const void*, A0, A1), const void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4930 | return Callback<R(A0, A1)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4931 | } |
annieluo2 | 0:d6c9b09b4042 | 4932 | |
annieluo2 | 0:d6c9b09b4042 | 4933 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4934 | * |
annieluo2 | 0:d6c9b09b4042 | 4935 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4936 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4937 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4938 | */ |
annieluo2 | 0:d6c9b09b4042 | 4939 | template <typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 4940 | Callback<R(A0, A1)> callback(R (*func)(volatile void*, A0, A1), volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4941 | return Callback<R(A0, A1)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4942 | } |
annieluo2 | 0:d6c9b09b4042 | 4943 | |
annieluo2 | 0:d6c9b09b4042 | 4944 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4945 | * |
annieluo2 | 0:d6c9b09b4042 | 4946 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4947 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4948 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4949 | */ |
annieluo2 | 0:d6c9b09b4042 | 4950 | template <typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 4951 | Callback<R(A0, A1)> callback(R (*func)(const volatile void*, A0, A1), const volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4952 | return Callback<R(A0, A1)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4953 | } |
annieluo2 | 0:d6c9b09b4042 | 4954 | |
annieluo2 | 0:d6c9b09b4042 | 4955 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4956 | * |
annieluo2 | 0:d6c9b09b4042 | 4957 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4958 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4959 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4960 | */ |
annieluo2 | 0:d6c9b09b4042 | 4961 | template <typename T, typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 4962 | Callback<R(A0, A1)> callback(R (*func)(T*, A0, A1), T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4963 | return Callback<R(A0, A1)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4964 | } |
annieluo2 | 0:d6c9b09b4042 | 4965 | |
annieluo2 | 0:d6c9b09b4042 | 4966 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4967 | * |
annieluo2 | 0:d6c9b09b4042 | 4968 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4969 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4970 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4971 | */ |
annieluo2 | 0:d6c9b09b4042 | 4972 | template <typename T, typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 4973 | Callback<R(A0, A1)> callback(R (*func)(const T*, A0, A1), const T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4974 | return Callback<R(A0, A1)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4975 | } |
annieluo2 | 0:d6c9b09b4042 | 4976 | |
annieluo2 | 0:d6c9b09b4042 | 4977 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4978 | * |
annieluo2 | 0:d6c9b09b4042 | 4979 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4980 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4981 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4982 | */ |
annieluo2 | 0:d6c9b09b4042 | 4983 | template <typename T, typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 4984 | Callback<R(A0, A1)> callback(R (*func)(volatile T*, A0, A1), volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4985 | return Callback<R(A0, A1)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4986 | } |
annieluo2 | 0:d6c9b09b4042 | 4987 | |
annieluo2 | 0:d6c9b09b4042 | 4988 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 4989 | * |
annieluo2 | 0:d6c9b09b4042 | 4990 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 4991 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 4992 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 4993 | */ |
annieluo2 | 0:d6c9b09b4042 | 4994 | template <typename T, typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 4995 | Callback<R(A0, A1)> callback(R (*func)(const volatile T*, A0, A1), const volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 4996 | return Callback<R(A0, A1)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 4997 | } |
annieluo2 | 0:d6c9b09b4042 | 4998 | |
annieluo2 | 0:d6c9b09b4042 | 4999 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5000 | * |
annieluo2 | 0:d6c9b09b4042 | 5001 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5002 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5003 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5004 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5005 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5006 | */ |
annieluo2 | 0:d6c9b09b4042 | 5007 | template <typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 5008 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5009 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5010 | Callback<R(A0, A1)> callback(void *obj, R (*func)(void*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 5011 | return Callback<R(A0, A1)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5012 | } |
annieluo2 | 0:d6c9b09b4042 | 5013 | |
annieluo2 | 0:d6c9b09b4042 | 5014 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5015 | * |
annieluo2 | 0:d6c9b09b4042 | 5016 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5017 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5018 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5019 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5020 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5021 | */ |
annieluo2 | 0:d6c9b09b4042 | 5022 | template <typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 5023 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5024 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5025 | Callback<R(A0, A1)> callback(const void *obj, R (*func)(const void*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 5026 | return Callback<R(A0, A1)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5027 | } |
annieluo2 | 0:d6c9b09b4042 | 5028 | |
annieluo2 | 0:d6c9b09b4042 | 5029 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5030 | * |
annieluo2 | 0:d6c9b09b4042 | 5031 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5032 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5033 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5034 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5035 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5036 | */ |
annieluo2 | 0:d6c9b09b4042 | 5037 | template <typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 5038 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5039 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5040 | Callback<R(A0, A1)> callback(volatile void *obj, R (*func)(volatile void*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 5041 | return Callback<R(A0, A1)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5042 | } |
annieluo2 | 0:d6c9b09b4042 | 5043 | |
annieluo2 | 0:d6c9b09b4042 | 5044 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5045 | * |
annieluo2 | 0:d6c9b09b4042 | 5046 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5047 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5048 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5049 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5050 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5051 | */ |
annieluo2 | 0:d6c9b09b4042 | 5052 | template <typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 5053 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5054 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5055 | Callback<R(A0, A1)> callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 5056 | return Callback<R(A0, A1)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5057 | } |
annieluo2 | 0:d6c9b09b4042 | 5058 | |
annieluo2 | 0:d6c9b09b4042 | 5059 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5060 | * |
annieluo2 | 0:d6c9b09b4042 | 5061 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5062 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5063 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5064 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5065 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5066 | */ |
annieluo2 | 0:d6c9b09b4042 | 5067 | template <typename T, typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 5068 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5069 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5070 | Callback<R(A0, A1)> callback(T *obj, R (*func)(T*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 5071 | return Callback<R(A0, A1)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5072 | } |
annieluo2 | 0:d6c9b09b4042 | 5073 | |
annieluo2 | 0:d6c9b09b4042 | 5074 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5075 | * |
annieluo2 | 0:d6c9b09b4042 | 5076 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5077 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5078 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5079 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5080 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5081 | */ |
annieluo2 | 0:d6c9b09b4042 | 5082 | template <typename T, typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 5083 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5084 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5085 | Callback<R(A0, A1)> callback(const T *obj, R (*func)(const T*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 5086 | return Callback<R(A0, A1)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5087 | } |
annieluo2 | 0:d6c9b09b4042 | 5088 | |
annieluo2 | 0:d6c9b09b4042 | 5089 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5090 | * |
annieluo2 | 0:d6c9b09b4042 | 5091 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5092 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5093 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5094 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5095 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5096 | */ |
annieluo2 | 0:d6c9b09b4042 | 5097 | template <typename T, typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 5098 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5099 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5100 | Callback<R(A0, A1)> callback(volatile T *obj, R (*func)(volatile T*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 5101 | return Callback<R(A0, A1)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5102 | } |
annieluo2 | 0:d6c9b09b4042 | 5103 | |
annieluo2 | 0:d6c9b09b4042 | 5104 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5105 | * |
annieluo2 | 0:d6c9b09b4042 | 5106 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5107 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5108 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5109 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5110 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5111 | */ |
annieluo2 | 0:d6c9b09b4042 | 5112 | template <typename T, typename R, typename A0, typename A1> |
annieluo2 | 0:d6c9b09b4042 | 5113 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5114 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5115 | Callback<R(A0, A1)> callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1)) { |
annieluo2 | 0:d6c9b09b4042 | 5116 | return Callback<R(A0, A1)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5117 | } |
annieluo2 | 0:d6c9b09b4042 | 5118 | |
annieluo2 | 0:d6c9b09b4042 | 5119 | |
annieluo2 | 0:d6c9b09b4042 | 5120 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5121 | * |
annieluo2 | 0:d6c9b09b4042 | 5122 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5123 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5124 | */ |
annieluo2 | 0:d6c9b09b4042 | 5125 | template <typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 5126 | Callback<R(A0, A1, A2)> callback(R (*func)(A0, A1, A2) = 0) { |
annieluo2 | 0:d6c9b09b4042 | 5127 | return Callback<R(A0, A1, A2)>(func); |
annieluo2 | 0:d6c9b09b4042 | 5128 | } |
annieluo2 | 0:d6c9b09b4042 | 5129 | |
annieluo2 | 0:d6c9b09b4042 | 5130 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5131 | * |
annieluo2 | 0:d6c9b09b4042 | 5132 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5133 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5134 | */ |
annieluo2 | 0:d6c9b09b4042 | 5135 | template <typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 5136 | Callback<R(A0, A1, A2)> callback(const Callback<R(A0, A1, A2)> &func) { |
annieluo2 | 0:d6c9b09b4042 | 5137 | return Callback<R(A0, A1, A2)>(func); |
annieluo2 | 0:d6c9b09b4042 | 5138 | } |
annieluo2 | 0:d6c9b09b4042 | 5139 | |
annieluo2 | 0:d6c9b09b4042 | 5140 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5141 | * |
annieluo2 | 0:d6c9b09b4042 | 5142 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5143 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 5144 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5145 | */ |
annieluo2 | 0:d6c9b09b4042 | 5146 | template<typename T, typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 5147 | Callback<R(A0, A1, A2)> callback(T *obj, R (T::*func)(A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 5148 | return Callback<R(A0, A1, A2)>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 5149 | } |
annieluo2 | 0:d6c9b09b4042 | 5150 | |
annieluo2 | 0:d6c9b09b4042 | 5151 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5152 | * |
annieluo2 | 0:d6c9b09b4042 | 5153 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5154 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 5155 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5156 | */ |
annieluo2 | 0:d6c9b09b4042 | 5157 | template<typename T, typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 5158 | Callback<R(A0, A1, A2)> callback(const T *obj, R (T::*func)(A0, A1, A2) const) { |
annieluo2 | 0:d6c9b09b4042 | 5159 | return Callback<R(A0, A1, A2)>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 5160 | } |
annieluo2 | 0:d6c9b09b4042 | 5161 | |
annieluo2 | 0:d6c9b09b4042 | 5162 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5163 | * |
annieluo2 | 0:d6c9b09b4042 | 5164 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5165 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 5166 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5167 | */ |
annieluo2 | 0:d6c9b09b4042 | 5168 | template<typename T, typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 5169 | Callback<R(A0, A1, A2)> callback(volatile T *obj, R (T::*func)(A0, A1, A2) volatile) { |
annieluo2 | 0:d6c9b09b4042 | 5170 | return Callback<R(A0, A1, A2)>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 5171 | } |
annieluo2 | 0:d6c9b09b4042 | 5172 | |
annieluo2 | 0:d6c9b09b4042 | 5173 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5174 | * |
annieluo2 | 0:d6c9b09b4042 | 5175 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5176 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 5177 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5178 | */ |
annieluo2 | 0:d6c9b09b4042 | 5179 | template<typename T, typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 5180 | Callback<R(A0, A1, A2)> callback(const volatile T *obj, R (T::*func)(A0, A1, A2) const volatile) { |
annieluo2 | 0:d6c9b09b4042 | 5181 | return Callback<R(A0, A1, A2)>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 5182 | } |
annieluo2 | 0:d6c9b09b4042 | 5183 | |
annieluo2 | 0:d6c9b09b4042 | 5184 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5185 | * |
annieluo2 | 0:d6c9b09b4042 | 5186 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5187 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5188 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5189 | */ |
annieluo2 | 0:d6c9b09b4042 | 5190 | template <typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 5191 | Callback<R(A0, A1, A2)> callback(R (*func)(void*, A0, A1, A2), void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5192 | return Callback<R(A0, A1, A2)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5193 | } |
annieluo2 | 0:d6c9b09b4042 | 5194 | |
annieluo2 | 0:d6c9b09b4042 | 5195 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5196 | * |
annieluo2 | 0:d6c9b09b4042 | 5197 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5198 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5199 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5200 | */ |
annieluo2 | 0:d6c9b09b4042 | 5201 | template <typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 5202 | Callback<R(A0, A1, A2)> callback(R (*func)(const void*, A0, A1, A2), const void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5203 | return Callback<R(A0, A1, A2)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5204 | } |
annieluo2 | 0:d6c9b09b4042 | 5205 | |
annieluo2 | 0:d6c9b09b4042 | 5206 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5207 | * |
annieluo2 | 0:d6c9b09b4042 | 5208 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5209 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5210 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5211 | */ |
annieluo2 | 0:d6c9b09b4042 | 5212 | template <typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 5213 | Callback<R(A0, A1, A2)> callback(R (*func)(volatile void*, A0, A1, A2), volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5214 | return Callback<R(A0, A1, A2)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5215 | } |
annieluo2 | 0:d6c9b09b4042 | 5216 | |
annieluo2 | 0:d6c9b09b4042 | 5217 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5218 | * |
annieluo2 | 0:d6c9b09b4042 | 5219 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5220 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5221 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5222 | */ |
annieluo2 | 0:d6c9b09b4042 | 5223 | template <typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 5224 | Callback<R(A0, A1, A2)> callback(R (*func)(const volatile void*, A0, A1, A2), const volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5225 | return Callback<R(A0, A1, A2)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5226 | } |
annieluo2 | 0:d6c9b09b4042 | 5227 | |
annieluo2 | 0:d6c9b09b4042 | 5228 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5229 | * |
annieluo2 | 0:d6c9b09b4042 | 5230 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5231 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5232 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5233 | */ |
annieluo2 | 0:d6c9b09b4042 | 5234 | template <typename T, typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 5235 | Callback<R(A0, A1, A2)> callback(R (*func)(T*, A0, A1, A2), T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5236 | return Callback<R(A0, A1, A2)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5237 | } |
annieluo2 | 0:d6c9b09b4042 | 5238 | |
annieluo2 | 0:d6c9b09b4042 | 5239 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5240 | * |
annieluo2 | 0:d6c9b09b4042 | 5241 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5242 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5243 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5244 | */ |
annieluo2 | 0:d6c9b09b4042 | 5245 | template <typename T, typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 5246 | Callback<R(A0, A1, A2)> callback(R (*func)(const T*, A0, A1, A2), const T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5247 | return Callback<R(A0, A1, A2)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5248 | } |
annieluo2 | 0:d6c9b09b4042 | 5249 | |
annieluo2 | 0:d6c9b09b4042 | 5250 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5251 | * |
annieluo2 | 0:d6c9b09b4042 | 5252 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5253 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5254 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5255 | */ |
annieluo2 | 0:d6c9b09b4042 | 5256 | template <typename T, typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 5257 | Callback<R(A0, A1, A2)> callback(R (*func)(volatile T*, A0, A1, A2), volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5258 | return Callback<R(A0, A1, A2)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5259 | } |
annieluo2 | 0:d6c9b09b4042 | 5260 | |
annieluo2 | 0:d6c9b09b4042 | 5261 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5262 | * |
annieluo2 | 0:d6c9b09b4042 | 5263 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5264 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5265 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5266 | */ |
annieluo2 | 0:d6c9b09b4042 | 5267 | template <typename T, typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 5268 | Callback<R(A0, A1, A2)> callback(R (*func)(const volatile T*, A0, A1, A2), const volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5269 | return Callback<R(A0, A1, A2)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5270 | } |
annieluo2 | 0:d6c9b09b4042 | 5271 | |
annieluo2 | 0:d6c9b09b4042 | 5272 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5273 | * |
annieluo2 | 0:d6c9b09b4042 | 5274 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5275 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5276 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5277 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5278 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5279 | */ |
annieluo2 | 0:d6c9b09b4042 | 5280 | template <typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 5281 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5282 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5283 | Callback<R(A0, A1, A2)> callback(void *obj, R (*func)(void*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 5284 | return Callback<R(A0, A1, A2)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5285 | } |
annieluo2 | 0:d6c9b09b4042 | 5286 | |
annieluo2 | 0:d6c9b09b4042 | 5287 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5288 | * |
annieluo2 | 0:d6c9b09b4042 | 5289 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5290 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5291 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5292 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5293 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5294 | */ |
annieluo2 | 0:d6c9b09b4042 | 5295 | template <typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 5296 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5297 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5298 | Callback<R(A0, A1, A2)> callback(const void *obj, R (*func)(const void*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 5299 | return Callback<R(A0, A1, A2)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5300 | } |
annieluo2 | 0:d6c9b09b4042 | 5301 | |
annieluo2 | 0:d6c9b09b4042 | 5302 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5303 | * |
annieluo2 | 0:d6c9b09b4042 | 5304 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5305 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5306 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5307 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5308 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5309 | */ |
annieluo2 | 0:d6c9b09b4042 | 5310 | template <typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 5311 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5312 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5313 | Callback<R(A0, A1, A2)> callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 5314 | return Callback<R(A0, A1, A2)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5315 | } |
annieluo2 | 0:d6c9b09b4042 | 5316 | |
annieluo2 | 0:d6c9b09b4042 | 5317 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5318 | * |
annieluo2 | 0:d6c9b09b4042 | 5319 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5320 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5321 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5322 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5323 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5324 | */ |
annieluo2 | 0:d6c9b09b4042 | 5325 | template <typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 5326 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5327 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5328 | Callback<R(A0, A1, A2)> callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 5329 | return Callback<R(A0, A1, A2)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5330 | } |
annieluo2 | 0:d6c9b09b4042 | 5331 | |
annieluo2 | 0:d6c9b09b4042 | 5332 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5333 | * |
annieluo2 | 0:d6c9b09b4042 | 5334 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5335 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5336 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5337 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5338 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5339 | */ |
annieluo2 | 0:d6c9b09b4042 | 5340 | template <typename T, typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 5341 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5342 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5343 | Callback<R(A0, A1, A2)> callback(T *obj, R (*func)(T*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 5344 | return Callback<R(A0, A1, A2)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5345 | } |
annieluo2 | 0:d6c9b09b4042 | 5346 | |
annieluo2 | 0:d6c9b09b4042 | 5347 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5348 | * |
annieluo2 | 0:d6c9b09b4042 | 5349 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5350 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5351 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5352 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5353 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5354 | */ |
annieluo2 | 0:d6c9b09b4042 | 5355 | template <typename T, typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 5356 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5357 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5358 | Callback<R(A0, A1, A2)> callback(const T *obj, R (*func)(const T*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 5359 | return Callback<R(A0, A1, A2)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5360 | } |
annieluo2 | 0:d6c9b09b4042 | 5361 | |
annieluo2 | 0:d6c9b09b4042 | 5362 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5363 | * |
annieluo2 | 0:d6c9b09b4042 | 5364 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5365 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5366 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5367 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5368 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5369 | */ |
annieluo2 | 0:d6c9b09b4042 | 5370 | template <typename T, typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 5371 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5372 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5373 | Callback<R(A0, A1, A2)> callback(volatile T *obj, R (*func)(volatile T*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 5374 | return Callback<R(A0, A1, A2)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5375 | } |
annieluo2 | 0:d6c9b09b4042 | 5376 | |
annieluo2 | 0:d6c9b09b4042 | 5377 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5378 | * |
annieluo2 | 0:d6c9b09b4042 | 5379 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5380 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5381 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5382 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5383 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5384 | */ |
annieluo2 | 0:d6c9b09b4042 | 5385 | template <typename T, typename R, typename A0, typename A1, typename A2> |
annieluo2 | 0:d6c9b09b4042 | 5386 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5387 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5388 | Callback<R(A0, A1, A2)> callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2)) { |
annieluo2 | 0:d6c9b09b4042 | 5389 | return Callback<R(A0, A1, A2)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5390 | } |
annieluo2 | 0:d6c9b09b4042 | 5391 | |
annieluo2 | 0:d6c9b09b4042 | 5392 | |
annieluo2 | 0:d6c9b09b4042 | 5393 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5394 | * |
annieluo2 | 0:d6c9b09b4042 | 5395 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5396 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5397 | */ |
annieluo2 | 0:d6c9b09b4042 | 5398 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 5399 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(A0, A1, A2, A3) = 0) { |
annieluo2 | 0:d6c9b09b4042 | 5400 | return Callback<R(A0, A1, A2, A3)>(func); |
annieluo2 | 0:d6c9b09b4042 | 5401 | } |
annieluo2 | 0:d6c9b09b4042 | 5402 | |
annieluo2 | 0:d6c9b09b4042 | 5403 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5404 | * |
annieluo2 | 0:d6c9b09b4042 | 5405 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5406 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5407 | */ |
annieluo2 | 0:d6c9b09b4042 | 5408 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 5409 | Callback<R(A0, A1, A2, A3)> callback(const Callback<R(A0, A1, A2, A3)> &func) { |
annieluo2 | 0:d6c9b09b4042 | 5410 | return Callback<R(A0, A1, A2, A3)>(func); |
annieluo2 | 0:d6c9b09b4042 | 5411 | } |
annieluo2 | 0:d6c9b09b4042 | 5412 | |
annieluo2 | 0:d6c9b09b4042 | 5413 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5414 | * |
annieluo2 | 0:d6c9b09b4042 | 5415 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5416 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 5417 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5418 | */ |
annieluo2 | 0:d6c9b09b4042 | 5419 | template<typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 5420 | Callback<R(A0, A1, A2, A3)> callback(T *obj, R (T::*func)(A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 5421 | return Callback<R(A0, A1, A2, A3)>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 5422 | } |
annieluo2 | 0:d6c9b09b4042 | 5423 | |
annieluo2 | 0:d6c9b09b4042 | 5424 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5425 | * |
annieluo2 | 0:d6c9b09b4042 | 5426 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5427 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 5428 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5429 | */ |
annieluo2 | 0:d6c9b09b4042 | 5430 | template<typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 5431 | Callback<R(A0, A1, A2, A3)> callback(const T *obj, R (T::*func)(A0, A1, A2, A3) const) { |
annieluo2 | 0:d6c9b09b4042 | 5432 | return Callback<R(A0, A1, A2, A3)>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 5433 | } |
annieluo2 | 0:d6c9b09b4042 | 5434 | |
annieluo2 | 0:d6c9b09b4042 | 5435 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5436 | * |
annieluo2 | 0:d6c9b09b4042 | 5437 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5438 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 5439 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5440 | */ |
annieluo2 | 0:d6c9b09b4042 | 5441 | template<typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 5442 | Callback<R(A0, A1, A2, A3)> callback(volatile T *obj, R (T::*func)(A0, A1, A2, A3) volatile) { |
annieluo2 | 0:d6c9b09b4042 | 5443 | return Callback<R(A0, A1, A2, A3)>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 5444 | } |
annieluo2 | 0:d6c9b09b4042 | 5445 | |
annieluo2 | 0:d6c9b09b4042 | 5446 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5447 | * |
annieluo2 | 0:d6c9b09b4042 | 5448 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5449 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 5450 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5451 | */ |
annieluo2 | 0:d6c9b09b4042 | 5452 | template<typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 5453 | Callback<R(A0, A1, A2, A3)> callback(const volatile T *obj, R (T::*func)(A0, A1, A2, A3) const volatile) { |
annieluo2 | 0:d6c9b09b4042 | 5454 | return Callback<R(A0, A1, A2, A3)>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 5455 | } |
annieluo2 | 0:d6c9b09b4042 | 5456 | |
annieluo2 | 0:d6c9b09b4042 | 5457 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5458 | * |
annieluo2 | 0:d6c9b09b4042 | 5459 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5460 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5461 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5462 | */ |
annieluo2 | 0:d6c9b09b4042 | 5463 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 5464 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(void*, A0, A1, A2, A3), void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5465 | return Callback<R(A0, A1, A2, A3)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5466 | } |
annieluo2 | 0:d6c9b09b4042 | 5467 | |
annieluo2 | 0:d6c9b09b4042 | 5468 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5469 | * |
annieluo2 | 0:d6c9b09b4042 | 5470 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5471 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5472 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5473 | */ |
annieluo2 | 0:d6c9b09b4042 | 5474 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 5475 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(const void*, A0, A1, A2, A3), const void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5476 | return Callback<R(A0, A1, A2, A3)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5477 | } |
annieluo2 | 0:d6c9b09b4042 | 5478 | |
annieluo2 | 0:d6c9b09b4042 | 5479 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5480 | * |
annieluo2 | 0:d6c9b09b4042 | 5481 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5482 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5483 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5484 | */ |
annieluo2 | 0:d6c9b09b4042 | 5485 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 5486 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(volatile void*, A0, A1, A2, A3), volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5487 | return Callback<R(A0, A1, A2, A3)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5488 | } |
annieluo2 | 0:d6c9b09b4042 | 5489 | |
annieluo2 | 0:d6c9b09b4042 | 5490 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5491 | * |
annieluo2 | 0:d6c9b09b4042 | 5492 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5493 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5494 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5495 | */ |
annieluo2 | 0:d6c9b09b4042 | 5496 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 5497 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(const volatile void*, A0, A1, A2, A3), const volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5498 | return Callback<R(A0, A1, A2, A3)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5499 | } |
annieluo2 | 0:d6c9b09b4042 | 5500 | |
annieluo2 | 0:d6c9b09b4042 | 5501 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5502 | * |
annieluo2 | 0:d6c9b09b4042 | 5503 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5504 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5505 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5506 | */ |
annieluo2 | 0:d6c9b09b4042 | 5507 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 5508 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(T*, A0, A1, A2, A3), T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5509 | return Callback<R(A0, A1, A2, A3)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5510 | } |
annieluo2 | 0:d6c9b09b4042 | 5511 | |
annieluo2 | 0:d6c9b09b4042 | 5512 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5513 | * |
annieluo2 | 0:d6c9b09b4042 | 5514 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5515 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5516 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5517 | */ |
annieluo2 | 0:d6c9b09b4042 | 5518 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 5519 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(const T*, A0, A1, A2, A3), const T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5520 | return Callback<R(A0, A1, A2, A3)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5521 | } |
annieluo2 | 0:d6c9b09b4042 | 5522 | |
annieluo2 | 0:d6c9b09b4042 | 5523 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5524 | * |
annieluo2 | 0:d6c9b09b4042 | 5525 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5526 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5527 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5528 | */ |
annieluo2 | 0:d6c9b09b4042 | 5529 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 5530 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(volatile T*, A0, A1, A2, A3), volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5531 | return Callback<R(A0, A1, A2, A3)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5532 | } |
annieluo2 | 0:d6c9b09b4042 | 5533 | |
annieluo2 | 0:d6c9b09b4042 | 5534 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5535 | * |
annieluo2 | 0:d6c9b09b4042 | 5536 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5537 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5538 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5539 | */ |
annieluo2 | 0:d6c9b09b4042 | 5540 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 5541 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(const volatile T*, A0, A1, A2, A3), const volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5542 | return Callback<R(A0, A1, A2, A3)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5543 | } |
annieluo2 | 0:d6c9b09b4042 | 5544 | |
annieluo2 | 0:d6c9b09b4042 | 5545 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5546 | * |
annieluo2 | 0:d6c9b09b4042 | 5547 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5548 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5549 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5550 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5551 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5552 | */ |
annieluo2 | 0:d6c9b09b4042 | 5553 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 5554 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5555 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5556 | Callback<R(A0, A1, A2, A3)> callback(void *obj, R (*func)(void*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 5557 | return Callback<R(A0, A1, A2, A3)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5558 | } |
annieluo2 | 0:d6c9b09b4042 | 5559 | |
annieluo2 | 0:d6c9b09b4042 | 5560 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5561 | * |
annieluo2 | 0:d6c9b09b4042 | 5562 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5563 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5564 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5565 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5566 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5567 | */ |
annieluo2 | 0:d6c9b09b4042 | 5568 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 5569 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5570 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5571 | Callback<R(A0, A1, A2, A3)> callback(const void *obj, R (*func)(const void*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 5572 | return Callback<R(A0, A1, A2, A3)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5573 | } |
annieluo2 | 0:d6c9b09b4042 | 5574 | |
annieluo2 | 0:d6c9b09b4042 | 5575 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5576 | * |
annieluo2 | 0:d6c9b09b4042 | 5577 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5578 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5579 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5580 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5581 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5582 | */ |
annieluo2 | 0:d6c9b09b4042 | 5583 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 5584 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5585 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5586 | Callback<R(A0, A1, A2, A3)> callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 5587 | return Callback<R(A0, A1, A2, A3)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5588 | } |
annieluo2 | 0:d6c9b09b4042 | 5589 | |
annieluo2 | 0:d6c9b09b4042 | 5590 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5591 | * |
annieluo2 | 0:d6c9b09b4042 | 5592 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5593 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5594 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5595 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5596 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5597 | */ |
annieluo2 | 0:d6c9b09b4042 | 5598 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 5599 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5600 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5601 | Callback<R(A0, A1, A2, A3)> callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 5602 | return Callback<R(A0, A1, A2, A3)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5603 | } |
annieluo2 | 0:d6c9b09b4042 | 5604 | |
annieluo2 | 0:d6c9b09b4042 | 5605 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5606 | * |
annieluo2 | 0:d6c9b09b4042 | 5607 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5608 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5609 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5610 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5611 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5612 | */ |
annieluo2 | 0:d6c9b09b4042 | 5613 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 5614 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5615 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5616 | Callback<R(A0, A1, A2, A3)> callback(T *obj, R (*func)(T*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 5617 | return Callback<R(A0, A1, A2, A3)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5618 | } |
annieluo2 | 0:d6c9b09b4042 | 5619 | |
annieluo2 | 0:d6c9b09b4042 | 5620 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5621 | * |
annieluo2 | 0:d6c9b09b4042 | 5622 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5623 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5624 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5625 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5626 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5627 | */ |
annieluo2 | 0:d6c9b09b4042 | 5628 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 5629 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5630 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5631 | Callback<R(A0, A1, A2, A3)> callback(const T *obj, R (*func)(const T*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 5632 | return Callback<R(A0, A1, A2, A3)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5633 | } |
annieluo2 | 0:d6c9b09b4042 | 5634 | |
annieluo2 | 0:d6c9b09b4042 | 5635 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5636 | * |
annieluo2 | 0:d6c9b09b4042 | 5637 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5638 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5639 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5640 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5641 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5642 | */ |
annieluo2 | 0:d6c9b09b4042 | 5643 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 5644 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5645 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5646 | Callback<R(A0, A1, A2, A3)> callback(volatile T *obj, R (*func)(volatile T*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 5647 | return Callback<R(A0, A1, A2, A3)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5648 | } |
annieluo2 | 0:d6c9b09b4042 | 5649 | |
annieluo2 | 0:d6c9b09b4042 | 5650 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5651 | * |
annieluo2 | 0:d6c9b09b4042 | 5652 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5653 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5654 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5655 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5656 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5657 | */ |
annieluo2 | 0:d6c9b09b4042 | 5658 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
annieluo2 | 0:d6c9b09b4042 | 5659 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5660 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5661 | Callback<R(A0, A1, A2, A3)> callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2, A3)) { |
annieluo2 | 0:d6c9b09b4042 | 5662 | return Callback<R(A0, A1, A2, A3)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5663 | } |
annieluo2 | 0:d6c9b09b4042 | 5664 | |
annieluo2 | 0:d6c9b09b4042 | 5665 | |
annieluo2 | 0:d6c9b09b4042 | 5666 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5667 | * |
annieluo2 | 0:d6c9b09b4042 | 5668 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5669 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5670 | */ |
annieluo2 | 0:d6c9b09b4042 | 5671 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 5672 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(A0, A1, A2, A3, A4) = 0) { |
annieluo2 | 0:d6c9b09b4042 | 5673 | return Callback<R(A0, A1, A2, A3, A4)>(func); |
annieluo2 | 0:d6c9b09b4042 | 5674 | } |
annieluo2 | 0:d6c9b09b4042 | 5675 | |
annieluo2 | 0:d6c9b09b4042 | 5676 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5677 | * |
annieluo2 | 0:d6c9b09b4042 | 5678 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5679 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5680 | */ |
annieluo2 | 0:d6c9b09b4042 | 5681 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 5682 | Callback<R(A0, A1, A2, A3, A4)> callback(const Callback<R(A0, A1, A2, A3, A4)> &func) { |
annieluo2 | 0:d6c9b09b4042 | 5683 | return Callback<R(A0, A1, A2, A3, A4)>(func); |
annieluo2 | 0:d6c9b09b4042 | 5684 | } |
annieluo2 | 0:d6c9b09b4042 | 5685 | |
annieluo2 | 0:d6c9b09b4042 | 5686 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5687 | * |
annieluo2 | 0:d6c9b09b4042 | 5688 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5689 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 5690 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5691 | */ |
annieluo2 | 0:d6c9b09b4042 | 5692 | template<typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 5693 | Callback<R(A0, A1, A2, A3, A4)> callback(T *obj, R (T::*func)(A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 5694 | return Callback<R(A0, A1, A2, A3, A4)>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 5695 | } |
annieluo2 | 0:d6c9b09b4042 | 5696 | |
annieluo2 | 0:d6c9b09b4042 | 5697 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5698 | * |
annieluo2 | 0:d6c9b09b4042 | 5699 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5700 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 5701 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5702 | */ |
annieluo2 | 0:d6c9b09b4042 | 5703 | template<typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 5704 | Callback<R(A0, A1, A2, A3, A4)> callback(const T *obj, R (T::*func)(A0, A1, A2, A3, A4) const) { |
annieluo2 | 0:d6c9b09b4042 | 5705 | return Callback<R(A0, A1, A2, A3, A4)>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 5706 | } |
annieluo2 | 0:d6c9b09b4042 | 5707 | |
annieluo2 | 0:d6c9b09b4042 | 5708 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5709 | * |
annieluo2 | 0:d6c9b09b4042 | 5710 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5711 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 5712 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5713 | */ |
annieluo2 | 0:d6c9b09b4042 | 5714 | template<typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 5715 | Callback<R(A0, A1, A2, A3, A4)> callback(volatile T *obj, R (T::*func)(A0, A1, A2, A3, A4) volatile) { |
annieluo2 | 0:d6c9b09b4042 | 5716 | return Callback<R(A0, A1, A2, A3, A4)>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 5717 | } |
annieluo2 | 0:d6c9b09b4042 | 5718 | |
annieluo2 | 0:d6c9b09b4042 | 5719 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5720 | * |
annieluo2 | 0:d6c9b09b4042 | 5721 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5722 | * @param method Member function to attach |
annieluo2 | 0:d6c9b09b4042 | 5723 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5724 | */ |
annieluo2 | 0:d6c9b09b4042 | 5725 | template<typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 5726 | Callback<R(A0, A1, A2, A3, A4)> callback(const volatile T *obj, R (T::*func)(A0, A1, A2, A3, A4) const volatile) { |
annieluo2 | 0:d6c9b09b4042 | 5727 | return Callback<R(A0, A1, A2, A3, A4)>(obj, func); |
annieluo2 | 0:d6c9b09b4042 | 5728 | } |
annieluo2 | 0:d6c9b09b4042 | 5729 | |
annieluo2 | 0:d6c9b09b4042 | 5730 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5731 | * |
annieluo2 | 0:d6c9b09b4042 | 5732 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5733 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5734 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5735 | */ |
annieluo2 | 0:d6c9b09b4042 | 5736 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 5737 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(void*, A0, A1, A2, A3, A4), void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5738 | return Callback<R(A0, A1, A2, A3, A4)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5739 | } |
annieluo2 | 0:d6c9b09b4042 | 5740 | |
annieluo2 | 0:d6c9b09b4042 | 5741 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5742 | * |
annieluo2 | 0:d6c9b09b4042 | 5743 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5744 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5745 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5746 | */ |
annieluo2 | 0:d6c9b09b4042 | 5747 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 5748 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(const void*, A0, A1, A2, A3, A4), const void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5749 | return Callback<R(A0, A1, A2, A3, A4)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5750 | } |
annieluo2 | 0:d6c9b09b4042 | 5751 | |
annieluo2 | 0:d6c9b09b4042 | 5752 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5753 | * |
annieluo2 | 0:d6c9b09b4042 | 5754 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5755 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5756 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5757 | */ |
annieluo2 | 0:d6c9b09b4042 | 5758 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 5759 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(volatile void*, A0, A1, A2, A3, A4), volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5760 | return Callback<R(A0, A1, A2, A3, A4)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5761 | } |
annieluo2 | 0:d6c9b09b4042 | 5762 | |
annieluo2 | 0:d6c9b09b4042 | 5763 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5764 | * |
annieluo2 | 0:d6c9b09b4042 | 5765 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5766 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5767 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5768 | */ |
annieluo2 | 0:d6c9b09b4042 | 5769 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 5770 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(const volatile void*, A0, A1, A2, A3, A4), const volatile void *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5771 | return Callback<R(A0, A1, A2, A3, A4)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5772 | } |
annieluo2 | 0:d6c9b09b4042 | 5773 | |
annieluo2 | 0:d6c9b09b4042 | 5774 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5775 | * |
annieluo2 | 0:d6c9b09b4042 | 5776 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5777 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5778 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5779 | */ |
annieluo2 | 0:d6c9b09b4042 | 5780 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 5781 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(T*, A0, A1, A2, A3, A4), T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5782 | return Callback<R(A0, A1, A2, A3, A4)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5783 | } |
annieluo2 | 0:d6c9b09b4042 | 5784 | |
annieluo2 | 0:d6c9b09b4042 | 5785 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5786 | * |
annieluo2 | 0:d6c9b09b4042 | 5787 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5788 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5789 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5790 | */ |
annieluo2 | 0:d6c9b09b4042 | 5791 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 5792 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(const T*, A0, A1, A2, A3, A4), const T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5793 | return Callback<R(A0, A1, A2, A3, A4)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5794 | } |
annieluo2 | 0:d6c9b09b4042 | 5795 | |
annieluo2 | 0:d6c9b09b4042 | 5796 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5797 | * |
annieluo2 | 0:d6c9b09b4042 | 5798 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5799 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5800 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5801 | */ |
annieluo2 | 0:d6c9b09b4042 | 5802 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 5803 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(volatile T*, A0, A1, A2, A3, A4), volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5804 | return Callback<R(A0, A1, A2, A3, A4)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5805 | } |
annieluo2 | 0:d6c9b09b4042 | 5806 | |
annieluo2 | 0:d6c9b09b4042 | 5807 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5808 | * |
annieluo2 | 0:d6c9b09b4042 | 5809 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5810 | * @param arg Pointer argument to function |
annieluo2 | 0:d6c9b09b4042 | 5811 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5812 | */ |
annieluo2 | 0:d6c9b09b4042 | 5813 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 5814 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(const volatile T*, A0, A1, A2, A3, A4), const volatile T *arg) { |
annieluo2 | 0:d6c9b09b4042 | 5815 | return Callback<R(A0, A1, A2, A3, A4)>(func, arg); |
annieluo2 | 0:d6c9b09b4042 | 5816 | } |
annieluo2 | 0:d6c9b09b4042 | 5817 | |
annieluo2 | 0:d6c9b09b4042 | 5818 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5819 | * |
annieluo2 | 0:d6c9b09b4042 | 5820 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5821 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5822 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5823 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5824 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5825 | */ |
annieluo2 | 0:d6c9b09b4042 | 5826 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 5827 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5828 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5829 | Callback<R(A0, A1, A2, A3, A4)> callback(void *obj, R (*func)(void*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 5830 | return Callback<R(A0, A1, A2, A3, A4)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5831 | } |
annieluo2 | 0:d6c9b09b4042 | 5832 | |
annieluo2 | 0:d6c9b09b4042 | 5833 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5834 | * |
annieluo2 | 0:d6c9b09b4042 | 5835 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5836 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5837 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5838 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5839 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5840 | */ |
annieluo2 | 0:d6c9b09b4042 | 5841 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 5842 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5843 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5844 | Callback<R(A0, A1, A2, A3, A4)> callback(const void *obj, R (*func)(const void*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 5845 | return Callback<R(A0, A1, A2, A3, A4)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5846 | } |
annieluo2 | 0:d6c9b09b4042 | 5847 | |
annieluo2 | 0:d6c9b09b4042 | 5848 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5849 | * |
annieluo2 | 0:d6c9b09b4042 | 5850 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5851 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5852 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5853 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5854 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5855 | */ |
annieluo2 | 0:d6c9b09b4042 | 5856 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 5857 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5858 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5859 | Callback<R(A0, A1, A2, A3, A4)> callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 5860 | return Callback<R(A0, A1, A2, A3, A4)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5861 | } |
annieluo2 | 0:d6c9b09b4042 | 5862 | |
annieluo2 | 0:d6c9b09b4042 | 5863 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5864 | * |
annieluo2 | 0:d6c9b09b4042 | 5865 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5866 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5867 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5868 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5869 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5870 | */ |
annieluo2 | 0:d6c9b09b4042 | 5871 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 5872 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5873 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5874 | Callback<R(A0, A1, A2, A3, A4)> callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 5875 | return Callback<R(A0, A1, A2, A3, A4)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5876 | } |
annieluo2 | 0:d6c9b09b4042 | 5877 | |
annieluo2 | 0:d6c9b09b4042 | 5878 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5879 | * |
annieluo2 | 0:d6c9b09b4042 | 5880 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5881 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5882 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5883 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5884 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5885 | */ |
annieluo2 | 0:d6c9b09b4042 | 5886 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 5887 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5888 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5889 | Callback<R(A0, A1, A2, A3, A4)> callback(T *obj, R (*func)(T*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 5890 | return Callback<R(A0, A1, A2, A3, A4)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5891 | } |
annieluo2 | 0:d6c9b09b4042 | 5892 | |
annieluo2 | 0:d6c9b09b4042 | 5893 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5894 | * |
annieluo2 | 0:d6c9b09b4042 | 5895 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5896 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5897 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5898 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5899 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5900 | */ |
annieluo2 | 0:d6c9b09b4042 | 5901 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 5902 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5903 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5904 | Callback<R(A0, A1, A2, A3, A4)> callback(const T *obj, R (*func)(const T*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 5905 | return Callback<R(A0, A1, A2, A3, A4)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5906 | } |
annieluo2 | 0:d6c9b09b4042 | 5907 | |
annieluo2 | 0:d6c9b09b4042 | 5908 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5909 | * |
annieluo2 | 0:d6c9b09b4042 | 5910 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5911 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5912 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5913 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5914 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5915 | */ |
annieluo2 | 0:d6c9b09b4042 | 5916 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 5917 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5918 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5919 | Callback<R(A0, A1, A2, A3, A4)> callback(volatile T *obj, R (*func)(volatile T*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 5920 | return Callback<R(A0, A1, A2, A3, A4)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5921 | } |
annieluo2 | 0:d6c9b09b4042 | 5922 | |
annieluo2 | 0:d6c9b09b4042 | 5923 | /** Create a callback class with type infered from the arguments |
annieluo2 | 0:d6c9b09b4042 | 5924 | * |
annieluo2 | 0:d6c9b09b4042 | 5925 | * @param obj Optional pointer to object to bind to function |
annieluo2 | 0:d6c9b09b4042 | 5926 | * @param func Static function to attach |
annieluo2 | 0:d6c9b09b4042 | 5927 | * @return Callback with infered type |
annieluo2 | 0:d6c9b09b4042 | 5928 | * @deprecated |
annieluo2 | 0:d6c9b09b4042 | 5929 | * Arguments to callback have been reordered to callback(func, arg) |
annieluo2 | 0:d6c9b09b4042 | 5930 | */ |
annieluo2 | 0:d6c9b09b4042 | 5931 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
annieluo2 | 0:d6c9b09b4042 | 5932 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
annieluo2 | 0:d6c9b09b4042 | 5933 | "Arguments to callback have been reordered to callback(func, arg)") |
annieluo2 | 0:d6c9b09b4042 | 5934 | Callback<R(A0, A1, A2, A3, A4)> callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2, A3, A4)) { |
annieluo2 | 0:d6c9b09b4042 | 5935 | return Callback<R(A0, A1, A2, A3, A4)>(func, obj); |
annieluo2 | 0:d6c9b09b4042 | 5936 | } |
annieluo2 | 0:d6c9b09b4042 | 5937 | |
annieluo2 | 0:d6c9b09b4042 | 5938 | |
annieluo2 | 0:d6c9b09b4042 | 5939 | } // namespace mbed |
annieluo2 | 0:d6c9b09b4042 | 5940 | |
annieluo2 | 0:d6c9b09b4042 | 5941 | #endif |
annieluo2 | 0:d6c9b09b4042 | 5942 | |
annieluo2 | 0:d6c9b09b4042 | 5943 | |
annieluo2 | 0:d6c9b09b4042 | 5944 | /** @}*/ |