mbed os with nrf51 internal bandgap enabled to read battery level
Dependents: BLE_file_test BLE_Blink ExternalEncoder
platform/Callback.h@0:f269e3021894, 2016-10-23 (annotated)
- Committer:
- elessair
- Date:
- Sun Oct 23 15:10:02 2016 +0000
- Revision:
- 0:f269e3021894
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elessair | 0:f269e3021894 | 1 | /* mbed Microcontroller Library |
elessair | 0:f269e3021894 | 2 | * Copyright (c) 2006-2015 ARM Limited |
elessair | 0:f269e3021894 | 3 | * |
elessair | 0:f269e3021894 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
elessair | 0:f269e3021894 | 5 | * you may not use this file except in compliance with the License. |
elessair | 0:f269e3021894 | 6 | * You may obtain a copy of the License at |
elessair | 0:f269e3021894 | 7 | * |
elessair | 0:f269e3021894 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
elessair | 0:f269e3021894 | 9 | * |
elessair | 0:f269e3021894 | 10 | * Unless required by applicable law or agreed to in writing, software |
elessair | 0:f269e3021894 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
elessair | 0:f269e3021894 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
elessair | 0:f269e3021894 | 13 | * See the License for the specific language governing permissions and |
elessair | 0:f269e3021894 | 14 | * limitations under the License. |
elessair | 0:f269e3021894 | 15 | */ |
elessair | 0:f269e3021894 | 16 | #ifndef MBED_CALLBACK_H |
elessair | 0:f269e3021894 | 17 | #define MBED_CALLBACK_H |
elessair | 0:f269e3021894 | 18 | |
elessair | 0:f269e3021894 | 19 | #include <string.h> |
elessair | 0:f269e3021894 | 20 | #include <stdint.h> |
elessair | 0:f269e3021894 | 21 | #include <new> |
elessair | 0:f269e3021894 | 22 | #include "platform/mbed_assert.h" |
elessair | 0:f269e3021894 | 23 | #include "platform/toolchain.h" |
elessair | 0:f269e3021894 | 24 | |
elessair | 0:f269e3021894 | 25 | namespace mbed { |
elessair | 0:f269e3021894 | 26 | /** \addtogroup platform */ |
elessair | 0:f269e3021894 | 27 | /** @{*/ |
elessair | 0:f269e3021894 | 28 | |
elessair | 0:f269e3021894 | 29 | |
elessair | 0:f269e3021894 | 30 | /** Callback class based on template specialization |
elessair | 0:f269e3021894 | 31 | * |
elessair | 0:f269e3021894 | 32 | * @Note Synchronization level: Not protected |
elessair | 0:f269e3021894 | 33 | */ |
elessair | 0:f269e3021894 | 34 | template <typename F> |
elessair | 0:f269e3021894 | 35 | class Callback; |
elessair | 0:f269e3021894 | 36 | |
elessair | 0:f269e3021894 | 37 | // Internal sfinae declarations |
elessair | 0:f269e3021894 | 38 | // |
elessair | 0:f269e3021894 | 39 | // These are used to eliminate overloads based on type attributes |
elessair | 0:f269e3021894 | 40 | // 1. Does a function object have a call operator |
elessair | 0:f269e3021894 | 41 | // 2. Does a function object fit in the available storage |
elessair | 0:f269e3021894 | 42 | // |
elessair | 0:f269e3021894 | 43 | // These eliminations are handled cleanly by the compiler and avoid |
elessair | 0:f269e3021894 | 44 | // massive and misleading error messages when confronted with an |
elessair | 0:f269e3021894 | 45 | // invalid type (or worse, runtime failures) |
elessair | 0:f269e3021894 | 46 | namespace detail { |
elessair | 0:f269e3021894 | 47 | struct nil {}; |
elessair | 0:f269e3021894 | 48 | |
elessair | 0:f269e3021894 | 49 | template <bool B, typename R = nil> |
elessair | 0:f269e3021894 | 50 | struct enable_if { typedef R type; }; |
elessair | 0:f269e3021894 | 51 | |
elessair | 0:f269e3021894 | 52 | template <typename R> |
elessair | 0:f269e3021894 | 53 | struct enable_if<false, R> {}; |
elessair | 0:f269e3021894 | 54 | |
elessair | 0:f269e3021894 | 55 | template <typename M, M> |
elessair | 0:f269e3021894 | 56 | struct is_type { |
elessair | 0:f269e3021894 | 57 | static const bool value = true; |
elessair | 0:f269e3021894 | 58 | }; |
elessair | 0:f269e3021894 | 59 | } |
elessair | 0:f269e3021894 | 60 | |
elessair | 0:f269e3021894 | 61 | /** Callback class based on template specialization |
elessair | 0:f269e3021894 | 62 | * |
elessair | 0:f269e3021894 | 63 | * @Note Synchronization level: Not protected |
elessair | 0:f269e3021894 | 64 | */ |
elessair | 0:f269e3021894 | 65 | template <typename R> |
elessair | 0:f269e3021894 | 66 | class Callback<R()> { |
elessair | 0:f269e3021894 | 67 | public: |
elessair | 0:f269e3021894 | 68 | /** Create a Callback with a static function |
elessair | 0:f269e3021894 | 69 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 70 | */ |
elessair | 0:f269e3021894 | 71 | Callback(R (*func)() = 0) { |
elessair | 0:f269e3021894 | 72 | if (!func) { |
elessair | 0:f269e3021894 | 73 | _ops = 0; |
elessair | 0:f269e3021894 | 74 | } else { |
elessair | 0:f269e3021894 | 75 | generate(func); |
elessair | 0:f269e3021894 | 76 | } |
elessair | 0:f269e3021894 | 77 | } |
elessair | 0:f269e3021894 | 78 | |
elessair | 0:f269e3021894 | 79 | /** Attach a Callback |
elessair | 0:f269e3021894 | 80 | * @param func The Callback to attach |
elessair | 0:f269e3021894 | 81 | */ |
elessair | 0:f269e3021894 | 82 | Callback(const Callback<R()> &func) { |
elessair | 0:f269e3021894 | 83 | if (func._ops) { |
elessair | 0:f269e3021894 | 84 | func._ops->move(this, &func); |
elessair | 0:f269e3021894 | 85 | } |
elessair | 0:f269e3021894 | 86 | _ops = func._ops; |
elessair | 0:f269e3021894 | 87 | } |
elessair | 0:f269e3021894 | 88 | |
elessair | 0:f269e3021894 | 89 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 90 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 91 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 92 | */ |
elessair | 0:f269e3021894 | 93 | template<typename T> |
elessair | 0:f269e3021894 | 94 | Callback(T *obj, R (T::*method)()) { |
elessair | 0:f269e3021894 | 95 | generate(method_context<T, R (T::*)()>(obj, method)); |
elessair | 0:f269e3021894 | 96 | } |
elessair | 0:f269e3021894 | 97 | |
elessair | 0:f269e3021894 | 98 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 99 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 100 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 101 | */ |
elessair | 0:f269e3021894 | 102 | template<typename T> |
elessair | 0:f269e3021894 | 103 | Callback(const T *obj, R (T::*method)() const) { |
elessair | 0:f269e3021894 | 104 | generate(method_context<const T, R (T::*)() const>(obj, method)); |
elessair | 0:f269e3021894 | 105 | } |
elessair | 0:f269e3021894 | 106 | |
elessair | 0:f269e3021894 | 107 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 108 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 109 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 110 | */ |
elessair | 0:f269e3021894 | 111 | template<typename T> |
elessair | 0:f269e3021894 | 112 | Callback(volatile T *obj, R (T::*method)() volatile) { |
elessair | 0:f269e3021894 | 113 | generate(method_context<volatile T, R (T::*)() volatile>(obj, method)); |
elessair | 0:f269e3021894 | 114 | } |
elessair | 0:f269e3021894 | 115 | |
elessair | 0:f269e3021894 | 116 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 117 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 118 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 119 | */ |
elessair | 0:f269e3021894 | 120 | template<typename T> |
elessair | 0:f269e3021894 | 121 | Callback(const volatile T *obj, R (T::*method)() const volatile) { |
elessair | 0:f269e3021894 | 122 | generate(method_context<const volatile T, R (T::*)() const volatile>(obj, method)); |
elessair | 0:f269e3021894 | 123 | } |
elessair | 0:f269e3021894 | 124 | |
elessair | 0:f269e3021894 | 125 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 126 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 127 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 128 | */ |
elessair | 0:f269e3021894 | 129 | Callback(R (*func)(void*), void *arg) { |
elessair | 0:f269e3021894 | 130 | generate(function_context<R (*)(void*), void>(func, arg)); |
elessair | 0:f269e3021894 | 131 | } |
elessair | 0:f269e3021894 | 132 | |
elessair | 0:f269e3021894 | 133 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 134 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 135 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 136 | */ |
elessair | 0:f269e3021894 | 137 | Callback(R (*func)(const void*), const void *arg) { |
elessair | 0:f269e3021894 | 138 | generate(function_context<R (*)(const void*), const void>(func, arg)); |
elessair | 0:f269e3021894 | 139 | } |
elessair | 0:f269e3021894 | 140 | |
elessair | 0:f269e3021894 | 141 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 142 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 143 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 144 | */ |
elessair | 0:f269e3021894 | 145 | Callback(R (*func)(volatile void*), volatile void *arg) { |
elessair | 0:f269e3021894 | 146 | generate(function_context<R (*)(volatile void*), volatile void>(func, arg)); |
elessair | 0:f269e3021894 | 147 | } |
elessair | 0:f269e3021894 | 148 | |
elessair | 0:f269e3021894 | 149 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 150 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 151 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 152 | */ |
elessair | 0:f269e3021894 | 153 | Callback(R (*func)(const volatile void*), const volatile void *arg) { |
elessair | 0:f269e3021894 | 154 | generate(function_context<R (*)(const volatile void*), const volatile void>(func, arg)); |
elessair | 0:f269e3021894 | 155 | } |
elessair | 0:f269e3021894 | 156 | |
elessair | 0:f269e3021894 | 157 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 158 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 159 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 160 | */ |
elessair | 0:f269e3021894 | 161 | template<typename T> |
elessair | 0:f269e3021894 | 162 | Callback(R (*func)(T*), T *arg) { |
elessair | 0:f269e3021894 | 163 | generate(function_context<R (*)(T*), T>(func, arg)); |
elessair | 0:f269e3021894 | 164 | } |
elessair | 0:f269e3021894 | 165 | |
elessair | 0:f269e3021894 | 166 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 167 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 168 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 169 | */ |
elessair | 0:f269e3021894 | 170 | template<typename T> |
elessair | 0:f269e3021894 | 171 | Callback(R (*func)(const T*), const T *arg) { |
elessair | 0:f269e3021894 | 172 | generate(function_context<R (*)(const T*), const T>(func, arg)); |
elessair | 0:f269e3021894 | 173 | } |
elessair | 0:f269e3021894 | 174 | |
elessair | 0:f269e3021894 | 175 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 176 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 177 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 178 | */ |
elessair | 0:f269e3021894 | 179 | template<typename T> |
elessair | 0:f269e3021894 | 180 | Callback(R (*func)(volatile T*), volatile T *arg) { |
elessair | 0:f269e3021894 | 181 | generate(function_context<R (*)(volatile T*), volatile T>(func, arg)); |
elessair | 0:f269e3021894 | 182 | } |
elessair | 0:f269e3021894 | 183 | |
elessair | 0:f269e3021894 | 184 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 185 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 186 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 187 | */ |
elessair | 0:f269e3021894 | 188 | template<typename T> |
elessair | 0:f269e3021894 | 189 | Callback(R (*func)(const volatile T*), const volatile T *arg) { |
elessair | 0:f269e3021894 | 190 | generate(function_context<R (*)(const volatile T*), const volatile T>(func, arg)); |
elessair | 0:f269e3021894 | 191 | } |
elessair | 0:f269e3021894 | 192 | |
elessair | 0:f269e3021894 | 193 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 194 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 195 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 196 | */ |
elessair | 0:f269e3021894 | 197 | template <typename F> |
elessair | 0:f269e3021894 | 198 | Callback(F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 199 | detail::is_type<R (F::*)(), &F::operator()>::value && |
elessair | 0:f269e3021894 | 200 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 201 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 202 | generate(f); |
elessair | 0:f269e3021894 | 203 | } |
elessair | 0:f269e3021894 | 204 | |
elessair | 0:f269e3021894 | 205 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 206 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 207 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 208 | */ |
elessair | 0:f269e3021894 | 209 | template <typename F> |
elessair | 0:f269e3021894 | 210 | Callback(const F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 211 | detail::is_type<R (F::*)() const, &F::operator()>::value && |
elessair | 0:f269e3021894 | 212 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 213 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 214 | generate(f); |
elessair | 0:f269e3021894 | 215 | } |
elessair | 0:f269e3021894 | 216 | |
elessair | 0:f269e3021894 | 217 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 218 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 219 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 220 | */ |
elessair | 0:f269e3021894 | 221 | template <typename F> |
elessair | 0:f269e3021894 | 222 | Callback(volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 223 | detail::is_type<R (F::*)() volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 224 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 225 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 226 | generate(f); |
elessair | 0:f269e3021894 | 227 | } |
elessair | 0:f269e3021894 | 228 | |
elessair | 0:f269e3021894 | 229 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 230 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 231 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 232 | */ |
elessair | 0:f269e3021894 | 233 | template <typename F> |
elessair | 0:f269e3021894 | 234 | Callback(const volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 235 | detail::is_type<R (F::*)() const volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 236 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 237 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 238 | generate(f); |
elessair | 0:f269e3021894 | 239 | } |
elessair | 0:f269e3021894 | 240 | |
elessair | 0:f269e3021894 | 241 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 242 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 243 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 244 | * @deprecated |
elessair | 0:f269e3021894 | 245 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 246 | */ |
elessair | 0:f269e3021894 | 247 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 248 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 249 | Callback(void *obj, R (*func)(void*)) { |
elessair | 0:f269e3021894 | 250 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 251 | } |
elessair | 0:f269e3021894 | 252 | |
elessair | 0:f269e3021894 | 253 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 254 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 255 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 256 | * @deprecated |
elessair | 0:f269e3021894 | 257 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 258 | */ |
elessair | 0:f269e3021894 | 259 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 260 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 261 | Callback(const void *obj, R (*func)(const void*)) { |
elessair | 0:f269e3021894 | 262 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 263 | } |
elessair | 0:f269e3021894 | 264 | |
elessair | 0:f269e3021894 | 265 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 266 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 267 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 268 | * @deprecated |
elessair | 0:f269e3021894 | 269 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 270 | */ |
elessair | 0:f269e3021894 | 271 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 272 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 273 | Callback(volatile void *obj, R (*func)(volatile void*)) { |
elessair | 0:f269e3021894 | 274 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 275 | } |
elessair | 0:f269e3021894 | 276 | |
elessair | 0:f269e3021894 | 277 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 278 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 279 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 280 | * @deprecated |
elessair | 0:f269e3021894 | 281 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 282 | */ |
elessair | 0:f269e3021894 | 283 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 284 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 285 | Callback(const volatile void *obj, R (*func)(const volatile void*)) { |
elessair | 0:f269e3021894 | 286 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 287 | } |
elessair | 0:f269e3021894 | 288 | |
elessair | 0:f269e3021894 | 289 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 290 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 291 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 292 | * @deprecated |
elessair | 0:f269e3021894 | 293 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 294 | */ |
elessair | 0:f269e3021894 | 295 | template<typename T> |
elessair | 0:f269e3021894 | 296 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 297 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 298 | Callback(T *obj, R (*func)(T*)) { |
elessair | 0:f269e3021894 | 299 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 300 | } |
elessair | 0:f269e3021894 | 301 | |
elessair | 0:f269e3021894 | 302 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 303 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 304 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 305 | * @deprecated |
elessair | 0:f269e3021894 | 306 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 307 | */ |
elessair | 0:f269e3021894 | 308 | template<typename T> |
elessair | 0:f269e3021894 | 309 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 310 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 311 | Callback(const T *obj, R (*func)(const T*)) { |
elessair | 0:f269e3021894 | 312 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 313 | } |
elessair | 0:f269e3021894 | 314 | |
elessair | 0:f269e3021894 | 315 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 316 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 317 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 318 | * @deprecated |
elessair | 0:f269e3021894 | 319 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 320 | */ |
elessair | 0:f269e3021894 | 321 | template<typename T> |
elessair | 0:f269e3021894 | 322 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 323 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 324 | Callback(volatile T *obj, R (*func)(volatile T*)) { |
elessair | 0:f269e3021894 | 325 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 326 | } |
elessair | 0:f269e3021894 | 327 | |
elessair | 0:f269e3021894 | 328 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 329 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 330 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 331 | * @deprecated |
elessair | 0:f269e3021894 | 332 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 333 | */ |
elessair | 0:f269e3021894 | 334 | template<typename T> |
elessair | 0:f269e3021894 | 335 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 336 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 337 | Callback(const volatile T *obj, R (*func)(const volatile T*)) { |
elessair | 0:f269e3021894 | 338 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 339 | } |
elessair | 0:f269e3021894 | 340 | |
elessair | 0:f269e3021894 | 341 | /** Destroy a callback |
elessair | 0:f269e3021894 | 342 | */ |
elessair | 0:f269e3021894 | 343 | ~Callback() { |
elessair | 0:f269e3021894 | 344 | if (_ops) { |
elessair | 0:f269e3021894 | 345 | _ops->dtor(this); |
elessair | 0:f269e3021894 | 346 | } |
elessair | 0:f269e3021894 | 347 | } |
elessair | 0:f269e3021894 | 348 | |
elessair | 0:f269e3021894 | 349 | /** Attach a static function |
elessair | 0:f269e3021894 | 350 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 351 | */ |
elessair | 0:f269e3021894 | 352 | void attach(R (*func)()) { |
elessair | 0:f269e3021894 | 353 | this->~Callback(); |
elessair | 0:f269e3021894 | 354 | new (this) Callback(func); |
elessair | 0:f269e3021894 | 355 | } |
elessair | 0:f269e3021894 | 356 | |
elessair | 0:f269e3021894 | 357 | /** Attach a Callback |
elessair | 0:f269e3021894 | 358 | * @param func The Callback to attach |
elessair | 0:f269e3021894 | 359 | */ |
elessair | 0:f269e3021894 | 360 | void attach(const Callback<R()> &func) { |
elessair | 0:f269e3021894 | 361 | this->~Callback(); |
elessair | 0:f269e3021894 | 362 | new (this) Callback(func); |
elessair | 0:f269e3021894 | 363 | } |
elessair | 0:f269e3021894 | 364 | |
elessair | 0:f269e3021894 | 365 | /** Attach a member function |
elessair | 0:f269e3021894 | 366 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 367 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 368 | */ |
elessair | 0:f269e3021894 | 369 | template<typename T> |
elessair | 0:f269e3021894 | 370 | void attach(T *obj, R (T::*method)()) { |
elessair | 0:f269e3021894 | 371 | this->~Callback(); |
elessair | 0:f269e3021894 | 372 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 373 | } |
elessair | 0:f269e3021894 | 374 | |
elessair | 0:f269e3021894 | 375 | /** Attach a member function |
elessair | 0:f269e3021894 | 376 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 377 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 378 | */ |
elessair | 0:f269e3021894 | 379 | template<typename T> |
elessair | 0:f269e3021894 | 380 | void attach(const T *obj, R (T::*method)() const) { |
elessair | 0:f269e3021894 | 381 | this->~Callback(); |
elessair | 0:f269e3021894 | 382 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 383 | } |
elessair | 0:f269e3021894 | 384 | |
elessair | 0:f269e3021894 | 385 | /** Attach a member function |
elessair | 0:f269e3021894 | 386 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 387 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 388 | */ |
elessair | 0:f269e3021894 | 389 | template<typename T> |
elessair | 0:f269e3021894 | 390 | void attach(volatile T *obj, R (T::*method)() volatile) { |
elessair | 0:f269e3021894 | 391 | this->~Callback(); |
elessair | 0:f269e3021894 | 392 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 393 | } |
elessair | 0:f269e3021894 | 394 | |
elessair | 0:f269e3021894 | 395 | /** Attach a member function |
elessair | 0:f269e3021894 | 396 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 397 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 398 | */ |
elessair | 0:f269e3021894 | 399 | template<typename T> |
elessair | 0:f269e3021894 | 400 | void attach(const volatile T *obj, R (T::*method)() const volatile) { |
elessair | 0:f269e3021894 | 401 | this->~Callback(); |
elessair | 0:f269e3021894 | 402 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 403 | } |
elessair | 0:f269e3021894 | 404 | |
elessair | 0:f269e3021894 | 405 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 406 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 407 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 408 | */ |
elessair | 0:f269e3021894 | 409 | void attach(R (*func)(void*), void *arg) { |
elessair | 0:f269e3021894 | 410 | this->~Callback(); |
elessair | 0:f269e3021894 | 411 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 412 | } |
elessair | 0:f269e3021894 | 413 | |
elessair | 0:f269e3021894 | 414 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 415 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 416 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 417 | */ |
elessair | 0:f269e3021894 | 418 | void attach(R (*func)(const void*), const void *arg) { |
elessair | 0:f269e3021894 | 419 | this->~Callback(); |
elessair | 0:f269e3021894 | 420 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 421 | } |
elessair | 0:f269e3021894 | 422 | |
elessair | 0:f269e3021894 | 423 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 424 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 425 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 426 | */ |
elessair | 0:f269e3021894 | 427 | void attach(R (*func)(volatile void*), volatile void *arg) { |
elessair | 0:f269e3021894 | 428 | this->~Callback(); |
elessair | 0:f269e3021894 | 429 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 430 | } |
elessair | 0:f269e3021894 | 431 | |
elessair | 0:f269e3021894 | 432 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 433 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 434 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 435 | */ |
elessair | 0:f269e3021894 | 436 | void attach(R (*func)(const volatile void*), const volatile void *arg) { |
elessair | 0:f269e3021894 | 437 | this->~Callback(); |
elessair | 0:f269e3021894 | 438 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 439 | } |
elessair | 0:f269e3021894 | 440 | |
elessair | 0:f269e3021894 | 441 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 442 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 443 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 444 | */ |
elessair | 0:f269e3021894 | 445 | template <typename T> |
elessair | 0:f269e3021894 | 446 | void attach(R (*func)(T*), T *arg) { |
elessair | 0:f269e3021894 | 447 | this->~Callback(); |
elessair | 0:f269e3021894 | 448 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 449 | } |
elessair | 0:f269e3021894 | 450 | |
elessair | 0:f269e3021894 | 451 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 452 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 453 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 454 | */ |
elessair | 0:f269e3021894 | 455 | template <typename T> |
elessair | 0:f269e3021894 | 456 | void attach(R (*func)(const T*), const T *arg) { |
elessair | 0:f269e3021894 | 457 | this->~Callback(); |
elessair | 0:f269e3021894 | 458 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 459 | } |
elessair | 0:f269e3021894 | 460 | |
elessair | 0:f269e3021894 | 461 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 462 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 463 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 464 | */ |
elessair | 0:f269e3021894 | 465 | template <typename T> |
elessair | 0:f269e3021894 | 466 | void attach(R (*func)(volatile T*), volatile T *arg) { |
elessair | 0:f269e3021894 | 467 | this->~Callback(); |
elessair | 0:f269e3021894 | 468 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 469 | } |
elessair | 0:f269e3021894 | 470 | |
elessair | 0:f269e3021894 | 471 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 472 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 473 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 474 | */ |
elessair | 0:f269e3021894 | 475 | template <typename T> |
elessair | 0:f269e3021894 | 476 | void attach(R (*func)(const volatile T*), const volatile T *arg) { |
elessair | 0:f269e3021894 | 477 | this->~Callback(); |
elessair | 0:f269e3021894 | 478 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 479 | } |
elessair | 0:f269e3021894 | 480 | |
elessair | 0:f269e3021894 | 481 | /** Attach a function object |
elessair | 0:f269e3021894 | 482 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 483 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 484 | */ |
elessair | 0:f269e3021894 | 485 | template <typename F> |
elessair | 0:f269e3021894 | 486 | void attach(F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 487 | detail::is_type<R (F::*)(), &F::operator()>::value && |
elessair | 0:f269e3021894 | 488 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 489 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 490 | this->~Callback(); |
elessair | 0:f269e3021894 | 491 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 492 | } |
elessair | 0:f269e3021894 | 493 | |
elessair | 0:f269e3021894 | 494 | /** Attach a function object |
elessair | 0:f269e3021894 | 495 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 496 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 497 | */ |
elessair | 0:f269e3021894 | 498 | template <typename F> |
elessair | 0:f269e3021894 | 499 | void attach(const F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 500 | detail::is_type<R (F::*)() const, &F::operator()>::value && |
elessair | 0:f269e3021894 | 501 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 502 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 503 | this->~Callback(); |
elessair | 0:f269e3021894 | 504 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 505 | } |
elessair | 0:f269e3021894 | 506 | |
elessair | 0:f269e3021894 | 507 | /** Attach a function object |
elessair | 0:f269e3021894 | 508 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 509 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 510 | */ |
elessair | 0:f269e3021894 | 511 | template <typename F> |
elessair | 0:f269e3021894 | 512 | void attach(volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 513 | detail::is_type<R (F::*)() volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 514 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 515 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 516 | this->~Callback(); |
elessair | 0:f269e3021894 | 517 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 518 | } |
elessair | 0:f269e3021894 | 519 | |
elessair | 0:f269e3021894 | 520 | /** Attach a function object |
elessair | 0:f269e3021894 | 521 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 522 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 523 | */ |
elessair | 0:f269e3021894 | 524 | template <typename F> |
elessair | 0:f269e3021894 | 525 | void attach(const volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 526 | detail::is_type<R (F::*)() const volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 527 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 528 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 529 | this->~Callback(); |
elessair | 0:f269e3021894 | 530 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 531 | } |
elessair | 0:f269e3021894 | 532 | |
elessair | 0:f269e3021894 | 533 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 534 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 535 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 536 | * @deprecated |
elessair | 0:f269e3021894 | 537 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 538 | */ |
elessair | 0:f269e3021894 | 539 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 540 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 541 | void attach(void *obj, R (*func)(void*)) { |
elessair | 0:f269e3021894 | 542 | this->~Callback(); |
elessair | 0:f269e3021894 | 543 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 544 | } |
elessair | 0:f269e3021894 | 545 | |
elessair | 0:f269e3021894 | 546 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 547 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 548 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 549 | * @deprecated |
elessair | 0:f269e3021894 | 550 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 551 | */ |
elessair | 0:f269e3021894 | 552 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 553 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 554 | void attach(const void *obj, R (*func)(const void*)) { |
elessair | 0:f269e3021894 | 555 | this->~Callback(); |
elessair | 0:f269e3021894 | 556 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 557 | } |
elessair | 0:f269e3021894 | 558 | |
elessair | 0:f269e3021894 | 559 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 560 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 561 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 562 | * @deprecated |
elessair | 0:f269e3021894 | 563 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 564 | */ |
elessair | 0:f269e3021894 | 565 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 566 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 567 | void attach(volatile void *obj, R (*func)(volatile void*)) { |
elessair | 0:f269e3021894 | 568 | this->~Callback(); |
elessair | 0:f269e3021894 | 569 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 570 | } |
elessair | 0:f269e3021894 | 571 | |
elessair | 0:f269e3021894 | 572 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 573 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 574 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 575 | * @deprecated |
elessair | 0:f269e3021894 | 576 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 577 | */ |
elessair | 0:f269e3021894 | 578 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 579 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 580 | void attach(const volatile void *obj, R (*func)(const volatile void*)) { |
elessair | 0:f269e3021894 | 581 | this->~Callback(); |
elessair | 0:f269e3021894 | 582 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 583 | } |
elessair | 0:f269e3021894 | 584 | |
elessair | 0:f269e3021894 | 585 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 586 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 587 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 588 | * @deprecated |
elessair | 0:f269e3021894 | 589 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 590 | */ |
elessair | 0:f269e3021894 | 591 | template <typename T> |
elessair | 0:f269e3021894 | 592 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 593 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 594 | void attach(T *obj, R (*func)(T*)) { |
elessair | 0:f269e3021894 | 595 | this->~Callback(); |
elessair | 0:f269e3021894 | 596 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 597 | } |
elessair | 0:f269e3021894 | 598 | |
elessair | 0:f269e3021894 | 599 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 600 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 601 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 602 | * @deprecated |
elessair | 0:f269e3021894 | 603 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 604 | */ |
elessair | 0:f269e3021894 | 605 | template <typename T> |
elessair | 0:f269e3021894 | 606 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 607 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 608 | void attach(const T *obj, R (*func)(const T*)) { |
elessair | 0:f269e3021894 | 609 | this->~Callback(); |
elessair | 0:f269e3021894 | 610 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 611 | } |
elessair | 0:f269e3021894 | 612 | |
elessair | 0:f269e3021894 | 613 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 614 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 615 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 616 | * @deprecated |
elessair | 0:f269e3021894 | 617 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 618 | */ |
elessair | 0:f269e3021894 | 619 | template <typename T> |
elessair | 0:f269e3021894 | 620 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 621 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 622 | void attach(volatile T *obj, R (*func)(volatile T*)) { |
elessair | 0:f269e3021894 | 623 | this->~Callback(); |
elessair | 0:f269e3021894 | 624 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 625 | } |
elessair | 0:f269e3021894 | 626 | |
elessair | 0:f269e3021894 | 627 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 628 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 629 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 630 | * @deprecated |
elessair | 0:f269e3021894 | 631 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 632 | */ |
elessair | 0:f269e3021894 | 633 | template <typename T> |
elessair | 0:f269e3021894 | 634 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 635 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 636 | void attach(const volatile T *obj, R (*func)(const volatile T*)) { |
elessair | 0:f269e3021894 | 637 | this->~Callback(); |
elessair | 0:f269e3021894 | 638 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 639 | } |
elessair | 0:f269e3021894 | 640 | |
elessair | 0:f269e3021894 | 641 | /** Assign a callback |
elessair | 0:f269e3021894 | 642 | */ |
elessair | 0:f269e3021894 | 643 | Callback &operator=(const Callback &that) { |
elessair | 0:f269e3021894 | 644 | if (this != &that) { |
elessair | 0:f269e3021894 | 645 | this->~Callback(); |
elessair | 0:f269e3021894 | 646 | new (this) Callback(that); |
elessair | 0:f269e3021894 | 647 | } |
elessair | 0:f269e3021894 | 648 | |
elessair | 0:f269e3021894 | 649 | return *this; |
elessair | 0:f269e3021894 | 650 | } |
elessair | 0:f269e3021894 | 651 | |
elessair | 0:f269e3021894 | 652 | /** Call the attached function |
elessair | 0:f269e3021894 | 653 | */ |
elessair | 0:f269e3021894 | 654 | R call() const { |
elessair | 0:f269e3021894 | 655 | MBED_ASSERT(_ops); |
elessair | 0:f269e3021894 | 656 | return _ops->call(this); |
elessair | 0:f269e3021894 | 657 | } |
elessair | 0:f269e3021894 | 658 | |
elessair | 0:f269e3021894 | 659 | /** Call the attached function |
elessair | 0:f269e3021894 | 660 | */ |
elessair | 0:f269e3021894 | 661 | R operator()() const { |
elessair | 0:f269e3021894 | 662 | return call(); |
elessair | 0:f269e3021894 | 663 | } |
elessair | 0:f269e3021894 | 664 | |
elessair | 0:f269e3021894 | 665 | /** Test if function has been attached |
elessair | 0:f269e3021894 | 666 | */ |
elessair | 0:f269e3021894 | 667 | operator bool() const { |
elessair | 0:f269e3021894 | 668 | return _ops; |
elessair | 0:f269e3021894 | 669 | } |
elessair | 0:f269e3021894 | 670 | |
elessair | 0:f269e3021894 | 671 | /** Test for equality |
elessair | 0:f269e3021894 | 672 | */ |
elessair | 0:f269e3021894 | 673 | friend bool operator==(const Callback &l, const Callback &r) { |
elessair | 0:f269e3021894 | 674 | return memcmp(&l, &r, sizeof(Callback)) == 0; |
elessair | 0:f269e3021894 | 675 | } |
elessair | 0:f269e3021894 | 676 | |
elessair | 0:f269e3021894 | 677 | /** Test for inequality |
elessair | 0:f269e3021894 | 678 | */ |
elessair | 0:f269e3021894 | 679 | friend bool operator!=(const Callback &l, const Callback &r) { |
elessair | 0:f269e3021894 | 680 | return !(l == r); |
elessair | 0:f269e3021894 | 681 | } |
elessair | 0:f269e3021894 | 682 | |
elessair | 0:f269e3021894 | 683 | /** Static thunk for passing as C-style function |
elessair | 0:f269e3021894 | 684 | * @param func Callback to call passed as void pointer |
elessair | 0:f269e3021894 | 685 | */ |
elessair | 0:f269e3021894 | 686 | static R thunk(void *func) { |
elessair | 0:f269e3021894 | 687 | return static_cast<Callback*>(func)->call(); |
elessair | 0:f269e3021894 | 688 | } |
elessair | 0:f269e3021894 | 689 | |
elessair | 0:f269e3021894 | 690 | private: |
elessair | 0:f269e3021894 | 691 | // Stored as pointer to function and pointer to optional object |
elessair | 0:f269e3021894 | 692 | // Function pointer is stored as union of possible function types |
elessair | 0:f269e3021894 | 693 | // to garuntee proper size and alignment |
elessair | 0:f269e3021894 | 694 | struct _class; |
elessair | 0:f269e3021894 | 695 | union { |
elessair | 0:f269e3021894 | 696 | void (*_staticfunc)(); |
elessair | 0:f269e3021894 | 697 | void (*_boundfunc)(_class*); |
elessair | 0:f269e3021894 | 698 | void (_class::*_methodfunc)(); |
elessair | 0:f269e3021894 | 699 | } _func; |
elessair | 0:f269e3021894 | 700 | void *_obj; |
elessair | 0:f269e3021894 | 701 | |
elessair | 0:f269e3021894 | 702 | // Dynamically dispatched operations |
elessair | 0:f269e3021894 | 703 | const struct ops { |
elessair | 0:f269e3021894 | 704 | R (*call)(const void*); |
elessair | 0:f269e3021894 | 705 | void (*move)(void*, const void*); |
elessair | 0:f269e3021894 | 706 | void (*dtor)(void*); |
elessair | 0:f269e3021894 | 707 | } *_ops; |
elessair | 0:f269e3021894 | 708 | |
elessair | 0:f269e3021894 | 709 | // Generate operations for function object |
elessair | 0:f269e3021894 | 710 | template <typename F> |
elessair | 0:f269e3021894 | 711 | void generate(const F &f) { |
elessair | 0:f269e3021894 | 712 | static const ops ops = { |
elessair | 0:f269e3021894 | 713 | &Callback::function_call<F>, |
elessair | 0:f269e3021894 | 714 | &Callback::function_move<F>, |
elessair | 0:f269e3021894 | 715 | &Callback::function_dtor<F>, |
elessair | 0:f269e3021894 | 716 | }; |
elessair | 0:f269e3021894 | 717 | |
elessair | 0:f269e3021894 | 718 | MBED_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F)); |
elessair | 0:f269e3021894 | 719 | new (this) F(f); |
elessair | 0:f269e3021894 | 720 | _ops = &ops; |
elessair | 0:f269e3021894 | 721 | } |
elessair | 0:f269e3021894 | 722 | |
elessair | 0:f269e3021894 | 723 | // Function attributes |
elessair | 0:f269e3021894 | 724 | template <typename F> |
elessair | 0:f269e3021894 | 725 | static R function_call(const void *p) { |
elessair | 0:f269e3021894 | 726 | return (*(F*)p)(); |
elessair | 0:f269e3021894 | 727 | } |
elessair | 0:f269e3021894 | 728 | |
elessair | 0:f269e3021894 | 729 | template <typename F> |
elessair | 0:f269e3021894 | 730 | static void function_move(void *d, const void *p) { |
elessair | 0:f269e3021894 | 731 | new (d) F(*(F*)p); |
elessair | 0:f269e3021894 | 732 | } |
elessair | 0:f269e3021894 | 733 | |
elessair | 0:f269e3021894 | 734 | template <typename F> |
elessair | 0:f269e3021894 | 735 | static void function_dtor(void *p) { |
elessair | 0:f269e3021894 | 736 | ((F*)p)->~F(); |
elessair | 0:f269e3021894 | 737 | } |
elessair | 0:f269e3021894 | 738 | |
elessair | 0:f269e3021894 | 739 | // Wrappers for functions with context |
elessair | 0:f269e3021894 | 740 | template <typename O, typename M> |
elessair | 0:f269e3021894 | 741 | struct method_context { |
elessair | 0:f269e3021894 | 742 | M method; |
elessair | 0:f269e3021894 | 743 | O *obj; |
elessair | 0:f269e3021894 | 744 | |
elessair | 0:f269e3021894 | 745 | method_context(O *obj, M method) |
elessair | 0:f269e3021894 | 746 | : method(method), obj(obj) {} |
elessair | 0:f269e3021894 | 747 | |
elessair | 0:f269e3021894 | 748 | R operator()() const { |
elessair | 0:f269e3021894 | 749 | return (obj->*method)(); |
elessair | 0:f269e3021894 | 750 | } |
elessair | 0:f269e3021894 | 751 | }; |
elessair | 0:f269e3021894 | 752 | |
elessair | 0:f269e3021894 | 753 | template <typename F, typename A> |
elessair | 0:f269e3021894 | 754 | struct function_context { |
elessair | 0:f269e3021894 | 755 | F func; |
elessair | 0:f269e3021894 | 756 | A *arg; |
elessair | 0:f269e3021894 | 757 | |
elessair | 0:f269e3021894 | 758 | function_context(F func, A *arg) |
elessair | 0:f269e3021894 | 759 | : func(func), arg(arg) {} |
elessair | 0:f269e3021894 | 760 | |
elessair | 0:f269e3021894 | 761 | R operator()() const { |
elessair | 0:f269e3021894 | 762 | return func(arg); |
elessair | 0:f269e3021894 | 763 | } |
elessair | 0:f269e3021894 | 764 | }; |
elessair | 0:f269e3021894 | 765 | }; |
elessair | 0:f269e3021894 | 766 | |
elessair | 0:f269e3021894 | 767 | /** Callback class based on template specialization |
elessair | 0:f269e3021894 | 768 | * |
elessair | 0:f269e3021894 | 769 | * @Note Synchronization level: Not protected |
elessair | 0:f269e3021894 | 770 | */ |
elessair | 0:f269e3021894 | 771 | template <typename R, typename A0> |
elessair | 0:f269e3021894 | 772 | class Callback<R(A0)> { |
elessair | 0:f269e3021894 | 773 | public: |
elessair | 0:f269e3021894 | 774 | /** Create a Callback with a static function |
elessair | 0:f269e3021894 | 775 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 776 | */ |
elessair | 0:f269e3021894 | 777 | Callback(R (*func)(A0) = 0) { |
elessair | 0:f269e3021894 | 778 | if (!func) { |
elessair | 0:f269e3021894 | 779 | _ops = 0; |
elessair | 0:f269e3021894 | 780 | } else { |
elessair | 0:f269e3021894 | 781 | generate(func); |
elessair | 0:f269e3021894 | 782 | } |
elessair | 0:f269e3021894 | 783 | } |
elessair | 0:f269e3021894 | 784 | |
elessair | 0:f269e3021894 | 785 | /** Attach a Callback |
elessair | 0:f269e3021894 | 786 | * @param func The Callback to attach |
elessair | 0:f269e3021894 | 787 | */ |
elessair | 0:f269e3021894 | 788 | Callback(const Callback<R(A0)> &func) { |
elessair | 0:f269e3021894 | 789 | if (func._ops) { |
elessair | 0:f269e3021894 | 790 | func._ops->move(this, &func); |
elessair | 0:f269e3021894 | 791 | } |
elessair | 0:f269e3021894 | 792 | _ops = func._ops; |
elessair | 0:f269e3021894 | 793 | } |
elessair | 0:f269e3021894 | 794 | |
elessair | 0:f269e3021894 | 795 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 796 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 797 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 798 | */ |
elessair | 0:f269e3021894 | 799 | template<typename T> |
elessair | 0:f269e3021894 | 800 | Callback(T *obj, R (T::*method)(A0)) { |
elessair | 0:f269e3021894 | 801 | generate(method_context<T, R (T::*)(A0)>(obj, method)); |
elessair | 0:f269e3021894 | 802 | } |
elessair | 0:f269e3021894 | 803 | |
elessair | 0:f269e3021894 | 804 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 805 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 806 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 807 | */ |
elessair | 0:f269e3021894 | 808 | template<typename T> |
elessair | 0:f269e3021894 | 809 | Callback(const T *obj, R (T::*method)(A0) const) { |
elessair | 0:f269e3021894 | 810 | generate(method_context<const T, R (T::*)(A0) const>(obj, method)); |
elessair | 0:f269e3021894 | 811 | } |
elessair | 0:f269e3021894 | 812 | |
elessair | 0:f269e3021894 | 813 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 814 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 815 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 816 | */ |
elessair | 0:f269e3021894 | 817 | template<typename T> |
elessair | 0:f269e3021894 | 818 | Callback(volatile T *obj, R (T::*method)(A0) volatile) { |
elessair | 0:f269e3021894 | 819 | generate(method_context<volatile T, R (T::*)(A0) volatile>(obj, method)); |
elessair | 0:f269e3021894 | 820 | } |
elessair | 0:f269e3021894 | 821 | |
elessair | 0:f269e3021894 | 822 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 823 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 824 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 825 | */ |
elessair | 0:f269e3021894 | 826 | template<typename T> |
elessair | 0:f269e3021894 | 827 | Callback(const volatile T *obj, R (T::*method)(A0) const volatile) { |
elessair | 0:f269e3021894 | 828 | generate(method_context<const volatile T, R (T::*)(A0) const volatile>(obj, method)); |
elessair | 0:f269e3021894 | 829 | } |
elessair | 0:f269e3021894 | 830 | |
elessair | 0:f269e3021894 | 831 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 832 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 833 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 834 | */ |
elessair | 0:f269e3021894 | 835 | Callback(R (*func)(void*, A0), void *arg) { |
elessair | 0:f269e3021894 | 836 | generate(function_context<R (*)(void*, A0), void>(func, arg)); |
elessair | 0:f269e3021894 | 837 | } |
elessair | 0:f269e3021894 | 838 | |
elessair | 0:f269e3021894 | 839 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 840 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 841 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 842 | */ |
elessair | 0:f269e3021894 | 843 | Callback(R (*func)(const void*, A0), const void *arg) { |
elessair | 0:f269e3021894 | 844 | generate(function_context<R (*)(const void*, A0), const void>(func, arg)); |
elessair | 0:f269e3021894 | 845 | } |
elessair | 0:f269e3021894 | 846 | |
elessair | 0:f269e3021894 | 847 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 848 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 849 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 850 | */ |
elessair | 0:f269e3021894 | 851 | Callback(R (*func)(volatile void*, A0), volatile void *arg) { |
elessair | 0:f269e3021894 | 852 | generate(function_context<R (*)(volatile void*, A0), volatile void>(func, arg)); |
elessair | 0:f269e3021894 | 853 | } |
elessair | 0:f269e3021894 | 854 | |
elessair | 0:f269e3021894 | 855 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 856 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 857 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 858 | */ |
elessair | 0:f269e3021894 | 859 | Callback(R (*func)(const volatile void*, A0), const volatile void *arg) { |
elessair | 0:f269e3021894 | 860 | generate(function_context<R (*)(const volatile void*, A0), const volatile void>(func, arg)); |
elessair | 0:f269e3021894 | 861 | } |
elessair | 0:f269e3021894 | 862 | |
elessair | 0:f269e3021894 | 863 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 864 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 865 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 866 | */ |
elessair | 0:f269e3021894 | 867 | template<typename T> |
elessair | 0:f269e3021894 | 868 | Callback(R (*func)(T*, A0), T *arg) { |
elessair | 0:f269e3021894 | 869 | generate(function_context<R (*)(T*, A0), T>(func, arg)); |
elessair | 0:f269e3021894 | 870 | } |
elessair | 0:f269e3021894 | 871 | |
elessair | 0:f269e3021894 | 872 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 873 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 874 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 875 | */ |
elessair | 0:f269e3021894 | 876 | template<typename T> |
elessair | 0:f269e3021894 | 877 | Callback(R (*func)(const T*, A0), const T *arg) { |
elessair | 0:f269e3021894 | 878 | generate(function_context<R (*)(const T*, A0), const T>(func, arg)); |
elessair | 0:f269e3021894 | 879 | } |
elessair | 0:f269e3021894 | 880 | |
elessair | 0:f269e3021894 | 881 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 882 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 883 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 884 | */ |
elessair | 0:f269e3021894 | 885 | template<typename T> |
elessair | 0:f269e3021894 | 886 | Callback(R (*func)(volatile T*, A0), volatile T *arg) { |
elessair | 0:f269e3021894 | 887 | generate(function_context<R (*)(volatile T*, A0), volatile T>(func, arg)); |
elessair | 0:f269e3021894 | 888 | } |
elessair | 0:f269e3021894 | 889 | |
elessair | 0:f269e3021894 | 890 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 891 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 892 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 893 | */ |
elessair | 0:f269e3021894 | 894 | template<typename T> |
elessair | 0:f269e3021894 | 895 | Callback(R (*func)(const volatile T*, A0), const volatile T *arg) { |
elessair | 0:f269e3021894 | 896 | generate(function_context<R (*)(const volatile T*, A0), const volatile T>(func, arg)); |
elessair | 0:f269e3021894 | 897 | } |
elessair | 0:f269e3021894 | 898 | |
elessair | 0:f269e3021894 | 899 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 900 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 901 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 902 | */ |
elessair | 0:f269e3021894 | 903 | template <typename F> |
elessair | 0:f269e3021894 | 904 | Callback(F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 905 | detail::is_type<R (F::*)(A0), &F::operator()>::value && |
elessair | 0:f269e3021894 | 906 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 907 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 908 | generate(f); |
elessair | 0:f269e3021894 | 909 | } |
elessair | 0:f269e3021894 | 910 | |
elessair | 0:f269e3021894 | 911 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 912 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 913 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 914 | */ |
elessair | 0:f269e3021894 | 915 | template <typename F> |
elessair | 0:f269e3021894 | 916 | Callback(const F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 917 | detail::is_type<R (F::*)(A0) const, &F::operator()>::value && |
elessair | 0:f269e3021894 | 918 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 919 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 920 | generate(f); |
elessair | 0:f269e3021894 | 921 | } |
elessair | 0:f269e3021894 | 922 | |
elessair | 0:f269e3021894 | 923 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 924 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 925 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 926 | */ |
elessair | 0:f269e3021894 | 927 | template <typename F> |
elessair | 0:f269e3021894 | 928 | Callback(volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 929 | detail::is_type<R (F::*)(A0) volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 930 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 931 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 932 | generate(f); |
elessair | 0:f269e3021894 | 933 | } |
elessair | 0:f269e3021894 | 934 | |
elessair | 0:f269e3021894 | 935 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 936 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 937 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 938 | */ |
elessair | 0:f269e3021894 | 939 | template <typename F> |
elessair | 0:f269e3021894 | 940 | Callback(const volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 941 | detail::is_type<R (F::*)(A0) const volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 942 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 943 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 944 | generate(f); |
elessair | 0:f269e3021894 | 945 | } |
elessair | 0:f269e3021894 | 946 | |
elessair | 0:f269e3021894 | 947 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 948 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 949 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 950 | * @deprecated |
elessair | 0:f269e3021894 | 951 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 952 | */ |
elessair | 0:f269e3021894 | 953 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 954 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 955 | Callback(void *obj, R (*func)(void*, A0)) { |
elessair | 0:f269e3021894 | 956 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 957 | } |
elessair | 0:f269e3021894 | 958 | |
elessair | 0:f269e3021894 | 959 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 960 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 961 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 962 | * @deprecated |
elessair | 0:f269e3021894 | 963 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 964 | */ |
elessair | 0:f269e3021894 | 965 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 966 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 967 | Callback(const void *obj, R (*func)(const void*, A0)) { |
elessair | 0:f269e3021894 | 968 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 969 | } |
elessair | 0:f269e3021894 | 970 | |
elessair | 0:f269e3021894 | 971 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 972 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 973 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 974 | * @deprecated |
elessair | 0:f269e3021894 | 975 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 976 | */ |
elessair | 0:f269e3021894 | 977 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 978 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 979 | Callback(volatile void *obj, R (*func)(volatile void*, A0)) { |
elessair | 0:f269e3021894 | 980 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 981 | } |
elessair | 0:f269e3021894 | 982 | |
elessair | 0:f269e3021894 | 983 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 984 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 985 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 986 | * @deprecated |
elessair | 0:f269e3021894 | 987 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 988 | */ |
elessair | 0:f269e3021894 | 989 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 990 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 991 | Callback(const volatile void *obj, R (*func)(const volatile void*, A0)) { |
elessair | 0:f269e3021894 | 992 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 993 | } |
elessair | 0:f269e3021894 | 994 | |
elessair | 0:f269e3021894 | 995 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 996 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 997 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 998 | * @deprecated |
elessair | 0:f269e3021894 | 999 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 1000 | */ |
elessair | 0:f269e3021894 | 1001 | template<typename T> |
elessair | 0:f269e3021894 | 1002 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1003 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 1004 | Callback(T *obj, R (*func)(T*, A0)) { |
elessair | 0:f269e3021894 | 1005 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1006 | } |
elessair | 0:f269e3021894 | 1007 | |
elessair | 0:f269e3021894 | 1008 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 1009 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1010 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1011 | * @deprecated |
elessair | 0:f269e3021894 | 1012 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 1013 | */ |
elessair | 0:f269e3021894 | 1014 | template<typename T> |
elessair | 0:f269e3021894 | 1015 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1016 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 1017 | Callback(const T *obj, R (*func)(const T*, A0)) { |
elessair | 0:f269e3021894 | 1018 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1019 | } |
elessair | 0:f269e3021894 | 1020 | |
elessair | 0:f269e3021894 | 1021 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 1022 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1023 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1024 | * @deprecated |
elessair | 0:f269e3021894 | 1025 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 1026 | */ |
elessair | 0:f269e3021894 | 1027 | template<typename T> |
elessair | 0:f269e3021894 | 1028 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1029 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 1030 | Callback(volatile T *obj, R (*func)(volatile T*, A0)) { |
elessair | 0:f269e3021894 | 1031 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1032 | } |
elessair | 0:f269e3021894 | 1033 | |
elessair | 0:f269e3021894 | 1034 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 1035 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1036 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1037 | * @deprecated |
elessair | 0:f269e3021894 | 1038 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 1039 | */ |
elessair | 0:f269e3021894 | 1040 | template<typename T> |
elessair | 0:f269e3021894 | 1041 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1042 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 1043 | Callback(const volatile T *obj, R (*func)(const volatile T*, A0)) { |
elessair | 0:f269e3021894 | 1044 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1045 | } |
elessair | 0:f269e3021894 | 1046 | |
elessair | 0:f269e3021894 | 1047 | /** Destroy a callback |
elessair | 0:f269e3021894 | 1048 | */ |
elessair | 0:f269e3021894 | 1049 | ~Callback() { |
elessair | 0:f269e3021894 | 1050 | if (_ops) { |
elessair | 0:f269e3021894 | 1051 | _ops->dtor(this); |
elessair | 0:f269e3021894 | 1052 | } |
elessair | 0:f269e3021894 | 1053 | } |
elessair | 0:f269e3021894 | 1054 | |
elessair | 0:f269e3021894 | 1055 | /** Attach a static function |
elessair | 0:f269e3021894 | 1056 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1057 | */ |
elessair | 0:f269e3021894 | 1058 | void attach(R (*func)(A0)) { |
elessair | 0:f269e3021894 | 1059 | this->~Callback(); |
elessair | 0:f269e3021894 | 1060 | new (this) Callback(func); |
elessair | 0:f269e3021894 | 1061 | } |
elessair | 0:f269e3021894 | 1062 | |
elessair | 0:f269e3021894 | 1063 | /** Attach a Callback |
elessair | 0:f269e3021894 | 1064 | * @param func The Callback to attach |
elessair | 0:f269e3021894 | 1065 | */ |
elessair | 0:f269e3021894 | 1066 | void attach(const Callback<R(A0)> &func) { |
elessair | 0:f269e3021894 | 1067 | this->~Callback(); |
elessair | 0:f269e3021894 | 1068 | new (this) Callback(func); |
elessair | 0:f269e3021894 | 1069 | } |
elessair | 0:f269e3021894 | 1070 | |
elessair | 0:f269e3021894 | 1071 | /** Attach a member function |
elessair | 0:f269e3021894 | 1072 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 1073 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 1074 | */ |
elessair | 0:f269e3021894 | 1075 | template<typename T> |
elessair | 0:f269e3021894 | 1076 | void attach(T *obj, R (T::*method)(A0)) { |
elessair | 0:f269e3021894 | 1077 | this->~Callback(); |
elessair | 0:f269e3021894 | 1078 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 1079 | } |
elessair | 0:f269e3021894 | 1080 | |
elessair | 0:f269e3021894 | 1081 | /** Attach a member function |
elessair | 0:f269e3021894 | 1082 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 1083 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 1084 | */ |
elessair | 0:f269e3021894 | 1085 | template<typename T> |
elessair | 0:f269e3021894 | 1086 | void attach(const T *obj, R (T::*method)(A0) const) { |
elessair | 0:f269e3021894 | 1087 | this->~Callback(); |
elessair | 0:f269e3021894 | 1088 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 1089 | } |
elessair | 0:f269e3021894 | 1090 | |
elessair | 0:f269e3021894 | 1091 | /** Attach a member function |
elessair | 0:f269e3021894 | 1092 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 1093 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 1094 | */ |
elessair | 0:f269e3021894 | 1095 | template<typename T> |
elessair | 0:f269e3021894 | 1096 | void attach(volatile T *obj, R (T::*method)(A0) volatile) { |
elessair | 0:f269e3021894 | 1097 | this->~Callback(); |
elessair | 0:f269e3021894 | 1098 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 1099 | } |
elessair | 0:f269e3021894 | 1100 | |
elessair | 0:f269e3021894 | 1101 | /** Attach a member function |
elessair | 0:f269e3021894 | 1102 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 1103 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 1104 | */ |
elessair | 0:f269e3021894 | 1105 | template<typename T> |
elessair | 0:f269e3021894 | 1106 | void attach(const volatile T *obj, R (T::*method)(A0) const volatile) { |
elessair | 0:f269e3021894 | 1107 | this->~Callback(); |
elessair | 0:f269e3021894 | 1108 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 1109 | } |
elessair | 0:f269e3021894 | 1110 | |
elessair | 0:f269e3021894 | 1111 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1112 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1113 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1114 | */ |
elessair | 0:f269e3021894 | 1115 | void attach(R (*func)(void*, A0), void *arg) { |
elessair | 0:f269e3021894 | 1116 | this->~Callback(); |
elessair | 0:f269e3021894 | 1117 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 1118 | } |
elessair | 0:f269e3021894 | 1119 | |
elessair | 0:f269e3021894 | 1120 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1121 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1122 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1123 | */ |
elessair | 0:f269e3021894 | 1124 | void attach(R (*func)(const void*, A0), const void *arg) { |
elessair | 0:f269e3021894 | 1125 | this->~Callback(); |
elessair | 0:f269e3021894 | 1126 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 1127 | } |
elessair | 0:f269e3021894 | 1128 | |
elessair | 0:f269e3021894 | 1129 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1130 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1131 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1132 | */ |
elessair | 0:f269e3021894 | 1133 | void attach(R (*func)(volatile void*, A0), volatile void *arg) { |
elessair | 0:f269e3021894 | 1134 | this->~Callback(); |
elessair | 0:f269e3021894 | 1135 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 1136 | } |
elessair | 0:f269e3021894 | 1137 | |
elessair | 0:f269e3021894 | 1138 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1139 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1140 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1141 | */ |
elessair | 0:f269e3021894 | 1142 | void attach(R (*func)(const volatile void*, A0), const volatile void *arg) { |
elessair | 0:f269e3021894 | 1143 | this->~Callback(); |
elessair | 0:f269e3021894 | 1144 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 1145 | } |
elessair | 0:f269e3021894 | 1146 | |
elessair | 0:f269e3021894 | 1147 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1148 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1149 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1150 | */ |
elessair | 0:f269e3021894 | 1151 | template <typename T> |
elessair | 0:f269e3021894 | 1152 | void attach(R (*func)(T*, A0), T *arg) { |
elessair | 0:f269e3021894 | 1153 | this->~Callback(); |
elessair | 0:f269e3021894 | 1154 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 1155 | } |
elessair | 0:f269e3021894 | 1156 | |
elessair | 0:f269e3021894 | 1157 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1158 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1159 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1160 | */ |
elessair | 0:f269e3021894 | 1161 | template <typename T> |
elessair | 0:f269e3021894 | 1162 | void attach(R (*func)(const T*, A0), const T *arg) { |
elessair | 0:f269e3021894 | 1163 | this->~Callback(); |
elessair | 0:f269e3021894 | 1164 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 1165 | } |
elessair | 0:f269e3021894 | 1166 | |
elessair | 0:f269e3021894 | 1167 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1168 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1169 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1170 | */ |
elessair | 0:f269e3021894 | 1171 | template <typename T> |
elessair | 0:f269e3021894 | 1172 | void attach(R (*func)(volatile T*, A0), volatile T *arg) { |
elessair | 0:f269e3021894 | 1173 | this->~Callback(); |
elessair | 0:f269e3021894 | 1174 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 1175 | } |
elessair | 0:f269e3021894 | 1176 | |
elessair | 0:f269e3021894 | 1177 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1178 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1179 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1180 | */ |
elessair | 0:f269e3021894 | 1181 | template <typename T> |
elessair | 0:f269e3021894 | 1182 | void attach(R (*func)(const volatile T*, A0), const volatile T *arg) { |
elessair | 0:f269e3021894 | 1183 | this->~Callback(); |
elessair | 0:f269e3021894 | 1184 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 1185 | } |
elessair | 0:f269e3021894 | 1186 | |
elessair | 0:f269e3021894 | 1187 | /** Attach a function object |
elessair | 0:f269e3021894 | 1188 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 1189 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 1190 | */ |
elessair | 0:f269e3021894 | 1191 | template <typename F> |
elessair | 0:f269e3021894 | 1192 | void attach(F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 1193 | detail::is_type<R (F::*)(A0), &F::operator()>::value && |
elessair | 0:f269e3021894 | 1194 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 1195 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 1196 | this->~Callback(); |
elessair | 0:f269e3021894 | 1197 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 1198 | } |
elessair | 0:f269e3021894 | 1199 | |
elessair | 0:f269e3021894 | 1200 | /** Attach a function object |
elessair | 0:f269e3021894 | 1201 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 1202 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 1203 | */ |
elessair | 0:f269e3021894 | 1204 | template <typename F> |
elessair | 0:f269e3021894 | 1205 | void attach(const F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 1206 | detail::is_type<R (F::*)(A0) const, &F::operator()>::value && |
elessair | 0:f269e3021894 | 1207 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 1208 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 1209 | this->~Callback(); |
elessair | 0:f269e3021894 | 1210 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 1211 | } |
elessair | 0:f269e3021894 | 1212 | |
elessair | 0:f269e3021894 | 1213 | /** Attach a function object |
elessair | 0:f269e3021894 | 1214 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 1215 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 1216 | */ |
elessair | 0:f269e3021894 | 1217 | template <typename F> |
elessair | 0:f269e3021894 | 1218 | void attach(volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 1219 | detail::is_type<R (F::*)(A0) volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 1220 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 1221 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 1222 | this->~Callback(); |
elessair | 0:f269e3021894 | 1223 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 1224 | } |
elessair | 0:f269e3021894 | 1225 | |
elessair | 0:f269e3021894 | 1226 | /** Attach a function object |
elessair | 0:f269e3021894 | 1227 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 1228 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 1229 | */ |
elessair | 0:f269e3021894 | 1230 | template <typename F> |
elessair | 0:f269e3021894 | 1231 | void attach(const volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 1232 | detail::is_type<R (F::*)(A0) const volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 1233 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 1234 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 1235 | this->~Callback(); |
elessair | 0:f269e3021894 | 1236 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 1237 | } |
elessair | 0:f269e3021894 | 1238 | |
elessair | 0:f269e3021894 | 1239 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1240 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1241 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1242 | * @deprecated |
elessair | 0:f269e3021894 | 1243 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 1244 | */ |
elessair | 0:f269e3021894 | 1245 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1246 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 1247 | void attach(void *obj, R (*func)(void*, A0)) { |
elessair | 0:f269e3021894 | 1248 | this->~Callback(); |
elessair | 0:f269e3021894 | 1249 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1250 | } |
elessair | 0:f269e3021894 | 1251 | |
elessair | 0:f269e3021894 | 1252 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1253 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1254 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1255 | * @deprecated |
elessair | 0:f269e3021894 | 1256 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 1257 | */ |
elessair | 0:f269e3021894 | 1258 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1259 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 1260 | void attach(const void *obj, R (*func)(const void*, A0)) { |
elessair | 0:f269e3021894 | 1261 | this->~Callback(); |
elessair | 0:f269e3021894 | 1262 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1263 | } |
elessair | 0:f269e3021894 | 1264 | |
elessair | 0:f269e3021894 | 1265 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1266 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1267 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1268 | * @deprecated |
elessair | 0:f269e3021894 | 1269 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 1270 | */ |
elessair | 0:f269e3021894 | 1271 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1272 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 1273 | void attach(volatile void *obj, R (*func)(volatile void*, A0)) { |
elessair | 0:f269e3021894 | 1274 | this->~Callback(); |
elessair | 0:f269e3021894 | 1275 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1276 | } |
elessair | 0:f269e3021894 | 1277 | |
elessair | 0:f269e3021894 | 1278 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1279 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1280 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1281 | * @deprecated |
elessair | 0:f269e3021894 | 1282 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 1283 | */ |
elessair | 0:f269e3021894 | 1284 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1285 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 1286 | void attach(const volatile void *obj, R (*func)(const volatile void*, A0)) { |
elessair | 0:f269e3021894 | 1287 | this->~Callback(); |
elessair | 0:f269e3021894 | 1288 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1289 | } |
elessair | 0:f269e3021894 | 1290 | |
elessair | 0:f269e3021894 | 1291 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1292 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1293 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1294 | * @deprecated |
elessair | 0:f269e3021894 | 1295 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 1296 | */ |
elessair | 0:f269e3021894 | 1297 | template <typename T> |
elessair | 0:f269e3021894 | 1298 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1299 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 1300 | void attach(T *obj, R (*func)(T*, A0)) { |
elessair | 0:f269e3021894 | 1301 | this->~Callback(); |
elessair | 0:f269e3021894 | 1302 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1303 | } |
elessair | 0:f269e3021894 | 1304 | |
elessair | 0:f269e3021894 | 1305 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1306 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1307 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1308 | * @deprecated |
elessair | 0:f269e3021894 | 1309 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 1310 | */ |
elessair | 0:f269e3021894 | 1311 | template <typename T> |
elessair | 0:f269e3021894 | 1312 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1313 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 1314 | void attach(const T *obj, R (*func)(const T*, A0)) { |
elessair | 0:f269e3021894 | 1315 | this->~Callback(); |
elessair | 0:f269e3021894 | 1316 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1317 | } |
elessair | 0:f269e3021894 | 1318 | |
elessair | 0:f269e3021894 | 1319 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1320 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1321 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1322 | * @deprecated |
elessair | 0:f269e3021894 | 1323 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 1324 | */ |
elessair | 0:f269e3021894 | 1325 | template <typename T> |
elessair | 0:f269e3021894 | 1326 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1327 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 1328 | void attach(volatile T *obj, R (*func)(volatile T*, A0)) { |
elessair | 0:f269e3021894 | 1329 | this->~Callback(); |
elessair | 0:f269e3021894 | 1330 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1331 | } |
elessair | 0:f269e3021894 | 1332 | |
elessair | 0:f269e3021894 | 1333 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1334 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1335 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1336 | * @deprecated |
elessair | 0:f269e3021894 | 1337 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 1338 | */ |
elessair | 0:f269e3021894 | 1339 | template <typename T> |
elessair | 0:f269e3021894 | 1340 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1341 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 1342 | void attach(const volatile T *obj, R (*func)(const volatile T*, A0)) { |
elessair | 0:f269e3021894 | 1343 | this->~Callback(); |
elessair | 0:f269e3021894 | 1344 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1345 | } |
elessair | 0:f269e3021894 | 1346 | |
elessair | 0:f269e3021894 | 1347 | /** Assign a callback |
elessair | 0:f269e3021894 | 1348 | */ |
elessair | 0:f269e3021894 | 1349 | Callback &operator=(const Callback &that) { |
elessair | 0:f269e3021894 | 1350 | if (this != &that) { |
elessair | 0:f269e3021894 | 1351 | this->~Callback(); |
elessair | 0:f269e3021894 | 1352 | new (this) Callback(that); |
elessair | 0:f269e3021894 | 1353 | } |
elessair | 0:f269e3021894 | 1354 | |
elessair | 0:f269e3021894 | 1355 | return *this; |
elessair | 0:f269e3021894 | 1356 | } |
elessair | 0:f269e3021894 | 1357 | |
elessair | 0:f269e3021894 | 1358 | /** Call the attached function |
elessair | 0:f269e3021894 | 1359 | */ |
elessair | 0:f269e3021894 | 1360 | R call(A0 a0) const { |
elessair | 0:f269e3021894 | 1361 | MBED_ASSERT(_ops); |
elessair | 0:f269e3021894 | 1362 | return _ops->call(this, a0); |
elessair | 0:f269e3021894 | 1363 | } |
elessair | 0:f269e3021894 | 1364 | |
elessair | 0:f269e3021894 | 1365 | /** Call the attached function |
elessair | 0:f269e3021894 | 1366 | */ |
elessair | 0:f269e3021894 | 1367 | R operator()(A0 a0) const { |
elessair | 0:f269e3021894 | 1368 | return call(a0); |
elessair | 0:f269e3021894 | 1369 | } |
elessair | 0:f269e3021894 | 1370 | |
elessair | 0:f269e3021894 | 1371 | /** Test if function has been attached |
elessair | 0:f269e3021894 | 1372 | */ |
elessair | 0:f269e3021894 | 1373 | operator bool() const { |
elessair | 0:f269e3021894 | 1374 | return _ops; |
elessair | 0:f269e3021894 | 1375 | } |
elessair | 0:f269e3021894 | 1376 | |
elessair | 0:f269e3021894 | 1377 | /** Test for equality |
elessair | 0:f269e3021894 | 1378 | */ |
elessair | 0:f269e3021894 | 1379 | friend bool operator==(const Callback &l, const Callback &r) { |
elessair | 0:f269e3021894 | 1380 | return memcmp(&l, &r, sizeof(Callback)) == 0; |
elessair | 0:f269e3021894 | 1381 | } |
elessair | 0:f269e3021894 | 1382 | |
elessair | 0:f269e3021894 | 1383 | /** Test for inequality |
elessair | 0:f269e3021894 | 1384 | */ |
elessair | 0:f269e3021894 | 1385 | friend bool operator!=(const Callback &l, const Callback &r) { |
elessair | 0:f269e3021894 | 1386 | return !(l == r); |
elessair | 0:f269e3021894 | 1387 | } |
elessair | 0:f269e3021894 | 1388 | |
elessair | 0:f269e3021894 | 1389 | /** Static thunk for passing as C-style function |
elessair | 0:f269e3021894 | 1390 | * @param func Callback to call passed as void pointer |
elessair | 0:f269e3021894 | 1391 | */ |
elessair | 0:f269e3021894 | 1392 | static R thunk(void *func, A0 a0) { |
elessair | 0:f269e3021894 | 1393 | return static_cast<Callback*>(func)->call(a0); |
elessair | 0:f269e3021894 | 1394 | } |
elessair | 0:f269e3021894 | 1395 | |
elessair | 0:f269e3021894 | 1396 | private: |
elessair | 0:f269e3021894 | 1397 | // Stored as pointer to function and pointer to optional object |
elessair | 0:f269e3021894 | 1398 | // Function pointer is stored as union of possible function types |
elessair | 0:f269e3021894 | 1399 | // to garuntee proper size and alignment |
elessair | 0:f269e3021894 | 1400 | struct _class; |
elessair | 0:f269e3021894 | 1401 | union { |
elessair | 0:f269e3021894 | 1402 | void (*_staticfunc)(A0); |
elessair | 0:f269e3021894 | 1403 | void (*_boundfunc)(_class*, A0); |
elessair | 0:f269e3021894 | 1404 | void (_class::*_methodfunc)(A0); |
elessair | 0:f269e3021894 | 1405 | } _func; |
elessair | 0:f269e3021894 | 1406 | void *_obj; |
elessair | 0:f269e3021894 | 1407 | |
elessair | 0:f269e3021894 | 1408 | // Dynamically dispatched operations |
elessair | 0:f269e3021894 | 1409 | const struct ops { |
elessair | 0:f269e3021894 | 1410 | R (*call)(const void*, A0); |
elessair | 0:f269e3021894 | 1411 | void (*move)(void*, const void*); |
elessair | 0:f269e3021894 | 1412 | void (*dtor)(void*); |
elessair | 0:f269e3021894 | 1413 | } *_ops; |
elessair | 0:f269e3021894 | 1414 | |
elessair | 0:f269e3021894 | 1415 | // Generate operations for function object |
elessair | 0:f269e3021894 | 1416 | template <typename F> |
elessair | 0:f269e3021894 | 1417 | void generate(const F &f) { |
elessair | 0:f269e3021894 | 1418 | static const ops ops = { |
elessair | 0:f269e3021894 | 1419 | &Callback::function_call<F>, |
elessair | 0:f269e3021894 | 1420 | &Callback::function_move<F>, |
elessair | 0:f269e3021894 | 1421 | &Callback::function_dtor<F>, |
elessair | 0:f269e3021894 | 1422 | }; |
elessair | 0:f269e3021894 | 1423 | |
elessair | 0:f269e3021894 | 1424 | MBED_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F)); |
elessair | 0:f269e3021894 | 1425 | new (this) F(f); |
elessair | 0:f269e3021894 | 1426 | _ops = &ops; |
elessair | 0:f269e3021894 | 1427 | } |
elessair | 0:f269e3021894 | 1428 | |
elessair | 0:f269e3021894 | 1429 | // Function attributes |
elessair | 0:f269e3021894 | 1430 | template <typename F> |
elessair | 0:f269e3021894 | 1431 | static R function_call(const void *p, A0 a0) { |
elessair | 0:f269e3021894 | 1432 | return (*(F*)p)(a0); |
elessair | 0:f269e3021894 | 1433 | } |
elessair | 0:f269e3021894 | 1434 | |
elessair | 0:f269e3021894 | 1435 | template <typename F> |
elessair | 0:f269e3021894 | 1436 | static void function_move(void *d, const void *p) { |
elessair | 0:f269e3021894 | 1437 | new (d) F(*(F*)p); |
elessair | 0:f269e3021894 | 1438 | } |
elessair | 0:f269e3021894 | 1439 | |
elessair | 0:f269e3021894 | 1440 | template <typename F> |
elessair | 0:f269e3021894 | 1441 | static void function_dtor(void *p) { |
elessair | 0:f269e3021894 | 1442 | ((F*)p)->~F(); |
elessair | 0:f269e3021894 | 1443 | } |
elessair | 0:f269e3021894 | 1444 | |
elessair | 0:f269e3021894 | 1445 | // Wrappers for functions with context |
elessair | 0:f269e3021894 | 1446 | template <typename O, typename M> |
elessair | 0:f269e3021894 | 1447 | struct method_context { |
elessair | 0:f269e3021894 | 1448 | M method; |
elessair | 0:f269e3021894 | 1449 | O *obj; |
elessair | 0:f269e3021894 | 1450 | |
elessair | 0:f269e3021894 | 1451 | method_context(O *obj, M method) |
elessair | 0:f269e3021894 | 1452 | : method(method), obj(obj) {} |
elessair | 0:f269e3021894 | 1453 | |
elessair | 0:f269e3021894 | 1454 | R operator()(A0 a0) const { |
elessair | 0:f269e3021894 | 1455 | return (obj->*method)(a0); |
elessair | 0:f269e3021894 | 1456 | } |
elessair | 0:f269e3021894 | 1457 | }; |
elessair | 0:f269e3021894 | 1458 | |
elessair | 0:f269e3021894 | 1459 | template <typename F, typename A> |
elessair | 0:f269e3021894 | 1460 | struct function_context { |
elessair | 0:f269e3021894 | 1461 | F func; |
elessair | 0:f269e3021894 | 1462 | A *arg; |
elessair | 0:f269e3021894 | 1463 | |
elessair | 0:f269e3021894 | 1464 | function_context(F func, A *arg) |
elessair | 0:f269e3021894 | 1465 | : func(func), arg(arg) {} |
elessair | 0:f269e3021894 | 1466 | |
elessair | 0:f269e3021894 | 1467 | R operator()(A0 a0) const { |
elessair | 0:f269e3021894 | 1468 | return func(arg, a0); |
elessair | 0:f269e3021894 | 1469 | } |
elessair | 0:f269e3021894 | 1470 | }; |
elessair | 0:f269e3021894 | 1471 | }; |
elessair | 0:f269e3021894 | 1472 | |
elessair | 0:f269e3021894 | 1473 | /** Callback class based on template specialization |
elessair | 0:f269e3021894 | 1474 | * |
elessair | 0:f269e3021894 | 1475 | * @Note Synchronization level: Not protected |
elessair | 0:f269e3021894 | 1476 | */ |
elessair | 0:f269e3021894 | 1477 | template <typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 1478 | class Callback<R(A0, A1)> { |
elessair | 0:f269e3021894 | 1479 | public: |
elessair | 0:f269e3021894 | 1480 | /** Create a Callback with a static function |
elessair | 0:f269e3021894 | 1481 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1482 | */ |
elessair | 0:f269e3021894 | 1483 | Callback(R (*func)(A0, A1) = 0) { |
elessair | 0:f269e3021894 | 1484 | if (!func) { |
elessair | 0:f269e3021894 | 1485 | _ops = 0; |
elessair | 0:f269e3021894 | 1486 | } else { |
elessair | 0:f269e3021894 | 1487 | generate(func); |
elessair | 0:f269e3021894 | 1488 | } |
elessair | 0:f269e3021894 | 1489 | } |
elessair | 0:f269e3021894 | 1490 | |
elessair | 0:f269e3021894 | 1491 | /** Attach a Callback |
elessair | 0:f269e3021894 | 1492 | * @param func The Callback to attach |
elessair | 0:f269e3021894 | 1493 | */ |
elessair | 0:f269e3021894 | 1494 | Callback(const Callback<R(A0, A1)> &func) { |
elessair | 0:f269e3021894 | 1495 | if (func._ops) { |
elessair | 0:f269e3021894 | 1496 | func._ops->move(this, &func); |
elessair | 0:f269e3021894 | 1497 | } |
elessair | 0:f269e3021894 | 1498 | _ops = func._ops; |
elessair | 0:f269e3021894 | 1499 | } |
elessair | 0:f269e3021894 | 1500 | |
elessair | 0:f269e3021894 | 1501 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 1502 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 1503 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 1504 | */ |
elessair | 0:f269e3021894 | 1505 | template<typename T> |
elessair | 0:f269e3021894 | 1506 | Callback(T *obj, R (T::*method)(A0, A1)) { |
elessair | 0:f269e3021894 | 1507 | generate(method_context<T, R (T::*)(A0, A1)>(obj, method)); |
elessair | 0:f269e3021894 | 1508 | } |
elessair | 0:f269e3021894 | 1509 | |
elessair | 0:f269e3021894 | 1510 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 1511 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 1512 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 1513 | */ |
elessair | 0:f269e3021894 | 1514 | template<typename T> |
elessair | 0:f269e3021894 | 1515 | Callback(const T *obj, R (T::*method)(A0, A1) const) { |
elessair | 0:f269e3021894 | 1516 | generate(method_context<const T, R (T::*)(A0, A1) const>(obj, method)); |
elessair | 0:f269e3021894 | 1517 | } |
elessair | 0:f269e3021894 | 1518 | |
elessair | 0:f269e3021894 | 1519 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 1520 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 1521 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 1522 | */ |
elessair | 0:f269e3021894 | 1523 | template<typename T> |
elessair | 0:f269e3021894 | 1524 | Callback(volatile T *obj, R (T::*method)(A0, A1) volatile) { |
elessair | 0:f269e3021894 | 1525 | generate(method_context<volatile T, R (T::*)(A0, A1) volatile>(obj, method)); |
elessair | 0:f269e3021894 | 1526 | } |
elessair | 0:f269e3021894 | 1527 | |
elessair | 0:f269e3021894 | 1528 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 1529 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 1530 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 1531 | */ |
elessair | 0:f269e3021894 | 1532 | template<typename T> |
elessair | 0:f269e3021894 | 1533 | Callback(const volatile T *obj, R (T::*method)(A0, A1) const volatile) { |
elessair | 0:f269e3021894 | 1534 | generate(method_context<const volatile T, R (T::*)(A0, A1) const volatile>(obj, method)); |
elessair | 0:f269e3021894 | 1535 | } |
elessair | 0:f269e3021894 | 1536 | |
elessair | 0:f269e3021894 | 1537 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 1538 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1539 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1540 | */ |
elessair | 0:f269e3021894 | 1541 | Callback(R (*func)(void*, A0, A1), void *arg) { |
elessair | 0:f269e3021894 | 1542 | generate(function_context<R (*)(void*, A0, A1), void>(func, arg)); |
elessair | 0:f269e3021894 | 1543 | } |
elessair | 0:f269e3021894 | 1544 | |
elessair | 0:f269e3021894 | 1545 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 1546 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1547 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1548 | */ |
elessair | 0:f269e3021894 | 1549 | Callback(R (*func)(const void*, A0, A1), const void *arg) { |
elessair | 0:f269e3021894 | 1550 | generate(function_context<R (*)(const void*, A0, A1), const void>(func, arg)); |
elessair | 0:f269e3021894 | 1551 | } |
elessair | 0:f269e3021894 | 1552 | |
elessair | 0:f269e3021894 | 1553 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 1554 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1555 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1556 | */ |
elessair | 0:f269e3021894 | 1557 | Callback(R (*func)(volatile void*, A0, A1), volatile void *arg) { |
elessair | 0:f269e3021894 | 1558 | generate(function_context<R (*)(volatile void*, A0, A1), volatile void>(func, arg)); |
elessair | 0:f269e3021894 | 1559 | } |
elessair | 0:f269e3021894 | 1560 | |
elessair | 0:f269e3021894 | 1561 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 1562 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1563 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1564 | */ |
elessair | 0:f269e3021894 | 1565 | Callback(R (*func)(const volatile void*, A0, A1), const volatile void *arg) { |
elessair | 0:f269e3021894 | 1566 | generate(function_context<R (*)(const volatile void*, A0, A1), const volatile void>(func, arg)); |
elessair | 0:f269e3021894 | 1567 | } |
elessair | 0:f269e3021894 | 1568 | |
elessair | 0:f269e3021894 | 1569 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 1570 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1571 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1572 | */ |
elessair | 0:f269e3021894 | 1573 | template<typename T> |
elessair | 0:f269e3021894 | 1574 | Callback(R (*func)(T*, A0, A1), T *arg) { |
elessair | 0:f269e3021894 | 1575 | generate(function_context<R (*)(T*, A0, A1), T>(func, arg)); |
elessair | 0:f269e3021894 | 1576 | } |
elessair | 0:f269e3021894 | 1577 | |
elessair | 0:f269e3021894 | 1578 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 1579 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1580 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1581 | */ |
elessair | 0:f269e3021894 | 1582 | template<typename T> |
elessair | 0:f269e3021894 | 1583 | Callback(R (*func)(const T*, A0, A1), const T *arg) { |
elessair | 0:f269e3021894 | 1584 | generate(function_context<R (*)(const T*, A0, A1), const T>(func, arg)); |
elessair | 0:f269e3021894 | 1585 | } |
elessair | 0:f269e3021894 | 1586 | |
elessair | 0:f269e3021894 | 1587 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 1588 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1589 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1590 | */ |
elessair | 0:f269e3021894 | 1591 | template<typename T> |
elessair | 0:f269e3021894 | 1592 | Callback(R (*func)(volatile T*, A0, A1), volatile T *arg) { |
elessair | 0:f269e3021894 | 1593 | generate(function_context<R (*)(volatile T*, A0, A1), volatile T>(func, arg)); |
elessair | 0:f269e3021894 | 1594 | } |
elessair | 0:f269e3021894 | 1595 | |
elessair | 0:f269e3021894 | 1596 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 1597 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1598 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1599 | */ |
elessair | 0:f269e3021894 | 1600 | template<typename T> |
elessair | 0:f269e3021894 | 1601 | Callback(R (*func)(const volatile T*, A0, A1), const volatile T *arg) { |
elessair | 0:f269e3021894 | 1602 | generate(function_context<R (*)(const volatile T*, A0, A1), const volatile T>(func, arg)); |
elessair | 0:f269e3021894 | 1603 | } |
elessair | 0:f269e3021894 | 1604 | |
elessair | 0:f269e3021894 | 1605 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 1606 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 1607 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 1608 | */ |
elessair | 0:f269e3021894 | 1609 | template <typename F> |
elessair | 0:f269e3021894 | 1610 | Callback(F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 1611 | detail::is_type<R (F::*)(A0, A1), &F::operator()>::value && |
elessair | 0:f269e3021894 | 1612 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 1613 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 1614 | generate(f); |
elessair | 0:f269e3021894 | 1615 | } |
elessair | 0:f269e3021894 | 1616 | |
elessair | 0:f269e3021894 | 1617 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 1618 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 1619 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 1620 | */ |
elessair | 0:f269e3021894 | 1621 | template <typename F> |
elessair | 0:f269e3021894 | 1622 | Callback(const F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 1623 | detail::is_type<R (F::*)(A0, A1) const, &F::operator()>::value && |
elessair | 0:f269e3021894 | 1624 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 1625 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 1626 | generate(f); |
elessair | 0:f269e3021894 | 1627 | } |
elessair | 0:f269e3021894 | 1628 | |
elessair | 0:f269e3021894 | 1629 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 1630 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 1631 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 1632 | */ |
elessair | 0:f269e3021894 | 1633 | template <typename F> |
elessair | 0:f269e3021894 | 1634 | Callback(volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 1635 | detail::is_type<R (F::*)(A0, A1) volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 1636 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 1637 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 1638 | generate(f); |
elessair | 0:f269e3021894 | 1639 | } |
elessair | 0:f269e3021894 | 1640 | |
elessair | 0:f269e3021894 | 1641 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 1642 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 1643 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 1644 | */ |
elessair | 0:f269e3021894 | 1645 | template <typename F> |
elessair | 0:f269e3021894 | 1646 | Callback(const volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 1647 | detail::is_type<R (F::*)(A0, A1) const volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 1648 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 1649 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 1650 | generate(f); |
elessair | 0:f269e3021894 | 1651 | } |
elessair | 0:f269e3021894 | 1652 | |
elessair | 0:f269e3021894 | 1653 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 1654 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1655 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1656 | * @deprecated |
elessair | 0:f269e3021894 | 1657 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 1658 | */ |
elessair | 0:f269e3021894 | 1659 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1660 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 1661 | Callback(void *obj, R (*func)(void*, A0, A1)) { |
elessair | 0:f269e3021894 | 1662 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1663 | } |
elessair | 0:f269e3021894 | 1664 | |
elessair | 0:f269e3021894 | 1665 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 1666 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1667 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1668 | * @deprecated |
elessair | 0:f269e3021894 | 1669 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 1670 | */ |
elessair | 0:f269e3021894 | 1671 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1672 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 1673 | Callback(const void *obj, R (*func)(const void*, A0, A1)) { |
elessair | 0:f269e3021894 | 1674 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1675 | } |
elessair | 0:f269e3021894 | 1676 | |
elessair | 0:f269e3021894 | 1677 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 1678 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1679 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1680 | * @deprecated |
elessair | 0:f269e3021894 | 1681 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 1682 | */ |
elessair | 0:f269e3021894 | 1683 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1684 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 1685 | Callback(volatile void *obj, R (*func)(volatile void*, A0, A1)) { |
elessair | 0:f269e3021894 | 1686 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1687 | } |
elessair | 0:f269e3021894 | 1688 | |
elessair | 0:f269e3021894 | 1689 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 1690 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1691 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1692 | * @deprecated |
elessair | 0:f269e3021894 | 1693 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 1694 | */ |
elessair | 0:f269e3021894 | 1695 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1696 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 1697 | Callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1)) { |
elessair | 0:f269e3021894 | 1698 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1699 | } |
elessair | 0:f269e3021894 | 1700 | |
elessair | 0:f269e3021894 | 1701 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 1702 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1703 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1704 | * @deprecated |
elessair | 0:f269e3021894 | 1705 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 1706 | */ |
elessair | 0:f269e3021894 | 1707 | template<typename T> |
elessair | 0:f269e3021894 | 1708 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1709 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 1710 | Callback(T *obj, R (*func)(T*, A0, A1)) { |
elessair | 0:f269e3021894 | 1711 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1712 | } |
elessair | 0:f269e3021894 | 1713 | |
elessair | 0:f269e3021894 | 1714 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 1715 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1716 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1717 | * @deprecated |
elessair | 0:f269e3021894 | 1718 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 1719 | */ |
elessair | 0:f269e3021894 | 1720 | template<typename T> |
elessair | 0:f269e3021894 | 1721 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1722 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 1723 | Callback(const T *obj, R (*func)(const T*, A0, A1)) { |
elessair | 0:f269e3021894 | 1724 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1725 | } |
elessair | 0:f269e3021894 | 1726 | |
elessair | 0:f269e3021894 | 1727 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 1728 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1729 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1730 | * @deprecated |
elessair | 0:f269e3021894 | 1731 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 1732 | */ |
elessair | 0:f269e3021894 | 1733 | template<typename T> |
elessair | 0:f269e3021894 | 1734 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1735 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 1736 | Callback(volatile T *obj, R (*func)(volatile T*, A0, A1)) { |
elessair | 0:f269e3021894 | 1737 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1738 | } |
elessair | 0:f269e3021894 | 1739 | |
elessair | 0:f269e3021894 | 1740 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 1741 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1742 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1743 | * @deprecated |
elessair | 0:f269e3021894 | 1744 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 1745 | */ |
elessair | 0:f269e3021894 | 1746 | template<typename T> |
elessair | 0:f269e3021894 | 1747 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1748 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 1749 | Callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1)) { |
elessair | 0:f269e3021894 | 1750 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1751 | } |
elessair | 0:f269e3021894 | 1752 | |
elessair | 0:f269e3021894 | 1753 | /** Destroy a callback |
elessair | 0:f269e3021894 | 1754 | */ |
elessair | 0:f269e3021894 | 1755 | ~Callback() { |
elessair | 0:f269e3021894 | 1756 | if (_ops) { |
elessair | 0:f269e3021894 | 1757 | _ops->dtor(this); |
elessair | 0:f269e3021894 | 1758 | } |
elessair | 0:f269e3021894 | 1759 | } |
elessair | 0:f269e3021894 | 1760 | |
elessair | 0:f269e3021894 | 1761 | /** Attach a static function |
elessair | 0:f269e3021894 | 1762 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1763 | */ |
elessair | 0:f269e3021894 | 1764 | void attach(R (*func)(A0, A1)) { |
elessair | 0:f269e3021894 | 1765 | this->~Callback(); |
elessair | 0:f269e3021894 | 1766 | new (this) Callback(func); |
elessair | 0:f269e3021894 | 1767 | } |
elessair | 0:f269e3021894 | 1768 | |
elessair | 0:f269e3021894 | 1769 | /** Attach a Callback |
elessair | 0:f269e3021894 | 1770 | * @param func The Callback to attach |
elessair | 0:f269e3021894 | 1771 | */ |
elessair | 0:f269e3021894 | 1772 | void attach(const Callback<R(A0, A1)> &func) { |
elessair | 0:f269e3021894 | 1773 | this->~Callback(); |
elessair | 0:f269e3021894 | 1774 | new (this) Callback(func); |
elessair | 0:f269e3021894 | 1775 | } |
elessair | 0:f269e3021894 | 1776 | |
elessair | 0:f269e3021894 | 1777 | /** Attach a member function |
elessair | 0:f269e3021894 | 1778 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 1779 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 1780 | */ |
elessair | 0:f269e3021894 | 1781 | template<typename T> |
elessair | 0:f269e3021894 | 1782 | void attach(T *obj, R (T::*method)(A0, A1)) { |
elessair | 0:f269e3021894 | 1783 | this->~Callback(); |
elessair | 0:f269e3021894 | 1784 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 1785 | } |
elessair | 0:f269e3021894 | 1786 | |
elessair | 0:f269e3021894 | 1787 | /** Attach a member function |
elessair | 0:f269e3021894 | 1788 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 1789 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 1790 | */ |
elessair | 0:f269e3021894 | 1791 | template<typename T> |
elessair | 0:f269e3021894 | 1792 | void attach(const T *obj, R (T::*method)(A0, A1) const) { |
elessair | 0:f269e3021894 | 1793 | this->~Callback(); |
elessair | 0:f269e3021894 | 1794 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 1795 | } |
elessair | 0:f269e3021894 | 1796 | |
elessair | 0:f269e3021894 | 1797 | /** Attach a member function |
elessair | 0:f269e3021894 | 1798 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 1799 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 1800 | */ |
elessair | 0:f269e3021894 | 1801 | template<typename T> |
elessair | 0:f269e3021894 | 1802 | void attach(volatile T *obj, R (T::*method)(A0, A1) volatile) { |
elessair | 0:f269e3021894 | 1803 | this->~Callback(); |
elessair | 0:f269e3021894 | 1804 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 1805 | } |
elessair | 0:f269e3021894 | 1806 | |
elessair | 0:f269e3021894 | 1807 | /** Attach a member function |
elessair | 0:f269e3021894 | 1808 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 1809 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 1810 | */ |
elessair | 0:f269e3021894 | 1811 | template<typename T> |
elessair | 0:f269e3021894 | 1812 | void attach(const volatile T *obj, R (T::*method)(A0, A1) const volatile) { |
elessair | 0:f269e3021894 | 1813 | this->~Callback(); |
elessair | 0:f269e3021894 | 1814 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 1815 | } |
elessair | 0:f269e3021894 | 1816 | |
elessair | 0:f269e3021894 | 1817 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1818 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1819 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1820 | */ |
elessair | 0:f269e3021894 | 1821 | void attach(R (*func)(void*, A0, A1), void *arg) { |
elessair | 0:f269e3021894 | 1822 | this->~Callback(); |
elessair | 0:f269e3021894 | 1823 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 1824 | } |
elessair | 0:f269e3021894 | 1825 | |
elessair | 0:f269e3021894 | 1826 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1827 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1828 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1829 | */ |
elessair | 0:f269e3021894 | 1830 | void attach(R (*func)(const void*, A0, A1), const void *arg) { |
elessair | 0:f269e3021894 | 1831 | this->~Callback(); |
elessair | 0:f269e3021894 | 1832 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 1833 | } |
elessair | 0:f269e3021894 | 1834 | |
elessair | 0:f269e3021894 | 1835 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1836 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1837 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1838 | */ |
elessair | 0:f269e3021894 | 1839 | void attach(R (*func)(volatile void*, A0, A1), volatile void *arg) { |
elessair | 0:f269e3021894 | 1840 | this->~Callback(); |
elessair | 0:f269e3021894 | 1841 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 1842 | } |
elessair | 0:f269e3021894 | 1843 | |
elessair | 0:f269e3021894 | 1844 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1845 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1846 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1847 | */ |
elessair | 0:f269e3021894 | 1848 | void attach(R (*func)(const volatile void*, A0, A1), const volatile void *arg) { |
elessair | 0:f269e3021894 | 1849 | this->~Callback(); |
elessair | 0:f269e3021894 | 1850 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 1851 | } |
elessair | 0:f269e3021894 | 1852 | |
elessair | 0:f269e3021894 | 1853 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1854 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1855 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1856 | */ |
elessair | 0:f269e3021894 | 1857 | template <typename T> |
elessair | 0:f269e3021894 | 1858 | void attach(R (*func)(T*, A0, A1), T *arg) { |
elessair | 0:f269e3021894 | 1859 | this->~Callback(); |
elessair | 0:f269e3021894 | 1860 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 1861 | } |
elessair | 0:f269e3021894 | 1862 | |
elessair | 0:f269e3021894 | 1863 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1864 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1865 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1866 | */ |
elessair | 0:f269e3021894 | 1867 | template <typename T> |
elessair | 0:f269e3021894 | 1868 | void attach(R (*func)(const T*, A0, A1), const T *arg) { |
elessair | 0:f269e3021894 | 1869 | this->~Callback(); |
elessair | 0:f269e3021894 | 1870 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 1871 | } |
elessair | 0:f269e3021894 | 1872 | |
elessair | 0:f269e3021894 | 1873 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1874 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1875 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1876 | */ |
elessair | 0:f269e3021894 | 1877 | template <typename T> |
elessair | 0:f269e3021894 | 1878 | void attach(R (*func)(volatile T*, A0, A1), volatile T *arg) { |
elessair | 0:f269e3021894 | 1879 | this->~Callback(); |
elessair | 0:f269e3021894 | 1880 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 1881 | } |
elessair | 0:f269e3021894 | 1882 | |
elessair | 0:f269e3021894 | 1883 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1884 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1885 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 1886 | */ |
elessair | 0:f269e3021894 | 1887 | template <typename T> |
elessair | 0:f269e3021894 | 1888 | void attach(R (*func)(const volatile T*, A0, A1), const volatile T *arg) { |
elessair | 0:f269e3021894 | 1889 | this->~Callback(); |
elessair | 0:f269e3021894 | 1890 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 1891 | } |
elessair | 0:f269e3021894 | 1892 | |
elessair | 0:f269e3021894 | 1893 | /** Attach a function object |
elessair | 0:f269e3021894 | 1894 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 1895 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 1896 | */ |
elessair | 0:f269e3021894 | 1897 | template <typename F> |
elessair | 0:f269e3021894 | 1898 | void attach(F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 1899 | detail::is_type<R (F::*)(A0, A1), &F::operator()>::value && |
elessair | 0:f269e3021894 | 1900 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 1901 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 1902 | this->~Callback(); |
elessair | 0:f269e3021894 | 1903 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 1904 | } |
elessair | 0:f269e3021894 | 1905 | |
elessair | 0:f269e3021894 | 1906 | /** Attach a function object |
elessair | 0:f269e3021894 | 1907 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 1908 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 1909 | */ |
elessair | 0:f269e3021894 | 1910 | template <typename F> |
elessair | 0:f269e3021894 | 1911 | void attach(const F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 1912 | detail::is_type<R (F::*)(A0, A1) const, &F::operator()>::value && |
elessair | 0:f269e3021894 | 1913 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 1914 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 1915 | this->~Callback(); |
elessair | 0:f269e3021894 | 1916 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 1917 | } |
elessair | 0:f269e3021894 | 1918 | |
elessair | 0:f269e3021894 | 1919 | /** Attach a function object |
elessair | 0:f269e3021894 | 1920 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 1921 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 1922 | */ |
elessair | 0:f269e3021894 | 1923 | template <typename F> |
elessair | 0:f269e3021894 | 1924 | void attach(volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 1925 | detail::is_type<R (F::*)(A0, A1) volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 1926 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 1927 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 1928 | this->~Callback(); |
elessair | 0:f269e3021894 | 1929 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 1930 | } |
elessair | 0:f269e3021894 | 1931 | |
elessair | 0:f269e3021894 | 1932 | /** Attach a function object |
elessair | 0:f269e3021894 | 1933 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 1934 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 1935 | */ |
elessair | 0:f269e3021894 | 1936 | template <typename F> |
elessair | 0:f269e3021894 | 1937 | void attach(const volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 1938 | detail::is_type<R (F::*)(A0, A1) const volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 1939 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 1940 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 1941 | this->~Callback(); |
elessair | 0:f269e3021894 | 1942 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 1943 | } |
elessair | 0:f269e3021894 | 1944 | |
elessair | 0:f269e3021894 | 1945 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1946 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1947 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1948 | * @deprecated |
elessair | 0:f269e3021894 | 1949 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 1950 | */ |
elessair | 0:f269e3021894 | 1951 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1952 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 1953 | void attach(void *obj, R (*func)(void*, A0, A1)) { |
elessair | 0:f269e3021894 | 1954 | this->~Callback(); |
elessair | 0:f269e3021894 | 1955 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1956 | } |
elessair | 0:f269e3021894 | 1957 | |
elessair | 0:f269e3021894 | 1958 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1959 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1960 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1961 | * @deprecated |
elessair | 0:f269e3021894 | 1962 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 1963 | */ |
elessair | 0:f269e3021894 | 1964 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1965 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 1966 | void attach(const void *obj, R (*func)(const void*, A0, A1)) { |
elessair | 0:f269e3021894 | 1967 | this->~Callback(); |
elessair | 0:f269e3021894 | 1968 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1969 | } |
elessair | 0:f269e3021894 | 1970 | |
elessair | 0:f269e3021894 | 1971 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1972 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1973 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1974 | * @deprecated |
elessair | 0:f269e3021894 | 1975 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 1976 | */ |
elessair | 0:f269e3021894 | 1977 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1978 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 1979 | void attach(volatile void *obj, R (*func)(volatile void*, A0, A1)) { |
elessair | 0:f269e3021894 | 1980 | this->~Callback(); |
elessair | 0:f269e3021894 | 1981 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1982 | } |
elessair | 0:f269e3021894 | 1983 | |
elessair | 0:f269e3021894 | 1984 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1985 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1986 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 1987 | * @deprecated |
elessair | 0:f269e3021894 | 1988 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 1989 | */ |
elessair | 0:f269e3021894 | 1990 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 1991 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 1992 | void attach(const volatile void *obj, R (*func)(const volatile void*, A0, A1)) { |
elessair | 0:f269e3021894 | 1993 | this->~Callback(); |
elessair | 0:f269e3021894 | 1994 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 1995 | } |
elessair | 0:f269e3021894 | 1996 | |
elessair | 0:f269e3021894 | 1997 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 1998 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 1999 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2000 | * @deprecated |
elessair | 0:f269e3021894 | 2001 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 2002 | */ |
elessair | 0:f269e3021894 | 2003 | template <typename T> |
elessair | 0:f269e3021894 | 2004 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 2005 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 2006 | void attach(T *obj, R (*func)(T*, A0, A1)) { |
elessair | 0:f269e3021894 | 2007 | this->~Callback(); |
elessair | 0:f269e3021894 | 2008 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 2009 | } |
elessair | 0:f269e3021894 | 2010 | |
elessair | 0:f269e3021894 | 2011 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 2012 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 2013 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2014 | * @deprecated |
elessair | 0:f269e3021894 | 2015 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 2016 | */ |
elessair | 0:f269e3021894 | 2017 | template <typename T> |
elessair | 0:f269e3021894 | 2018 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 2019 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 2020 | void attach(const T *obj, R (*func)(const T*, A0, A1)) { |
elessair | 0:f269e3021894 | 2021 | this->~Callback(); |
elessair | 0:f269e3021894 | 2022 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 2023 | } |
elessair | 0:f269e3021894 | 2024 | |
elessair | 0:f269e3021894 | 2025 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 2026 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 2027 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2028 | * @deprecated |
elessair | 0:f269e3021894 | 2029 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 2030 | */ |
elessair | 0:f269e3021894 | 2031 | template <typename T> |
elessair | 0:f269e3021894 | 2032 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 2033 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 2034 | void attach(volatile T *obj, R (*func)(volatile T*, A0, A1)) { |
elessair | 0:f269e3021894 | 2035 | this->~Callback(); |
elessair | 0:f269e3021894 | 2036 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 2037 | } |
elessair | 0:f269e3021894 | 2038 | |
elessair | 0:f269e3021894 | 2039 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 2040 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 2041 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2042 | * @deprecated |
elessair | 0:f269e3021894 | 2043 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 2044 | */ |
elessair | 0:f269e3021894 | 2045 | template <typename T> |
elessair | 0:f269e3021894 | 2046 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 2047 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 2048 | void attach(const volatile T *obj, R (*func)(const volatile T*, A0, A1)) { |
elessair | 0:f269e3021894 | 2049 | this->~Callback(); |
elessair | 0:f269e3021894 | 2050 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 2051 | } |
elessair | 0:f269e3021894 | 2052 | |
elessair | 0:f269e3021894 | 2053 | /** Assign a callback |
elessair | 0:f269e3021894 | 2054 | */ |
elessair | 0:f269e3021894 | 2055 | Callback &operator=(const Callback &that) { |
elessair | 0:f269e3021894 | 2056 | if (this != &that) { |
elessair | 0:f269e3021894 | 2057 | this->~Callback(); |
elessair | 0:f269e3021894 | 2058 | new (this) Callback(that); |
elessair | 0:f269e3021894 | 2059 | } |
elessair | 0:f269e3021894 | 2060 | |
elessair | 0:f269e3021894 | 2061 | return *this; |
elessair | 0:f269e3021894 | 2062 | } |
elessair | 0:f269e3021894 | 2063 | |
elessair | 0:f269e3021894 | 2064 | /** Call the attached function |
elessair | 0:f269e3021894 | 2065 | */ |
elessair | 0:f269e3021894 | 2066 | R call(A0 a0, A1 a1) const { |
elessair | 0:f269e3021894 | 2067 | MBED_ASSERT(_ops); |
elessair | 0:f269e3021894 | 2068 | return _ops->call(this, a0, a1); |
elessair | 0:f269e3021894 | 2069 | } |
elessair | 0:f269e3021894 | 2070 | |
elessair | 0:f269e3021894 | 2071 | /** Call the attached function |
elessair | 0:f269e3021894 | 2072 | */ |
elessair | 0:f269e3021894 | 2073 | R operator()(A0 a0, A1 a1) const { |
elessair | 0:f269e3021894 | 2074 | return call(a0, a1); |
elessair | 0:f269e3021894 | 2075 | } |
elessair | 0:f269e3021894 | 2076 | |
elessair | 0:f269e3021894 | 2077 | /** Test if function has been attached |
elessair | 0:f269e3021894 | 2078 | */ |
elessair | 0:f269e3021894 | 2079 | operator bool() const { |
elessair | 0:f269e3021894 | 2080 | return _ops; |
elessair | 0:f269e3021894 | 2081 | } |
elessair | 0:f269e3021894 | 2082 | |
elessair | 0:f269e3021894 | 2083 | /** Test for equality |
elessair | 0:f269e3021894 | 2084 | */ |
elessair | 0:f269e3021894 | 2085 | friend bool operator==(const Callback &l, const Callback &r) { |
elessair | 0:f269e3021894 | 2086 | return memcmp(&l, &r, sizeof(Callback)) == 0; |
elessair | 0:f269e3021894 | 2087 | } |
elessair | 0:f269e3021894 | 2088 | |
elessair | 0:f269e3021894 | 2089 | /** Test for inequality |
elessair | 0:f269e3021894 | 2090 | */ |
elessair | 0:f269e3021894 | 2091 | friend bool operator!=(const Callback &l, const Callback &r) { |
elessair | 0:f269e3021894 | 2092 | return !(l == r); |
elessair | 0:f269e3021894 | 2093 | } |
elessair | 0:f269e3021894 | 2094 | |
elessair | 0:f269e3021894 | 2095 | /** Static thunk for passing as C-style function |
elessair | 0:f269e3021894 | 2096 | * @param func Callback to call passed as void pointer |
elessair | 0:f269e3021894 | 2097 | */ |
elessair | 0:f269e3021894 | 2098 | static R thunk(void *func, A0 a0, A1 a1) { |
elessair | 0:f269e3021894 | 2099 | return static_cast<Callback*>(func)->call(a0, a1); |
elessair | 0:f269e3021894 | 2100 | } |
elessair | 0:f269e3021894 | 2101 | |
elessair | 0:f269e3021894 | 2102 | private: |
elessair | 0:f269e3021894 | 2103 | // Stored as pointer to function and pointer to optional object |
elessair | 0:f269e3021894 | 2104 | // Function pointer is stored as union of possible function types |
elessair | 0:f269e3021894 | 2105 | // to garuntee proper size and alignment |
elessair | 0:f269e3021894 | 2106 | struct _class; |
elessair | 0:f269e3021894 | 2107 | union { |
elessair | 0:f269e3021894 | 2108 | void (*_staticfunc)(A0, A1); |
elessair | 0:f269e3021894 | 2109 | void (*_boundfunc)(_class*, A0, A1); |
elessair | 0:f269e3021894 | 2110 | void (_class::*_methodfunc)(A0, A1); |
elessair | 0:f269e3021894 | 2111 | } _func; |
elessair | 0:f269e3021894 | 2112 | void *_obj; |
elessair | 0:f269e3021894 | 2113 | |
elessair | 0:f269e3021894 | 2114 | // Dynamically dispatched operations |
elessair | 0:f269e3021894 | 2115 | const struct ops { |
elessair | 0:f269e3021894 | 2116 | R (*call)(const void*, A0, A1); |
elessair | 0:f269e3021894 | 2117 | void (*move)(void*, const void*); |
elessair | 0:f269e3021894 | 2118 | void (*dtor)(void*); |
elessair | 0:f269e3021894 | 2119 | } *_ops; |
elessair | 0:f269e3021894 | 2120 | |
elessair | 0:f269e3021894 | 2121 | // Generate operations for function object |
elessair | 0:f269e3021894 | 2122 | template <typename F> |
elessair | 0:f269e3021894 | 2123 | void generate(const F &f) { |
elessair | 0:f269e3021894 | 2124 | static const ops ops = { |
elessair | 0:f269e3021894 | 2125 | &Callback::function_call<F>, |
elessair | 0:f269e3021894 | 2126 | &Callback::function_move<F>, |
elessair | 0:f269e3021894 | 2127 | &Callback::function_dtor<F>, |
elessair | 0:f269e3021894 | 2128 | }; |
elessair | 0:f269e3021894 | 2129 | |
elessair | 0:f269e3021894 | 2130 | MBED_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F)); |
elessair | 0:f269e3021894 | 2131 | new (this) F(f); |
elessair | 0:f269e3021894 | 2132 | _ops = &ops; |
elessair | 0:f269e3021894 | 2133 | } |
elessair | 0:f269e3021894 | 2134 | |
elessair | 0:f269e3021894 | 2135 | // Function attributes |
elessair | 0:f269e3021894 | 2136 | template <typename F> |
elessair | 0:f269e3021894 | 2137 | static R function_call(const void *p, A0 a0, A1 a1) { |
elessair | 0:f269e3021894 | 2138 | return (*(F*)p)(a0, a1); |
elessair | 0:f269e3021894 | 2139 | } |
elessair | 0:f269e3021894 | 2140 | |
elessair | 0:f269e3021894 | 2141 | template <typename F> |
elessair | 0:f269e3021894 | 2142 | static void function_move(void *d, const void *p) { |
elessair | 0:f269e3021894 | 2143 | new (d) F(*(F*)p); |
elessair | 0:f269e3021894 | 2144 | } |
elessair | 0:f269e3021894 | 2145 | |
elessair | 0:f269e3021894 | 2146 | template <typename F> |
elessair | 0:f269e3021894 | 2147 | static void function_dtor(void *p) { |
elessair | 0:f269e3021894 | 2148 | ((F*)p)->~F(); |
elessair | 0:f269e3021894 | 2149 | } |
elessair | 0:f269e3021894 | 2150 | |
elessair | 0:f269e3021894 | 2151 | // Wrappers for functions with context |
elessair | 0:f269e3021894 | 2152 | template <typename O, typename M> |
elessair | 0:f269e3021894 | 2153 | struct method_context { |
elessair | 0:f269e3021894 | 2154 | M method; |
elessair | 0:f269e3021894 | 2155 | O *obj; |
elessair | 0:f269e3021894 | 2156 | |
elessair | 0:f269e3021894 | 2157 | method_context(O *obj, M method) |
elessair | 0:f269e3021894 | 2158 | : method(method), obj(obj) {} |
elessair | 0:f269e3021894 | 2159 | |
elessair | 0:f269e3021894 | 2160 | R operator()(A0 a0, A1 a1) const { |
elessair | 0:f269e3021894 | 2161 | return (obj->*method)(a0, a1); |
elessair | 0:f269e3021894 | 2162 | } |
elessair | 0:f269e3021894 | 2163 | }; |
elessair | 0:f269e3021894 | 2164 | |
elessair | 0:f269e3021894 | 2165 | template <typename F, typename A> |
elessair | 0:f269e3021894 | 2166 | struct function_context { |
elessair | 0:f269e3021894 | 2167 | F func; |
elessair | 0:f269e3021894 | 2168 | A *arg; |
elessair | 0:f269e3021894 | 2169 | |
elessair | 0:f269e3021894 | 2170 | function_context(F func, A *arg) |
elessair | 0:f269e3021894 | 2171 | : func(func), arg(arg) {} |
elessair | 0:f269e3021894 | 2172 | |
elessair | 0:f269e3021894 | 2173 | R operator()(A0 a0, A1 a1) const { |
elessair | 0:f269e3021894 | 2174 | return func(arg, a0, a1); |
elessair | 0:f269e3021894 | 2175 | } |
elessair | 0:f269e3021894 | 2176 | }; |
elessair | 0:f269e3021894 | 2177 | }; |
elessair | 0:f269e3021894 | 2178 | |
elessair | 0:f269e3021894 | 2179 | /** Callback class based on template specialization |
elessair | 0:f269e3021894 | 2180 | * |
elessair | 0:f269e3021894 | 2181 | * @Note Synchronization level: Not protected |
elessair | 0:f269e3021894 | 2182 | */ |
elessair | 0:f269e3021894 | 2183 | template <typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 2184 | class Callback<R(A0, A1, A2)> { |
elessair | 0:f269e3021894 | 2185 | public: |
elessair | 0:f269e3021894 | 2186 | /** Create a Callback with a static function |
elessair | 0:f269e3021894 | 2187 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2188 | */ |
elessair | 0:f269e3021894 | 2189 | Callback(R (*func)(A0, A1, A2) = 0) { |
elessair | 0:f269e3021894 | 2190 | if (!func) { |
elessair | 0:f269e3021894 | 2191 | _ops = 0; |
elessair | 0:f269e3021894 | 2192 | } else { |
elessair | 0:f269e3021894 | 2193 | generate(func); |
elessair | 0:f269e3021894 | 2194 | } |
elessair | 0:f269e3021894 | 2195 | } |
elessair | 0:f269e3021894 | 2196 | |
elessair | 0:f269e3021894 | 2197 | /** Attach a Callback |
elessair | 0:f269e3021894 | 2198 | * @param func The Callback to attach |
elessair | 0:f269e3021894 | 2199 | */ |
elessair | 0:f269e3021894 | 2200 | Callback(const Callback<R(A0, A1, A2)> &func) { |
elessair | 0:f269e3021894 | 2201 | if (func._ops) { |
elessair | 0:f269e3021894 | 2202 | func._ops->move(this, &func); |
elessair | 0:f269e3021894 | 2203 | } |
elessair | 0:f269e3021894 | 2204 | _ops = func._ops; |
elessair | 0:f269e3021894 | 2205 | } |
elessair | 0:f269e3021894 | 2206 | |
elessair | 0:f269e3021894 | 2207 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 2208 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 2209 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 2210 | */ |
elessair | 0:f269e3021894 | 2211 | template<typename T> |
elessair | 0:f269e3021894 | 2212 | Callback(T *obj, R (T::*method)(A0, A1, A2)) { |
elessair | 0:f269e3021894 | 2213 | generate(method_context<T, R (T::*)(A0, A1, A2)>(obj, method)); |
elessair | 0:f269e3021894 | 2214 | } |
elessair | 0:f269e3021894 | 2215 | |
elessair | 0:f269e3021894 | 2216 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 2217 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 2218 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 2219 | */ |
elessair | 0:f269e3021894 | 2220 | template<typename T> |
elessair | 0:f269e3021894 | 2221 | Callback(const T *obj, R (T::*method)(A0, A1, A2) const) { |
elessair | 0:f269e3021894 | 2222 | generate(method_context<const T, R (T::*)(A0, A1, A2) const>(obj, method)); |
elessair | 0:f269e3021894 | 2223 | } |
elessair | 0:f269e3021894 | 2224 | |
elessair | 0:f269e3021894 | 2225 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 2226 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 2227 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 2228 | */ |
elessair | 0:f269e3021894 | 2229 | template<typename T> |
elessair | 0:f269e3021894 | 2230 | Callback(volatile T *obj, R (T::*method)(A0, A1, A2) volatile) { |
elessair | 0:f269e3021894 | 2231 | generate(method_context<volatile T, R (T::*)(A0, A1, A2) volatile>(obj, method)); |
elessair | 0:f269e3021894 | 2232 | } |
elessair | 0:f269e3021894 | 2233 | |
elessair | 0:f269e3021894 | 2234 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 2235 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 2236 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 2237 | */ |
elessair | 0:f269e3021894 | 2238 | template<typename T> |
elessair | 0:f269e3021894 | 2239 | Callback(const volatile T *obj, R (T::*method)(A0, A1, A2) const volatile) { |
elessair | 0:f269e3021894 | 2240 | generate(method_context<const volatile T, R (T::*)(A0, A1, A2) const volatile>(obj, method)); |
elessair | 0:f269e3021894 | 2241 | } |
elessair | 0:f269e3021894 | 2242 | |
elessair | 0:f269e3021894 | 2243 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 2244 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2245 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 2246 | */ |
elessair | 0:f269e3021894 | 2247 | Callback(R (*func)(void*, A0, A1, A2), void *arg) { |
elessair | 0:f269e3021894 | 2248 | generate(function_context<R (*)(void*, A0, A1, A2), void>(func, arg)); |
elessair | 0:f269e3021894 | 2249 | } |
elessair | 0:f269e3021894 | 2250 | |
elessair | 0:f269e3021894 | 2251 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 2252 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2253 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 2254 | */ |
elessair | 0:f269e3021894 | 2255 | Callback(R (*func)(const void*, A0, A1, A2), const void *arg) { |
elessair | 0:f269e3021894 | 2256 | generate(function_context<R (*)(const void*, A0, A1, A2), const void>(func, arg)); |
elessair | 0:f269e3021894 | 2257 | } |
elessair | 0:f269e3021894 | 2258 | |
elessair | 0:f269e3021894 | 2259 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 2260 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2261 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 2262 | */ |
elessair | 0:f269e3021894 | 2263 | Callback(R (*func)(volatile void*, A0, A1, A2), volatile void *arg) { |
elessair | 0:f269e3021894 | 2264 | generate(function_context<R (*)(volatile void*, A0, A1, A2), volatile void>(func, arg)); |
elessair | 0:f269e3021894 | 2265 | } |
elessair | 0:f269e3021894 | 2266 | |
elessair | 0:f269e3021894 | 2267 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 2268 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2269 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 2270 | */ |
elessair | 0:f269e3021894 | 2271 | Callback(R (*func)(const volatile void*, A0, A1, A2), const volatile void *arg) { |
elessair | 0:f269e3021894 | 2272 | generate(function_context<R (*)(const volatile void*, A0, A1, A2), const volatile void>(func, arg)); |
elessair | 0:f269e3021894 | 2273 | } |
elessair | 0:f269e3021894 | 2274 | |
elessair | 0:f269e3021894 | 2275 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 2276 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2277 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 2278 | */ |
elessair | 0:f269e3021894 | 2279 | template<typename T> |
elessair | 0:f269e3021894 | 2280 | Callback(R (*func)(T*, A0, A1, A2), T *arg) { |
elessair | 0:f269e3021894 | 2281 | generate(function_context<R (*)(T*, A0, A1, A2), T>(func, arg)); |
elessair | 0:f269e3021894 | 2282 | } |
elessair | 0:f269e3021894 | 2283 | |
elessair | 0:f269e3021894 | 2284 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 2285 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2286 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 2287 | */ |
elessair | 0:f269e3021894 | 2288 | template<typename T> |
elessair | 0:f269e3021894 | 2289 | Callback(R (*func)(const T*, A0, A1, A2), const T *arg) { |
elessair | 0:f269e3021894 | 2290 | generate(function_context<R (*)(const T*, A0, A1, A2), const T>(func, arg)); |
elessair | 0:f269e3021894 | 2291 | } |
elessair | 0:f269e3021894 | 2292 | |
elessair | 0:f269e3021894 | 2293 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 2294 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2295 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 2296 | */ |
elessair | 0:f269e3021894 | 2297 | template<typename T> |
elessair | 0:f269e3021894 | 2298 | Callback(R (*func)(volatile T*, A0, A1, A2), volatile T *arg) { |
elessair | 0:f269e3021894 | 2299 | generate(function_context<R (*)(volatile T*, A0, A1, A2), volatile T>(func, arg)); |
elessair | 0:f269e3021894 | 2300 | } |
elessair | 0:f269e3021894 | 2301 | |
elessair | 0:f269e3021894 | 2302 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 2303 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2304 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 2305 | */ |
elessair | 0:f269e3021894 | 2306 | template<typename T> |
elessair | 0:f269e3021894 | 2307 | Callback(R (*func)(const volatile T*, A0, A1, A2), const volatile T *arg) { |
elessair | 0:f269e3021894 | 2308 | generate(function_context<R (*)(const volatile T*, A0, A1, A2), const volatile T>(func, arg)); |
elessair | 0:f269e3021894 | 2309 | } |
elessair | 0:f269e3021894 | 2310 | |
elessair | 0:f269e3021894 | 2311 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 2312 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 2313 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 2314 | */ |
elessair | 0:f269e3021894 | 2315 | template <typename F> |
elessair | 0:f269e3021894 | 2316 | Callback(F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 2317 | detail::is_type<R (F::*)(A0, A1, A2), &F::operator()>::value && |
elessair | 0:f269e3021894 | 2318 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 2319 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 2320 | generate(f); |
elessair | 0:f269e3021894 | 2321 | } |
elessair | 0:f269e3021894 | 2322 | |
elessair | 0:f269e3021894 | 2323 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 2324 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 2325 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 2326 | */ |
elessair | 0:f269e3021894 | 2327 | template <typename F> |
elessair | 0:f269e3021894 | 2328 | Callback(const F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 2329 | detail::is_type<R (F::*)(A0, A1, A2) const, &F::operator()>::value && |
elessair | 0:f269e3021894 | 2330 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 2331 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 2332 | generate(f); |
elessair | 0:f269e3021894 | 2333 | } |
elessair | 0:f269e3021894 | 2334 | |
elessair | 0:f269e3021894 | 2335 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 2336 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 2337 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 2338 | */ |
elessair | 0:f269e3021894 | 2339 | template <typename F> |
elessair | 0:f269e3021894 | 2340 | Callback(volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 2341 | detail::is_type<R (F::*)(A0, A1, A2) volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 2342 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 2343 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 2344 | generate(f); |
elessair | 0:f269e3021894 | 2345 | } |
elessair | 0:f269e3021894 | 2346 | |
elessair | 0:f269e3021894 | 2347 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 2348 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 2349 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 2350 | */ |
elessair | 0:f269e3021894 | 2351 | template <typename F> |
elessair | 0:f269e3021894 | 2352 | Callback(const volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 2353 | detail::is_type<R (F::*)(A0, A1, A2) const volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 2354 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 2355 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 2356 | generate(f); |
elessair | 0:f269e3021894 | 2357 | } |
elessair | 0:f269e3021894 | 2358 | |
elessair | 0:f269e3021894 | 2359 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 2360 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 2361 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2362 | * @deprecated |
elessair | 0:f269e3021894 | 2363 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 2364 | */ |
elessair | 0:f269e3021894 | 2365 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 2366 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 2367 | Callback(void *obj, R (*func)(void*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 2368 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 2369 | } |
elessair | 0:f269e3021894 | 2370 | |
elessair | 0:f269e3021894 | 2371 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 2372 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 2373 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2374 | * @deprecated |
elessair | 0:f269e3021894 | 2375 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 2376 | */ |
elessair | 0:f269e3021894 | 2377 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 2378 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 2379 | Callback(const void *obj, R (*func)(const void*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 2380 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 2381 | } |
elessair | 0:f269e3021894 | 2382 | |
elessair | 0:f269e3021894 | 2383 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 2384 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 2385 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2386 | * @deprecated |
elessair | 0:f269e3021894 | 2387 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 2388 | */ |
elessair | 0:f269e3021894 | 2389 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 2390 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 2391 | Callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 2392 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 2393 | } |
elessair | 0:f269e3021894 | 2394 | |
elessair | 0:f269e3021894 | 2395 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 2396 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 2397 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2398 | * @deprecated |
elessair | 0:f269e3021894 | 2399 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 2400 | */ |
elessair | 0:f269e3021894 | 2401 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 2402 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 2403 | Callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 2404 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 2405 | } |
elessair | 0:f269e3021894 | 2406 | |
elessair | 0:f269e3021894 | 2407 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 2408 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 2409 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2410 | * @deprecated |
elessair | 0:f269e3021894 | 2411 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 2412 | */ |
elessair | 0:f269e3021894 | 2413 | template<typename T> |
elessair | 0:f269e3021894 | 2414 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 2415 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 2416 | Callback(T *obj, R (*func)(T*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 2417 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 2418 | } |
elessair | 0:f269e3021894 | 2419 | |
elessair | 0:f269e3021894 | 2420 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 2421 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 2422 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2423 | * @deprecated |
elessair | 0:f269e3021894 | 2424 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 2425 | */ |
elessair | 0:f269e3021894 | 2426 | template<typename T> |
elessair | 0:f269e3021894 | 2427 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 2428 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 2429 | Callback(const T *obj, R (*func)(const T*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 2430 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 2431 | } |
elessair | 0:f269e3021894 | 2432 | |
elessair | 0:f269e3021894 | 2433 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 2434 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 2435 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2436 | * @deprecated |
elessair | 0:f269e3021894 | 2437 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 2438 | */ |
elessair | 0:f269e3021894 | 2439 | template<typename T> |
elessair | 0:f269e3021894 | 2440 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 2441 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 2442 | Callback(volatile T *obj, R (*func)(volatile T*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 2443 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 2444 | } |
elessair | 0:f269e3021894 | 2445 | |
elessair | 0:f269e3021894 | 2446 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 2447 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 2448 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2449 | * @deprecated |
elessair | 0:f269e3021894 | 2450 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 2451 | */ |
elessair | 0:f269e3021894 | 2452 | template<typename T> |
elessair | 0:f269e3021894 | 2453 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 2454 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 2455 | Callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 2456 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 2457 | } |
elessair | 0:f269e3021894 | 2458 | |
elessair | 0:f269e3021894 | 2459 | /** Destroy a callback |
elessair | 0:f269e3021894 | 2460 | */ |
elessair | 0:f269e3021894 | 2461 | ~Callback() { |
elessair | 0:f269e3021894 | 2462 | if (_ops) { |
elessair | 0:f269e3021894 | 2463 | _ops->dtor(this); |
elessair | 0:f269e3021894 | 2464 | } |
elessair | 0:f269e3021894 | 2465 | } |
elessair | 0:f269e3021894 | 2466 | |
elessair | 0:f269e3021894 | 2467 | /** Attach a static function |
elessair | 0:f269e3021894 | 2468 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2469 | */ |
elessair | 0:f269e3021894 | 2470 | void attach(R (*func)(A0, A1, A2)) { |
elessair | 0:f269e3021894 | 2471 | this->~Callback(); |
elessair | 0:f269e3021894 | 2472 | new (this) Callback(func); |
elessair | 0:f269e3021894 | 2473 | } |
elessair | 0:f269e3021894 | 2474 | |
elessair | 0:f269e3021894 | 2475 | /** Attach a Callback |
elessair | 0:f269e3021894 | 2476 | * @param func The Callback to attach |
elessair | 0:f269e3021894 | 2477 | */ |
elessair | 0:f269e3021894 | 2478 | void attach(const Callback<R(A0, A1, A2)> &func) { |
elessair | 0:f269e3021894 | 2479 | this->~Callback(); |
elessair | 0:f269e3021894 | 2480 | new (this) Callback(func); |
elessair | 0:f269e3021894 | 2481 | } |
elessair | 0:f269e3021894 | 2482 | |
elessair | 0:f269e3021894 | 2483 | /** Attach a member function |
elessair | 0:f269e3021894 | 2484 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 2485 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 2486 | */ |
elessair | 0:f269e3021894 | 2487 | template<typename T> |
elessair | 0:f269e3021894 | 2488 | void attach(T *obj, R (T::*method)(A0, A1, A2)) { |
elessair | 0:f269e3021894 | 2489 | this->~Callback(); |
elessair | 0:f269e3021894 | 2490 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 2491 | } |
elessair | 0:f269e3021894 | 2492 | |
elessair | 0:f269e3021894 | 2493 | /** Attach a member function |
elessair | 0:f269e3021894 | 2494 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 2495 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 2496 | */ |
elessair | 0:f269e3021894 | 2497 | template<typename T> |
elessair | 0:f269e3021894 | 2498 | void attach(const T *obj, R (T::*method)(A0, A1, A2) const) { |
elessair | 0:f269e3021894 | 2499 | this->~Callback(); |
elessair | 0:f269e3021894 | 2500 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 2501 | } |
elessair | 0:f269e3021894 | 2502 | |
elessair | 0:f269e3021894 | 2503 | /** Attach a member function |
elessair | 0:f269e3021894 | 2504 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 2505 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 2506 | */ |
elessair | 0:f269e3021894 | 2507 | template<typename T> |
elessair | 0:f269e3021894 | 2508 | void attach(volatile T *obj, R (T::*method)(A0, A1, A2) volatile) { |
elessair | 0:f269e3021894 | 2509 | this->~Callback(); |
elessair | 0:f269e3021894 | 2510 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 2511 | } |
elessair | 0:f269e3021894 | 2512 | |
elessair | 0:f269e3021894 | 2513 | /** Attach a member function |
elessair | 0:f269e3021894 | 2514 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 2515 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 2516 | */ |
elessair | 0:f269e3021894 | 2517 | template<typename T> |
elessair | 0:f269e3021894 | 2518 | void attach(const volatile T *obj, R (T::*method)(A0, A1, A2) const volatile) { |
elessair | 0:f269e3021894 | 2519 | this->~Callback(); |
elessair | 0:f269e3021894 | 2520 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 2521 | } |
elessair | 0:f269e3021894 | 2522 | |
elessair | 0:f269e3021894 | 2523 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 2524 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2525 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 2526 | */ |
elessair | 0:f269e3021894 | 2527 | void attach(R (*func)(void*, A0, A1, A2), void *arg) { |
elessair | 0:f269e3021894 | 2528 | this->~Callback(); |
elessair | 0:f269e3021894 | 2529 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 2530 | } |
elessair | 0:f269e3021894 | 2531 | |
elessair | 0:f269e3021894 | 2532 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 2533 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2534 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 2535 | */ |
elessair | 0:f269e3021894 | 2536 | void attach(R (*func)(const void*, A0, A1, A2), const void *arg) { |
elessair | 0:f269e3021894 | 2537 | this->~Callback(); |
elessair | 0:f269e3021894 | 2538 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 2539 | } |
elessair | 0:f269e3021894 | 2540 | |
elessair | 0:f269e3021894 | 2541 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 2542 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2543 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 2544 | */ |
elessair | 0:f269e3021894 | 2545 | void attach(R (*func)(volatile void*, A0, A1, A2), volatile void *arg) { |
elessair | 0:f269e3021894 | 2546 | this->~Callback(); |
elessair | 0:f269e3021894 | 2547 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 2548 | } |
elessair | 0:f269e3021894 | 2549 | |
elessair | 0:f269e3021894 | 2550 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 2551 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2552 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 2553 | */ |
elessair | 0:f269e3021894 | 2554 | void attach(R (*func)(const volatile void*, A0, A1, A2), const volatile void *arg) { |
elessair | 0:f269e3021894 | 2555 | this->~Callback(); |
elessair | 0:f269e3021894 | 2556 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 2557 | } |
elessair | 0:f269e3021894 | 2558 | |
elessair | 0:f269e3021894 | 2559 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 2560 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2561 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 2562 | */ |
elessair | 0:f269e3021894 | 2563 | template <typename T> |
elessair | 0:f269e3021894 | 2564 | void attach(R (*func)(T*, A0, A1, A2), T *arg) { |
elessair | 0:f269e3021894 | 2565 | this->~Callback(); |
elessair | 0:f269e3021894 | 2566 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 2567 | } |
elessair | 0:f269e3021894 | 2568 | |
elessair | 0:f269e3021894 | 2569 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 2570 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2571 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 2572 | */ |
elessair | 0:f269e3021894 | 2573 | template <typename T> |
elessair | 0:f269e3021894 | 2574 | void attach(R (*func)(const T*, A0, A1, A2), const T *arg) { |
elessair | 0:f269e3021894 | 2575 | this->~Callback(); |
elessair | 0:f269e3021894 | 2576 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 2577 | } |
elessair | 0:f269e3021894 | 2578 | |
elessair | 0:f269e3021894 | 2579 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 2580 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2581 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 2582 | */ |
elessair | 0:f269e3021894 | 2583 | template <typename T> |
elessair | 0:f269e3021894 | 2584 | void attach(R (*func)(volatile T*, A0, A1, A2), volatile T *arg) { |
elessair | 0:f269e3021894 | 2585 | this->~Callback(); |
elessair | 0:f269e3021894 | 2586 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 2587 | } |
elessair | 0:f269e3021894 | 2588 | |
elessair | 0:f269e3021894 | 2589 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 2590 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2591 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 2592 | */ |
elessair | 0:f269e3021894 | 2593 | template <typename T> |
elessair | 0:f269e3021894 | 2594 | void attach(R (*func)(const volatile T*, A0, A1, A2), const volatile T *arg) { |
elessair | 0:f269e3021894 | 2595 | this->~Callback(); |
elessair | 0:f269e3021894 | 2596 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 2597 | } |
elessair | 0:f269e3021894 | 2598 | |
elessair | 0:f269e3021894 | 2599 | /** Attach a function object |
elessair | 0:f269e3021894 | 2600 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 2601 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 2602 | */ |
elessair | 0:f269e3021894 | 2603 | template <typename F> |
elessair | 0:f269e3021894 | 2604 | void attach(F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 2605 | detail::is_type<R (F::*)(A0, A1, A2), &F::operator()>::value && |
elessair | 0:f269e3021894 | 2606 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 2607 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 2608 | this->~Callback(); |
elessair | 0:f269e3021894 | 2609 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 2610 | } |
elessair | 0:f269e3021894 | 2611 | |
elessair | 0:f269e3021894 | 2612 | /** Attach a function object |
elessair | 0:f269e3021894 | 2613 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 2614 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 2615 | */ |
elessair | 0:f269e3021894 | 2616 | template <typename F> |
elessair | 0:f269e3021894 | 2617 | void attach(const F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 2618 | detail::is_type<R (F::*)(A0, A1, A2) const, &F::operator()>::value && |
elessair | 0:f269e3021894 | 2619 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 2620 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 2621 | this->~Callback(); |
elessair | 0:f269e3021894 | 2622 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 2623 | } |
elessair | 0:f269e3021894 | 2624 | |
elessair | 0:f269e3021894 | 2625 | /** Attach a function object |
elessair | 0:f269e3021894 | 2626 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 2627 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 2628 | */ |
elessair | 0:f269e3021894 | 2629 | template <typename F> |
elessair | 0:f269e3021894 | 2630 | void attach(volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 2631 | detail::is_type<R (F::*)(A0, A1, A2) volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 2632 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 2633 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 2634 | this->~Callback(); |
elessair | 0:f269e3021894 | 2635 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 2636 | } |
elessair | 0:f269e3021894 | 2637 | |
elessair | 0:f269e3021894 | 2638 | /** Attach a function object |
elessair | 0:f269e3021894 | 2639 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 2640 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 2641 | */ |
elessair | 0:f269e3021894 | 2642 | template <typename F> |
elessair | 0:f269e3021894 | 2643 | void attach(const volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 2644 | detail::is_type<R (F::*)(A0, A1, A2) const volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 2645 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 2646 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 2647 | this->~Callback(); |
elessair | 0:f269e3021894 | 2648 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 2649 | } |
elessair | 0:f269e3021894 | 2650 | |
elessair | 0:f269e3021894 | 2651 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 2652 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 2653 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2654 | * @deprecated |
elessair | 0:f269e3021894 | 2655 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 2656 | */ |
elessair | 0:f269e3021894 | 2657 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 2658 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 2659 | void attach(void *obj, R (*func)(void*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 2660 | this->~Callback(); |
elessair | 0:f269e3021894 | 2661 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 2662 | } |
elessair | 0:f269e3021894 | 2663 | |
elessair | 0:f269e3021894 | 2664 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 2665 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 2666 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2667 | * @deprecated |
elessair | 0:f269e3021894 | 2668 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 2669 | */ |
elessair | 0:f269e3021894 | 2670 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 2671 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 2672 | void attach(const void *obj, R (*func)(const void*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 2673 | this->~Callback(); |
elessair | 0:f269e3021894 | 2674 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 2675 | } |
elessair | 0:f269e3021894 | 2676 | |
elessair | 0:f269e3021894 | 2677 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 2678 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 2679 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2680 | * @deprecated |
elessair | 0:f269e3021894 | 2681 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 2682 | */ |
elessair | 0:f269e3021894 | 2683 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 2684 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 2685 | void attach(volatile void *obj, R (*func)(volatile void*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 2686 | this->~Callback(); |
elessair | 0:f269e3021894 | 2687 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 2688 | } |
elessair | 0:f269e3021894 | 2689 | |
elessair | 0:f269e3021894 | 2690 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 2691 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 2692 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2693 | * @deprecated |
elessair | 0:f269e3021894 | 2694 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 2695 | */ |
elessair | 0:f269e3021894 | 2696 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 2697 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 2698 | void attach(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 2699 | this->~Callback(); |
elessair | 0:f269e3021894 | 2700 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 2701 | } |
elessair | 0:f269e3021894 | 2702 | |
elessair | 0:f269e3021894 | 2703 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 2704 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 2705 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2706 | * @deprecated |
elessair | 0:f269e3021894 | 2707 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 2708 | */ |
elessair | 0:f269e3021894 | 2709 | template <typename T> |
elessair | 0:f269e3021894 | 2710 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 2711 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 2712 | void attach(T *obj, R (*func)(T*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 2713 | this->~Callback(); |
elessair | 0:f269e3021894 | 2714 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 2715 | } |
elessair | 0:f269e3021894 | 2716 | |
elessair | 0:f269e3021894 | 2717 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 2718 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 2719 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2720 | * @deprecated |
elessair | 0:f269e3021894 | 2721 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 2722 | */ |
elessair | 0:f269e3021894 | 2723 | template <typename T> |
elessair | 0:f269e3021894 | 2724 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 2725 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 2726 | void attach(const T *obj, R (*func)(const T*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 2727 | this->~Callback(); |
elessair | 0:f269e3021894 | 2728 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 2729 | } |
elessair | 0:f269e3021894 | 2730 | |
elessair | 0:f269e3021894 | 2731 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 2732 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 2733 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2734 | * @deprecated |
elessair | 0:f269e3021894 | 2735 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 2736 | */ |
elessair | 0:f269e3021894 | 2737 | template <typename T> |
elessair | 0:f269e3021894 | 2738 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 2739 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 2740 | void attach(volatile T *obj, R (*func)(volatile T*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 2741 | this->~Callback(); |
elessair | 0:f269e3021894 | 2742 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 2743 | } |
elessair | 0:f269e3021894 | 2744 | |
elessair | 0:f269e3021894 | 2745 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 2746 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 2747 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2748 | * @deprecated |
elessair | 0:f269e3021894 | 2749 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 2750 | */ |
elessair | 0:f269e3021894 | 2751 | template <typename T> |
elessair | 0:f269e3021894 | 2752 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 2753 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 2754 | void attach(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 2755 | this->~Callback(); |
elessair | 0:f269e3021894 | 2756 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 2757 | } |
elessair | 0:f269e3021894 | 2758 | |
elessair | 0:f269e3021894 | 2759 | /** Assign a callback |
elessair | 0:f269e3021894 | 2760 | */ |
elessair | 0:f269e3021894 | 2761 | Callback &operator=(const Callback &that) { |
elessair | 0:f269e3021894 | 2762 | if (this != &that) { |
elessair | 0:f269e3021894 | 2763 | this->~Callback(); |
elessair | 0:f269e3021894 | 2764 | new (this) Callback(that); |
elessair | 0:f269e3021894 | 2765 | } |
elessair | 0:f269e3021894 | 2766 | |
elessair | 0:f269e3021894 | 2767 | return *this; |
elessair | 0:f269e3021894 | 2768 | } |
elessair | 0:f269e3021894 | 2769 | |
elessair | 0:f269e3021894 | 2770 | /** Call the attached function |
elessair | 0:f269e3021894 | 2771 | */ |
elessair | 0:f269e3021894 | 2772 | R call(A0 a0, A1 a1, A2 a2) const { |
elessair | 0:f269e3021894 | 2773 | MBED_ASSERT(_ops); |
elessair | 0:f269e3021894 | 2774 | return _ops->call(this, a0, a1, a2); |
elessair | 0:f269e3021894 | 2775 | } |
elessair | 0:f269e3021894 | 2776 | |
elessair | 0:f269e3021894 | 2777 | /** Call the attached function |
elessair | 0:f269e3021894 | 2778 | */ |
elessair | 0:f269e3021894 | 2779 | R operator()(A0 a0, A1 a1, A2 a2) const { |
elessair | 0:f269e3021894 | 2780 | return call(a0, a1, a2); |
elessair | 0:f269e3021894 | 2781 | } |
elessair | 0:f269e3021894 | 2782 | |
elessair | 0:f269e3021894 | 2783 | /** Test if function has been attached |
elessair | 0:f269e3021894 | 2784 | */ |
elessair | 0:f269e3021894 | 2785 | operator bool() const { |
elessair | 0:f269e3021894 | 2786 | return _ops; |
elessair | 0:f269e3021894 | 2787 | } |
elessair | 0:f269e3021894 | 2788 | |
elessair | 0:f269e3021894 | 2789 | /** Test for equality |
elessair | 0:f269e3021894 | 2790 | */ |
elessair | 0:f269e3021894 | 2791 | friend bool operator==(const Callback &l, const Callback &r) { |
elessair | 0:f269e3021894 | 2792 | return memcmp(&l, &r, sizeof(Callback)) == 0; |
elessair | 0:f269e3021894 | 2793 | } |
elessair | 0:f269e3021894 | 2794 | |
elessair | 0:f269e3021894 | 2795 | /** Test for inequality |
elessair | 0:f269e3021894 | 2796 | */ |
elessair | 0:f269e3021894 | 2797 | friend bool operator!=(const Callback &l, const Callback &r) { |
elessair | 0:f269e3021894 | 2798 | return !(l == r); |
elessair | 0:f269e3021894 | 2799 | } |
elessair | 0:f269e3021894 | 2800 | |
elessair | 0:f269e3021894 | 2801 | /** Static thunk for passing as C-style function |
elessair | 0:f269e3021894 | 2802 | * @param func Callback to call passed as void pointer |
elessair | 0:f269e3021894 | 2803 | */ |
elessair | 0:f269e3021894 | 2804 | static R thunk(void *func, A0 a0, A1 a1, A2 a2) { |
elessair | 0:f269e3021894 | 2805 | return static_cast<Callback*>(func)->call(a0, a1, a2); |
elessair | 0:f269e3021894 | 2806 | } |
elessair | 0:f269e3021894 | 2807 | |
elessair | 0:f269e3021894 | 2808 | private: |
elessair | 0:f269e3021894 | 2809 | // Stored as pointer to function and pointer to optional object |
elessair | 0:f269e3021894 | 2810 | // Function pointer is stored as union of possible function types |
elessair | 0:f269e3021894 | 2811 | // to garuntee proper size and alignment |
elessair | 0:f269e3021894 | 2812 | struct _class; |
elessair | 0:f269e3021894 | 2813 | union { |
elessair | 0:f269e3021894 | 2814 | void (*_staticfunc)(A0, A1, A2); |
elessair | 0:f269e3021894 | 2815 | void (*_boundfunc)(_class*, A0, A1, A2); |
elessair | 0:f269e3021894 | 2816 | void (_class::*_methodfunc)(A0, A1, A2); |
elessair | 0:f269e3021894 | 2817 | } _func; |
elessair | 0:f269e3021894 | 2818 | void *_obj; |
elessair | 0:f269e3021894 | 2819 | |
elessair | 0:f269e3021894 | 2820 | // Dynamically dispatched operations |
elessair | 0:f269e3021894 | 2821 | const struct ops { |
elessair | 0:f269e3021894 | 2822 | R (*call)(const void*, A0, A1, A2); |
elessair | 0:f269e3021894 | 2823 | void (*move)(void*, const void*); |
elessair | 0:f269e3021894 | 2824 | void (*dtor)(void*); |
elessair | 0:f269e3021894 | 2825 | } *_ops; |
elessair | 0:f269e3021894 | 2826 | |
elessair | 0:f269e3021894 | 2827 | // Generate operations for function object |
elessair | 0:f269e3021894 | 2828 | template <typename F> |
elessair | 0:f269e3021894 | 2829 | void generate(const F &f) { |
elessair | 0:f269e3021894 | 2830 | static const ops ops = { |
elessair | 0:f269e3021894 | 2831 | &Callback::function_call<F>, |
elessair | 0:f269e3021894 | 2832 | &Callback::function_move<F>, |
elessair | 0:f269e3021894 | 2833 | &Callback::function_dtor<F>, |
elessair | 0:f269e3021894 | 2834 | }; |
elessair | 0:f269e3021894 | 2835 | |
elessair | 0:f269e3021894 | 2836 | MBED_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F)); |
elessair | 0:f269e3021894 | 2837 | new (this) F(f); |
elessair | 0:f269e3021894 | 2838 | _ops = &ops; |
elessair | 0:f269e3021894 | 2839 | } |
elessair | 0:f269e3021894 | 2840 | |
elessair | 0:f269e3021894 | 2841 | // Function attributes |
elessair | 0:f269e3021894 | 2842 | template <typename F> |
elessair | 0:f269e3021894 | 2843 | static R function_call(const void *p, A0 a0, A1 a1, A2 a2) { |
elessair | 0:f269e3021894 | 2844 | return (*(F*)p)(a0, a1, a2); |
elessair | 0:f269e3021894 | 2845 | } |
elessair | 0:f269e3021894 | 2846 | |
elessair | 0:f269e3021894 | 2847 | template <typename F> |
elessair | 0:f269e3021894 | 2848 | static void function_move(void *d, const void *p) { |
elessair | 0:f269e3021894 | 2849 | new (d) F(*(F*)p); |
elessair | 0:f269e3021894 | 2850 | } |
elessair | 0:f269e3021894 | 2851 | |
elessair | 0:f269e3021894 | 2852 | template <typename F> |
elessair | 0:f269e3021894 | 2853 | static void function_dtor(void *p) { |
elessair | 0:f269e3021894 | 2854 | ((F*)p)->~F(); |
elessair | 0:f269e3021894 | 2855 | } |
elessair | 0:f269e3021894 | 2856 | |
elessair | 0:f269e3021894 | 2857 | // Wrappers for functions with context |
elessair | 0:f269e3021894 | 2858 | template <typename O, typename M> |
elessair | 0:f269e3021894 | 2859 | struct method_context { |
elessair | 0:f269e3021894 | 2860 | M method; |
elessair | 0:f269e3021894 | 2861 | O *obj; |
elessair | 0:f269e3021894 | 2862 | |
elessair | 0:f269e3021894 | 2863 | method_context(O *obj, M method) |
elessair | 0:f269e3021894 | 2864 | : method(method), obj(obj) {} |
elessair | 0:f269e3021894 | 2865 | |
elessair | 0:f269e3021894 | 2866 | R operator()(A0 a0, A1 a1, A2 a2) const { |
elessair | 0:f269e3021894 | 2867 | return (obj->*method)(a0, a1, a2); |
elessair | 0:f269e3021894 | 2868 | } |
elessair | 0:f269e3021894 | 2869 | }; |
elessair | 0:f269e3021894 | 2870 | |
elessair | 0:f269e3021894 | 2871 | template <typename F, typename A> |
elessair | 0:f269e3021894 | 2872 | struct function_context { |
elessair | 0:f269e3021894 | 2873 | F func; |
elessair | 0:f269e3021894 | 2874 | A *arg; |
elessair | 0:f269e3021894 | 2875 | |
elessair | 0:f269e3021894 | 2876 | function_context(F func, A *arg) |
elessair | 0:f269e3021894 | 2877 | : func(func), arg(arg) {} |
elessair | 0:f269e3021894 | 2878 | |
elessair | 0:f269e3021894 | 2879 | R operator()(A0 a0, A1 a1, A2 a2) const { |
elessair | 0:f269e3021894 | 2880 | return func(arg, a0, a1, a2); |
elessair | 0:f269e3021894 | 2881 | } |
elessair | 0:f269e3021894 | 2882 | }; |
elessair | 0:f269e3021894 | 2883 | }; |
elessair | 0:f269e3021894 | 2884 | |
elessair | 0:f269e3021894 | 2885 | /** Callback class based on template specialization |
elessair | 0:f269e3021894 | 2886 | * |
elessair | 0:f269e3021894 | 2887 | * @Note Synchronization level: Not protected |
elessair | 0:f269e3021894 | 2888 | */ |
elessair | 0:f269e3021894 | 2889 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 2890 | class Callback<R(A0, A1, A2, A3)> { |
elessair | 0:f269e3021894 | 2891 | public: |
elessair | 0:f269e3021894 | 2892 | /** Create a Callback with a static function |
elessair | 0:f269e3021894 | 2893 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2894 | */ |
elessair | 0:f269e3021894 | 2895 | Callback(R (*func)(A0, A1, A2, A3) = 0) { |
elessair | 0:f269e3021894 | 2896 | if (!func) { |
elessair | 0:f269e3021894 | 2897 | _ops = 0; |
elessair | 0:f269e3021894 | 2898 | } else { |
elessair | 0:f269e3021894 | 2899 | generate(func); |
elessair | 0:f269e3021894 | 2900 | } |
elessair | 0:f269e3021894 | 2901 | } |
elessair | 0:f269e3021894 | 2902 | |
elessair | 0:f269e3021894 | 2903 | /** Attach a Callback |
elessair | 0:f269e3021894 | 2904 | * @param func The Callback to attach |
elessair | 0:f269e3021894 | 2905 | */ |
elessair | 0:f269e3021894 | 2906 | Callback(const Callback<R(A0, A1, A2, A3)> &func) { |
elessair | 0:f269e3021894 | 2907 | if (func._ops) { |
elessair | 0:f269e3021894 | 2908 | func._ops->move(this, &func); |
elessair | 0:f269e3021894 | 2909 | } |
elessair | 0:f269e3021894 | 2910 | _ops = func._ops; |
elessair | 0:f269e3021894 | 2911 | } |
elessair | 0:f269e3021894 | 2912 | |
elessair | 0:f269e3021894 | 2913 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 2914 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 2915 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 2916 | */ |
elessair | 0:f269e3021894 | 2917 | template<typename T> |
elessair | 0:f269e3021894 | 2918 | Callback(T *obj, R (T::*method)(A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 2919 | generate(method_context<T, R (T::*)(A0, A1, A2, A3)>(obj, method)); |
elessair | 0:f269e3021894 | 2920 | } |
elessair | 0:f269e3021894 | 2921 | |
elessair | 0:f269e3021894 | 2922 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 2923 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 2924 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 2925 | */ |
elessair | 0:f269e3021894 | 2926 | template<typename T> |
elessair | 0:f269e3021894 | 2927 | Callback(const T *obj, R (T::*method)(A0, A1, A2, A3) const) { |
elessair | 0:f269e3021894 | 2928 | generate(method_context<const T, R (T::*)(A0, A1, A2, A3) const>(obj, method)); |
elessair | 0:f269e3021894 | 2929 | } |
elessair | 0:f269e3021894 | 2930 | |
elessair | 0:f269e3021894 | 2931 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 2932 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 2933 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 2934 | */ |
elessair | 0:f269e3021894 | 2935 | template<typename T> |
elessair | 0:f269e3021894 | 2936 | Callback(volatile T *obj, R (T::*method)(A0, A1, A2, A3) volatile) { |
elessair | 0:f269e3021894 | 2937 | generate(method_context<volatile T, R (T::*)(A0, A1, A2, A3) volatile>(obj, method)); |
elessair | 0:f269e3021894 | 2938 | } |
elessair | 0:f269e3021894 | 2939 | |
elessair | 0:f269e3021894 | 2940 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 2941 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 2942 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 2943 | */ |
elessair | 0:f269e3021894 | 2944 | template<typename T> |
elessair | 0:f269e3021894 | 2945 | Callback(const volatile T *obj, R (T::*method)(A0, A1, A2, A3) const volatile) { |
elessair | 0:f269e3021894 | 2946 | generate(method_context<const volatile T, R (T::*)(A0, A1, A2, A3) const volatile>(obj, method)); |
elessair | 0:f269e3021894 | 2947 | } |
elessair | 0:f269e3021894 | 2948 | |
elessair | 0:f269e3021894 | 2949 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 2950 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2951 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 2952 | */ |
elessair | 0:f269e3021894 | 2953 | Callback(R (*func)(void*, A0, A1, A2, A3), void *arg) { |
elessair | 0:f269e3021894 | 2954 | generate(function_context<R (*)(void*, A0, A1, A2, A3), void>(func, arg)); |
elessair | 0:f269e3021894 | 2955 | } |
elessair | 0:f269e3021894 | 2956 | |
elessair | 0:f269e3021894 | 2957 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 2958 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2959 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 2960 | */ |
elessair | 0:f269e3021894 | 2961 | Callback(R (*func)(const void*, A0, A1, A2, A3), const void *arg) { |
elessair | 0:f269e3021894 | 2962 | generate(function_context<R (*)(const void*, A0, A1, A2, A3), const void>(func, arg)); |
elessair | 0:f269e3021894 | 2963 | } |
elessair | 0:f269e3021894 | 2964 | |
elessair | 0:f269e3021894 | 2965 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 2966 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2967 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 2968 | */ |
elessair | 0:f269e3021894 | 2969 | Callback(R (*func)(volatile void*, A0, A1, A2, A3), volatile void *arg) { |
elessair | 0:f269e3021894 | 2970 | generate(function_context<R (*)(volatile void*, A0, A1, A2, A3), volatile void>(func, arg)); |
elessair | 0:f269e3021894 | 2971 | } |
elessair | 0:f269e3021894 | 2972 | |
elessair | 0:f269e3021894 | 2973 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 2974 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2975 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 2976 | */ |
elessair | 0:f269e3021894 | 2977 | Callback(R (*func)(const volatile void*, A0, A1, A2, A3), const volatile void *arg) { |
elessair | 0:f269e3021894 | 2978 | generate(function_context<R (*)(const volatile void*, A0, A1, A2, A3), const volatile void>(func, arg)); |
elessair | 0:f269e3021894 | 2979 | } |
elessair | 0:f269e3021894 | 2980 | |
elessair | 0:f269e3021894 | 2981 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 2982 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2983 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 2984 | */ |
elessair | 0:f269e3021894 | 2985 | template<typename T> |
elessair | 0:f269e3021894 | 2986 | Callback(R (*func)(T*, A0, A1, A2, A3), T *arg) { |
elessair | 0:f269e3021894 | 2987 | generate(function_context<R (*)(T*, A0, A1, A2, A3), T>(func, arg)); |
elessair | 0:f269e3021894 | 2988 | } |
elessair | 0:f269e3021894 | 2989 | |
elessair | 0:f269e3021894 | 2990 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 2991 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 2992 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 2993 | */ |
elessair | 0:f269e3021894 | 2994 | template<typename T> |
elessair | 0:f269e3021894 | 2995 | Callback(R (*func)(const T*, A0, A1, A2, A3), const T *arg) { |
elessair | 0:f269e3021894 | 2996 | generate(function_context<R (*)(const T*, A0, A1, A2, A3), const T>(func, arg)); |
elessair | 0:f269e3021894 | 2997 | } |
elessair | 0:f269e3021894 | 2998 | |
elessair | 0:f269e3021894 | 2999 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3000 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3001 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3002 | */ |
elessair | 0:f269e3021894 | 3003 | template<typename T> |
elessair | 0:f269e3021894 | 3004 | Callback(R (*func)(volatile T*, A0, A1, A2, A3), volatile T *arg) { |
elessair | 0:f269e3021894 | 3005 | generate(function_context<R (*)(volatile T*, A0, A1, A2, A3), volatile T>(func, arg)); |
elessair | 0:f269e3021894 | 3006 | } |
elessair | 0:f269e3021894 | 3007 | |
elessair | 0:f269e3021894 | 3008 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3009 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3010 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3011 | */ |
elessair | 0:f269e3021894 | 3012 | template<typename T> |
elessair | 0:f269e3021894 | 3013 | Callback(R (*func)(const volatile T*, A0, A1, A2, A3), const volatile T *arg) { |
elessair | 0:f269e3021894 | 3014 | generate(function_context<R (*)(const volatile T*, A0, A1, A2, A3), const volatile T>(func, arg)); |
elessair | 0:f269e3021894 | 3015 | } |
elessair | 0:f269e3021894 | 3016 | |
elessair | 0:f269e3021894 | 3017 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 3018 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 3019 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 3020 | */ |
elessair | 0:f269e3021894 | 3021 | template <typename F> |
elessair | 0:f269e3021894 | 3022 | Callback(F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 3023 | detail::is_type<R (F::*)(A0, A1, A2, A3), &F::operator()>::value && |
elessair | 0:f269e3021894 | 3024 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 3025 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 3026 | generate(f); |
elessair | 0:f269e3021894 | 3027 | } |
elessair | 0:f269e3021894 | 3028 | |
elessair | 0:f269e3021894 | 3029 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 3030 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 3031 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 3032 | */ |
elessair | 0:f269e3021894 | 3033 | template <typename F> |
elessair | 0:f269e3021894 | 3034 | Callback(const F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 3035 | detail::is_type<R (F::*)(A0, A1, A2, A3) const, &F::operator()>::value && |
elessair | 0:f269e3021894 | 3036 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 3037 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 3038 | generate(f); |
elessair | 0:f269e3021894 | 3039 | } |
elessair | 0:f269e3021894 | 3040 | |
elessair | 0:f269e3021894 | 3041 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 3042 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 3043 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 3044 | */ |
elessair | 0:f269e3021894 | 3045 | template <typename F> |
elessair | 0:f269e3021894 | 3046 | Callback(volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 3047 | detail::is_type<R (F::*)(A0, A1, A2, A3) volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 3048 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 3049 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 3050 | generate(f); |
elessair | 0:f269e3021894 | 3051 | } |
elessair | 0:f269e3021894 | 3052 | |
elessair | 0:f269e3021894 | 3053 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 3054 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 3055 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 3056 | */ |
elessair | 0:f269e3021894 | 3057 | template <typename F> |
elessair | 0:f269e3021894 | 3058 | Callback(const volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 3059 | detail::is_type<R (F::*)(A0, A1, A2, A3) const volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 3060 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 3061 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 3062 | generate(f); |
elessair | 0:f269e3021894 | 3063 | } |
elessair | 0:f269e3021894 | 3064 | |
elessair | 0:f269e3021894 | 3065 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3066 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3067 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3068 | * @deprecated |
elessair | 0:f269e3021894 | 3069 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 3070 | */ |
elessair | 0:f269e3021894 | 3071 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3072 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 3073 | Callback(void *obj, R (*func)(void*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 3074 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3075 | } |
elessair | 0:f269e3021894 | 3076 | |
elessair | 0:f269e3021894 | 3077 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3078 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3079 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3080 | * @deprecated |
elessair | 0:f269e3021894 | 3081 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 3082 | */ |
elessair | 0:f269e3021894 | 3083 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3084 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 3085 | Callback(const void *obj, R (*func)(const void*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 3086 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3087 | } |
elessair | 0:f269e3021894 | 3088 | |
elessair | 0:f269e3021894 | 3089 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3090 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3091 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3092 | * @deprecated |
elessair | 0:f269e3021894 | 3093 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 3094 | */ |
elessair | 0:f269e3021894 | 3095 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3096 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 3097 | Callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 3098 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3099 | } |
elessair | 0:f269e3021894 | 3100 | |
elessair | 0:f269e3021894 | 3101 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3102 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3103 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3104 | * @deprecated |
elessair | 0:f269e3021894 | 3105 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 3106 | */ |
elessair | 0:f269e3021894 | 3107 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3108 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 3109 | Callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 3110 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3111 | } |
elessair | 0:f269e3021894 | 3112 | |
elessair | 0:f269e3021894 | 3113 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3114 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3115 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3116 | * @deprecated |
elessair | 0:f269e3021894 | 3117 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 3118 | */ |
elessair | 0:f269e3021894 | 3119 | template<typename T> |
elessair | 0:f269e3021894 | 3120 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3121 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 3122 | Callback(T *obj, R (*func)(T*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 3123 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3124 | } |
elessair | 0:f269e3021894 | 3125 | |
elessair | 0:f269e3021894 | 3126 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3127 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3128 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3129 | * @deprecated |
elessair | 0:f269e3021894 | 3130 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 3131 | */ |
elessair | 0:f269e3021894 | 3132 | template<typename T> |
elessair | 0:f269e3021894 | 3133 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3134 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 3135 | Callback(const T *obj, R (*func)(const T*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 3136 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3137 | } |
elessair | 0:f269e3021894 | 3138 | |
elessair | 0:f269e3021894 | 3139 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3140 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3141 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3142 | * @deprecated |
elessair | 0:f269e3021894 | 3143 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 3144 | */ |
elessair | 0:f269e3021894 | 3145 | template<typename T> |
elessair | 0:f269e3021894 | 3146 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3147 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 3148 | Callback(volatile T *obj, R (*func)(volatile T*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 3149 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3150 | } |
elessair | 0:f269e3021894 | 3151 | |
elessair | 0:f269e3021894 | 3152 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3153 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3154 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3155 | * @deprecated |
elessair | 0:f269e3021894 | 3156 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 3157 | */ |
elessair | 0:f269e3021894 | 3158 | template<typename T> |
elessair | 0:f269e3021894 | 3159 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3160 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 3161 | Callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 3162 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3163 | } |
elessair | 0:f269e3021894 | 3164 | |
elessair | 0:f269e3021894 | 3165 | /** Destroy a callback |
elessair | 0:f269e3021894 | 3166 | */ |
elessair | 0:f269e3021894 | 3167 | ~Callback() { |
elessair | 0:f269e3021894 | 3168 | if (_ops) { |
elessair | 0:f269e3021894 | 3169 | _ops->dtor(this); |
elessair | 0:f269e3021894 | 3170 | } |
elessair | 0:f269e3021894 | 3171 | } |
elessair | 0:f269e3021894 | 3172 | |
elessair | 0:f269e3021894 | 3173 | /** Attach a static function |
elessair | 0:f269e3021894 | 3174 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3175 | */ |
elessair | 0:f269e3021894 | 3176 | void attach(R (*func)(A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 3177 | this->~Callback(); |
elessair | 0:f269e3021894 | 3178 | new (this) Callback(func); |
elessair | 0:f269e3021894 | 3179 | } |
elessair | 0:f269e3021894 | 3180 | |
elessair | 0:f269e3021894 | 3181 | /** Attach a Callback |
elessair | 0:f269e3021894 | 3182 | * @param func The Callback to attach |
elessair | 0:f269e3021894 | 3183 | */ |
elessair | 0:f269e3021894 | 3184 | void attach(const Callback<R(A0, A1, A2, A3)> &func) { |
elessair | 0:f269e3021894 | 3185 | this->~Callback(); |
elessair | 0:f269e3021894 | 3186 | new (this) Callback(func); |
elessair | 0:f269e3021894 | 3187 | } |
elessair | 0:f269e3021894 | 3188 | |
elessair | 0:f269e3021894 | 3189 | /** Attach a member function |
elessair | 0:f269e3021894 | 3190 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 3191 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 3192 | */ |
elessair | 0:f269e3021894 | 3193 | template<typename T> |
elessair | 0:f269e3021894 | 3194 | void attach(T *obj, R (T::*method)(A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 3195 | this->~Callback(); |
elessair | 0:f269e3021894 | 3196 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 3197 | } |
elessair | 0:f269e3021894 | 3198 | |
elessair | 0:f269e3021894 | 3199 | /** Attach a member function |
elessair | 0:f269e3021894 | 3200 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 3201 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 3202 | */ |
elessair | 0:f269e3021894 | 3203 | template<typename T> |
elessair | 0:f269e3021894 | 3204 | void attach(const T *obj, R (T::*method)(A0, A1, A2, A3) const) { |
elessair | 0:f269e3021894 | 3205 | this->~Callback(); |
elessair | 0:f269e3021894 | 3206 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 3207 | } |
elessair | 0:f269e3021894 | 3208 | |
elessair | 0:f269e3021894 | 3209 | /** Attach a member function |
elessair | 0:f269e3021894 | 3210 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 3211 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 3212 | */ |
elessair | 0:f269e3021894 | 3213 | template<typename T> |
elessair | 0:f269e3021894 | 3214 | void attach(volatile T *obj, R (T::*method)(A0, A1, A2, A3) volatile) { |
elessair | 0:f269e3021894 | 3215 | this->~Callback(); |
elessair | 0:f269e3021894 | 3216 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 3217 | } |
elessair | 0:f269e3021894 | 3218 | |
elessair | 0:f269e3021894 | 3219 | /** Attach a member function |
elessair | 0:f269e3021894 | 3220 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 3221 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 3222 | */ |
elessair | 0:f269e3021894 | 3223 | template<typename T> |
elessair | 0:f269e3021894 | 3224 | void attach(const volatile T *obj, R (T::*method)(A0, A1, A2, A3) const volatile) { |
elessair | 0:f269e3021894 | 3225 | this->~Callback(); |
elessair | 0:f269e3021894 | 3226 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 3227 | } |
elessair | 0:f269e3021894 | 3228 | |
elessair | 0:f269e3021894 | 3229 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3230 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3231 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3232 | */ |
elessair | 0:f269e3021894 | 3233 | void attach(R (*func)(void*, A0, A1, A2, A3), void *arg) { |
elessair | 0:f269e3021894 | 3234 | this->~Callback(); |
elessair | 0:f269e3021894 | 3235 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 3236 | } |
elessair | 0:f269e3021894 | 3237 | |
elessair | 0:f269e3021894 | 3238 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3239 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3240 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3241 | */ |
elessair | 0:f269e3021894 | 3242 | void attach(R (*func)(const void*, A0, A1, A2, A3), const void *arg) { |
elessair | 0:f269e3021894 | 3243 | this->~Callback(); |
elessair | 0:f269e3021894 | 3244 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 3245 | } |
elessair | 0:f269e3021894 | 3246 | |
elessair | 0:f269e3021894 | 3247 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3248 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3249 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3250 | */ |
elessair | 0:f269e3021894 | 3251 | void attach(R (*func)(volatile void*, A0, A1, A2, A3), volatile void *arg) { |
elessair | 0:f269e3021894 | 3252 | this->~Callback(); |
elessair | 0:f269e3021894 | 3253 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 3254 | } |
elessair | 0:f269e3021894 | 3255 | |
elessair | 0:f269e3021894 | 3256 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3257 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3258 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3259 | */ |
elessair | 0:f269e3021894 | 3260 | void attach(R (*func)(const volatile void*, A0, A1, A2, A3), const volatile void *arg) { |
elessair | 0:f269e3021894 | 3261 | this->~Callback(); |
elessair | 0:f269e3021894 | 3262 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 3263 | } |
elessair | 0:f269e3021894 | 3264 | |
elessair | 0:f269e3021894 | 3265 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3266 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3267 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3268 | */ |
elessair | 0:f269e3021894 | 3269 | template <typename T> |
elessair | 0:f269e3021894 | 3270 | void attach(R (*func)(T*, A0, A1, A2, A3), T *arg) { |
elessair | 0:f269e3021894 | 3271 | this->~Callback(); |
elessair | 0:f269e3021894 | 3272 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 3273 | } |
elessair | 0:f269e3021894 | 3274 | |
elessair | 0:f269e3021894 | 3275 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3276 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3277 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3278 | */ |
elessair | 0:f269e3021894 | 3279 | template <typename T> |
elessair | 0:f269e3021894 | 3280 | void attach(R (*func)(const T*, A0, A1, A2, A3), const T *arg) { |
elessair | 0:f269e3021894 | 3281 | this->~Callback(); |
elessair | 0:f269e3021894 | 3282 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 3283 | } |
elessair | 0:f269e3021894 | 3284 | |
elessair | 0:f269e3021894 | 3285 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3286 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3287 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3288 | */ |
elessair | 0:f269e3021894 | 3289 | template <typename T> |
elessair | 0:f269e3021894 | 3290 | void attach(R (*func)(volatile T*, A0, A1, A2, A3), volatile T *arg) { |
elessair | 0:f269e3021894 | 3291 | this->~Callback(); |
elessair | 0:f269e3021894 | 3292 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 3293 | } |
elessair | 0:f269e3021894 | 3294 | |
elessair | 0:f269e3021894 | 3295 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3296 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3297 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3298 | */ |
elessair | 0:f269e3021894 | 3299 | template <typename T> |
elessair | 0:f269e3021894 | 3300 | void attach(R (*func)(const volatile T*, A0, A1, A2, A3), const volatile T *arg) { |
elessair | 0:f269e3021894 | 3301 | this->~Callback(); |
elessair | 0:f269e3021894 | 3302 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 3303 | } |
elessair | 0:f269e3021894 | 3304 | |
elessair | 0:f269e3021894 | 3305 | /** Attach a function object |
elessair | 0:f269e3021894 | 3306 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 3307 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 3308 | */ |
elessair | 0:f269e3021894 | 3309 | template <typename F> |
elessair | 0:f269e3021894 | 3310 | void attach(F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 3311 | detail::is_type<R (F::*)(A0, A1, A2, A3), &F::operator()>::value && |
elessair | 0:f269e3021894 | 3312 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 3313 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 3314 | this->~Callback(); |
elessair | 0:f269e3021894 | 3315 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 3316 | } |
elessair | 0:f269e3021894 | 3317 | |
elessair | 0:f269e3021894 | 3318 | /** Attach a function object |
elessair | 0:f269e3021894 | 3319 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 3320 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 3321 | */ |
elessair | 0:f269e3021894 | 3322 | template <typename F> |
elessair | 0:f269e3021894 | 3323 | void attach(const F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 3324 | detail::is_type<R (F::*)(A0, A1, A2, A3) const, &F::operator()>::value && |
elessair | 0:f269e3021894 | 3325 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 3326 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 3327 | this->~Callback(); |
elessair | 0:f269e3021894 | 3328 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 3329 | } |
elessair | 0:f269e3021894 | 3330 | |
elessair | 0:f269e3021894 | 3331 | /** Attach a function object |
elessair | 0:f269e3021894 | 3332 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 3333 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 3334 | */ |
elessair | 0:f269e3021894 | 3335 | template <typename F> |
elessair | 0:f269e3021894 | 3336 | void attach(volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 3337 | detail::is_type<R (F::*)(A0, A1, A2, A3) volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 3338 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 3339 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 3340 | this->~Callback(); |
elessair | 0:f269e3021894 | 3341 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 3342 | } |
elessair | 0:f269e3021894 | 3343 | |
elessair | 0:f269e3021894 | 3344 | /** Attach a function object |
elessair | 0:f269e3021894 | 3345 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 3346 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 3347 | */ |
elessair | 0:f269e3021894 | 3348 | template <typename F> |
elessair | 0:f269e3021894 | 3349 | void attach(const volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 3350 | detail::is_type<R (F::*)(A0, A1, A2, A3) const volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 3351 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 3352 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 3353 | this->~Callback(); |
elessair | 0:f269e3021894 | 3354 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 3355 | } |
elessair | 0:f269e3021894 | 3356 | |
elessair | 0:f269e3021894 | 3357 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3358 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3359 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3360 | * @deprecated |
elessair | 0:f269e3021894 | 3361 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 3362 | */ |
elessair | 0:f269e3021894 | 3363 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3364 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 3365 | void attach(void *obj, R (*func)(void*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 3366 | this->~Callback(); |
elessair | 0:f269e3021894 | 3367 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3368 | } |
elessair | 0:f269e3021894 | 3369 | |
elessair | 0:f269e3021894 | 3370 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3371 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3372 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3373 | * @deprecated |
elessair | 0:f269e3021894 | 3374 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 3375 | */ |
elessair | 0:f269e3021894 | 3376 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3377 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 3378 | void attach(const void *obj, R (*func)(const void*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 3379 | this->~Callback(); |
elessair | 0:f269e3021894 | 3380 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3381 | } |
elessair | 0:f269e3021894 | 3382 | |
elessair | 0:f269e3021894 | 3383 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3384 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3385 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3386 | * @deprecated |
elessair | 0:f269e3021894 | 3387 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 3388 | */ |
elessair | 0:f269e3021894 | 3389 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3390 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 3391 | void attach(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 3392 | this->~Callback(); |
elessair | 0:f269e3021894 | 3393 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3394 | } |
elessair | 0:f269e3021894 | 3395 | |
elessair | 0:f269e3021894 | 3396 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3397 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3398 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3399 | * @deprecated |
elessair | 0:f269e3021894 | 3400 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 3401 | */ |
elessair | 0:f269e3021894 | 3402 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3403 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 3404 | void attach(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 3405 | this->~Callback(); |
elessair | 0:f269e3021894 | 3406 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3407 | } |
elessair | 0:f269e3021894 | 3408 | |
elessair | 0:f269e3021894 | 3409 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3410 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3411 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3412 | * @deprecated |
elessair | 0:f269e3021894 | 3413 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 3414 | */ |
elessair | 0:f269e3021894 | 3415 | template <typename T> |
elessair | 0:f269e3021894 | 3416 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3417 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 3418 | void attach(T *obj, R (*func)(T*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 3419 | this->~Callback(); |
elessair | 0:f269e3021894 | 3420 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3421 | } |
elessair | 0:f269e3021894 | 3422 | |
elessair | 0:f269e3021894 | 3423 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3424 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3425 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3426 | * @deprecated |
elessair | 0:f269e3021894 | 3427 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 3428 | */ |
elessair | 0:f269e3021894 | 3429 | template <typename T> |
elessair | 0:f269e3021894 | 3430 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3431 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 3432 | void attach(const T *obj, R (*func)(const T*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 3433 | this->~Callback(); |
elessair | 0:f269e3021894 | 3434 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3435 | } |
elessair | 0:f269e3021894 | 3436 | |
elessair | 0:f269e3021894 | 3437 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3438 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3439 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3440 | * @deprecated |
elessair | 0:f269e3021894 | 3441 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 3442 | */ |
elessair | 0:f269e3021894 | 3443 | template <typename T> |
elessair | 0:f269e3021894 | 3444 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3445 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 3446 | void attach(volatile T *obj, R (*func)(volatile T*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 3447 | this->~Callback(); |
elessair | 0:f269e3021894 | 3448 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3449 | } |
elessair | 0:f269e3021894 | 3450 | |
elessair | 0:f269e3021894 | 3451 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3452 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3453 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3454 | * @deprecated |
elessair | 0:f269e3021894 | 3455 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 3456 | */ |
elessair | 0:f269e3021894 | 3457 | template <typename T> |
elessair | 0:f269e3021894 | 3458 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3459 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 3460 | void attach(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 3461 | this->~Callback(); |
elessair | 0:f269e3021894 | 3462 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3463 | } |
elessair | 0:f269e3021894 | 3464 | |
elessair | 0:f269e3021894 | 3465 | /** Assign a callback |
elessair | 0:f269e3021894 | 3466 | */ |
elessair | 0:f269e3021894 | 3467 | Callback &operator=(const Callback &that) { |
elessair | 0:f269e3021894 | 3468 | if (this != &that) { |
elessair | 0:f269e3021894 | 3469 | this->~Callback(); |
elessair | 0:f269e3021894 | 3470 | new (this) Callback(that); |
elessair | 0:f269e3021894 | 3471 | } |
elessair | 0:f269e3021894 | 3472 | |
elessair | 0:f269e3021894 | 3473 | return *this; |
elessair | 0:f269e3021894 | 3474 | } |
elessair | 0:f269e3021894 | 3475 | |
elessair | 0:f269e3021894 | 3476 | /** Call the attached function |
elessair | 0:f269e3021894 | 3477 | */ |
elessair | 0:f269e3021894 | 3478 | R call(A0 a0, A1 a1, A2 a2, A3 a3) const { |
elessair | 0:f269e3021894 | 3479 | MBED_ASSERT(_ops); |
elessair | 0:f269e3021894 | 3480 | return _ops->call(this, a0, a1, a2, a3); |
elessair | 0:f269e3021894 | 3481 | } |
elessair | 0:f269e3021894 | 3482 | |
elessair | 0:f269e3021894 | 3483 | /** Call the attached function |
elessair | 0:f269e3021894 | 3484 | */ |
elessair | 0:f269e3021894 | 3485 | R operator()(A0 a0, A1 a1, A2 a2, A3 a3) const { |
elessair | 0:f269e3021894 | 3486 | return call(a0, a1, a2, a3); |
elessair | 0:f269e3021894 | 3487 | } |
elessair | 0:f269e3021894 | 3488 | |
elessair | 0:f269e3021894 | 3489 | /** Test if function has been attached |
elessair | 0:f269e3021894 | 3490 | */ |
elessair | 0:f269e3021894 | 3491 | operator bool() const { |
elessair | 0:f269e3021894 | 3492 | return _ops; |
elessair | 0:f269e3021894 | 3493 | } |
elessair | 0:f269e3021894 | 3494 | |
elessair | 0:f269e3021894 | 3495 | /** Test for equality |
elessair | 0:f269e3021894 | 3496 | */ |
elessair | 0:f269e3021894 | 3497 | friend bool operator==(const Callback &l, const Callback &r) { |
elessair | 0:f269e3021894 | 3498 | return memcmp(&l, &r, sizeof(Callback)) == 0; |
elessair | 0:f269e3021894 | 3499 | } |
elessair | 0:f269e3021894 | 3500 | |
elessair | 0:f269e3021894 | 3501 | /** Test for inequality |
elessair | 0:f269e3021894 | 3502 | */ |
elessair | 0:f269e3021894 | 3503 | friend bool operator!=(const Callback &l, const Callback &r) { |
elessair | 0:f269e3021894 | 3504 | return !(l == r); |
elessair | 0:f269e3021894 | 3505 | } |
elessair | 0:f269e3021894 | 3506 | |
elessair | 0:f269e3021894 | 3507 | /** Static thunk for passing as C-style function |
elessair | 0:f269e3021894 | 3508 | * @param func Callback to call passed as void pointer |
elessair | 0:f269e3021894 | 3509 | */ |
elessair | 0:f269e3021894 | 3510 | static R thunk(void *func, A0 a0, A1 a1, A2 a2, A3 a3) { |
elessair | 0:f269e3021894 | 3511 | return static_cast<Callback*>(func)->call(a0, a1, a2, a3); |
elessair | 0:f269e3021894 | 3512 | } |
elessair | 0:f269e3021894 | 3513 | |
elessair | 0:f269e3021894 | 3514 | private: |
elessair | 0:f269e3021894 | 3515 | // Stored as pointer to function and pointer to optional object |
elessair | 0:f269e3021894 | 3516 | // Function pointer is stored as union of possible function types |
elessair | 0:f269e3021894 | 3517 | // to garuntee proper size and alignment |
elessair | 0:f269e3021894 | 3518 | struct _class; |
elessair | 0:f269e3021894 | 3519 | union { |
elessair | 0:f269e3021894 | 3520 | void (*_staticfunc)(A0, A1, A2, A3); |
elessair | 0:f269e3021894 | 3521 | void (*_boundfunc)(_class*, A0, A1, A2, A3); |
elessair | 0:f269e3021894 | 3522 | void (_class::*_methodfunc)(A0, A1, A2, A3); |
elessair | 0:f269e3021894 | 3523 | } _func; |
elessair | 0:f269e3021894 | 3524 | void *_obj; |
elessair | 0:f269e3021894 | 3525 | |
elessair | 0:f269e3021894 | 3526 | // Dynamically dispatched operations |
elessair | 0:f269e3021894 | 3527 | const struct ops { |
elessair | 0:f269e3021894 | 3528 | R (*call)(const void*, A0, A1, A2, A3); |
elessair | 0:f269e3021894 | 3529 | void (*move)(void*, const void*); |
elessair | 0:f269e3021894 | 3530 | void (*dtor)(void*); |
elessair | 0:f269e3021894 | 3531 | } *_ops; |
elessair | 0:f269e3021894 | 3532 | |
elessair | 0:f269e3021894 | 3533 | // Generate operations for function object |
elessair | 0:f269e3021894 | 3534 | template <typename F> |
elessair | 0:f269e3021894 | 3535 | void generate(const F &f) { |
elessair | 0:f269e3021894 | 3536 | static const ops ops = { |
elessair | 0:f269e3021894 | 3537 | &Callback::function_call<F>, |
elessair | 0:f269e3021894 | 3538 | &Callback::function_move<F>, |
elessair | 0:f269e3021894 | 3539 | &Callback::function_dtor<F>, |
elessair | 0:f269e3021894 | 3540 | }; |
elessair | 0:f269e3021894 | 3541 | |
elessair | 0:f269e3021894 | 3542 | MBED_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F)); |
elessair | 0:f269e3021894 | 3543 | new (this) F(f); |
elessair | 0:f269e3021894 | 3544 | _ops = &ops; |
elessair | 0:f269e3021894 | 3545 | } |
elessair | 0:f269e3021894 | 3546 | |
elessair | 0:f269e3021894 | 3547 | // Function attributes |
elessair | 0:f269e3021894 | 3548 | template <typename F> |
elessair | 0:f269e3021894 | 3549 | static R function_call(const void *p, A0 a0, A1 a1, A2 a2, A3 a3) { |
elessair | 0:f269e3021894 | 3550 | return (*(F*)p)(a0, a1, a2, a3); |
elessair | 0:f269e3021894 | 3551 | } |
elessair | 0:f269e3021894 | 3552 | |
elessair | 0:f269e3021894 | 3553 | template <typename F> |
elessair | 0:f269e3021894 | 3554 | static void function_move(void *d, const void *p) { |
elessair | 0:f269e3021894 | 3555 | new (d) F(*(F*)p); |
elessair | 0:f269e3021894 | 3556 | } |
elessair | 0:f269e3021894 | 3557 | |
elessair | 0:f269e3021894 | 3558 | template <typename F> |
elessair | 0:f269e3021894 | 3559 | static void function_dtor(void *p) { |
elessair | 0:f269e3021894 | 3560 | ((F*)p)->~F(); |
elessair | 0:f269e3021894 | 3561 | } |
elessair | 0:f269e3021894 | 3562 | |
elessair | 0:f269e3021894 | 3563 | // Wrappers for functions with context |
elessair | 0:f269e3021894 | 3564 | template <typename O, typename M> |
elessair | 0:f269e3021894 | 3565 | struct method_context { |
elessair | 0:f269e3021894 | 3566 | M method; |
elessair | 0:f269e3021894 | 3567 | O *obj; |
elessair | 0:f269e3021894 | 3568 | |
elessair | 0:f269e3021894 | 3569 | method_context(O *obj, M method) |
elessair | 0:f269e3021894 | 3570 | : method(method), obj(obj) {} |
elessair | 0:f269e3021894 | 3571 | |
elessair | 0:f269e3021894 | 3572 | R operator()(A0 a0, A1 a1, A2 a2, A3 a3) const { |
elessair | 0:f269e3021894 | 3573 | return (obj->*method)(a0, a1, a2, a3); |
elessair | 0:f269e3021894 | 3574 | } |
elessair | 0:f269e3021894 | 3575 | }; |
elessair | 0:f269e3021894 | 3576 | |
elessair | 0:f269e3021894 | 3577 | template <typename F, typename A> |
elessair | 0:f269e3021894 | 3578 | struct function_context { |
elessair | 0:f269e3021894 | 3579 | F func; |
elessair | 0:f269e3021894 | 3580 | A *arg; |
elessair | 0:f269e3021894 | 3581 | |
elessair | 0:f269e3021894 | 3582 | function_context(F func, A *arg) |
elessair | 0:f269e3021894 | 3583 | : func(func), arg(arg) {} |
elessair | 0:f269e3021894 | 3584 | |
elessair | 0:f269e3021894 | 3585 | R operator()(A0 a0, A1 a1, A2 a2, A3 a3) const { |
elessair | 0:f269e3021894 | 3586 | return func(arg, a0, a1, a2, a3); |
elessair | 0:f269e3021894 | 3587 | } |
elessair | 0:f269e3021894 | 3588 | }; |
elessair | 0:f269e3021894 | 3589 | }; |
elessair | 0:f269e3021894 | 3590 | |
elessair | 0:f269e3021894 | 3591 | /** Callback class based on template specialization |
elessair | 0:f269e3021894 | 3592 | * |
elessair | 0:f269e3021894 | 3593 | * @Note Synchronization level: Not protected |
elessair | 0:f269e3021894 | 3594 | */ |
elessair | 0:f269e3021894 | 3595 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 3596 | class Callback<R(A0, A1, A2, A3, A4)> { |
elessair | 0:f269e3021894 | 3597 | public: |
elessair | 0:f269e3021894 | 3598 | /** Create a Callback with a static function |
elessair | 0:f269e3021894 | 3599 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3600 | */ |
elessair | 0:f269e3021894 | 3601 | Callback(R (*func)(A0, A1, A2, A3, A4) = 0) { |
elessair | 0:f269e3021894 | 3602 | if (!func) { |
elessair | 0:f269e3021894 | 3603 | _ops = 0; |
elessair | 0:f269e3021894 | 3604 | } else { |
elessair | 0:f269e3021894 | 3605 | generate(func); |
elessair | 0:f269e3021894 | 3606 | } |
elessair | 0:f269e3021894 | 3607 | } |
elessair | 0:f269e3021894 | 3608 | |
elessair | 0:f269e3021894 | 3609 | /** Attach a Callback |
elessair | 0:f269e3021894 | 3610 | * @param func The Callback to attach |
elessair | 0:f269e3021894 | 3611 | */ |
elessair | 0:f269e3021894 | 3612 | Callback(const Callback<R(A0, A1, A2, A3, A4)> &func) { |
elessair | 0:f269e3021894 | 3613 | if (func._ops) { |
elessair | 0:f269e3021894 | 3614 | func._ops->move(this, &func); |
elessair | 0:f269e3021894 | 3615 | } |
elessair | 0:f269e3021894 | 3616 | _ops = func._ops; |
elessair | 0:f269e3021894 | 3617 | } |
elessair | 0:f269e3021894 | 3618 | |
elessair | 0:f269e3021894 | 3619 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 3620 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 3621 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 3622 | */ |
elessair | 0:f269e3021894 | 3623 | template<typename T> |
elessair | 0:f269e3021894 | 3624 | Callback(T *obj, R (T::*method)(A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 3625 | generate(method_context<T, R (T::*)(A0, A1, A2, A3, A4)>(obj, method)); |
elessair | 0:f269e3021894 | 3626 | } |
elessair | 0:f269e3021894 | 3627 | |
elessair | 0:f269e3021894 | 3628 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 3629 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 3630 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 3631 | */ |
elessair | 0:f269e3021894 | 3632 | template<typename T> |
elessair | 0:f269e3021894 | 3633 | Callback(const T *obj, R (T::*method)(A0, A1, A2, A3, A4) const) { |
elessair | 0:f269e3021894 | 3634 | generate(method_context<const T, R (T::*)(A0, A1, A2, A3, A4) const>(obj, method)); |
elessair | 0:f269e3021894 | 3635 | } |
elessair | 0:f269e3021894 | 3636 | |
elessair | 0:f269e3021894 | 3637 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 3638 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 3639 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 3640 | */ |
elessair | 0:f269e3021894 | 3641 | template<typename T> |
elessair | 0:f269e3021894 | 3642 | Callback(volatile T *obj, R (T::*method)(A0, A1, A2, A3, A4) volatile) { |
elessair | 0:f269e3021894 | 3643 | generate(method_context<volatile T, R (T::*)(A0, A1, A2, A3, A4) volatile>(obj, method)); |
elessair | 0:f269e3021894 | 3644 | } |
elessair | 0:f269e3021894 | 3645 | |
elessair | 0:f269e3021894 | 3646 | /** Create a Callback with a member function |
elessair | 0:f269e3021894 | 3647 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 3648 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 3649 | */ |
elessair | 0:f269e3021894 | 3650 | template<typename T> |
elessair | 0:f269e3021894 | 3651 | Callback(const volatile T *obj, R (T::*method)(A0, A1, A2, A3, A4) const volatile) { |
elessair | 0:f269e3021894 | 3652 | generate(method_context<const volatile T, R (T::*)(A0, A1, A2, A3, A4) const volatile>(obj, method)); |
elessair | 0:f269e3021894 | 3653 | } |
elessair | 0:f269e3021894 | 3654 | |
elessair | 0:f269e3021894 | 3655 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3656 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3657 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3658 | */ |
elessair | 0:f269e3021894 | 3659 | Callback(R (*func)(void*, A0, A1, A2, A3, A4), void *arg) { |
elessair | 0:f269e3021894 | 3660 | generate(function_context<R (*)(void*, A0, A1, A2, A3, A4), void>(func, arg)); |
elessair | 0:f269e3021894 | 3661 | } |
elessair | 0:f269e3021894 | 3662 | |
elessair | 0:f269e3021894 | 3663 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3664 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3665 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3666 | */ |
elessair | 0:f269e3021894 | 3667 | Callback(R (*func)(const void*, A0, A1, A2, A3, A4), const void *arg) { |
elessair | 0:f269e3021894 | 3668 | generate(function_context<R (*)(const void*, A0, A1, A2, A3, A4), const void>(func, arg)); |
elessair | 0:f269e3021894 | 3669 | } |
elessair | 0:f269e3021894 | 3670 | |
elessair | 0:f269e3021894 | 3671 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3672 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3673 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3674 | */ |
elessair | 0:f269e3021894 | 3675 | Callback(R (*func)(volatile void*, A0, A1, A2, A3, A4), volatile void *arg) { |
elessair | 0:f269e3021894 | 3676 | generate(function_context<R (*)(volatile void*, A0, A1, A2, A3, A4), volatile void>(func, arg)); |
elessair | 0:f269e3021894 | 3677 | } |
elessair | 0:f269e3021894 | 3678 | |
elessair | 0:f269e3021894 | 3679 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3680 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3681 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3682 | */ |
elessair | 0:f269e3021894 | 3683 | Callback(R (*func)(const volatile void*, A0, A1, A2, A3, A4), const volatile void *arg) { |
elessair | 0:f269e3021894 | 3684 | generate(function_context<R (*)(const volatile void*, A0, A1, A2, A3, A4), const volatile void>(func, arg)); |
elessair | 0:f269e3021894 | 3685 | } |
elessair | 0:f269e3021894 | 3686 | |
elessair | 0:f269e3021894 | 3687 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3688 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3689 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3690 | */ |
elessair | 0:f269e3021894 | 3691 | template<typename T> |
elessair | 0:f269e3021894 | 3692 | Callback(R (*func)(T*, A0, A1, A2, A3, A4), T *arg) { |
elessair | 0:f269e3021894 | 3693 | generate(function_context<R (*)(T*, A0, A1, A2, A3, A4), T>(func, arg)); |
elessair | 0:f269e3021894 | 3694 | } |
elessair | 0:f269e3021894 | 3695 | |
elessair | 0:f269e3021894 | 3696 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3697 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3698 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3699 | */ |
elessair | 0:f269e3021894 | 3700 | template<typename T> |
elessair | 0:f269e3021894 | 3701 | Callback(R (*func)(const T*, A0, A1, A2, A3, A4), const T *arg) { |
elessair | 0:f269e3021894 | 3702 | generate(function_context<R (*)(const T*, A0, A1, A2, A3, A4), const T>(func, arg)); |
elessair | 0:f269e3021894 | 3703 | } |
elessair | 0:f269e3021894 | 3704 | |
elessair | 0:f269e3021894 | 3705 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3706 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3707 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3708 | */ |
elessair | 0:f269e3021894 | 3709 | template<typename T> |
elessair | 0:f269e3021894 | 3710 | Callback(R (*func)(volatile T*, A0, A1, A2, A3, A4), volatile T *arg) { |
elessair | 0:f269e3021894 | 3711 | generate(function_context<R (*)(volatile T*, A0, A1, A2, A3, A4), volatile T>(func, arg)); |
elessair | 0:f269e3021894 | 3712 | } |
elessair | 0:f269e3021894 | 3713 | |
elessair | 0:f269e3021894 | 3714 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3715 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3716 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3717 | */ |
elessair | 0:f269e3021894 | 3718 | template<typename T> |
elessair | 0:f269e3021894 | 3719 | Callback(R (*func)(const volatile T*, A0, A1, A2, A3, A4), const volatile T *arg) { |
elessair | 0:f269e3021894 | 3720 | generate(function_context<R (*)(const volatile T*, A0, A1, A2, A3, A4), const volatile T>(func, arg)); |
elessair | 0:f269e3021894 | 3721 | } |
elessair | 0:f269e3021894 | 3722 | |
elessair | 0:f269e3021894 | 3723 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 3724 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 3725 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 3726 | */ |
elessair | 0:f269e3021894 | 3727 | template <typename F> |
elessair | 0:f269e3021894 | 3728 | Callback(F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 3729 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4), &F::operator()>::value && |
elessair | 0:f269e3021894 | 3730 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 3731 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 3732 | generate(f); |
elessair | 0:f269e3021894 | 3733 | } |
elessair | 0:f269e3021894 | 3734 | |
elessair | 0:f269e3021894 | 3735 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 3736 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 3737 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 3738 | */ |
elessair | 0:f269e3021894 | 3739 | template <typename F> |
elessair | 0:f269e3021894 | 3740 | Callback(const F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 3741 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4) const, &F::operator()>::value && |
elessair | 0:f269e3021894 | 3742 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 3743 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 3744 | generate(f); |
elessair | 0:f269e3021894 | 3745 | } |
elessair | 0:f269e3021894 | 3746 | |
elessair | 0:f269e3021894 | 3747 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 3748 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 3749 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 3750 | */ |
elessair | 0:f269e3021894 | 3751 | template <typename F> |
elessair | 0:f269e3021894 | 3752 | Callback(volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 3753 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4) volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 3754 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 3755 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 3756 | generate(f); |
elessair | 0:f269e3021894 | 3757 | } |
elessair | 0:f269e3021894 | 3758 | |
elessair | 0:f269e3021894 | 3759 | /** Create a Callback with a function object |
elessair | 0:f269e3021894 | 3760 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 3761 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 3762 | */ |
elessair | 0:f269e3021894 | 3763 | template <typename F> |
elessair | 0:f269e3021894 | 3764 | Callback(const volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 3765 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4) const volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 3766 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 3767 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 3768 | generate(f); |
elessair | 0:f269e3021894 | 3769 | } |
elessair | 0:f269e3021894 | 3770 | |
elessair | 0:f269e3021894 | 3771 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3772 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3773 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3774 | * @deprecated |
elessair | 0:f269e3021894 | 3775 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 3776 | */ |
elessair | 0:f269e3021894 | 3777 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3778 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 3779 | Callback(void *obj, R (*func)(void*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 3780 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3781 | } |
elessair | 0:f269e3021894 | 3782 | |
elessair | 0:f269e3021894 | 3783 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3784 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3785 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3786 | * @deprecated |
elessair | 0:f269e3021894 | 3787 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 3788 | */ |
elessair | 0:f269e3021894 | 3789 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3790 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 3791 | Callback(const void *obj, R (*func)(const void*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 3792 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3793 | } |
elessair | 0:f269e3021894 | 3794 | |
elessair | 0:f269e3021894 | 3795 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3796 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3797 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3798 | * @deprecated |
elessair | 0:f269e3021894 | 3799 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 3800 | */ |
elessair | 0:f269e3021894 | 3801 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3802 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 3803 | Callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 3804 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3805 | } |
elessair | 0:f269e3021894 | 3806 | |
elessair | 0:f269e3021894 | 3807 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3808 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3809 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3810 | * @deprecated |
elessair | 0:f269e3021894 | 3811 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 3812 | */ |
elessair | 0:f269e3021894 | 3813 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3814 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 3815 | Callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 3816 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3817 | } |
elessair | 0:f269e3021894 | 3818 | |
elessair | 0:f269e3021894 | 3819 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3820 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3821 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3822 | * @deprecated |
elessair | 0:f269e3021894 | 3823 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 3824 | */ |
elessair | 0:f269e3021894 | 3825 | template<typename T> |
elessair | 0:f269e3021894 | 3826 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3827 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 3828 | Callback(T *obj, R (*func)(T*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 3829 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3830 | } |
elessair | 0:f269e3021894 | 3831 | |
elessair | 0:f269e3021894 | 3832 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3833 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3834 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3835 | * @deprecated |
elessair | 0:f269e3021894 | 3836 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 3837 | */ |
elessair | 0:f269e3021894 | 3838 | template<typename T> |
elessair | 0:f269e3021894 | 3839 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3840 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 3841 | Callback(const T *obj, R (*func)(const T*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 3842 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3843 | } |
elessair | 0:f269e3021894 | 3844 | |
elessair | 0:f269e3021894 | 3845 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3846 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3847 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3848 | * @deprecated |
elessair | 0:f269e3021894 | 3849 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 3850 | */ |
elessair | 0:f269e3021894 | 3851 | template<typename T> |
elessair | 0:f269e3021894 | 3852 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3853 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 3854 | Callback(volatile T *obj, R (*func)(volatile T*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 3855 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3856 | } |
elessair | 0:f269e3021894 | 3857 | |
elessair | 0:f269e3021894 | 3858 | /** Create a Callback with a static function and bound pointer |
elessair | 0:f269e3021894 | 3859 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 3860 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3861 | * @deprecated |
elessair | 0:f269e3021894 | 3862 | * Arguments to callback have been reordered to Callback(func, arg) |
elessair | 0:f269e3021894 | 3863 | */ |
elessair | 0:f269e3021894 | 3864 | template<typename T> |
elessair | 0:f269e3021894 | 3865 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 3866 | "Arguments to callback have been reordered to Callback(func, arg)") |
elessair | 0:f269e3021894 | 3867 | Callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 3868 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 3869 | } |
elessair | 0:f269e3021894 | 3870 | |
elessair | 0:f269e3021894 | 3871 | /** Destroy a callback |
elessair | 0:f269e3021894 | 3872 | */ |
elessair | 0:f269e3021894 | 3873 | ~Callback() { |
elessair | 0:f269e3021894 | 3874 | if (_ops) { |
elessair | 0:f269e3021894 | 3875 | _ops->dtor(this); |
elessair | 0:f269e3021894 | 3876 | } |
elessair | 0:f269e3021894 | 3877 | } |
elessair | 0:f269e3021894 | 3878 | |
elessair | 0:f269e3021894 | 3879 | /** Attach a static function |
elessair | 0:f269e3021894 | 3880 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3881 | */ |
elessair | 0:f269e3021894 | 3882 | void attach(R (*func)(A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 3883 | this->~Callback(); |
elessair | 0:f269e3021894 | 3884 | new (this) Callback(func); |
elessair | 0:f269e3021894 | 3885 | } |
elessair | 0:f269e3021894 | 3886 | |
elessair | 0:f269e3021894 | 3887 | /** Attach a Callback |
elessair | 0:f269e3021894 | 3888 | * @param func The Callback to attach |
elessair | 0:f269e3021894 | 3889 | */ |
elessair | 0:f269e3021894 | 3890 | void attach(const Callback<R(A0, A1, A2, A3, A4)> &func) { |
elessair | 0:f269e3021894 | 3891 | this->~Callback(); |
elessair | 0:f269e3021894 | 3892 | new (this) Callback(func); |
elessair | 0:f269e3021894 | 3893 | } |
elessair | 0:f269e3021894 | 3894 | |
elessair | 0:f269e3021894 | 3895 | /** Attach a member function |
elessair | 0:f269e3021894 | 3896 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 3897 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 3898 | */ |
elessair | 0:f269e3021894 | 3899 | template<typename T> |
elessair | 0:f269e3021894 | 3900 | void attach(T *obj, R (T::*method)(A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 3901 | this->~Callback(); |
elessair | 0:f269e3021894 | 3902 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 3903 | } |
elessair | 0:f269e3021894 | 3904 | |
elessair | 0:f269e3021894 | 3905 | /** Attach a member function |
elessair | 0:f269e3021894 | 3906 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 3907 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 3908 | */ |
elessair | 0:f269e3021894 | 3909 | template<typename T> |
elessair | 0:f269e3021894 | 3910 | void attach(const T *obj, R (T::*method)(A0, A1, A2, A3, A4) const) { |
elessair | 0:f269e3021894 | 3911 | this->~Callback(); |
elessair | 0:f269e3021894 | 3912 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 3913 | } |
elessair | 0:f269e3021894 | 3914 | |
elessair | 0:f269e3021894 | 3915 | /** Attach a member function |
elessair | 0:f269e3021894 | 3916 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 3917 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 3918 | */ |
elessair | 0:f269e3021894 | 3919 | template<typename T> |
elessair | 0:f269e3021894 | 3920 | void attach(volatile T *obj, R (T::*method)(A0, A1, A2, A3, A4) volatile) { |
elessair | 0:f269e3021894 | 3921 | this->~Callback(); |
elessair | 0:f269e3021894 | 3922 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 3923 | } |
elessair | 0:f269e3021894 | 3924 | |
elessair | 0:f269e3021894 | 3925 | /** Attach a member function |
elessair | 0:f269e3021894 | 3926 | * @param obj Pointer to object to invoke member function on |
elessair | 0:f269e3021894 | 3927 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 3928 | */ |
elessair | 0:f269e3021894 | 3929 | template<typename T> |
elessair | 0:f269e3021894 | 3930 | void attach(const volatile T *obj, R (T::*method)(A0, A1, A2, A3, A4) const volatile) { |
elessair | 0:f269e3021894 | 3931 | this->~Callback(); |
elessair | 0:f269e3021894 | 3932 | new (this) Callback(obj, method); |
elessair | 0:f269e3021894 | 3933 | } |
elessair | 0:f269e3021894 | 3934 | |
elessair | 0:f269e3021894 | 3935 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3936 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3937 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3938 | */ |
elessair | 0:f269e3021894 | 3939 | void attach(R (*func)(void*, A0, A1, A2, A3, A4), void *arg) { |
elessair | 0:f269e3021894 | 3940 | this->~Callback(); |
elessair | 0:f269e3021894 | 3941 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 3942 | } |
elessair | 0:f269e3021894 | 3943 | |
elessair | 0:f269e3021894 | 3944 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3945 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3946 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3947 | */ |
elessair | 0:f269e3021894 | 3948 | void attach(R (*func)(const void*, A0, A1, A2, A3, A4), const void *arg) { |
elessair | 0:f269e3021894 | 3949 | this->~Callback(); |
elessair | 0:f269e3021894 | 3950 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 3951 | } |
elessair | 0:f269e3021894 | 3952 | |
elessair | 0:f269e3021894 | 3953 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3954 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3955 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3956 | */ |
elessair | 0:f269e3021894 | 3957 | void attach(R (*func)(volatile void*, A0, A1, A2, A3, A4), volatile void *arg) { |
elessair | 0:f269e3021894 | 3958 | this->~Callback(); |
elessair | 0:f269e3021894 | 3959 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 3960 | } |
elessair | 0:f269e3021894 | 3961 | |
elessair | 0:f269e3021894 | 3962 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3963 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3964 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3965 | */ |
elessair | 0:f269e3021894 | 3966 | void attach(R (*func)(const volatile void*, A0, A1, A2, A3, A4), const volatile void *arg) { |
elessair | 0:f269e3021894 | 3967 | this->~Callback(); |
elessair | 0:f269e3021894 | 3968 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 3969 | } |
elessair | 0:f269e3021894 | 3970 | |
elessair | 0:f269e3021894 | 3971 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3972 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3973 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3974 | */ |
elessair | 0:f269e3021894 | 3975 | template <typename T> |
elessair | 0:f269e3021894 | 3976 | void attach(R (*func)(T*, A0, A1, A2, A3, A4), T *arg) { |
elessair | 0:f269e3021894 | 3977 | this->~Callback(); |
elessair | 0:f269e3021894 | 3978 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 3979 | } |
elessair | 0:f269e3021894 | 3980 | |
elessair | 0:f269e3021894 | 3981 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3982 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3983 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3984 | */ |
elessair | 0:f269e3021894 | 3985 | template <typename T> |
elessair | 0:f269e3021894 | 3986 | void attach(R (*func)(const T*, A0, A1, A2, A3, A4), const T *arg) { |
elessair | 0:f269e3021894 | 3987 | this->~Callback(); |
elessair | 0:f269e3021894 | 3988 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 3989 | } |
elessair | 0:f269e3021894 | 3990 | |
elessair | 0:f269e3021894 | 3991 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 3992 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 3993 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 3994 | */ |
elessair | 0:f269e3021894 | 3995 | template <typename T> |
elessair | 0:f269e3021894 | 3996 | void attach(R (*func)(volatile T*, A0, A1, A2, A3, A4), volatile T *arg) { |
elessair | 0:f269e3021894 | 3997 | this->~Callback(); |
elessair | 0:f269e3021894 | 3998 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 3999 | } |
elessair | 0:f269e3021894 | 4000 | |
elessair | 0:f269e3021894 | 4001 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 4002 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4003 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4004 | */ |
elessair | 0:f269e3021894 | 4005 | template <typename T> |
elessair | 0:f269e3021894 | 4006 | void attach(R (*func)(const volatile T*, A0, A1, A2, A3, A4), const volatile T *arg) { |
elessair | 0:f269e3021894 | 4007 | this->~Callback(); |
elessair | 0:f269e3021894 | 4008 | new (this) Callback(func, arg); |
elessair | 0:f269e3021894 | 4009 | } |
elessair | 0:f269e3021894 | 4010 | |
elessair | 0:f269e3021894 | 4011 | /** Attach a function object |
elessair | 0:f269e3021894 | 4012 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 4013 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 4014 | */ |
elessair | 0:f269e3021894 | 4015 | template <typename F> |
elessair | 0:f269e3021894 | 4016 | void attach(F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 4017 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4), &F::operator()>::value && |
elessair | 0:f269e3021894 | 4018 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 4019 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 4020 | this->~Callback(); |
elessair | 0:f269e3021894 | 4021 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 4022 | } |
elessair | 0:f269e3021894 | 4023 | |
elessair | 0:f269e3021894 | 4024 | /** Attach a function object |
elessair | 0:f269e3021894 | 4025 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 4026 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 4027 | */ |
elessair | 0:f269e3021894 | 4028 | template <typename F> |
elessair | 0:f269e3021894 | 4029 | void attach(const F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 4030 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4) const, &F::operator()>::value && |
elessair | 0:f269e3021894 | 4031 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 4032 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 4033 | this->~Callback(); |
elessair | 0:f269e3021894 | 4034 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 4035 | } |
elessair | 0:f269e3021894 | 4036 | |
elessair | 0:f269e3021894 | 4037 | /** Attach a function object |
elessair | 0:f269e3021894 | 4038 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 4039 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 4040 | */ |
elessair | 0:f269e3021894 | 4041 | template <typename F> |
elessair | 0:f269e3021894 | 4042 | void attach(volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 4043 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4) volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 4044 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 4045 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 4046 | this->~Callback(); |
elessair | 0:f269e3021894 | 4047 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 4048 | } |
elessair | 0:f269e3021894 | 4049 | |
elessair | 0:f269e3021894 | 4050 | /** Attach a function object |
elessair | 0:f269e3021894 | 4051 | * @param func Function object to attach |
elessair | 0:f269e3021894 | 4052 | * @note The function object is limited to a single word of storage |
elessair | 0:f269e3021894 | 4053 | */ |
elessair | 0:f269e3021894 | 4054 | template <typename F> |
elessair | 0:f269e3021894 | 4055 | void attach(const volatile F f, typename detail::enable_if< |
elessair | 0:f269e3021894 | 4056 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4) const volatile, &F::operator()>::value && |
elessair | 0:f269e3021894 | 4057 | sizeof(F) <= sizeof(uintptr_t) |
elessair | 0:f269e3021894 | 4058 | >::type = detail::nil()) { |
elessair | 0:f269e3021894 | 4059 | this->~Callback(); |
elessair | 0:f269e3021894 | 4060 | new (this) Callback(f); |
elessair | 0:f269e3021894 | 4061 | } |
elessair | 0:f269e3021894 | 4062 | |
elessair | 0:f269e3021894 | 4063 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 4064 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 4065 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4066 | * @deprecated |
elessair | 0:f269e3021894 | 4067 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 4068 | */ |
elessair | 0:f269e3021894 | 4069 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4070 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 4071 | void attach(void *obj, R (*func)(void*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 4072 | this->~Callback(); |
elessair | 0:f269e3021894 | 4073 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 4074 | } |
elessair | 0:f269e3021894 | 4075 | |
elessair | 0:f269e3021894 | 4076 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 4077 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 4078 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4079 | * @deprecated |
elessair | 0:f269e3021894 | 4080 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 4081 | */ |
elessair | 0:f269e3021894 | 4082 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4083 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 4084 | void attach(const void *obj, R (*func)(const void*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 4085 | this->~Callback(); |
elessair | 0:f269e3021894 | 4086 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 4087 | } |
elessair | 0:f269e3021894 | 4088 | |
elessair | 0:f269e3021894 | 4089 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 4090 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 4091 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4092 | * @deprecated |
elessair | 0:f269e3021894 | 4093 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 4094 | */ |
elessair | 0:f269e3021894 | 4095 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4096 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 4097 | void attach(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 4098 | this->~Callback(); |
elessair | 0:f269e3021894 | 4099 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 4100 | } |
elessair | 0:f269e3021894 | 4101 | |
elessair | 0:f269e3021894 | 4102 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 4103 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 4104 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4105 | * @deprecated |
elessair | 0:f269e3021894 | 4106 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 4107 | */ |
elessair | 0:f269e3021894 | 4108 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4109 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 4110 | void attach(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 4111 | this->~Callback(); |
elessair | 0:f269e3021894 | 4112 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 4113 | } |
elessair | 0:f269e3021894 | 4114 | |
elessair | 0:f269e3021894 | 4115 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 4116 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 4117 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4118 | * @deprecated |
elessair | 0:f269e3021894 | 4119 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 4120 | */ |
elessair | 0:f269e3021894 | 4121 | template <typename T> |
elessair | 0:f269e3021894 | 4122 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4123 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 4124 | void attach(T *obj, R (*func)(T*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 4125 | this->~Callback(); |
elessair | 0:f269e3021894 | 4126 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 4127 | } |
elessair | 0:f269e3021894 | 4128 | |
elessair | 0:f269e3021894 | 4129 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 4130 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 4131 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4132 | * @deprecated |
elessair | 0:f269e3021894 | 4133 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 4134 | */ |
elessair | 0:f269e3021894 | 4135 | template <typename T> |
elessair | 0:f269e3021894 | 4136 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4137 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 4138 | void attach(const T *obj, R (*func)(const T*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 4139 | this->~Callback(); |
elessair | 0:f269e3021894 | 4140 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 4141 | } |
elessair | 0:f269e3021894 | 4142 | |
elessair | 0:f269e3021894 | 4143 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 4144 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 4145 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4146 | * @deprecated |
elessair | 0:f269e3021894 | 4147 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 4148 | */ |
elessair | 0:f269e3021894 | 4149 | template <typename T> |
elessair | 0:f269e3021894 | 4150 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4151 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 4152 | void attach(volatile T *obj, R (*func)(volatile T*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 4153 | this->~Callback(); |
elessair | 0:f269e3021894 | 4154 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 4155 | } |
elessair | 0:f269e3021894 | 4156 | |
elessair | 0:f269e3021894 | 4157 | /** Attach a static function with a bound pointer |
elessair | 0:f269e3021894 | 4158 | * @param obj Pointer to object to bind to function |
elessair | 0:f269e3021894 | 4159 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4160 | * @deprecated |
elessair | 0:f269e3021894 | 4161 | * Arguments to callback have been reordered to attach(func, arg) |
elessair | 0:f269e3021894 | 4162 | */ |
elessair | 0:f269e3021894 | 4163 | template <typename T> |
elessair | 0:f269e3021894 | 4164 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4165 | "Arguments to callback have been reordered to attach(func, arg)") |
elessair | 0:f269e3021894 | 4166 | void attach(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 4167 | this->~Callback(); |
elessair | 0:f269e3021894 | 4168 | new (this) Callback(func, obj); |
elessair | 0:f269e3021894 | 4169 | } |
elessair | 0:f269e3021894 | 4170 | |
elessair | 0:f269e3021894 | 4171 | /** Assign a callback |
elessair | 0:f269e3021894 | 4172 | */ |
elessair | 0:f269e3021894 | 4173 | Callback &operator=(const Callback &that) { |
elessair | 0:f269e3021894 | 4174 | if (this != &that) { |
elessair | 0:f269e3021894 | 4175 | this->~Callback(); |
elessair | 0:f269e3021894 | 4176 | new (this) Callback(that); |
elessair | 0:f269e3021894 | 4177 | } |
elessair | 0:f269e3021894 | 4178 | |
elessair | 0:f269e3021894 | 4179 | return *this; |
elessair | 0:f269e3021894 | 4180 | } |
elessair | 0:f269e3021894 | 4181 | |
elessair | 0:f269e3021894 | 4182 | /** Call the attached function |
elessair | 0:f269e3021894 | 4183 | */ |
elessair | 0:f269e3021894 | 4184 | R call(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const { |
elessair | 0:f269e3021894 | 4185 | MBED_ASSERT(_ops); |
elessair | 0:f269e3021894 | 4186 | return _ops->call(this, a0, a1, a2, a3, a4); |
elessair | 0:f269e3021894 | 4187 | } |
elessair | 0:f269e3021894 | 4188 | |
elessair | 0:f269e3021894 | 4189 | /** Call the attached function |
elessair | 0:f269e3021894 | 4190 | */ |
elessair | 0:f269e3021894 | 4191 | R operator()(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const { |
elessair | 0:f269e3021894 | 4192 | return call(a0, a1, a2, a3, a4); |
elessair | 0:f269e3021894 | 4193 | } |
elessair | 0:f269e3021894 | 4194 | |
elessair | 0:f269e3021894 | 4195 | /** Test if function has been attached |
elessair | 0:f269e3021894 | 4196 | */ |
elessair | 0:f269e3021894 | 4197 | operator bool() const { |
elessair | 0:f269e3021894 | 4198 | return _ops; |
elessair | 0:f269e3021894 | 4199 | } |
elessair | 0:f269e3021894 | 4200 | |
elessair | 0:f269e3021894 | 4201 | /** Test for equality |
elessair | 0:f269e3021894 | 4202 | */ |
elessair | 0:f269e3021894 | 4203 | friend bool operator==(const Callback &l, const Callback &r) { |
elessair | 0:f269e3021894 | 4204 | return memcmp(&l, &r, sizeof(Callback)) == 0; |
elessair | 0:f269e3021894 | 4205 | } |
elessair | 0:f269e3021894 | 4206 | |
elessair | 0:f269e3021894 | 4207 | /** Test for inequality |
elessair | 0:f269e3021894 | 4208 | */ |
elessair | 0:f269e3021894 | 4209 | friend bool operator!=(const Callback &l, const Callback &r) { |
elessair | 0:f269e3021894 | 4210 | return !(l == r); |
elessair | 0:f269e3021894 | 4211 | } |
elessair | 0:f269e3021894 | 4212 | |
elessair | 0:f269e3021894 | 4213 | /** Static thunk for passing as C-style function |
elessair | 0:f269e3021894 | 4214 | * @param func Callback to call passed as void pointer |
elessair | 0:f269e3021894 | 4215 | */ |
elessair | 0:f269e3021894 | 4216 | static R thunk(void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { |
elessair | 0:f269e3021894 | 4217 | return static_cast<Callback*>(func)->call(a0, a1, a2, a3, a4); |
elessair | 0:f269e3021894 | 4218 | } |
elessair | 0:f269e3021894 | 4219 | |
elessair | 0:f269e3021894 | 4220 | private: |
elessair | 0:f269e3021894 | 4221 | // Stored as pointer to function and pointer to optional object |
elessair | 0:f269e3021894 | 4222 | // Function pointer is stored as union of possible function types |
elessair | 0:f269e3021894 | 4223 | // to garuntee proper size and alignment |
elessair | 0:f269e3021894 | 4224 | struct _class; |
elessair | 0:f269e3021894 | 4225 | union { |
elessair | 0:f269e3021894 | 4226 | void (*_staticfunc)(A0, A1, A2, A3, A4); |
elessair | 0:f269e3021894 | 4227 | void (*_boundfunc)(_class*, A0, A1, A2, A3, A4); |
elessair | 0:f269e3021894 | 4228 | void (_class::*_methodfunc)(A0, A1, A2, A3, A4); |
elessair | 0:f269e3021894 | 4229 | } _func; |
elessair | 0:f269e3021894 | 4230 | void *_obj; |
elessair | 0:f269e3021894 | 4231 | |
elessair | 0:f269e3021894 | 4232 | // Dynamically dispatched operations |
elessair | 0:f269e3021894 | 4233 | const struct ops { |
elessair | 0:f269e3021894 | 4234 | R (*call)(const void*, A0, A1, A2, A3, A4); |
elessair | 0:f269e3021894 | 4235 | void (*move)(void*, const void*); |
elessair | 0:f269e3021894 | 4236 | void (*dtor)(void*); |
elessair | 0:f269e3021894 | 4237 | } *_ops; |
elessair | 0:f269e3021894 | 4238 | |
elessair | 0:f269e3021894 | 4239 | // Generate operations for function object |
elessair | 0:f269e3021894 | 4240 | template <typename F> |
elessair | 0:f269e3021894 | 4241 | void generate(const F &f) { |
elessair | 0:f269e3021894 | 4242 | static const ops ops = { |
elessair | 0:f269e3021894 | 4243 | &Callback::function_call<F>, |
elessair | 0:f269e3021894 | 4244 | &Callback::function_move<F>, |
elessair | 0:f269e3021894 | 4245 | &Callback::function_dtor<F>, |
elessair | 0:f269e3021894 | 4246 | }; |
elessair | 0:f269e3021894 | 4247 | |
elessair | 0:f269e3021894 | 4248 | MBED_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F)); |
elessair | 0:f269e3021894 | 4249 | new (this) F(f); |
elessair | 0:f269e3021894 | 4250 | _ops = &ops; |
elessair | 0:f269e3021894 | 4251 | } |
elessair | 0:f269e3021894 | 4252 | |
elessair | 0:f269e3021894 | 4253 | // Function attributes |
elessair | 0:f269e3021894 | 4254 | template <typename F> |
elessair | 0:f269e3021894 | 4255 | static R function_call(const void *p, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { |
elessair | 0:f269e3021894 | 4256 | return (*(F*)p)(a0, a1, a2, a3, a4); |
elessair | 0:f269e3021894 | 4257 | } |
elessair | 0:f269e3021894 | 4258 | |
elessair | 0:f269e3021894 | 4259 | template <typename F> |
elessair | 0:f269e3021894 | 4260 | static void function_move(void *d, const void *p) { |
elessair | 0:f269e3021894 | 4261 | new (d) F(*(F*)p); |
elessair | 0:f269e3021894 | 4262 | } |
elessair | 0:f269e3021894 | 4263 | |
elessair | 0:f269e3021894 | 4264 | template <typename F> |
elessair | 0:f269e3021894 | 4265 | static void function_dtor(void *p) { |
elessair | 0:f269e3021894 | 4266 | ((F*)p)->~F(); |
elessair | 0:f269e3021894 | 4267 | } |
elessair | 0:f269e3021894 | 4268 | |
elessair | 0:f269e3021894 | 4269 | // Wrappers for functions with context |
elessair | 0:f269e3021894 | 4270 | template <typename O, typename M> |
elessair | 0:f269e3021894 | 4271 | struct method_context { |
elessair | 0:f269e3021894 | 4272 | M method; |
elessair | 0:f269e3021894 | 4273 | O *obj; |
elessair | 0:f269e3021894 | 4274 | |
elessair | 0:f269e3021894 | 4275 | method_context(O *obj, M method) |
elessair | 0:f269e3021894 | 4276 | : method(method), obj(obj) {} |
elessair | 0:f269e3021894 | 4277 | |
elessair | 0:f269e3021894 | 4278 | R operator()(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const { |
elessair | 0:f269e3021894 | 4279 | return (obj->*method)(a0, a1, a2, a3, a4); |
elessair | 0:f269e3021894 | 4280 | } |
elessair | 0:f269e3021894 | 4281 | }; |
elessair | 0:f269e3021894 | 4282 | |
elessair | 0:f269e3021894 | 4283 | template <typename F, typename A> |
elessair | 0:f269e3021894 | 4284 | struct function_context { |
elessair | 0:f269e3021894 | 4285 | F func; |
elessair | 0:f269e3021894 | 4286 | A *arg; |
elessair | 0:f269e3021894 | 4287 | |
elessair | 0:f269e3021894 | 4288 | function_context(F func, A *arg) |
elessair | 0:f269e3021894 | 4289 | : func(func), arg(arg) {} |
elessair | 0:f269e3021894 | 4290 | |
elessair | 0:f269e3021894 | 4291 | R operator()(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const { |
elessair | 0:f269e3021894 | 4292 | return func(arg, a0, a1, a2, a3, a4); |
elessair | 0:f269e3021894 | 4293 | } |
elessair | 0:f269e3021894 | 4294 | }; |
elessair | 0:f269e3021894 | 4295 | }; |
elessair | 0:f269e3021894 | 4296 | |
elessair | 0:f269e3021894 | 4297 | // Internally used event type |
elessair | 0:f269e3021894 | 4298 | typedef Callback<void(int)> event_callback_t; |
elessair | 0:f269e3021894 | 4299 | |
elessair | 0:f269e3021894 | 4300 | |
elessair | 0:f269e3021894 | 4301 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4302 | * |
elessair | 0:f269e3021894 | 4303 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4304 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4305 | */ |
elessair | 0:f269e3021894 | 4306 | template <typename R> |
elessair | 0:f269e3021894 | 4307 | Callback<R()> callback(R (*func)() = 0) { |
elessair | 0:f269e3021894 | 4308 | return Callback<R()>(func); |
elessair | 0:f269e3021894 | 4309 | } |
elessair | 0:f269e3021894 | 4310 | |
elessair | 0:f269e3021894 | 4311 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4312 | * |
elessair | 0:f269e3021894 | 4313 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4314 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4315 | */ |
elessair | 0:f269e3021894 | 4316 | template <typename R> |
elessair | 0:f269e3021894 | 4317 | Callback<R()> callback(const Callback<R()> &func) { |
elessair | 0:f269e3021894 | 4318 | return Callback<R()>(func); |
elessair | 0:f269e3021894 | 4319 | } |
elessair | 0:f269e3021894 | 4320 | |
elessair | 0:f269e3021894 | 4321 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4322 | * |
elessair | 0:f269e3021894 | 4323 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4324 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 4325 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4326 | */ |
elessair | 0:f269e3021894 | 4327 | template<typename T, typename R> |
elessair | 0:f269e3021894 | 4328 | Callback<R()> callback(T *obj, R (T::*func)()) { |
elessair | 0:f269e3021894 | 4329 | return Callback<R()>(obj, func); |
elessair | 0:f269e3021894 | 4330 | } |
elessair | 0:f269e3021894 | 4331 | |
elessair | 0:f269e3021894 | 4332 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4333 | * |
elessair | 0:f269e3021894 | 4334 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4335 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 4336 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4337 | */ |
elessair | 0:f269e3021894 | 4338 | template<typename T, typename R> |
elessair | 0:f269e3021894 | 4339 | Callback<R()> callback(const T *obj, R (T::*func)() const) { |
elessair | 0:f269e3021894 | 4340 | return Callback<R()>(obj, func); |
elessair | 0:f269e3021894 | 4341 | } |
elessair | 0:f269e3021894 | 4342 | |
elessair | 0:f269e3021894 | 4343 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4344 | * |
elessair | 0:f269e3021894 | 4345 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4346 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 4347 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4348 | */ |
elessair | 0:f269e3021894 | 4349 | template<typename T, typename R> |
elessair | 0:f269e3021894 | 4350 | Callback<R()> callback(volatile T *obj, R (T::*func)() volatile) { |
elessair | 0:f269e3021894 | 4351 | return Callback<R()>(obj, func); |
elessair | 0:f269e3021894 | 4352 | } |
elessair | 0:f269e3021894 | 4353 | |
elessair | 0:f269e3021894 | 4354 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4355 | * |
elessair | 0:f269e3021894 | 4356 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4357 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 4358 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4359 | */ |
elessair | 0:f269e3021894 | 4360 | template<typename T, typename R> |
elessair | 0:f269e3021894 | 4361 | Callback<R()> callback(const volatile T *obj, R (T::*func)() const volatile) { |
elessair | 0:f269e3021894 | 4362 | return Callback<R()>(obj, func); |
elessair | 0:f269e3021894 | 4363 | } |
elessair | 0:f269e3021894 | 4364 | |
elessair | 0:f269e3021894 | 4365 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4366 | * |
elessair | 0:f269e3021894 | 4367 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4368 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4369 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4370 | */ |
elessair | 0:f269e3021894 | 4371 | template <typename R> |
elessair | 0:f269e3021894 | 4372 | Callback<R()> callback(R (*func)(void*), void *arg) { |
elessair | 0:f269e3021894 | 4373 | return Callback<R()>(func, arg); |
elessair | 0:f269e3021894 | 4374 | } |
elessair | 0:f269e3021894 | 4375 | |
elessair | 0:f269e3021894 | 4376 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4377 | * |
elessair | 0:f269e3021894 | 4378 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4379 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4380 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4381 | */ |
elessair | 0:f269e3021894 | 4382 | template <typename R> |
elessair | 0:f269e3021894 | 4383 | Callback<R()> callback(R (*func)(const void*), const void *arg) { |
elessair | 0:f269e3021894 | 4384 | return Callback<R()>(func, arg); |
elessair | 0:f269e3021894 | 4385 | } |
elessair | 0:f269e3021894 | 4386 | |
elessair | 0:f269e3021894 | 4387 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4388 | * |
elessair | 0:f269e3021894 | 4389 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4390 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4391 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4392 | */ |
elessair | 0:f269e3021894 | 4393 | template <typename R> |
elessair | 0:f269e3021894 | 4394 | Callback<R()> callback(R (*func)(volatile void*), volatile void *arg) { |
elessair | 0:f269e3021894 | 4395 | return Callback<R()>(func, arg); |
elessair | 0:f269e3021894 | 4396 | } |
elessair | 0:f269e3021894 | 4397 | |
elessair | 0:f269e3021894 | 4398 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4399 | * |
elessair | 0:f269e3021894 | 4400 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4401 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4402 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4403 | */ |
elessair | 0:f269e3021894 | 4404 | template <typename R> |
elessair | 0:f269e3021894 | 4405 | Callback<R()> callback(R (*func)(const volatile void*), const volatile void *arg) { |
elessair | 0:f269e3021894 | 4406 | return Callback<R()>(func, arg); |
elessair | 0:f269e3021894 | 4407 | } |
elessair | 0:f269e3021894 | 4408 | |
elessair | 0:f269e3021894 | 4409 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4410 | * |
elessair | 0:f269e3021894 | 4411 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4412 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4413 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4414 | */ |
elessair | 0:f269e3021894 | 4415 | template <typename T, typename R> |
elessair | 0:f269e3021894 | 4416 | Callback<R()> callback(R (*func)(T*), T *arg) { |
elessair | 0:f269e3021894 | 4417 | return Callback<R()>(func, arg); |
elessair | 0:f269e3021894 | 4418 | } |
elessair | 0:f269e3021894 | 4419 | |
elessair | 0:f269e3021894 | 4420 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4421 | * |
elessair | 0:f269e3021894 | 4422 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4423 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4424 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4425 | */ |
elessair | 0:f269e3021894 | 4426 | template <typename T, typename R> |
elessair | 0:f269e3021894 | 4427 | Callback<R()> callback(R (*func)(const T*), const T *arg) { |
elessair | 0:f269e3021894 | 4428 | return Callback<R()>(func, arg); |
elessair | 0:f269e3021894 | 4429 | } |
elessair | 0:f269e3021894 | 4430 | |
elessair | 0:f269e3021894 | 4431 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4432 | * |
elessair | 0:f269e3021894 | 4433 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4434 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4435 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4436 | */ |
elessair | 0:f269e3021894 | 4437 | template <typename T, typename R> |
elessair | 0:f269e3021894 | 4438 | Callback<R()> callback(R (*func)(volatile T*), volatile T *arg) { |
elessair | 0:f269e3021894 | 4439 | return Callback<R()>(func, arg); |
elessair | 0:f269e3021894 | 4440 | } |
elessair | 0:f269e3021894 | 4441 | |
elessair | 0:f269e3021894 | 4442 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4443 | * |
elessair | 0:f269e3021894 | 4444 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4445 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4446 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4447 | */ |
elessair | 0:f269e3021894 | 4448 | template <typename T, typename R> |
elessair | 0:f269e3021894 | 4449 | Callback<R()> callback(R (*func)(const volatile T*), const volatile T *arg) { |
elessair | 0:f269e3021894 | 4450 | return Callback<R()>(func, arg); |
elessair | 0:f269e3021894 | 4451 | } |
elessair | 0:f269e3021894 | 4452 | |
elessair | 0:f269e3021894 | 4453 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4454 | * |
elessair | 0:f269e3021894 | 4455 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4456 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4457 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4458 | * @deprecated |
elessair | 0:f269e3021894 | 4459 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 4460 | */ |
elessair | 0:f269e3021894 | 4461 | template <typename R> |
elessair | 0:f269e3021894 | 4462 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4463 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 4464 | Callback<R()> callback(void *obj, R (*func)(void*)) { |
elessair | 0:f269e3021894 | 4465 | return Callback<R()>(func, obj); |
elessair | 0:f269e3021894 | 4466 | } |
elessair | 0:f269e3021894 | 4467 | |
elessair | 0:f269e3021894 | 4468 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4469 | * |
elessair | 0:f269e3021894 | 4470 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4471 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4472 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4473 | * @deprecated |
elessair | 0:f269e3021894 | 4474 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 4475 | */ |
elessair | 0:f269e3021894 | 4476 | template <typename R> |
elessair | 0:f269e3021894 | 4477 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4478 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 4479 | Callback<R()> callback(const void *obj, R (*func)(const void*)) { |
elessair | 0:f269e3021894 | 4480 | return Callback<R()>(func, obj); |
elessair | 0:f269e3021894 | 4481 | } |
elessair | 0:f269e3021894 | 4482 | |
elessair | 0:f269e3021894 | 4483 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4484 | * |
elessair | 0:f269e3021894 | 4485 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4486 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4487 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4488 | * @deprecated |
elessair | 0:f269e3021894 | 4489 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 4490 | */ |
elessair | 0:f269e3021894 | 4491 | template <typename R> |
elessair | 0:f269e3021894 | 4492 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4493 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 4494 | Callback<R()> callback(volatile void *obj, R (*func)(volatile void*)) { |
elessair | 0:f269e3021894 | 4495 | return Callback<R()>(func, obj); |
elessair | 0:f269e3021894 | 4496 | } |
elessair | 0:f269e3021894 | 4497 | |
elessair | 0:f269e3021894 | 4498 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4499 | * |
elessair | 0:f269e3021894 | 4500 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4501 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4502 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4503 | * @deprecated |
elessair | 0:f269e3021894 | 4504 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 4505 | */ |
elessair | 0:f269e3021894 | 4506 | template <typename R> |
elessair | 0:f269e3021894 | 4507 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4508 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 4509 | Callback<R()> callback(const volatile void *obj, R (*func)(const volatile void*)) { |
elessair | 0:f269e3021894 | 4510 | return Callback<R()>(func, obj); |
elessair | 0:f269e3021894 | 4511 | } |
elessair | 0:f269e3021894 | 4512 | |
elessair | 0:f269e3021894 | 4513 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4514 | * |
elessair | 0:f269e3021894 | 4515 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4516 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4517 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4518 | * @deprecated |
elessair | 0:f269e3021894 | 4519 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 4520 | */ |
elessair | 0:f269e3021894 | 4521 | template <typename T, typename R> |
elessair | 0:f269e3021894 | 4522 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4523 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 4524 | Callback<R()> callback(T *obj, R (*func)(T*)) { |
elessair | 0:f269e3021894 | 4525 | return Callback<R()>(func, obj); |
elessair | 0:f269e3021894 | 4526 | } |
elessair | 0:f269e3021894 | 4527 | |
elessair | 0:f269e3021894 | 4528 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4529 | * |
elessair | 0:f269e3021894 | 4530 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4531 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4532 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4533 | * @deprecated |
elessair | 0:f269e3021894 | 4534 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 4535 | */ |
elessair | 0:f269e3021894 | 4536 | template <typename T, typename R> |
elessair | 0:f269e3021894 | 4537 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4538 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 4539 | Callback<R()> callback(const T *obj, R (*func)(const T*)) { |
elessair | 0:f269e3021894 | 4540 | return Callback<R()>(func, obj); |
elessair | 0:f269e3021894 | 4541 | } |
elessair | 0:f269e3021894 | 4542 | |
elessair | 0:f269e3021894 | 4543 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4544 | * |
elessair | 0:f269e3021894 | 4545 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4546 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4547 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4548 | * @deprecated |
elessair | 0:f269e3021894 | 4549 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 4550 | */ |
elessair | 0:f269e3021894 | 4551 | template <typename T, typename R> |
elessair | 0:f269e3021894 | 4552 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4553 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 4554 | Callback<R()> callback(volatile T *obj, R (*func)(volatile T*)) { |
elessair | 0:f269e3021894 | 4555 | return Callback<R()>(func, obj); |
elessair | 0:f269e3021894 | 4556 | } |
elessair | 0:f269e3021894 | 4557 | |
elessair | 0:f269e3021894 | 4558 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4559 | * |
elessair | 0:f269e3021894 | 4560 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4561 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4562 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4563 | * @deprecated |
elessair | 0:f269e3021894 | 4564 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 4565 | */ |
elessair | 0:f269e3021894 | 4566 | template <typename T, typename R> |
elessair | 0:f269e3021894 | 4567 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4568 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 4569 | Callback<R()> callback(const volatile T *obj, R (*func)(const volatile T*)) { |
elessair | 0:f269e3021894 | 4570 | return Callback<R()>(func, obj); |
elessair | 0:f269e3021894 | 4571 | } |
elessair | 0:f269e3021894 | 4572 | |
elessair | 0:f269e3021894 | 4573 | |
elessair | 0:f269e3021894 | 4574 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4575 | * |
elessair | 0:f269e3021894 | 4576 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4577 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4578 | */ |
elessair | 0:f269e3021894 | 4579 | template <typename R, typename A0> |
elessair | 0:f269e3021894 | 4580 | Callback<R(A0)> callback(R (*func)(A0) = 0) { |
elessair | 0:f269e3021894 | 4581 | return Callback<R(A0)>(func); |
elessair | 0:f269e3021894 | 4582 | } |
elessair | 0:f269e3021894 | 4583 | |
elessair | 0:f269e3021894 | 4584 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4585 | * |
elessair | 0:f269e3021894 | 4586 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4587 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4588 | */ |
elessair | 0:f269e3021894 | 4589 | template <typename R, typename A0> |
elessair | 0:f269e3021894 | 4590 | Callback<R(A0)> callback(const Callback<R(A0)> &func) { |
elessair | 0:f269e3021894 | 4591 | return Callback<R(A0)>(func); |
elessair | 0:f269e3021894 | 4592 | } |
elessair | 0:f269e3021894 | 4593 | |
elessair | 0:f269e3021894 | 4594 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4595 | * |
elessair | 0:f269e3021894 | 4596 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4597 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 4598 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4599 | */ |
elessair | 0:f269e3021894 | 4600 | template<typename T, typename R, typename A0> |
elessair | 0:f269e3021894 | 4601 | Callback<R(A0)> callback(T *obj, R (T::*func)(A0)) { |
elessair | 0:f269e3021894 | 4602 | return Callback<R(A0)>(obj, func); |
elessair | 0:f269e3021894 | 4603 | } |
elessair | 0:f269e3021894 | 4604 | |
elessair | 0:f269e3021894 | 4605 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4606 | * |
elessair | 0:f269e3021894 | 4607 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4608 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 4609 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4610 | */ |
elessair | 0:f269e3021894 | 4611 | template<typename T, typename R, typename A0> |
elessair | 0:f269e3021894 | 4612 | Callback<R(A0)> callback(const T *obj, R (T::*func)(A0) const) { |
elessair | 0:f269e3021894 | 4613 | return Callback<R(A0)>(obj, func); |
elessair | 0:f269e3021894 | 4614 | } |
elessair | 0:f269e3021894 | 4615 | |
elessair | 0:f269e3021894 | 4616 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4617 | * |
elessair | 0:f269e3021894 | 4618 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4619 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 4620 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4621 | */ |
elessair | 0:f269e3021894 | 4622 | template<typename T, typename R, typename A0> |
elessair | 0:f269e3021894 | 4623 | Callback<R(A0)> callback(volatile T *obj, R (T::*func)(A0) volatile) { |
elessair | 0:f269e3021894 | 4624 | return Callback<R(A0)>(obj, func); |
elessair | 0:f269e3021894 | 4625 | } |
elessair | 0:f269e3021894 | 4626 | |
elessair | 0:f269e3021894 | 4627 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4628 | * |
elessair | 0:f269e3021894 | 4629 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4630 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 4631 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4632 | */ |
elessair | 0:f269e3021894 | 4633 | template<typename T, typename R, typename A0> |
elessair | 0:f269e3021894 | 4634 | Callback<R(A0)> callback(const volatile T *obj, R (T::*func)(A0) const volatile) { |
elessair | 0:f269e3021894 | 4635 | return Callback<R(A0)>(obj, func); |
elessair | 0:f269e3021894 | 4636 | } |
elessair | 0:f269e3021894 | 4637 | |
elessair | 0:f269e3021894 | 4638 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4639 | * |
elessair | 0:f269e3021894 | 4640 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4641 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4642 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4643 | */ |
elessair | 0:f269e3021894 | 4644 | template <typename R, typename A0> |
elessair | 0:f269e3021894 | 4645 | Callback<R(A0)> callback(R (*func)(void*, A0), void *arg) { |
elessair | 0:f269e3021894 | 4646 | return Callback<R(A0)>(func, arg); |
elessair | 0:f269e3021894 | 4647 | } |
elessair | 0:f269e3021894 | 4648 | |
elessair | 0:f269e3021894 | 4649 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4650 | * |
elessair | 0:f269e3021894 | 4651 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4652 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4653 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4654 | */ |
elessair | 0:f269e3021894 | 4655 | template <typename R, typename A0> |
elessair | 0:f269e3021894 | 4656 | Callback<R(A0)> callback(R (*func)(const void*, A0), const void *arg) { |
elessair | 0:f269e3021894 | 4657 | return Callback<R(A0)>(func, arg); |
elessair | 0:f269e3021894 | 4658 | } |
elessair | 0:f269e3021894 | 4659 | |
elessair | 0:f269e3021894 | 4660 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4661 | * |
elessair | 0:f269e3021894 | 4662 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4663 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4664 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4665 | */ |
elessair | 0:f269e3021894 | 4666 | template <typename R, typename A0> |
elessair | 0:f269e3021894 | 4667 | Callback<R(A0)> callback(R (*func)(volatile void*, A0), volatile void *arg) { |
elessair | 0:f269e3021894 | 4668 | return Callback<R(A0)>(func, arg); |
elessair | 0:f269e3021894 | 4669 | } |
elessair | 0:f269e3021894 | 4670 | |
elessair | 0:f269e3021894 | 4671 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4672 | * |
elessair | 0:f269e3021894 | 4673 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4674 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4675 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4676 | */ |
elessair | 0:f269e3021894 | 4677 | template <typename R, typename A0> |
elessair | 0:f269e3021894 | 4678 | Callback<R(A0)> callback(R (*func)(const volatile void*, A0), const volatile void *arg) { |
elessair | 0:f269e3021894 | 4679 | return Callback<R(A0)>(func, arg); |
elessair | 0:f269e3021894 | 4680 | } |
elessair | 0:f269e3021894 | 4681 | |
elessair | 0:f269e3021894 | 4682 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4683 | * |
elessair | 0:f269e3021894 | 4684 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4685 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4686 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4687 | */ |
elessair | 0:f269e3021894 | 4688 | template <typename T, typename R, typename A0> |
elessair | 0:f269e3021894 | 4689 | Callback<R(A0)> callback(R (*func)(T*, A0), T *arg) { |
elessair | 0:f269e3021894 | 4690 | return Callback<R(A0)>(func, arg); |
elessair | 0:f269e3021894 | 4691 | } |
elessair | 0:f269e3021894 | 4692 | |
elessair | 0:f269e3021894 | 4693 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4694 | * |
elessair | 0:f269e3021894 | 4695 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4696 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4697 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4698 | */ |
elessair | 0:f269e3021894 | 4699 | template <typename T, typename R, typename A0> |
elessair | 0:f269e3021894 | 4700 | Callback<R(A0)> callback(R (*func)(const T*, A0), const T *arg) { |
elessair | 0:f269e3021894 | 4701 | return Callback<R(A0)>(func, arg); |
elessair | 0:f269e3021894 | 4702 | } |
elessair | 0:f269e3021894 | 4703 | |
elessair | 0:f269e3021894 | 4704 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4705 | * |
elessair | 0:f269e3021894 | 4706 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4707 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4708 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4709 | */ |
elessair | 0:f269e3021894 | 4710 | template <typename T, typename R, typename A0> |
elessair | 0:f269e3021894 | 4711 | Callback<R(A0)> callback(R (*func)(volatile T*, A0), volatile T *arg) { |
elessair | 0:f269e3021894 | 4712 | return Callback<R(A0)>(func, arg); |
elessair | 0:f269e3021894 | 4713 | } |
elessair | 0:f269e3021894 | 4714 | |
elessair | 0:f269e3021894 | 4715 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4716 | * |
elessair | 0:f269e3021894 | 4717 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4718 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4719 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4720 | */ |
elessair | 0:f269e3021894 | 4721 | template <typename T, typename R, typename A0> |
elessair | 0:f269e3021894 | 4722 | Callback<R(A0)> callback(R (*func)(const volatile T*, A0), const volatile T *arg) { |
elessair | 0:f269e3021894 | 4723 | return Callback<R(A0)>(func, arg); |
elessair | 0:f269e3021894 | 4724 | } |
elessair | 0:f269e3021894 | 4725 | |
elessair | 0:f269e3021894 | 4726 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4727 | * |
elessair | 0:f269e3021894 | 4728 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4729 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4730 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4731 | * @deprecated |
elessair | 0:f269e3021894 | 4732 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 4733 | */ |
elessair | 0:f269e3021894 | 4734 | template <typename R, typename A0> |
elessair | 0:f269e3021894 | 4735 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4736 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 4737 | Callback<R(A0)> callback(void *obj, R (*func)(void*, A0)) { |
elessair | 0:f269e3021894 | 4738 | return Callback<R(A0)>(func, obj); |
elessair | 0:f269e3021894 | 4739 | } |
elessair | 0:f269e3021894 | 4740 | |
elessair | 0:f269e3021894 | 4741 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4742 | * |
elessair | 0:f269e3021894 | 4743 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4744 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4745 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4746 | * @deprecated |
elessair | 0:f269e3021894 | 4747 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 4748 | */ |
elessair | 0:f269e3021894 | 4749 | template <typename R, typename A0> |
elessair | 0:f269e3021894 | 4750 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4751 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 4752 | Callback<R(A0)> callback(const void *obj, R (*func)(const void*, A0)) { |
elessair | 0:f269e3021894 | 4753 | return Callback<R(A0)>(func, obj); |
elessair | 0:f269e3021894 | 4754 | } |
elessair | 0:f269e3021894 | 4755 | |
elessair | 0:f269e3021894 | 4756 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4757 | * |
elessair | 0:f269e3021894 | 4758 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4759 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4760 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4761 | * @deprecated |
elessair | 0:f269e3021894 | 4762 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 4763 | */ |
elessair | 0:f269e3021894 | 4764 | template <typename R, typename A0> |
elessair | 0:f269e3021894 | 4765 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4766 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 4767 | Callback<R(A0)> callback(volatile void *obj, R (*func)(volatile void*, A0)) { |
elessair | 0:f269e3021894 | 4768 | return Callback<R(A0)>(func, obj); |
elessair | 0:f269e3021894 | 4769 | } |
elessair | 0:f269e3021894 | 4770 | |
elessair | 0:f269e3021894 | 4771 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4772 | * |
elessair | 0:f269e3021894 | 4773 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4774 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4775 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4776 | * @deprecated |
elessair | 0:f269e3021894 | 4777 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 4778 | */ |
elessair | 0:f269e3021894 | 4779 | template <typename R, typename A0> |
elessair | 0:f269e3021894 | 4780 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4781 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 4782 | Callback<R(A0)> callback(const volatile void *obj, R (*func)(const volatile void*, A0)) { |
elessair | 0:f269e3021894 | 4783 | return Callback<R(A0)>(func, obj); |
elessair | 0:f269e3021894 | 4784 | } |
elessair | 0:f269e3021894 | 4785 | |
elessair | 0:f269e3021894 | 4786 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4787 | * |
elessair | 0:f269e3021894 | 4788 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4789 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4790 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4791 | * @deprecated |
elessair | 0:f269e3021894 | 4792 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 4793 | */ |
elessair | 0:f269e3021894 | 4794 | template <typename T, typename R, typename A0> |
elessair | 0:f269e3021894 | 4795 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4796 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 4797 | Callback<R(A0)> callback(T *obj, R (*func)(T*, A0)) { |
elessair | 0:f269e3021894 | 4798 | return Callback<R(A0)>(func, obj); |
elessair | 0:f269e3021894 | 4799 | } |
elessair | 0:f269e3021894 | 4800 | |
elessair | 0:f269e3021894 | 4801 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4802 | * |
elessair | 0:f269e3021894 | 4803 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4804 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4805 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4806 | * @deprecated |
elessair | 0:f269e3021894 | 4807 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 4808 | */ |
elessair | 0:f269e3021894 | 4809 | template <typename T, typename R, typename A0> |
elessair | 0:f269e3021894 | 4810 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4811 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 4812 | Callback<R(A0)> callback(const T *obj, R (*func)(const T*, A0)) { |
elessair | 0:f269e3021894 | 4813 | return Callback<R(A0)>(func, obj); |
elessair | 0:f269e3021894 | 4814 | } |
elessair | 0:f269e3021894 | 4815 | |
elessair | 0:f269e3021894 | 4816 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4817 | * |
elessair | 0:f269e3021894 | 4818 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4819 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4820 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4821 | * @deprecated |
elessair | 0:f269e3021894 | 4822 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 4823 | */ |
elessair | 0:f269e3021894 | 4824 | template <typename T, typename R, typename A0> |
elessair | 0:f269e3021894 | 4825 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4826 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 4827 | Callback<R(A0)> callback(volatile T *obj, R (*func)(volatile T*, A0)) { |
elessair | 0:f269e3021894 | 4828 | return Callback<R(A0)>(func, obj); |
elessair | 0:f269e3021894 | 4829 | } |
elessair | 0:f269e3021894 | 4830 | |
elessair | 0:f269e3021894 | 4831 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4832 | * |
elessair | 0:f269e3021894 | 4833 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4834 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4835 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4836 | * @deprecated |
elessair | 0:f269e3021894 | 4837 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 4838 | */ |
elessair | 0:f269e3021894 | 4839 | template <typename T, typename R, typename A0> |
elessair | 0:f269e3021894 | 4840 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 4841 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 4842 | Callback<R(A0)> callback(const volatile T *obj, R (*func)(const volatile T*, A0)) { |
elessair | 0:f269e3021894 | 4843 | return Callback<R(A0)>(func, obj); |
elessair | 0:f269e3021894 | 4844 | } |
elessair | 0:f269e3021894 | 4845 | |
elessair | 0:f269e3021894 | 4846 | |
elessair | 0:f269e3021894 | 4847 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4848 | * |
elessair | 0:f269e3021894 | 4849 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4850 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4851 | */ |
elessair | 0:f269e3021894 | 4852 | template <typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 4853 | Callback<R(A0, A1)> callback(R (*func)(A0, A1) = 0) { |
elessair | 0:f269e3021894 | 4854 | return Callback<R(A0, A1)>(func); |
elessair | 0:f269e3021894 | 4855 | } |
elessair | 0:f269e3021894 | 4856 | |
elessair | 0:f269e3021894 | 4857 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4858 | * |
elessair | 0:f269e3021894 | 4859 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4860 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4861 | */ |
elessair | 0:f269e3021894 | 4862 | template <typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 4863 | Callback<R(A0, A1)> callback(const Callback<R(A0, A1)> &func) { |
elessair | 0:f269e3021894 | 4864 | return Callback<R(A0, A1)>(func); |
elessair | 0:f269e3021894 | 4865 | } |
elessair | 0:f269e3021894 | 4866 | |
elessair | 0:f269e3021894 | 4867 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4868 | * |
elessair | 0:f269e3021894 | 4869 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4870 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 4871 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4872 | */ |
elessair | 0:f269e3021894 | 4873 | template<typename T, typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 4874 | Callback<R(A0, A1)> callback(T *obj, R (T::*func)(A0, A1)) { |
elessair | 0:f269e3021894 | 4875 | return Callback<R(A0, A1)>(obj, func); |
elessair | 0:f269e3021894 | 4876 | } |
elessair | 0:f269e3021894 | 4877 | |
elessair | 0:f269e3021894 | 4878 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4879 | * |
elessair | 0:f269e3021894 | 4880 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4881 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 4882 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4883 | */ |
elessair | 0:f269e3021894 | 4884 | template<typename T, typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 4885 | Callback<R(A0, A1)> callback(const T *obj, R (T::*func)(A0, A1) const) { |
elessair | 0:f269e3021894 | 4886 | return Callback<R(A0, A1)>(obj, func); |
elessair | 0:f269e3021894 | 4887 | } |
elessair | 0:f269e3021894 | 4888 | |
elessair | 0:f269e3021894 | 4889 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4890 | * |
elessair | 0:f269e3021894 | 4891 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4892 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 4893 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4894 | */ |
elessair | 0:f269e3021894 | 4895 | template<typename T, typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 4896 | Callback<R(A0, A1)> callback(volatile T *obj, R (T::*func)(A0, A1) volatile) { |
elessair | 0:f269e3021894 | 4897 | return Callback<R(A0, A1)>(obj, func); |
elessair | 0:f269e3021894 | 4898 | } |
elessair | 0:f269e3021894 | 4899 | |
elessair | 0:f269e3021894 | 4900 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4901 | * |
elessair | 0:f269e3021894 | 4902 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 4903 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 4904 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4905 | */ |
elessair | 0:f269e3021894 | 4906 | template<typename T, typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 4907 | Callback<R(A0, A1)> callback(const volatile T *obj, R (T::*func)(A0, A1) const volatile) { |
elessair | 0:f269e3021894 | 4908 | return Callback<R(A0, A1)>(obj, func); |
elessair | 0:f269e3021894 | 4909 | } |
elessair | 0:f269e3021894 | 4910 | |
elessair | 0:f269e3021894 | 4911 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4912 | * |
elessair | 0:f269e3021894 | 4913 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4914 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4915 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4916 | */ |
elessair | 0:f269e3021894 | 4917 | template <typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 4918 | Callback<R(A0, A1)> callback(R (*func)(void*, A0, A1), void *arg) { |
elessair | 0:f269e3021894 | 4919 | return Callback<R(A0, A1)>(func, arg); |
elessair | 0:f269e3021894 | 4920 | } |
elessair | 0:f269e3021894 | 4921 | |
elessair | 0:f269e3021894 | 4922 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4923 | * |
elessair | 0:f269e3021894 | 4924 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4925 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4926 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4927 | */ |
elessair | 0:f269e3021894 | 4928 | template <typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 4929 | Callback<R(A0, A1)> callback(R (*func)(const void*, A0, A1), const void *arg) { |
elessair | 0:f269e3021894 | 4930 | return Callback<R(A0, A1)>(func, arg); |
elessair | 0:f269e3021894 | 4931 | } |
elessair | 0:f269e3021894 | 4932 | |
elessair | 0:f269e3021894 | 4933 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4934 | * |
elessair | 0:f269e3021894 | 4935 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4936 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4937 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4938 | */ |
elessair | 0:f269e3021894 | 4939 | template <typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 4940 | Callback<R(A0, A1)> callback(R (*func)(volatile void*, A0, A1), volatile void *arg) { |
elessair | 0:f269e3021894 | 4941 | return Callback<R(A0, A1)>(func, arg); |
elessair | 0:f269e3021894 | 4942 | } |
elessair | 0:f269e3021894 | 4943 | |
elessair | 0:f269e3021894 | 4944 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4945 | * |
elessair | 0:f269e3021894 | 4946 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4947 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4948 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4949 | */ |
elessair | 0:f269e3021894 | 4950 | template <typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 4951 | Callback<R(A0, A1)> callback(R (*func)(const volatile void*, A0, A1), const volatile void *arg) { |
elessair | 0:f269e3021894 | 4952 | return Callback<R(A0, A1)>(func, arg); |
elessair | 0:f269e3021894 | 4953 | } |
elessair | 0:f269e3021894 | 4954 | |
elessair | 0:f269e3021894 | 4955 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4956 | * |
elessair | 0:f269e3021894 | 4957 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4958 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4959 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4960 | */ |
elessair | 0:f269e3021894 | 4961 | template <typename T, typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 4962 | Callback<R(A0, A1)> callback(R (*func)(T*, A0, A1), T *arg) { |
elessair | 0:f269e3021894 | 4963 | return Callback<R(A0, A1)>(func, arg); |
elessair | 0:f269e3021894 | 4964 | } |
elessair | 0:f269e3021894 | 4965 | |
elessair | 0:f269e3021894 | 4966 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4967 | * |
elessair | 0:f269e3021894 | 4968 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4969 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4970 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4971 | */ |
elessair | 0:f269e3021894 | 4972 | template <typename T, typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 4973 | Callback<R(A0, A1)> callback(R (*func)(const T*, A0, A1), const T *arg) { |
elessair | 0:f269e3021894 | 4974 | return Callback<R(A0, A1)>(func, arg); |
elessair | 0:f269e3021894 | 4975 | } |
elessair | 0:f269e3021894 | 4976 | |
elessair | 0:f269e3021894 | 4977 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4978 | * |
elessair | 0:f269e3021894 | 4979 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4980 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4981 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4982 | */ |
elessair | 0:f269e3021894 | 4983 | template <typename T, typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 4984 | Callback<R(A0, A1)> callback(R (*func)(volatile T*, A0, A1), volatile T *arg) { |
elessair | 0:f269e3021894 | 4985 | return Callback<R(A0, A1)>(func, arg); |
elessair | 0:f269e3021894 | 4986 | } |
elessair | 0:f269e3021894 | 4987 | |
elessair | 0:f269e3021894 | 4988 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 4989 | * |
elessair | 0:f269e3021894 | 4990 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 4991 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 4992 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 4993 | */ |
elessair | 0:f269e3021894 | 4994 | template <typename T, typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 4995 | Callback<R(A0, A1)> callback(R (*func)(const volatile T*, A0, A1), const volatile T *arg) { |
elessair | 0:f269e3021894 | 4996 | return Callback<R(A0, A1)>(func, arg); |
elessair | 0:f269e3021894 | 4997 | } |
elessair | 0:f269e3021894 | 4998 | |
elessair | 0:f269e3021894 | 4999 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5000 | * |
elessair | 0:f269e3021894 | 5001 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5002 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5003 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5004 | * @deprecated |
elessair | 0:f269e3021894 | 5005 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5006 | */ |
elessair | 0:f269e3021894 | 5007 | template <typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 5008 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5009 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5010 | Callback<R(A0, A1)> callback(void *obj, R (*func)(void*, A0, A1)) { |
elessair | 0:f269e3021894 | 5011 | return Callback<R(A0, A1)>(func, obj); |
elessair | 0:f269e3021894 | 5012 | } |
elessair | 0:f269e3021894 | 5013 | |
elessair | 0:f269e3021894 | 5014 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5015 | * |
elessair | 0:f269e3021894 | 5016 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5017 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5018 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5019 | * @deprecated |
elessair | 0:f269e3021894 | 5020 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5021 | */ |
elessair | 0:f269e3021894 | 5022 | template <typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 5023 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5024 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5025 | Callback<R(A0, A1)> callback(const void *obj, R (*func)(const void*, A0, A1)) { |
elessair | 0:f269e3021894 | 5026 | return Callback<R(A0, A1)>(func, obj); |
elessair | 0:f269e3021894 | 5027 | } |
elessair | 0:f269e3021894 | 5028 | |
elessair | 0:f269e3021894 | 5029 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5030 | * |
elessair | 0:f269e3021894 | 5031 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5032 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5033 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5034 | * @deprecated |
elessair | 0:f269e3021894 | 5035 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5036 | */ |
elessair | 0:f269e3021894 | 5037 | template <typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 5038 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5039 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5040 | Callback<R(A0, A1)> callback(volatile void *obj, R (*func)(volatile void*, A0, A1)) { |
elessair | 0:f269e3021894 | 5041 | return Callback<R(A0, A1)>(func, obj); |
elessair | 0:f269e3021894 | 5042 | } |
elessair | 0:f269e3021894 | 5043 | |
elessair | 0:f269e3021894 | 5044 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5045 | * |
elessair | 0:f269e3021894 | 5046 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5047 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5048 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5049 | * @deprecated |
elessair | 0:f269e3021894 | 5050 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5051 | */ |
elessair | 0:f269e3021894 | 5052 | template <typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 5053 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5054 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5055 | Callback<R(A0, A1)> callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1)) { |
elessair | 0:f269e3021894 | 5056 | return Callback<R(A0, A1)>(func, obj); |
elessair | 0:f269e3021894 | 5057 | } |
elessair | 0:f269e3021894 | 5058 | |
elessair | 0:f269e3021894 | 5059 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5060 | * |
elessair | 0:f269e3021894 | 5061 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5062 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5063 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5064 | * @deprecated |
elessair | 0:f269e3021894 | 5065 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5066 | */ |
elessair | 0:f269e3021894 | 5067 | template <typename T, typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 5068 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5069 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5070 | Callback<R(A0, A1)> callback(T *obj, R (*func)(T*, A0, A1)) { |
elessair | 0:f269e3021894 | 5071 | return Callback<R(A0, A1)>(func, obj); |
elessair | 0:f269e3021894 | 5072 | } |
elessair | 0:f269e3021894 | 5073 | |
elessair | 0:f269e3021894 | 5074 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5075 | * |
elessair | 0:f269e3021894 | 5076 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5077 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5078 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5079 | * @deprecated |
elessair | 0:f269e3021894 | 5080 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5081 | */ |
elessair | 0:f269e3021894 | 5082 | template <typename T, typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 5083 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5084 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5085 | Callback<R(A0, A1)> callback(const T *obj, R (*func)(const T*, A0, A1)) { |
elessair | 0:f269e3021894 | 5086 | return Callback<R(A0, A1)>(func, obj); |
elessair | 0:f269e3021894 | 5087 | } |
elessair | 0:f269e3021894 | 5088 | |
elessair | 0:f269e3021894 | 5089 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5090 | * |
elessair | 0:f269e3021894 | 5091 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5092 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5093 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5094 | * @deprecated |
elessair | 0:f269e3021894 | 5095 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5096 | */ |
elessair | 0:f269e3021894 | 5097 | template <typename T, typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 5098 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5099 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5100 | Callback<R(A0, A1)> callback(volatile T *obj, R (*func)(volatile T*, A0, A1)) { |
elessair | 0:f269e3021894 | 5101 | return Callback<R(A0, A1)>(func, obj); |
elessair | 0:f269e3021894 | 5102 | } |
elessair | 0:f269e3021894 | 5103 | |
elessair | 0:f269e3021894 | 5104 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5105 | * |
elessair | 0:f269e3021894 | 5106 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5107 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5108 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5109 | * @deprecated |
elessair | 0:f269e3021894 | 5110 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5111 | */ |
elessair | 0:f269e3021894 | 5112 | template <typename T, typename R, typename A0, typename A1> |
elessair | 0:f269e3021894 | 5113 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5114 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5115 | Callback<R(A0, A1)> callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1)) { |
elessair | 0:f269e3021894 | 5116 | return Callback<R(A0, A1)>(func, obj); |
elessair | 0:f269e3021894 | 5117 | } |
elessair | 0:f269e3021894 | 5118 | |
elessair | 0:f269e3021894 | 5119 | |
elessair | 0:f269e3021894 | 5120 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5121 | * |
elessair | 0:f269e3021894 | 5122 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5123 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5124 | */ |
elessair | 0:f269e3021894 | 5125 | template <typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 5126 | Callback<R(A0, A1, A2)> callback(R (*func)(A0, A1, A2) = 0) { |
elessair | 0:f269e3021894 | 5127 | return Callback<R(A0, A1, A2)>(func); |
elessair | 0:f269e3021894 | 5128 | } |
elessair | 0:f269e3021894 | 5129 | |
elessair | 0:f269e3021894 | 5130 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5131 | * |
elessair | 0:f269e3021894 | 5132 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5133 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5134 | */ |
elessair | 0:f269e3021894 | 5135 | template <typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 5136 | Callback<R(A0, A1, A2)> callback(const Callback<R(A0, A1, A2)> &func) { |
elessair | 0:f269e3021894 | 5137 | return Callback<R(A0, A1, A2)>(func); |
elessair | 0:f269e3021894 | 5138 | } |
elessair | 0:f269e3021894 | 5139 | |
elessair | 0:f269e3021894 | 5140 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5141 | * |
elessair | 0:f269e3021894 | 5142 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5143 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 5144 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5145 | */ |
elessair | 0:f269e3021894 | 5146 | template<typename T, typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 5147 | Callback<R(A0, A1, A2)> callback(T *obj, R (T::*func)(A0, A1, A2)) { |
elessair | 0:f269e3021894 | 5148 | return Callback<R(A0, A1, A2)>(obj, func); |
elessair | 0:f269e3021894 | 5149 | } |
elessair | 0:f269e3021894 | 5150 | |
elessair | 0:f269e3021894 | 5151 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5152 | * |
elessair | 0:f269e3021894 | 5153 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5154 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 5155 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5156 | */ |
elessair | 0:f269e3021894 | 5157 | template<typename T, typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 5158 | Callback<R(A0, A1, A2)> callback(const T *obj, R (T::*func)(A0, A1, A2) const) { |
elessair | 0:f269e3021894 | 5159 | return Callback<R(A0, A1, A2)>(obj, func); |
elessair | 0:f269e3021894 | 5160 | } |
elessair | 0:f269e3021894 | 5161 | |
elessair | 0:f269e3021894 | 5162 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5163 | * |
elessair | 0:f269e3021894 | 5164 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5165 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 5166 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5167 | */ |
elessair | 0:f269e3021894 | 5168 | template<typename T, typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 5169 | Callback<R(A0, A1, A2)> callback(volatile T *obj, R (T::*func)(A0, A1, A2) volatile) { |
elessair | 0:f269e3021894 | 5170 | return Callback<R(A0, A1, A2)>(obj, func); |
elessair | 0:f269e3021894 | 5171 | } |
elessair | 0:f269e3021894 | 5172 | |
elessair | 0:f269e3021894 | 5173 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5174 | * |
elessair | 0:f269e3021894 | 5175 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5176 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 5177 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5178 | */ |
elessair | 0:f269e3021894 | 5179 | template<typename T, typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 5180 | Callback<R(A0, A1, A2)> callback(const volatile T *obj, R (T::*func)(A0, A1, A2) const volatile) { |
elessair | 0:f269e3021894 | 5181 | return Callback<R(A0, A1, A2)>(obj, func); |
elessair | 0:f269e3021894 | 5182 | } |
elessair | 0:f269e3021894 | 5183 | |
elessair | 0:f269e3021894 | 5184 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5185 | * |
elessair | 0:f269e3021894 | 5186 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5187 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5188 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5189 | */ |
elessair | 0:f269e3021894 | 5190 | template <typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 5191 | Callback<R(A0, A1, A2)> callback(R (*func)(void*, A0, A1, A2), void *arg) { |
elessair | 0:f269e3021894 | 5192 | return Callback<R(A0, A1, A2)>(func, arg); |
elessair | 0:f269e3021894 | 5193 | } |
elessair | 0:f269e3021894 | 5194 | |
elessair | 0:f269e3021894 | 5195 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5196 | * |
elessair | 0:f269e3021894 | 5197 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5198 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5199 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5200 | */ |
elessair | 0:f269e3021894 | 5201 | template <typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 5202 | Callback<R(A0, A1, A2)> callback(R (*func)(const void*, A0, A1, A2), const void *arg) { |
elessair | 0:f269e3021894 | 5203 | return Callback<R(A0, A1, A2)>(func, arg); |
elessair | 0:f269e3021894 | 5204 | } |
elessair | 0:f269e3021894 | 5205 | |
elessair | 0:f269e3021894 | 5206 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5207 | * |
elessair | 0:f269e3021894 | 5208 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5209 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5210 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5211 | */ |
elessair | 0:f269e3021894 | 5212 | template <typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 5213 | Callback<R(A0, A1, A2)> callback(R (*func)(volatile void*, A0, A1, A2), volatile void *arg) { |
elessair | 0:f269e3021894 | 5214 | return Callback<R(A0, A1, A2)>(func, arg); |
elessair | 0:f269e3021894 | 5215 | } |
elessair | 0:f269e3021894 | 5216 | |
elessair | 0:f269e3021894 | 5217 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5218 | * |
elessair | 0:f269e3021894 | 5219 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5220 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5221 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5222 | */ |
elessair | 0:f269e3021894 | 5223 | template <typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 5224 | Callback<R(A0, A1, A2)> callback(R (*func)(const volatile void*, A0, A1, A2), const volatile void *arg) { |
elessair | 0:f269e3021894 | 5225 | return Callback<R(A0, A1, A2)>(func, arg); |
elessair | 0:f269e3021894 | 5226 | } |
elessair | 0:f269e3021894 | 5227 | |
elessair | 0:f269e3021894 | 5228 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5229 | * |
elessair | 0:f269e3021894 | 5230 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5231 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5232 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5233 | */ |
elessair | 0:f269e3021894 | 5234 | template <typename T, typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 5235 | Callback<R(A0, A1, A2)> callback(R (*func)(T*, A0, A1, A2), T *arg) { |
elessair | 0:f269e3021894 | 5236 | return Callback<R(A0, A1, A2)>(func, arg); |
elessair | 0:f269e3021894 | 5237 | } |
elessair | 0:f269e3021894 | 5238 | |
elessair | 0:f269e3021894 | 5239 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5240 | * |
elessair | 0:f269e3021894 | 5241 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5242 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5243 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5244 | */ |
elessair | 0:f269e3021894 | 5245 | template <typename T, typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 5246 | Callback<R(A0, A1, A2)> callback(R (*func)(const T*, A0, A1, A2), const T *arg) { |
elessair | 0:f269e3021894 | 5247 | return Callback<R(A0, A1, A2)>(func, arg); |
elessair | 0:f269e3021894 | 5248 | } |
elessair | 0:f269e3021894 | 5249 | |
elessair | 0:f269e3021894 | 5250 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5251 | * |
elessair | 0:f269e3021894 | 5252 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5253 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5254 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5255 | */ |
elessair | 0:f269e3021894 | 5256 | template <typename T, typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 5257 | Callback<R(A0, A1, A2)> callback(R (*func)(volatile T*, A0, A1, A2), volatile T *arg) { |
elessair | 0:f269e3021894 | 5258 | return Callback<R(A0, A1, A2)>(func, arg); |
elessair | 0:f269e3021894 | 5259 | } |
elessair | 0:f269e3021894 | 5260 | |
elessair | 0:f269e3021894 | 5261 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5262 | * |
elessair | 0:f269e3021894 | 5263 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5264 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5265 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5266 | */ |
elessair | 0:f269e3021894 | 5267 | template <typename T, typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 5268 | Callback<R(A0, A1, A2)> callback(R (*func)(const volatile T*, A0, A1, A2), const volatile T *arg) { |
elessair | 0:f269e3021894 | 5269 | return Callback<R(A0, A1, A2)>(func, arg); |
elessair | 0:f269e3021894 | 5270 | } |
elessair | 0:f269e3021894 | 5271 | |
elessair | 0:f269e3021894 | 5272 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5273 | * |
elessair | 0:f269e3021894 | 5274 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5275 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5276 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5277 | * @deprecated |
elessair | 0:f269e3021894 | 5278 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5279 | */ |
elessair | 0:f269e3021894 | 5280 | template <typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 5281 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5282 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5283 | Callback<R(A0, A1, A2)> callback(void *obj, R (*func)(void*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 5284 | return Callback<R(A0, A1, A2)>(func, obj); |
elessair | 0:f269e3021894 | 5285 | } |
elessair | 0:f269e3021894 | 5286 | |
elessair | 0:f269e3021894 | 5287 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5288 | * |
elessair | 0:f269e3021894 | 5289 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5290 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5291 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5292 | * @deprecated |
elessair | 0:f269e3021894 | 5293 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5294 | */ |
elessair | 0:f269e3021894 | 5295 | template <typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 5296 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5297 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5298 | Callback<R(A0, A1, A2)> callback(const void *obj, R (*func)(const void*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 5299 | return Callback<R(A0, A1, A2)>(func, obj); |
elessair | 0:f269e3021894 | 5300 | } |
elessair | 0:f269e3021894 | 5301 | |
elessair | 0:f269e3021894 | 5302 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5303 | * |
elessair | 0:f269e3021894 | 5304 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5305 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5306 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5307 | * @deprecated |
elessair | 0:f269e3021894 | 5308 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5309 | */ |
elessair | 0:f269e3021894 | 5310 | template <typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 5311 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5312 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5313 | Callback<R(A0, A1, A2)> callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 5314 | return Callback<R(A0, A1, A2)>(func, obj); |
elessair | 0:f269e3021894 | 5315 | } |
elessair | 0:f269e3021894 | 5316 | |
elessair | 0:f269e3021894 | 5317 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5318 | * |
elessair | 0:f269e3021894 | 5319 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5320 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5321 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5322 | * @deprecated |
elessair | 0:f269e3021894 | 5323 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5324 | */ |
elessair | 0:f269e3021894 | 5325 | template <typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 5326 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5327 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5328 | Callback<R(A0, A1, A2)> callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 5329 | return Callback<R(A0, A1, A2)>(func, obj); |
elessair | 0:f269e3021894 | 5330 | } |
elessair | 0:f269e3021894 | 5331 | |
elessair | 0:f269e3021894 | 5332 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5333 | * |
elessair | 0:f269e3021894 | 5334 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5335 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5336 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5337 | * @deprecated |
elessair | 0:f269e3021894 | 5338 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5339 | */ |
elessair | 0:f269e3021894 | 5340 | template <typename T, typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 5341 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5342 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5343 | Callback<R(A0, A1, A2)> callback(T *obj, R (*func)(T*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 5344 | return Callback<R(A0, A1, A2)>(func, obj); |
elessair | 0:f269e3021894 | 5345 | } |
elessair | 0:f269e3021894 | 5346 | |
elessair | 0:f269e3021894 | 5347 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5348 | * |
elessair | 0:f269e3021894 | 5349 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5350 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5351 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5352 | * @deprecated |
elessair | 0:f269e3021894 | 5353 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5354 | */ |
elessair | 0:f269e3021894 | 5355 | template <typename T, typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 5356 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5357 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5358 | Callback<R(A0, A1, A2)> callback(const T *obj, R (*func)(const T*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 5359 | return Callback<R(A0, A1, A2)>(func, obj); |
elessair | 0:f269e3021894 | 5360 | } |
elessair | 0:f269e3021894 | 5361 | |
elessair | 0:f269e3021894 | 5362 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5363 | * |
elessair | 0:f269e3021894 | 5364 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5365 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5366 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5367 | * @deprecated |
elessair | 0:f269e3021894 | 5368 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5369 | */ |
elessair | 0:f269e3021894 | 5370 | template <typename T, typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 5371 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5372 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5373 | Callback<R(A0, A1, A2)> callback(volatile T *obj, R (*func)(volatile T*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 5374 | return Callback<R(A0, A1, A2)>(func, obj); |
elessair | 0:f269e3021894 | 5375 | } |
elessair | 0:f269e3021894 | 5376 | |
elessair | 0:f269e3021894 | 5377 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5378 | * |
elessair | 0:f269e3021894 | 5379 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5380 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5381 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5382 | * @deprecated |
elessair | 0:f269e3021894 | 5383 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5384 | */ |
elessair | 0:f269e3021894 | 5385 | template <typename T, typename R, typename A0, typename A1, typename A2> |
elessair | 0:f269e3021894 | 5386 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5387 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5388 | Callback<R(A0, A1, A2)> callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2)) { |
elessair | 0:f269e3021894 | 5389 | return Callback<R(A0, A1, A2)>(func, obj); |
elessair | 0:f269e3021894 | 5390 | } |
elessair | 0:f269e3021894 | 5391 | |
elessair | 0:f269e3021894 | 5392 | |
elessair | 0:f269e3021894 | 5393 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5394 | * |
elessair | 0:f269e3021894 | 5395 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5396 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5397 | */ |
elessair | 0:f269e3021894 | 5398 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 5399 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(A0, A1, A2, A3) = 0) { |
elessair | 0:f269e3021894 | 5400 | return Callback<R(A0, A1, A2, A3)>(func); |
elessair | 0:f269e3021894 | 5401 | } |
elessair | 0:f269e3021894 | 5402 | |
elessair | 0:f269e3021894 | 5403 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5404 | * |
elessair | 0:f269e3021894 | 5405 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5406 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5407 | */ |
elessair | 0:f269e3021894 | 5408 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 5409 | Callback<R(A0, A1, A2, A3)> callback(const Callback<R(A0, A1, A2, A3)> &func) { |
elessair | 0:f269e3021894 | 5410 | return Callback<R(A0, A1, A2, A3)>(func); |
elessair | 0:f269e3021894 | 5411 | } |
elessair | 0:f269e3021894 | 5412 | |
elessair | 0:f269e3021894 | 5413 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5414 | * |
elessair | 0:f269e3021894 | 5415 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5416 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 5417 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5418 | */ |
elessair | 0:f269e3021894 | 5419 | template<typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 5420 | Callback<R(A0, A1, A2, A3)> callback(T *obj, R (T::*func)(A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 5421 | return Callback<R(A0, A1, A2, A3)>(obj, func); |
elessair | 0:f269e3021894 | 5422 | } |
elessair | 0:f269e3021894 | 5423 | |
elessair | 0:f269e3021894 | 5424 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5425 | * |
elessair | 0:f269e3021894 | 5426 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5427 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 5428 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5429 | */ |
elessair | 0:f269e3021894 | 5430 | template<typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 5431 | Callback<R(A0, A1, A2, A3)> callback(const T *obj, R (T::*func)(A0, A1, A2, A3) const) { |
elessair | 0:f269e3021894 | 5432 | return Callback<R(A0, A1, A2, A3)>(obj, func); |
elessair | 0:f269e3021894 | 5433 | } |
elessair | 0:f269e3021894 | 5434 | |
elessair | 0:f269e3021894 | 5435 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5436 | * |
elessair | 0:f269e3021894 | 5437 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5438 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 5439 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5440 | */ |
elessair | 0:f269e3021894 | 5441 | template<typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 5442 | Callback<R(A0, A1, A2, A3)> callback(volatile T *obj, R (T::*func)(A0, A1, A2, A3) volatile) { |
elessair | 0:f269e3021894 | 5443 | return Callback<R(A0, A1, A2, A3)>(obj, func); |
elessair | 0:f269e3021894 | 5444 | } |
elessair | 0:f269e3021894 | 5445 | |
elessair | 0:f269e3021894 | 5446 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5447 | * |
elessair | 0:f269e3021894 | 5448 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5449 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 5450 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5451 | */ |
elessair | 0:f269e3021894 | 5452 | template<typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 5453 | Callback<R(A0, A1, A2, A3)> callback(const volatile T *obj, R (T::*func)(A0, A1, A2, A3) const volatile) { |
elessair | 0:f269e3021894 | 5454 | return Callback<R(A0, A1, A2, A3)>(obj, func); |
elessair | 0:f269e3021894 | 5455 | } |
elessair | 0:f269e3021894 | 5456 | |
elessair | 0:f269e3021894 | 5457 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5458 | * |
elessair | 0:f269e3021894 | 5459 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5460 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5461 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5462 | */ |
elessair | 0:f269e3021894 | 5463 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 5464 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(void*, A0, A1, A2, A3), void *arg) { |
elessair | 0:f269e3021894 | 5465 | return Callback<R(A0, A1, A2, A3)>(func, arg); |
elessair | 0:f269e3021894 | 5466 | } |
elessair | 0:f269e3021894 | 5467 | |
elessair | 0:f269e3021894 | 5468 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5469 | * |
elessair | 0:f269e3021894 | 5470 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5471 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5472 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5473 | */ |
elessair | 0:f269e3021894 | 5474 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 5475 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(const void*, A0, A1, A2, A3), const void *arg) { |
elessair | 0:f269e3021894 | 5476 | return Callback<R(A0, A1, A2, A3)>(func, arg); |
elessair | 0:f269e3021894 | 5477 | } |
elessair | 0:f269e3021894 | 5478 | |
elessair | 0:f269e3021894 | 5479 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5480 | * |
elessair | 0:f269e3021894 | 5481 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5482 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5483 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5484 | */ |
elessair | 0:f269e3021894 | 5485 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 5486 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(volatile void*, A0, A1, A2, A3), volatile void *arg) { |
elessair | 0:f269e3021894 | 5487 | return Callback<R(A0, A1, A2, A3)>(func, arg); |
elessair | 0:f269e3021894 | 5488 | } |
elessair | 0:f269e3021894 | 5489 | |
elessair | 0:f269e3021894 | 5490 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5491 | * |
elessair | 0:f269e3021894 | 5492 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5493 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5494 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5495 | */ |
elessair | 0:f269e3021894 | 5496 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 5497 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(const volatile void*, A0, A1, A2, A3), const volatile void *arg) { |
elessair | 0:f269e3021894 | 5498 | return Callback<R(A0, A1, A2, A3)>(func, arg); |
elessair | 0:f269e3021894 | 5499 | } |
elessair | 0:f269e3021894 | 5500 | |
elessair | 0:f269e3021894 | 5501 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5502 | * |
elessair | 0:f269e3021894 | 5503 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5504 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5505 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5506 | */ |
elessair | 0:f269e3021894 | 5507 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 5508 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(T*, A0, A1, A2, A3), T *arg) { |
elessair | 0:f269e3021894 | 5509 | return Callback<R(A0, A1, A2, A3)>(func, arg); |
elessair | 0:f269e3021894 | 5510 | } |
elessair | 0:f269e3021894 | 5511 | |
elessair | 0:f269e3021894 | 5512 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5513 | * |
elessair | 0:f269e3021894 | 5514 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5515 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5516 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5517 | */ |
elessair | 0:f269e3021894 | 5518 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 5519 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(const T*, A0, A1, A2, A3), const T *arg) { |
elessair | 0:f269e3021894 | 5520 | return Callback<R(A0, A1, A2, A3)>(func, arg); |
elessair | 0:f269e3021894 | 5521 | } |
elessair | 0:f269e3021894 | 5522 | |
elessair | 0:f269e3021894 | 5523 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5524 | * |
elessair | 0:f269e3021894 | 5525 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5526 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5527 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5528 | */ |
elessair | 0:f269e3021894 | 5529 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 5530 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(volatile T*, A0, A1, A2, A3), volatile T *arg) { |
elessair | 0:f269e3021894 | 5531 | return Callback<R(A0, A1, A2, A3)>(func, arg); |
elessair | 0:f269e3021894 | 5532 | } |
elessair | 0:f269e3021894 | 5533 | |
elessair | 0:f269e3021894 | 5534 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5535 | * |
elessair | 0:f269e3021894 | 5536 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5537 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5538 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5539 | */ |
elessair | 0:f269e3021894 | 5540 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 5541 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(const volatile T*, A0, A1, A2, A3), const volatile T *arg) { |
elessair | 0:f269e3021894 | 5542 | return Callback<R(A0, A1, A2, A3)>(func, arg); |
elessair | 0:f269e3021894 | 5543 | } |
elessair | 0:f269e3021894 | 5544 | |
elessair | 0:f269e3021894 | 5545 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5546 | * |
elessair | 0:f269e3021894 | 5547 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5548 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5549 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5550 | * @deprecated |
elessair | 0:f269e3021894 | 5551 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5552 | */ |
elessair | 0:f269e3021894 | 5553 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 5554 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5555 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5556 | Callback<R(A0, A1, A2, A3)> callback(void *obj, R (*func)(void*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 5557 | return Callback<R(A0, A1, A2, A3)>(func, obj); |
elessair | 0:f269e3021894 | 5558 | } |
elessair | 0:f269e3021894 | 5559 | |
elessair | 0:f269e3021894 | 5560 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5561 | * |
elessair | 0:f269e3021894 | 5562 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5563 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5564 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5565 | * @deprecated |
elessair | 0:f269e3021894 | 5566 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5567 | */ |
elessair | 0:f269e3021894 | 5568 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 5569 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5570 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5571 | Callback<R(A0, A1, A2, A3)> callback(const void *obj, R (*func)(const void*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 5572 | return Callback<R(A0, A1, A2, A3)>(func, obj); |
elessair | 0:f269e3021894 | 5573 | } |
elessair | 0:f269e3021894 | 5574 | |
elessair | 0:f269e3021894 | 5575 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5576 | * |
elessair | 0:f269e3021894 | 5577 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5578 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5579 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5580 | * @deprecated |
elessair | 0:f269e3021894 | 5581 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5582 | */ |
elessair | 0:f269e3021894 | 5583 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 5584 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5585 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5586 | Callback<R(A0, A1, A2, A3)> callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 5587 | return Callback<R(A0, A1, A2, A3)>(func, obj); |
elessair | 0:f269e3021894 | 5588 | } |
elessair | 0:f269e3021894 | 5589 | |
elessair | 0:f269e3021894 | 5590 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5591 | * |
elessair | 0:f269e3021894 | 5592 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5593 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5594 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5595 | * @deprecated |
elessair | 0:f269e3021894 | 5596 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5597 | */ |
elessair | 0:f269e3021894 | 5598 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 5599 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5600 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5601 | Callback<R(A0, A1, A2, A3)> callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 5602 | return Callback<R(A0, A1, A2, A3)>(func, obj); |
elessair | 0:f269e3021894 | 5603 | } |
elessair | 0:f269e3021894 | 5604 | |
elessair | 0:f269e3021894 | 5605 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5606 | * |
elessair | 0:f269e3021894 | 5607 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5608 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5609 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5610 | * @deprecated |
elessair | 0:f269e3021894 | 5611 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5612 | */ |
elessair | 0:f269e3021894 | 5613 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 5614 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5615 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5616 | Callback<R(A0, A1, A2, A3)> callback(T *obj, R (*func)(T*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 5617 | return Callback<R(A0, A1, A2, A3)>(func, obj); |
elessair | 0:f269e3021894 | 5618 | } |
elessair | 0:f269e3021894 | 5619 | |
elessair | 0:f269e3021894 | 5620 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5621 | * |
elessair | 0:f269e3021894 | 5622 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5623 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5624 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5625 | * @deprecated |
elessair | 0:f269e3021894 | 5626 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5627 | */ |
elessair | 0:f269e3021894 | 5628 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 5629 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5630 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5631 | Callback<R(A0, A1, A2, A3)> callback(const T *obj, R (*func)(const T*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 5632 | return Callback<R(A0, A1, A2, A3)>(func, obj); |
elessair | 0:f269e3021894 | 5633 | } |
elessair | 0:f269e3021894 | 5634 | |
elessair | 0:f269e3021894 | 5635 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5636 | * |
elessair | 0:f269e3021894 | 5637 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5638 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5639 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5640 | * @deprecated |
elessair | 0:f269e3021894 | 5641 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5642 | */ |
elessair | 0:f269e3021894 | 5643 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 5644 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5645 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5646 | Callback<R(A0, A1, A2, A3)> callback(volatile T *obj, R (*func)(volatile T*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 5647 | return Callback<R(A0, A1, A2, A3)>(func, obj); |
elessair | 0:f269e3021894 | 5648 | } |
elessair | 0:f269e3021894 | 5649 | |
elessair | 0:f269e3021894 | 5650 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5651 | * |
elessair | 0:f269e3021894 | 5652 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5653 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5654 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5655 | * @deprecated |
elessair | 0:f269e3021894 | 5656 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5657 | */ |
elessair | 0:f269e3021894 | 5658 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3> |
elessair | 0:f269e3021894 | 5659 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5660 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5661 | Callback<R(A0, A1, A2, A3)> callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2, A3)) { |
elessair | 0:f269e3021894 | 5662 | return Callback<R(A0, A1, A2, A3)>(func, obj); |
elessair | 0:f269e3021894 | 5663 | } |
elessair | 0:f269e3021894 | 5664 | |
elessair | 0:f269e3021894 | 5665 | |
elessair | 0:f269e3021894 | 5666 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5667 | * |
elessair | 0:f269e3021894 | 5668 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5669 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5670 | */ |
elessair | 0:f269e3021894 | 5671 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 5672 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(A0, A1, A2, A3, A4) = 0) { |
elessair | 0:f269e3021894 | 5673 | return Callback<R(A0, A1, A2, A3, A4)>(func); |
elessair | 0:f269e3021894 | 5674 | } |
elessair | 0:f269e3021894 | 5675 | |
elessair | 0:f269e3021894 | 5676 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5677 | * |
elessair | 0:f269e3021894 | 5678 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5679 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5680 | */ |
elessair | 0:f269e3021894 | 5681 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 5682 | Callback<R(A0, A1, A2, A3, A4)> callback(const Callback<R(A0, A1, A2, A3, A4)> &func) { |
elessair | 0:f269e3021894 | 5683 | return Callback<R(A0, A1, A2, A3, A4)>(func); |
elessair | 0:f269e3021894 | 5684 | } |
elessair | 0:f269e3021894 | 5685 | |
elessair | 0:f269e3021894 | 5686 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5687 | * |
elessair | 0:f269e3021894 | 5688 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5689 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 5690 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5691 | */ |
elessair | 0:f269e3021894 | 5692 | template<typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 5693 | Callback<R(A0, A1, A2, A3, A4)> callback(T *obj, R (T::*func)(A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 5694 | return Callback<R(A0, A1, A2, A3, A4)>(obj, func); |
elessair | 0:f269e3021894 | 5695 | } |
elessair | 0:f269e3021894 | 5696 | |
elessair | 0:f269e3021894 | 5697 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5698 | * |
elessair | 0:f269e3021894 | 5699 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5700 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 5701 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5702 | */ |
elessair | 0:f269e3021894 | 5703 | template<typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 5704 | Callback<R(A0, A1, A2, A3, A4)> callback(const T *obj, R (T::*func)(A0, A1, A2, A3, A4) const) { |
elessair | 0:f269e3021894 | 5705 | return Callback<R(A0, A1, A2, A3, A4)>(obj, func); |
elessair | 0:f269e3021894 | 5706 | } |
elessair | 0:f269e3021894 | 5707 | |
elessair | 0:f269e3021894 | 5708 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5709 | * |
elessair | 0:f269e3021894 | 5710 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5711 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 5712 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5713 | */ |
elessair | 0:f269e3021894 | 5714 | template<typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 5715 | Callback<R(A0, A1, A2, A3, A4)> callback(volatile T *obj, R (T::*func)(A0, A1, A2, A3, A4) volatile) { |
elessair | 0:f269e3021894 | 5716 | return Callback<R(A0, A1, A2, A3, A4)>(obj, func); |
elessair | 0:f269e3021894 | 5717 | } |
elessair | 0:f269e3021894 | 5718 | |
elessair | 0:f269e3021894 | 5719 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5720 | * |
elessair | 0:f269e3021894 | 5721 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5722 | * @param method Member function to attach |
elessair | 0:f269e3021894 | 5723 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5724 | */ |
elessair | 0:f269e3021894 | 5725 | template<typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 5726 | Callback<R(A0, A1, A2, A3, A4)> callback(const volatile T *obj, R (T::*func)(A0, A1, A2, A3, A4) const volatile) { |
elessair | 0:f269e3021894 | 5727 | return Callback<R(A0, A1, A2, A3, A4)>(obj, func); |
elessair | 0:f269e3021894 | 5728 | } |
elessair | 0:f269e3021894 | 5729 | |
elessair | 0:f269e3021894 | 5730 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5731 | * |
elessair | 0:f269e3021894 | 5732 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5733 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5734 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5735 | */ |
elessair | 0:f269e3021894 | 5736 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 5737 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(void*, A0, A1, A2, A3, A4), void *arg) { |
elessair | 0:f269e3021894 | 5738 | return Callback<R(A0, A1, A2, A3, A4)>(func, arg); |
elessair | 0:f269e3021894 | 5739 | } |
elessair | 0:f269e3021894 | 5740 | |
elessair | 0:f269e3021894 | 5741 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5742 | * |
elessair | 0:f269e3021894 | 5743 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5744 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5745 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5746 | */ |
elessair | 0:f269e3021894 | 5747 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 5748 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(const void*, A0, A1, A2, A3, A4), const void *arg) { |
elessair | 0:f269e3021894 | 5749 | return Callback<R(A0, A1, A2, A3, A4)>(func, arg); |
elessair | 0:f269e3021894 | 5750 | } |
elessair | 0:f269e3021894 | 5751 | |
elessair | 0:f269e3021894 | 5752 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5753 | * |
elessair | 0:f269e3021894 | 5754 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5755 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5756 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5757 | */ |
elessair | 0:f269e3021894 | 5758 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 5759 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(volatile void*, A0, A1, A2, A3, A4), volatile void *arg) { |
elessair | 0:f269e3021894 | 5760 | return Callback<R(A0, A1, A2, A3, A4)>(func, arg); |
elessair | 0:f269e3021894 | 5761 | } |
elessair | 0:f269e3021894 | 5762 | |
elessair | 0:f269e3021894 | 5763 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5764 | * |
elessair | 0:f269e3021894 | 5765 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5766 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5767 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5768 | */ |
elessair | 0:f269e3021894 | 5769 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 5770 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(const volatile void*, A0, A1, A2, A3, A4), const volatile void *arg) { |
elessair | 0:f269e3021894 | 5771 | return Callback<R(A0, A1, A2, A3, A4)>(func, arg); |
elessair | 0:f269e3021894 | 5772 | } |
elessair | 0:f269e3021894 | 5773 | |
elessair | 0:f269e3021894 | 5774 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5775 | * |
elessair | 0:f269e3021894 | 5776 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5777 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5778 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5779 | */ |
elessair | 0:f269e3021894 | 5780 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 5781 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(T*, A0, A1, A2, A3, A4), T *arg) { |
elessair | 0:f269e3021894 | 5782 | return Callback<R(A0, A1, A2, A3, A4)>(func, arg); |
elessair | 0:f269e3021894 | 5783 | } |
elessair | 0:f269e3021894 | 5784 | |
elessair | 0:f269e3021894 | 5785 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5786 | * |
elessair | 0:f269e3021894 | 5787 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5788 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5789 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5790 | */ |
elessair | 0:f269e3021894 | 5791 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 5792 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(const T*, A0, A1, A2, A3, A4), const T *arg) { |
elessair | 0:f269e3021894 | 5793 | return Callback<R(A0, A1, A2, A3, A4)>(func, arg); |
elessair | 0:f269e3021894 | 5794 | } |
elessair | 0:f269e3021894 | 5795 | |
elessair | 0:f269e3021894 | 5796 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5797 | * |
elessair | 0:f269e3021894 | 5798 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5799 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5800 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5801 | */ |
elessair | 0:f269e3021894 | 5802 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 5803 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(volatile T*, A0, A1, A2, A3, A4), volatile T *arg) { |
elessair | 0:f269e3021894 | 5804 | return Callback<R(A0, A1, A2, A3, A4)>(func, arg); |
elessair | 0:f269e3021894 | 5805 | } |
elessair | 0:f269e3021894 | 5806 | |
elessair | 0:f269e3021894 | 5807 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5808 | * |
elessair | 0:f269e3021894 | 5809 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5810 | * @param arg Pointer argument to function |
elessair | 0:f269e3021894 | 5811 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5812 | */ |
elessair | 0:f269e3021894 | 5813 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 5814 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(const volatile T*, A0, A1, A2, A3, A4), const volatile T *arg) { |
elessair | 0:f269e3021894 | 5815 | return Callback<R(A0, A1, A2, A3, A4)>(func, arg); |
elessair | 0:f269e3021894 | 5816 | } |
elessair | 0:f269e3021894 | 5817 | |
elessair | 0:f269e3021894 | 5818 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5819 | * |
elessair | 0:f269e3021894 | 5820 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5821 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5822 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5823 | * @deprecated |
elessair | 0:f269e3021894 | 5824 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5825 | */ |
elessair | 0:f269e3021894 | 5826 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 5827 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5828 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5829 | Callback<R(A0, A1, A2, A3, A4)> callback(void *obj, R (*func)(void*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 5830 | return Callback<R(A0, A1, A2, A3, A4)>(func, obj); |
elessair | 0:f269e3021894 | 5831 | } |
elessair | 0:f269e3021894 | 5832 | |
elessair | 0:f269e3021894 | 5833 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5834 | * |
elessair | 0:f269e3021894 | 5835 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5836 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5837 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5838 | * @deprecated |
elessair | 0:f269e3021894 | 5839 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5840 | */ |
elessair | 0:f269e3021894 | 5841 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 5842 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5843 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5844 | Callback<R(A0, A1, A2, A3, A4)> callback(const void *obj, R (*func)(const void*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 5845 | return Callback<R(A0, A1, A2, A3, A4)>(func, obj); |
elessair | 0:f269e3021894 | 5846 | } |
elessair | 0:f269e3021894 | 5847 | |
elessair | 0:f269e3021894 | 5848 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5849 | * |
elessair | 0:f269e3021894 | 5850 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5851 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5852 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5853 | * @deprecated |
elessair | 0:f269e3021894 | 5854 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5855 | */ |
elessair | 0:f269e3021894 | 5856 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 5857 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5858 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5859 | Callback<R(A0, A1, A2, A3, A4)> callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 5860 | return Callback<R(A0, A1, A2, A3, A4)>(func, obj); |
elessair | 0:f269e3021894 | 5861 | } |
elessair | 0:f269e3021894 | 5862 | |
elessair | 0:f269e3021894 | 5863 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5864 | * |
elessair | 0:f269e3021894 | 5865 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5866 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5867 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5868 | * @deprecated |
elessair | 0:f269e3021894 | 5869 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5870 | */ |
elessair | 0:f269e3021894 | 5871 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 5872 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5873 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5874 | Callback<R(A0, A1, A2, A3, A4)> callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 5875 | return Callback<R(A0, A1, A2, A3, A4)>(func, obj); |
elessair | 0:f269e3021894 | 5876 | } |
elessair | 0:f269e3021894 | 5877 | |
elessair | 0:f269e3021894 | 5878 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5879 | * |
elessair | 0:f269e3021894 | 5880 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5881 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5882 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5883 | * @deprecated |
elessair | 0:f269e3021894 | 5884 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5885 | */ |
elessair | 0:f269e3021894 | 5886 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 5887 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5888 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5889 | Callback<R(A0, A1, A2, A3, A4)> callback(T *obj, R (*func)(T*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 5890 | return Callback<R(A0, A1, A2, A3, A4)>(func, obj); |
elessair | 0:f269e3021894 | 5891 | } |
elessair | 0:f269e3021894 | 5892 | |
elessair | 0:f269e3021894 | 5893 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5894 | * |
elessair | 0:f269e3021894 | 5895 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5896 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5897 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5898 | * @deprecated |
elessair | 0:f269e3021894 | 5899 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5900 | */ |
elessair | 0:f269e3021894 | 5901 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 5902 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5903 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5904 | Callback<R(A0, A1, A2, A3, A4)> callback(const T *obj, R (*func)(const T*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 5905 | return Callback<R(A0, A1, A2, A3, A4)>(func, obj); |
elessair | 0:f269e3021894 | 5906 | } |
elessair | 0:f269e3021894 | 5907 | |
elessair | 0:f269e3021894 | 5908 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5909 | * |
elessair | 0:f269e3021894 | 5910 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5911 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5912 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5913 | * @deprecated |
elessair | 0:f269e3021894 | 5914 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5915 | */ |
elessair | 0:f269e3021894 | 5916 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 5917 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5918 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5919 | Callback<R(A0, A1, A2, A3, A4)> callback(volatile T *obj, R (*func)(volatile T*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 5920 | return Callback<R(A0, A1, A2, A3, A4)>(func, obj); |
elessair | 0:f269e3021894 | 5921 | } |
elessair | 0:f269e3021894 | 5922 | |
elessair | 0:f269e3021894 | 5923 | /** Create a callback class with type infered from the arguments |
elessair | 0:f269e3021894 | 5924 | * |
elessair | 0:f269e3021894 | 5925 | * @param obj Optional pointer to object to bind to function |
elessair | 0:f269e3021894 | 5926 | * @param func Static function to attach |
elessair | 0:f269e3021894 | 5927 | * @return Callback with infered type |
elessair | 0:f269e3021894 | 5928 | * @deprecated |
elessair | 0:f269e3021894 | 5929 | * Arguments to callback have been reordered to callback(func, arg) |
elessair | 0:f269e3021894 | 5930 | */ |
elessair | 0:f269e3021894 | 5931 | template <typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
elessair | 0:f269e3021894 | 5932 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
elessair | 0:f269e3021894 | 5933 | "Arguments to callback have been reordered to callback(func, arg)") |
elessair | 0:f269e3021894 | 5934 | Callback<R(A0, A1, A2, A3, A4)> callback(const volatile T *obj, R (*func)(const volatile T*, A0, A1, A2, A3, A4)) { |
elessair | 0:f269e3021894 | 5935 | return Callback<R(A0, A1, A2, A3, A4)>(func, obj); |
elessair | 0:f269e3021894 | 5936 | } |
elessair | 0:f269e3021894 | 5937 | |
elessair | 0:f269e3021894 | 5938 | |
elessair | 0:f269e3021894 | 5939 | } // namespace mbed |
elessair | 0:f269e3021894 | 5940 | |
elessair | 0:f269e3021894 | 5941 | #endif |
elessair | 0:f269e3021894 | 5942 | |
elessair | 0:f269e3021894 | 5943 | |
elessair | 0:f269e3021894 | 5944 | /** @}*/ |