mbed library sources. Supersedes mbed-src.
Fork of mbed-dev by
platform/Callback.h@160:d5399cc887bb, 2017-03-14 (annotated)
- Committer:
- <>
- Date:
- Tue Mar 14 16:40:56 2017 +0000
- Revision:
- 160:d5399cc887bb
- Parent:
- 151:5eaa88a5bcc7
- Child:
- 167:e84263d55307
This updates the lib to the mbed lib v138
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 149:156823d33999 | 1 | /* mbed Microcontroller Library |
<> | 149:156823d33999 | 2 | * Copyright (c) 2006-2015 ARM Limited |
<> | 149:156823d33999 | 3 | * |
<> | 149:156823d33999 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
<> | 149:156823d33999 | 5 | * you may not use this file except in compliance with the License. |
<> | 149:156823d33999 | 6 | * You may obtain a copy of the License at |
<> | 149:156823d33999 | 7 | * |
<> | 149:156823d33999 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
<> | 149:156823d33999 | 9 | * |
<> | 149:156823d33999 | 10 | * Unless required by applicable law or agreed to in writing, software |
<> | 149:156823d33999 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
<> | 149:156823d33999 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
<> | 149:156823d33999 | 13 | * See the License for the specific language governing permissions and |
<> | 149:156823d33999 | 14 | * limitations under the License. |
<> | 149:156823d33999 | 15 | */ |
<> | 149:156823d33999 | 16 | #ifndef MBED_CALLBACK_H |
<> | 149:156823d33999 | 17 | #define MBED_CALLBACK_H |
<> | 149:156823d33999 | 18 | |
<> | 149:156823d33999 | 19 | #include <string.h> |
<> | 149:156823d33999 | 20 | #include <stdint.h> |
<> | 149:156823d33999 | 21 | #include <new> |
<> | 149:156823d33999 | 22 | #include "platform/mbed_assert.h" |
<> | 160:d5399cc887bb | 23 | #include "platform/mbed_toolchain.h" |
<> | 149:156823d33999 | 24 | |
<> | 149:156823d33999 | 25 | namespace mbed { |
<> | 149:156823d33999 | 26 | /** \addtogroup platform */ |
<> | 149:156823d33999 | 27 | /** @{*/ |
<> | 149:156823d33999 | 28 | |
<> | 149:156823d33999 | 29 | |
<> | 149:156823d33999 | 30 | /** Callback class based on template specialization |
<> | 149:156823d33999 | 31 | * |
<> | 149:156823d33999 | 32 | * @Note Synchronization level: Not protected |
<> | 149:156823d33999 | 33 | */ |
<> | 149:156823d33999 | 34 | template <typename F> |
<> | 149:156823d33999 | 35 | class Callback; |
<> | 149:156823d33999 | 36 | |
<> | 149:156823d33999 | 37 | // Internal sfinae declarations |
<> | 149:156823d33999 | 38 | // |
<> | 149:156823d33999 | 39 | // These are used to eliminate overloads based on type attributes |
<> | 149:156823d33999 | 40 | // 1. Does a function object have a call operator |
<> | 149:156823d33999 | 41 | // 2. Does a function object fit in the available storage |
<> | 149:156823d33999 | 42 | // |
<> | 149:156823d33999 | 43 | // These eliminations are handled cleanly by the compiler and avoid |
<> | 149:156823d33999 | 44 | // massive and misleading error messages when confronted with an |
<> | 149:156823d33999 | 45 | // invalid type (or worse, runtime failures) |
<> | 149:156823d33999 | 46 | namespace detail { |
<> | 149:156823d33999 | 47 | struct nil {}; |
<> | 149:156823d33999 | 48 | |
<> | 149:156823d33999 | 49 | template <bool B, typename R = nil> |
<> | 149:156823d33999 | 50 | struct enable_if { typedef R type; }; |
<> | 149:156823d33999 | 51 | |
<> | 149:156823d33999 | 52 | template <typename R> |
<> | 149:156823d33999 | 53 | struct enable_if<false, R> {}; |
<> | 149:156823d33999 | 54 | |
<> | 149:156823d33999 | 55 | template <typename M, M> |
<> | 149:156823d33999 | 56 | struct is_type { |
<> | 149:156823d33999 | 57 | static const bool value = true; |
<> | 149:156823d33999 | 58 | }; |
<> | 149:156823d33999 | 59 | } |
<> | 149:156823d33999 | 60 | |
<> | 149:156823d33999 | 61 | /** Callback class based on template specialization |
<> | 149:156823d33999 | 62 | * |
<> | 149:156823d33999 | 63 | * @Note Synchronization level: Not protected |
<> | 149:156823d33999 | 64 | */ |
<> | 149:156823d33999 | 65 | template <typename R> |
<> | 149:156823d33999 | 66 | class Callback<R()> { |
<> | 149:156823d33999 | 67 | public: |
<> | 149:156823d33999 | 68 | /** Create a Callback with a static function |
<> | 149:156823d33999 | 69 | * @param func Static function to attach |
<> | 149:156823d33999 | 70 | */ |
<> | 149:156823d33999 | 71 | Callback(R (*func)() = 0) { |
<> | 149:156823d33999 | 72 | if (!func) { |
<> | 149:156823d33999 | 73 | _ops = 0; |
<> | 149:156823d33999 | 74 | } else { |
<> | 149:156823d33999 | 75 | generate(func); |
<> | 149:156823d33999 | 76 | } |
<> | 149:156823d33999 | 77 | } |
<> | 149:156823d33999 | 78 | |
<> | 149:156823d33999 | 79 | /** Attach a Callback |
<> | 149:156823d33999 | 80 | * @param func The Callback to attach |
<> | 149:156823d33999 | 81 | */ |
<> | 149:156823d33999 | 82 | Callback(const Callback<R()> &func) { |
<> | 149:156823d33999 | 83 | if (func._ops) { |
<> | 149:156823d33999 | 84 | func._ops->move(this, &func); |
<> | 149:156823d33999 | 85 | } |
<> | 149:156823d33999 | 86 | _ops = func._ops; |
<> | 149:156823d33999 | 87 | } |
<> | 149:156823d33999 | 88 | |
<> | 149:156823d33999 | 89 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 90 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 91 | * @param method Member function to attach |
<> | 149:156823d33999 | 92 | */ |
<> | 151:5eaa88a5bcc7 | 93 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 94 | Callback(U *obj, R (T::*method)()) { |
<> | 149:156823d33999 | 95 | generate(method_context<T, R (T::*)()>(obj, method)); |
<> | 149:156823d33999 | 96 | } |
<> | 149:156823d33999 | 97 | |
<> | 149:156823d33999 | 98 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 99 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 100 | * @param method Member function to attach |
<> | 149:156823d33999 | 101 | */ |
<> | 151:5eaa88a5bcc7 | 102 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 103 | Callback(const U *obj, R (T::*method)() const) { |
<> | 149:156823d33999 | 104 | generate(method_context<const T, R (T::*)() const>(obj, method)); |
<> | 149:156823d33999 | 105 | } |
<> | 149:156823d33999 | 106 | |
<> | 149:156823d33999 | 107 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 108 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 109 | * @param method Member function to attach |
<> | 149:156823d33999 | 110 | */ |
<> | 151:5eaa88a5bcc7 | 111 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 112 | Callback(volatile U *obj, R (T::*method)() volatile) { |
<> | 149:156823d33999 | 113 | generate(method_context<volatile T, R (T::*)() volatile>(obj, method)); |
<> | 149:156823d33999 | 114 | } |
<> | 149:156823d33999 | 115 | |
<> | 149:156823d33999 | 116 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 117 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 118 | * @param method Member function to attach |
<> | 149:156823d33999 | 119 | */ |
<> | 151:5eaa88a5bcc7 | 120 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 121 | Callback(const volatile U *obj, R (T::*method)() const volatile) { |
<> | 149:156823d33999 | 122 | generate(method_context<const volatile T, R (T::*)() const volatile>(obj, method)); |
<> | 149:156823d33999 | 123 | } |
<> | 149:156823d33999 | 124 | |
<> | 149:156823d33999 | 125 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 126 | * @param func Static function to attach |
<> | 149:156823d33999 | 127 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 128 | */ |
<> | 151:5eaa88a5bcc7 | 129 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 130 | Callback(R (*func)(T*), U *arg) { |
<> | 149:156823d33999 | 131 | generate(function_context<R (*)(T*), T>(func, arg)); |
<> | 149:156823d33999 | 132 | } |
<> | 149:156823d33999 | 133 | |
<> | 149:156823d33999 | 134 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 135 | * @param func Static function to attach |
<> | 149:156823d33999 | 136 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 137 | */ |
<> | 151:5eaa88a5bcc7 | 138 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 139 | Callback(R (*func)(const T*), const U *arg) { |
<> | 149:156823d33999 | 140 | generate(function_context<R (*)(const T*), const T>(func, arg)); |
<> | 149:156823d33999 | 141 | } |
<> | 149:156823d33999 | 142 | |
<> | 149:156823d33999 | 143 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 144 | * @param func Static function to attach |
<> | 149:156823d33999 | 145 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 146 | */ |
<> | 151:5eaa88a5bcc7 | 147 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 148 | Callback(R (*func)(volatile T*), volatile U *arg) { |
<> | 149:156823d33999 | 149 | generate(function_context<R (*)(volatile T*), volatile T>(func, arg)); |
<> | 149:156823d33999 | 150 | } |
<> | 149:156823d33999 | 151 | |
<> | 149:156823d33999 | 152 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 153 | * @param func Static function to attach |
<> | 149:156823d33999 | 154 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 155 | */ |
<> | 151:5eaa88a5bcc7 | 156 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 157 | Callback(R (*func)(const volatile T*), const volatile U *arg) { |
<> | 149:156823d33999 | 158 | generate(function_context<R (*)(const volatile T*), const volatile T>(func, arg)); |
<> | 149:156823d33999 | 159 | } |
<> | 149:156823d33999 | 160 | |
<> | 149:156823d33999 | 161 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 162 | * @param func Function object to attach |
<> | 149:156823d33999 | 163 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 164 | */ |
<> | 149:156823d33999 | 165 | template <typename F> |
<> | 149:156823d33999 | 166 | Callback(F f, typename detail::enable_if< |
<> | 149:156823d33999 | 167 | detail::is_type<R (F::*)(), &F::operator()>::value && |
<> | 149:156823d33999 | 168 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 169 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 170 | generate(f); |
<> | 149:156823d33999 | 171 | } |
<> | 149:156823d33999 | 172 | |
<> | 149:156823d33999 | 173 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 174 | * @param func Function object to attach |
<> | 149:156823d33999 | 175 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 176 | */ |
<> | 149:156823d33999 | 177 | template <typename F> |
<> | 149:156823d33999 | 178 | Callback(const F f, typename detail::enable_if< |
<> | 149:156823d33999 | 179 | detail::is_type<R (F::*)() const, &F::operator()>::value && |
<> | 149:156823d33999 | 180 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 181 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 182 | generate(f); |
<> | 149:156823d33999 | 183 | } |
<> | 149:156823d33999 | 184 | |
<> | 149:156823d33999 | 185 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 186 | * @param func Function object to attach |
<> | 149:156823d33999 | 187 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 188 | */ |
<> | 149:156823d33999 | 189 | template <typename F> |
<> | 149:156823d33999 | 190 | Callback(volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 191 | detail::is_type<R (F::*)() volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 192 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 193 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 194 | generate(f); |
<> | 149:156823d33999 | 195 | } |
<> | 149:156823d33999 | 196 | |
<> | 149:156823d33999 | 197 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 198 | * @param func Function object to attach |
<> | 149:156823d33999 | 199 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 200 | */ |
<> | 149:156823d33999 | 201 | template <typename F> |
<> | 149:156823d33999 | 202 | Callback(const volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 203 | detail::is_type<R (F::*)() const volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 204 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 205 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 206 | generate(f); |
<> | 149:156823d33999 | 207 | } |
<> | 149:156823d33999 | 208 | |
<> | 149:156823d33999 | 209 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 210 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 211 | * @param func Static function to attach |
<> | 149:156823d33999 | 212 | * @deprecated |
<> | 149:156823d33999 | 213 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 214 | */ |
<> | 151:5eaa88a5bcc7 | 215 | template<typename T, typename U> |
<> | 149:156823d33999 | 216 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 217 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 218 | Callback(U *obj, R (*func)(T*)) { |
<> | 149:156823d33999 | 219 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 220 | } |
<> | 149:156823d33999 | 221 | |
<> | 149:156823d33999 | 222 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 223 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 224 | * @param func Static function to attach |
<> | 149:156823d33999 | 225 | * @deprecated |
<> | 149:156823d33999 | 226 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 227 | */ |
<> | 151:5eaa88a5bcc7 | 228 | template<typename T, typename U> |
<> | 149:156823d33999 | 229 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 230 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 231 | Callback(const U *obj, R (*func)(const T*)) { |
<> | 149:156823d33999 | 232 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 233 | } |
<> | 149:156823d33999 | 234 | |
<> | 149:156823d33999 | 235 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 236 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 237 | * @param func Static function to attach |
<> | 149:156823d33999 | 238 | * @deprecated |
<> | 149:156823d33999 | 239 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 240 | */ |
<> | 151:5eaa88a5bcc7 | 241 | template<typename T, typename U> |
<> | 149:156823d33999 | 242 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 243 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 244 | Callback(volatile U *obj, R (*func)(volatile T*)) { |
<> | 149:156823d33999 | 245 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 246 | } |
<> | 149:156823d33999 | 247 | |
<> | 149:156823d33999 | 248 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 249 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 250 | * @param func Static function to attach |
<> | 149:156823d33999 | 251 | * @deprecated |
<> | 149:156823d33999 | 252 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 253 | */ |
<> | 151:5eaa88a5bcc7 | 254 | template<typename T, typename U> |
<> | 149:156823d33999 | 255 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 256 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 257 | Callback(const volatile U *obj, R (*func)(const volatile T*)) { |
<> | 149:156823d33999 | 258 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 259 | } |
<> | 149:156823d33999 | 260 | |
<> | 149:156823d33999 | 261 | /** Destroy a callback |
<> | 149:156823d33999 | 262 | */ |
<> | 149:156823d33999 | 263 | ~Callback() { |
<> | 149:156823d33999 | 264 | if (_ops) { |
<> | 149:156823d33999 | 265 | _ops->dtor(this); |
<> | 149:156823d33999 | 266 | } |
<> | 149:156823d33999 | 267 | } |
<> | 149:156823d33999 | 268 | |
<> | 149:156823d33999 | 269 | /** Attach a static function |
<> | 149:156823d33999 | 270 | * @param func Static function to attach |
<> | 160:d5399cc887bb | 271 | * @deprecated |
<> | 160:d5399cc887bb | 272 | * Replaced by simple assignment 'Callback cb = func' |
<> | 160:d5399cc887bb | 273 | */ |
<> | 160:d5399cc887bb | 274 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 275 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 276 | void attach(R (*func)()) { |
<> | 149:156823d33999 | 277 | this->~Callback(); |
<> | 149:156823d33999 | 278 | new (this) Callback(func); |
<> | 149:156823d33999 | 279 | } |
<> | 149:156823d33999 | 280 | |
<> | 149:156823d33999 | 281 | /** Attach a Callback |
<> | 149:156823d33999 | 282 | * @param func The Callback to attach |
<> | 160:d5399cc887bb | 283 | * @deprecated |
<> | 160:d5399cc887bb | 284 | * Replaced by simple assignment 'Callback cb = func' |
<> | 160:d5399cc887bb | 285 | */ |
<> | 160:d5399cc887bb | 286 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 287 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 288 | void attach(const Callback<R()> &func) { |
<> | 149:156823d33999 | 289 | this->~Callback(); |
<> | 149:156823d33999 | 290 | new (this) Callback(func); |
<> | 149:156823d33999 | 291 | } |
<> | 149:156823d33999 | 292 | |
<> | 149:156823d33999 | 293 | /** Attach a member function |
<> | 149:156823d33999 | 294 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 295 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 296 | * @deprecated |
<> | 160:d5399cc887bb | 297 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 298 | */ |
<> | 151:5eaa88a5bcc7 | 299 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 300 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 301 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 302 | void attach(U *obj, R (T::*method)()) { |
<> | 149:156823d33999 | 303 | this->~Callback(); |
<> | 149:156823d33999 | 304 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 305 | } |
<> | 149:156823d33999 | 306 | |
<> | 149:156823d33999 | 307 | /** Attach a member function |
<> | 149:156823d33999 | 308 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 309 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 310 | * @deprecated |
<> | 160:d5399cc887bb | 311 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 312 | */ |
<> | 151:5eaa88a5bcc7 | 313 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 314 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 315 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 316 | void attach(const U *obj, R (T::*method)() const) { |
<> | 149:156823d33999 | 317 | this->~Callback(); |
<> | 149:156823d33999 | 318 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 319 | } |
<> | 149:156823d33999 | 320 | |
<> | 149:156823d33999 | 321 | /** Attach a member function |
<> | 149:156823d33999 | 322 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 323 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 324 | * @deprecated |
<> | 160:d5399cc887bb | 325 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 326 | */ |
<> | 151:5eaa88a5bcc7 | 327 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 328 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 329 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 330 | void attach(volatile U *obj, R (T::*method)() volatile) { |
<> | 149:156823d33999 | 331 | this->~Callback(); |
<> | 149:156823d33999 | 332 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 333 | } |
<> | 149:156823d33999 | 334 | |
<> | 149:156823d33999 | 335 | /** Attach a member function |
<> | 149:156823d33999 | 336 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 337 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 338 | * @deprecated |
<> | 160:d5399cc887bb | 339 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 340 | */ |
<> | 151:5eaa88a5bcc7 | 341 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 342 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 343 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 344 | void attach(const volatile U *obj, R (T::*method)() const volatile) { |
<> | 149:156823d33999 | 345 | this->~Callback(); |
<> | 149:156823d33999 | 346 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 347 | } |
<> | 149:156823d33999 | 348 | |
<> | 149:156823d33999 | 349 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 350 | * @param func Static function to attach |
<> | 149:156823d33999 | 351 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 352 | * @deprecated |
<> | 160:d5399cc887bb | 353 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 354 | */ |
<> | 151:5eaa88a5bcc7 | 355 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 356 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 357 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 358 | void attach(R (*func)(T*), U *arg) { |
<> | 149:156823d33999 | 359 | this->~Callback(); |
<> | 149:156823d33999 | 360 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 361 | } |
<> | 149:156823d33999 | 362 | |
<> | 149:156823d33999 | 363 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 364 | * @param func Static function to attach |
<> | 149:156823d33999 | 365 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 366 | * @deprecated |
<> | 160:d5399cc887bb | 367 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 368 | */ |
<> | 151:5eaa88a5bcc7 | 369 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 370 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 371 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 372 | void attach(R (*func)(const T*), const U *arg) { |
<> | 149:156823d33999 | 373 | this->~Callback(); |
<> | 149:156823d33999 | 374 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 375 | } |
<> | 149:156823d33999 | 376 | |
<> | 149:156823d33999 | 377 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 378 | * @param func Static function to attach |
<> | 149:156823d33999 | 379 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 380 | * @deprecated |
<> | 160:d5399cc887bb | 381 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 382 | */ |
<> | 151:5eaa88a5bcc7 | 383 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 384 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 385 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 386 | void attach(R (*func)(volatile T*), volatile U *arg) { |
<> | 149:156823d33999 | 387 | this->~Callback(); |
<> | 149:156823d33999 | 388 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 389 | } |
<> | 149:156823d33999 | 390 | |
<> | 149:156823d33999 | 391 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 392 | * @param func Static function to attach |
<> | 149:156823d33999 | 393 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 394 | * @deprecated |
<> | 160:d5399cc887bb | 395 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 396 | */ |
<> | 151:5eaa88a5bcc7 | 397 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 398 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 399 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 400 | void attach(R (*func)(const volatile T*), const volatile U *arg) { |
<> | 149:156823d33999 | 401 | this->~Callback(); |
<> | 149:156823d33999 | 402 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 403 | } |
<> | 149:156823d33999 | 404 | |
<> | 149:156823d33999 | 405 | /** Attach a function object |
<> | 149:156823d33999 | 406 | * @param func Function object to attach |
<> | 149:156823d33999 | 407 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 408 | * @deprecated |
<> | 160:d5399cc887bb | 409 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 410 | */ |
<> | 149:156823d33999 | 411 | template <typename F> |
<> | 160:d5399cc887bb | 412 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 413 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 414 | void attach(F f, typename detail::enable_if< |
<> | 149:156823d33999 | 415 | detail::is_type<R (F::*)(), &F::operator()>::value && |
<> | 149:156823d33999 | 416 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 417 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 418 | this->~Callback(); |
<> | 149:156823d33999 | 419 | new (this) Callback(f); |
<> | 149:156823d33999 | 420 | } |
<> | 149:156823d33999 | 421 | |
<> | 149:156823d33999 | 422 | /** Attach a function object |
<> | 149:156823d33999 | 423 | * @param func Function object to attach |
<> | 149:156823d33999 | 424 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 425 | * @deprecated |
<> | 160:d5399cc887bb | 426 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 427 | */ |
<> | 149:156823d33999 | 428 | template <typename F> |
<> | 160:d5399cc887bb | 429 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 430 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 431 | void attach(const F f, typename detail::enable_if< |
<> | 149:156823d33999 | 432 | detail::is_type<R (F::*)() const, &F::operator()>::value && |
<> | 149:156823d33999 | 433 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 434 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 435 | this->~Callback(); |
<> | 149:156823d33999 | 436 | new (this) Callback(f); |
<> | 149:156823d33999 | 437 | } |
<> | 149:156823d33999 | 438 | |
<> | 149:156823d33999 | 439 | /** Attach a function object |
<> | 149:156823d33999 | 440 | * @param func Function object to attach |
<> | 149:156823d33999 | 441 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 442 | * @deprecated |
<> | 160:d5399cc887bb | 443 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 444 | */ |
<> | 149:156823d33999 | 445 | template <typename F> |
<> | 160:d5399cc887bb | 446 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 447 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 448 | void attach(volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 449 | detail::is_type<R (F::*)() volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 450 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 451 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 452 | this->~Callback(); |
<> | 149:156823d33999 | 453 | new (this) Callback(f); |
<> | 149:156823d33999 | 454 | } |
<> | 149:156823d33999 | 455 | |
<> | 149:156823d33999 | 456 | /** Attach a function object |
<> | 149:156823d33999 | 457 | * @param func Function object to attach |
<> | 149:156823d33999 | 458 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 459 | * @deprecated |
<> | 160:d5399cc887bb | 460 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 461 | */ |
<> | 149:156823d33999 | 462 | template <typename F> |
<> | 160:d5399cc887bb | 463 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 464 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 465 | void attach(const volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 466 | detail::is_type<R (F::*)() const volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 467 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 468 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 469 | this->~Callback(); |
<> | 149:156823d33999 | 470 | new (this) Callback(f); |
<> | 149:156823d33999 | 471 | } |
<> | 149:156823d33999 | 472 | |
<> | 149:156823d33999 | 473 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 474 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 475 | * @param func Static function to attach |
<> | 149:156823d33999 | 476 | * @deprecated |
<> | 149:156823d33999 | 477 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 478 | */ |
<> | 151:5eaa88a5bcc7 | 479 | template <typename T, typename U> |
<> | 149:156823d33999 | 480 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 481 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 482 | void attach(U *obj, R (*func)(T*)) { |
<> | 149:156823d33999 | 483 | this->~Callback(); |
<> | 149:156823d33999 | 484 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 485 | } |
<> | 149:156823d33999 | 486 | |
<> | 149:156823d33999 | 487 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 488 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 489 | * @param func Static function to attach |
<> | 149:156823d33999 | 490 | * @deprecated |
<> | 149:156823d33999 | 491 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 492 | */ |
<> | 151:5eaa88a5bcc7 | 493 | template <typename T, typename U> |
<> | 149:156823d33999 | 494 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 495 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 496 | void attach(const U *obj, R (*func)(const T*)) { |
<> | 149:156823d33999 | 497 | this->~Callback(); |
<> | 149:156823d33999 | 498 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 499 | } |
<> | 149:156823d33999 | 500 | |
<> | 149:156823d33999 | 501 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 502 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 503 | * @param func Static function to attach |
<> | 149:156823d33999 | 504 | * @deprecated |
<> | 149:156823d33999 | 505 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 506 | */ |
<> | 151:5eaa88a5bcc7 | 507 | template <typename T, typename U> |
<> | 149:156823d33999 | 508 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 509 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 510 | void attach(volatile U *obj, R (*func)(volatile T*)) { |
<> | 149:156823d33999 | 511 | this->~Callback(); |
<> | 149:156823d33999 | 512 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 513 | } |
<> | 149:156823d33999 | 514 | |
<> | 149:156823d33999 | 515 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 516 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 517 | * @param func Static function to attach |
<> | 149:156823d33999 | 518 | * @deprecated |
<> | 149:156823d33999 | 519 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 520 | */ |
<> | 151:5eaa88a5bcc7 | 521 | template <typename T, typename U> |
<> | 149:156823d33999 | 522 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 523 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 524 | void attach(const volatile U *obj, R (*func)(const volatile T*)) { |
<> | 149:156823d33999 | 525 | this->~Callback(); |
<> | 149:156823d33999 | 526 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 527 | } |
<> | 149:156823d33999 | 528 | |
<> | 149:156823d33999 | 529 | /** Assign a callback |
<> | 149:156823d33999 | 530 | */ |
<> | 149:156823d33999 | 531 | Callback &operator=(const Callback &that) { |
<> | 149:156823d33999 | 532 | if (this != &that) { |
<> | 149:156823d33999 | 533 | this->~Callback(); |
<> | 149:156823d33999 | 534 | new (this) Callback(that); |
<> | 149:156823d33999 | 535 | } |
<> | 149:156823d33999 | 536 | |
<> | 149:156823d33999 | 537 | return *this; |
<> | 149:156823d33999 | 538 | } |
<> | 149:156823d33999 | 539 | |
<> | 149:156823d33999 | 540 | /** Call the attached function |
<> | 149:156823d33999 | 541 | */ |
<> | 149:156823d33999 | 542 | R call() const { |
<> | 149:156823d33999 | 543 | MBED_ASSERT(_ops); |
<> | 149:156823d33999 | 544 | return _ops->call(this); |
<> | 149:156823d33999 | 545 | } |
<> | 149:156823d33999 | 546 | |
<> | 149:156823d33999 | 547 | /** Call the attached function |
<> | 149:156823d33999 | 548 | */ |
<> | 149:156823d33999 | 549 | R operator()() const { |
<> | 149:156823d33999 | 550 | return call(); |
<> | 149:156823d33999 | 551 | } |
<> | 149:156823d33999 | 552 | |
<> | 149:156823d33999 | 553 | /** Test if function has been attached |
<> | 149:156823d33999 | 554 | */ |
<> | 149:156823d33999 | 555 | operator bool() const { |
<> | 149:156823d33999 | 556 | return _ops; |
<> | 149:156823d33999 | 557 | } |
<> | 149:156823d33999 | 558 | |
<> | 149:156823d33999 | 559 | /** Test for equality |
<> | 149:156823d33999 | 560 | */ |
<> | 149:156823d33999 | 561 | friend bool operator==(const Callback &l, const Callback &r) { |
<> | 149:156823d33999 | 562 | return memcmp(&l, &r, sizeof(Callback)) == 0; |
<> | 149:156823d33999 | 563 | } |
<> | 149:156823d33999 | 564 | |
<> | 149:156823d33999 | 565 | /** Test for inequality |
<> | 149:156823d33999 | 566 | */ |
<> | 149:156823d33999 | 567 | friend bool operator!=(const Callback &l, const Callback &r) { |
<> | 149:156823d33999 | 568 | return !(l == r); |
<> | 149:156823d33999 | 569 | } |
<> | 149:156823d33999 | 570 | |
<> | 149:156823d33999 | 571 | /** Static thunk for passing as C-style function |
<> | 149:156823d33999 | 572 | * @param func Callback to call passed as void pointer |
<> | 149:156823d33999 | 573 | */ |
<> | 149:156823d33999 | 574 | static R thunk(void *func) { |
<> | 149:156823d33999 | 575 | return static_cast<Callback*>(func)->call(); |
<> | 149:156823d33999 | 576 | } |
<> | 149:156823d33999 | 577 | |
<> | 149:156823d33999 | 578 | private: |
<> | 149:156823d33999 | 579 | // Stored as pointer to function and pointer to optional object |
<> | 149:156823d33999 | 580 | // Function pointer is stored as union of possible function types |
<> | 149:156823d33999 | 581 | // to garuntee proper size and alignment |
<> | 149:156823d33999 | 582 | struct _class; |
<> | 149:156823d33999 | 583 | union { |
<> | 149:156823d33999 | 584 | void (*_staticfunc)(); |
<> | 149:156823d33999 | 585 | void (*_boundfunc)(_class*); |
<> | 149:156823d33999 | 586 | void (_class::*_methodfunc)(); |
<> | 149:156823d33999 | 587 | } _func; |
<> | 149:156823d33999 | 588 | void *_obj; |
<> | 149:156823d33999 | 589 | |
<> | 149:156823d33999 | 590 | // Dynamically dispatched operations |
<> | 149:156823d33999 | 591 | const struct ops { |
<> | 149:156823d33999 | 592 | R (*call)(const void*); |
<> | 149:156823d33999 | 593 | void (*move)(void*, const void*); |
<> | 149:156823d33999 | 594 | void (*dtor)(void*); |
<> | 149:156823d33999 | 595 | } *_ops; |
<> | 149:156823d33999 | 596 | |
<> | 149:156823d33999 | 597 | // Generate operations for function object |
<> | 149:156823d33999 | 598 | template <typename F> |
<> | 149:156823d33999 | 599 | void generate(const F &f) { |
<> | 149:156823d33999 | 600 | static const ops ops = { |
<> | 149:156823d33999 | 601 | &Callback::function_call<F>, |
<> | 149:156823d33999 | 602 | &Callback::function_move<F>, |
<> | 149:156823d33999 | 603 | &Callback::function_dtor<F>, |
<> | 149:156823d33999 | 604 | }; |
<> | 149:156823d33999 | 605 | |
<> | 151:5eaa88a5bcc7 | 606 | MBED_STATIC_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F), |
<> | 151:5eaa88a5bcc7 | 607 | "Type F must not exceed the size of the Callback class"); |
<> | 149:156823d33999 | 608 | new (this) F(f); |
<> | 149:156823d33999 | 609 | _ops = &ops; |
<> | 149:156823d33999 | 610 | } |
<> | 149:156823d33999 | 611 | |
<> | 149:156823d33999 | 612 | // Function attributes |
<> | 149:156823d33999 | 613 | template <typename F> |
<> | 149:156823d33999 | 614 | static R function_call(const void *p) { |
<> | 149:156823d33999 | 615 | return (*(F*)p)(); |
<> | 149:156823d33999 | 616 | } |
<> | 149:156823d33999 | 617 | |
<> | 149:156823d33999 | 618 | template <typename F> |
<> | 149:156823d33999 | 619 | static void function_move(void *d, const void *p) { |
<> | 149:156823d33999 | 620 | new (d) F(*(F*)p); |
<> | 149:156823d33999 | 621 | } |
<> | 149:156823d33999 | 622 | |
<> | 149:156823d33999 | 623 | template <typename F> |
<> | 149:156823d33999 | 624 | static void function_dtor(void *p) { |
<> | 149:156823d33999 | 625 | ((F*)p)->~F(); |
<> | 149:156823d33999 | 626 | } |
<> | 149:156823d33999 | 627 | |
<> | 149:156823d33999 | 628 | // Wrappers for functions with context |
<> | 149:156823d33999 | 629 | template <typename O, typename M> |
<> | 149:156823d33999 | 630 | struct method_context { |
<> | 149:156823d33999 | 631 | M method; |
<> | 149:156823d33999 | 632 | O *obj; |
<> | 149:156823d33999 | 633 | |
<> | 149:156823d33999 | 634 | method_context(O *obj, M method) |
<> | 149:156823d33999 | 635 | : method(method), obj(obj) {} |
<> | 149:156823d33999 | 636 | |
<> | 149:156823d33999 | 637 | R operator()() const { |
<> | 149:156823d33999 | 638 | return (obj->*method)(); |
<> | 149:156823d33999 | 639 | } |
<> | 149:156823d33999 | 640 | }; |
<> | 149:156823d33999 | 641 | |
<> | 149:156823d33999 | 642 | template <typename F, typename A> |
<> | 149:156823d33999 | 643 | struct function_context { |
<> | 149:156823d33999 | 644 | F func; |
<> | 149:156823d33999 | 645 | A *arg; |
<> | 149:156823d33999 | 646 | |
<> | 149:156823d33999 | 647 | function_context(F func, A *arg) |
<> | 149:156823d33999 | 648 | : func(func), arg(arg) {} |
<> | 149:156823d33999 | 649 | |
<> | 149:156823d33999 | 650 | R operator()() const { |
<> | 149:156823d33999 | 651 | return func(arg); |
<> | 149:156823d33999 | 652 | } |
<> | 149:156823d33999 | 653 | }; |
<> | 149:156823d33999 | 654 | }; |
<> | 149:156823d33999 | 655 | |
<> | 149:156823d33999 | 656 | /** Callback class based on template specialization |
<> | 149:156823d33999 | 657 | * |
<> | 149:156823d33999 | 658 | * @Note Synchronization level: Not protected |
<> | 149:156823d33999 | 659 | */ |
<> | 149:156823d33999 | 660 | template <typename R, typename A0> |
<> | 149:156823d33999 | 661 | class Callback<R(A0)> { |
<> | 149:156823d33999 | 662 | public: |
<> | 149:156823d33999 | 663 | /** Create a Callback with a static function |
<> | 149:156823d33999 | 664 | * @param func Static function to attach |
<> | 149:156823d33999 | 665 | */ |
<> | 149:156823d33999 | 666 | Callback(R (*func)(A0) = 0) { |
<> | 149:156823d33999 | 667 | if (!func) { |
<> | 149:156823d33999 | 668 | _ops = 0; |
<> | 149:156823d33999 | 669 | } else { |
<> | 149:156823d33999 | 670 | generate(func); |
<> | 149:156823d33999 | 671 | } |
<> | 149:156823d33999 | 672 | } |
<> | 149:156823d33999 | 673 | |
<> | 149:156823d33999 | 674 | /** Attach a Callback |
<> | 149:156823d33999 | 675 | * @param func The Callback to attach |
<> | 149:156823d33999 | 676 | */ |
<> | 149:156823d33999 | 677 | Callback(const Callback<R(A0)> &func) { |
<> | 149:156823d33999 | 678 | if (func._ops) { |
<> | 149:156823d33999 | 679 | func._ops->move(this, &func); |
<> | 149:156823d33999 | 680 | } |
<> | 149:156823d33999 | 681 | _ops = func._ops; |
<> | 149:156823d33999 | 682 | } |
<> | 149:156823d33999 | 683 | |
<> | 149:156823d33999 | 684 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 685 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 686 | * @param method Member function to attach |
<> | 149:156823d33999 | 687 | */ |
<> | 151:5eaa88a5bcc7 | 688 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 689 | Callback(U *obj, R (T::*method)(A0)) { |
<> | 149:156823d33999 | 690 | generate(method_context<T, R (T::*)(A0)>(obj, method)); |
<> | 149:156823d33999 | 691 | } |
<> | 149:156823d33999 | 692 | |
<> | 149:156823d33999 | 693 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 694 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 695 | * @param method Member function to attach |
<> | 149:156823d33999 | 696 | */ |
<> | 151:5eaa88a5bcc7 | 697 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 698 | Callback(const U *obj, R (T::*method)(A0) const) { |
<> | 149:156823d33999 | 699 | generate(method_context<const T, R (T::*)(A0) const>(obj, method)); |
<> | 149:156823d33999 | 700 | } |
<> | 149:156823d33999 | 701 | |
<> | 149:156823d33999 | 702 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 703 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 704 | * @param method Member function to attach |
<> | 149:156823d33999 | 705 | */ |
<> | 151:5eaa88a5bcc7 | 706 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 707 | Callback(volatile U *obj, R (T::*method)(A0) volatile) { |
<> | 149:156823d33999 | 708 | generate(method_context<volatile T, R (T::*)(A0) volatile>(obj, method)); |
<> | 149:156823d33999 | 709 | } |
<> | 149:156823d33999 | 710 | |
<> | 149:156823d33999 | 711 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 712 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 713 | * @param method Member function to attach |
<> | 149:156823d33999 | 714 | */ |
<> | 151:5eaa88a5bcc7 | 715 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 716 | Callback(const volatile U *obj, R (T::*method)(A0) const volatile) { |
<> | 149:156823d33999 | 717 | generate(method_context<const volatile T, R (T::*)(A0) const volatile>(obj, method)); |
<> | 149:156823d33999 | 718 | } |
<> | 149:156823d33999 | 719 | |
<> | 149:156823d33999 | 720 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 721 | * @param func Static function to attach |
<> | 149:156823d33999 | 722 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 723 | */ |
<> | 151:5eaa88a5bcc7 | 724 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 725 | Callback(R (*func)(T*, A0), U *arg) { |
<> | 149:156823d33999 | 726 | generate(function_context<R (*)(T*, A0), T>(func, arg)); |
<> | 149:156823d33999 | 727 | } |
<> | 149:156823d33999 | 728 | |
<> | 149:156823d33999 | 729 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 730 | * @param func Static function to attach |
<> | 149:156823d33999 | 731 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 732 | */ |
<> | 151:5eaa88a5bcc7 | 733 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 734 | Callback(R (*func)(const T*, A0), const U *arg) { |
<> | 149:156823d33999 | 735 | generate(function_context<R (*)(const T*, A0), const T>(func, arg)); |
<> | 149:156823d33999 | 736 | } |
<> | 149:156823d33999 | 737 | |
<> | 149:156823d33999 | 738 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 739 | * @param func Static function to attach |
<> | 149:156823d33999 | 740 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 741 | */ |
<> | 151:5eaa88a5bcc7 | 742 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 743 | Callback(R (*func)(volatile T*, A0), volatile U *arg) { |
<> | 149:156823d33999 | 744 | generate(function_context<R (*)(volatile T*, A0), volatile T>(func, arg)); |
<> | 149:156823d33999 | 745 | } |
<> | 149:156823d33999 | 746 | |
<> | 149:156823d33999 | 747 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 748 | * @param func Static function to attach |
<> | 149:156823d33999 | 749 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 750 | */ |
<> | 151:5eaa88a5bcc7 | 751 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 752 | Callback(R (*func)(const volatile T*, A0), const volatile U *arg) { |
<> | 149:156823d33999 | 753 | generate(function_context<R (*)(const volatile T*, A0), const volatile T>(func, arg)); |
<> | 149:156823d33999 | 754 | } |
<> | 149:156823d33999 | 755 | |
<> | 149:156823d33999 | 756 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 757 | * @param func Function object to attach |
<> | 149:156823d33999 | 758 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 759 | */ |
<> | 149:156823d33999 | 760 | template <typename F> |
<> | 149:156823d33999 | 761 | Callback(F f, typename detail::enable_if< |
<> | 149:156823d33999 | 762 | detail::is_type<R (F::*)(A0), &F::operator()>::value && |
<> | 149:156823d33999 | 763 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 764 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 765 | generate(f); |
<> | 149:156823d33999 | 766 | } |
<> | 149:156823d33999 | 767 | |
<> | 149:156823d33999 | 768 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 769 | * @param func Function object to attach |
<> | 149:156823d33999 | 770 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 771 | */ |
<> | 149:156823d33999 | 772 | template <typename F> |
<> | 149:156823d33999 | 773 | Callback(const F f, typename detail::enable_if< |
<> | 149:156823d33999 | 774 | detail::is_type<R (F::*)(A0) const, &F::operator()>::value && |
<> | 149:156823d33999 | 775 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 776 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 777 | generate(f); |
<> | 149:156823d33999 | 778 | } |
<> | 149:156823d33999 | 779 | |
<> | 149:156823d33999 | 780 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 781 | * @param func Function object to attach |
<> | 149:156823d33999 | 782 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 783 | */ |
<> | 149:156823d33999 | 784 | template <typename F> |
<> | 149:156823d33999 | 785 | Callback(volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 786 | detail::is_type<R (F::*)(A0) volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 787 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 788 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 789 | generate(f); |
<> | 149:156823d33999 | 790 | } |
<> | 149:156823d33999 | 791 | |
<> | 149:156823d33999 | 792 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 793 | * @param func Function object to attach |
<> | 149:156823d33999 | 794 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 795 | */ |
<> | 149:156823d33999 | 796 | template <typename F> |
<> | 149:156823d33999 | 797 | Callback(const volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 798 | detail::is_type<R (F::*)(A0) const volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 799 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 800 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 801 | generate(f); |
<> | 149:156823d33999 | 802 | } |
<> | 149:156823d33999 | 803 | |
<> | 149:156823d33999 | 804 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 805 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 806 | * @param func Static function to attach |
<> | 149:156823d33999 | 807 | * @deprecated |
<> | 149:156823d33999 | 808 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 809 | */ |
<> | 151:5eaa88a5bcc7 | 810 | template<typename T, typename U> |
<> | 149:156823d33999 | 811 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 812 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 813 | Callback(U *obj, R (*func)(T*, A0)) { |
<> | 149:156823d33999 | 814 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 815 | } |
<> | 149:156823d33999 | 816 | |
<> | 149:156823d33999 | 817 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 818 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 819 | * @param func Static function to attach |
<> | 149:156823d33999 | 820 | * @deprecated |
<> | 149:156823d33999 | 821 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 822 | */ |
<> | 151:5eaa88a5bcc7 | 823 | template<typename T, typename U> |
<> | 149:156823d33999 | 824 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 825 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 826 | Callback(const U *obj, R (*func)(const T*, A0)) { |
<> | 149:156823d33999 | 827 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 828 | } |
<> | 149:156823d33999 | 829 | |
<> | 149:156823d33999 | 830 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 831 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 832 | * @param func Static function to attach |
<> | 149:156823d33999 | 833 | * @deprecated |
<> | 149:156823d33999 | 834 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 835 | */ |
<> | 151:5eaa88a5bcc7 | 836 | template<typename T, typename U> |
<> | 149:156823d33999 | 837 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 838 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 839 | Callback(volatile U *obj, R (*func)(volatile T*, A0)) { |
<> | 149:156823d33999 | 840 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 841 | } |
<> | 149:156823d33999 | 842 | |
<> | 149:156823d33999 | 843 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 844 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 845 | * @param func Static function to attach |
<> | 149:156823d33999 | 846 | * @deprecated |
<> | 149:156823d33999 | 847 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 848 | */ |
<> | 151:5eaa88a5bcc7 | 849 | template<typename T, typename U> |
<> | 149:156823d33999 | 850 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 851 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 852 | Callback(const volatile U *obj, R (*func)(const volatile T*, A0)) { |
<> | 149:156823d33999 | 853 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 854 | } |
<> | 149:156823d33999 | 855 | |
<> | 149:156823d33999 | 856 | /** Destroy a callback |
<> | 149:156823d33999 | 857 | */ |
<> | 149:156823d33999 | 858 | ~Callback() { |
<> | 149:156823d33999 | 859 | if (_ops) { |
<> | 149:156823d33999 | 860 | _ops->dtor(this); |
<> | 149:156823d33999 | 861 | } |
<> | 149:156823d33999 | 862 | } |
<> | 149:156823d33999 | 863 | |
<> | 149:156823d33999 | 864 | /** Attach a static function |
<> | 149:156823d33999 | 865 | * @param func Static function to attach |
<> | 160:d5399cc887bb | 866 | * @deprecated |
<> | 160:d5399cc887bb | 867 | * Replaced by simple assignment 'Callback cb = func' |
<> | 160:d5399cc887bb | 868 | */ |
<> | 160:d5399cc887bb | 869 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 870 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 871 | void attach(R (*func)(A0)) { |
<> | 149:156823d33999 | 872 | this->~Callback(); |
<> | 149:156823d33999 | 873 | new (this) Callback(func); |
<> | 149:156823d33999 | 874 | } |
<> | 149:156823d33999 | 875 | |
<> | 149:156823d33999 | 876 | /** Attach a Callback |
<> | 149:156823d33999 | 877 | * @param func The Callback to attach |
<> | 160:d5399cc887bb | 878 | * @deprecated |
<> | 160:d5399cc887bb | 879 | * Replaced by simple assignment 'Callback cb = func' |
<> | 160:d5399cc887bb | 880 | */ |
<> | 160:d5399cc887bb | 881 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 882 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 883 | void attach(const Callback<R(A0)> &func) { |
<> | 149:156823d33999 | 884 | this->~Callback(); |
<> | 149:156823d33999 | 885 | new (this) Callback(func); |
<> | 149:156823d33999 | 886 | } |
<> | 149:156823d33999 | 887 | |
<> | 149:156823d33999 | 888 | /** Attach a member function |
<> | 149:156823d33999 | 889 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 890 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 891 | * @deprecated |
<> | 160:d5399cc887bb | 892 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 893 | */ |
<> | 151:5eaa88a5bcc7 | 894 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 895 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 896 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 897 | void attach(U *obj, R (T::*method)(A0)) { |
<> | 149:156823d33999 | 898 | this->~Callback(); |
<> | 149:156823d33999 | 899 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 900 | } |
<> | 149:156823d33999 | 901 | |
<> | 149:156823d33999 | 902 | /** Attach a member function |
<> | 149:156823d33999 | 903 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 904 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 905 | * @deprecated |
<> | 160:d5399cc887bb | 906 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 907 | */ |
<> | 151:5eaa88a5bcc7 | 908 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 909 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 910 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 911 | void attach(const U *obj, R (T::*method)(A0) const) { |
<> | 149:156823d33999 | 912 | this->~Callback(); |
<> | 149:156823d33999 | 913 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 914 | } |
<> | 149:156823d33999 | 915 | |
<> | 149:156823d33999 | 916 | /** Attach a member function |
<> | 149:156823d33999 | 917 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 918 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 919 | * @deprecated |
<> | 160:d5399cc887bb | 920 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 921 | */ |
<> | 151:5eaa88a5bcc7 | 922 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 923 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 924 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 925 | void attach(volatile U *obj, R (T::*method)(A0) volatile) { |
<> | 149:156823d33999 | 926 | this->~Callback(); |
<> | 149:156823d33999 | 927 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 928 | } |
<> | 149:156823d33999 | 929 | |
<> | 149:156823d33999 | 930 | /** Attach a member function |
<> | 149:156823d33999 | 931 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 932 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 933 | * @deprecated |
<> | 160:d5399cc887bb | 934 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 935 | */ |
<> | 151:5eaa88a5bcc7 | 936 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 937 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 938 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 939 | void attach(const volatile U *obj, R (T::*method)(A0) const volatile) { |
<> | 149:156823d33999 | 940 | this->~Callback(); |
<> | 149:156823d33999 | 941 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 942 | } |
<> | 149:156823d33999 | 943 | |
<> | 149:156823d33999 | 944 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 945 | * @param func Static function to attach |
<> | 149:156823d33999 | 946 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 947 | * @deprecated |
<> | 160:d5399cc887bb | 948 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 949 | */ |
<> | 151:5eaa88a5bcc7 | 950 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 951 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 952 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 953 | void attach(R (*func)(T*, A0), U *arg) { |
<> | 149:156823d33999 | 954 | this->~Callback(); |
<> | 149:156823d33999 | 955 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 956 | } |
<> | 149:156823d33999 | 957 | |
<> | 149:156823d33999 | 958 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 959 | * @param func Static function to attach |
<> | 149:156823d33999 | 960 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 961 | * @deprecated |
<> | 160:d5399cc887bb | 962 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 963 | */ |
<> | 151:5eaa88a5bcc7 | 964 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 965 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 966 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 967 | void attach(R (*func)(const T*, A0), const U *arg) { |
<> | 149:156823d33999 | 968 | this->~Callback(); |
<> | 149:156823d33999 | 969 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 970 | } |
<> | 149:156823d33999 | 971 | |
<> | 149:156823d33999 | 972 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 973 | * @param func Static function to attach |
<> | 149:156823d33999 | 974 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 975 | * @deprecated |
<> | 160:d5399cc887bb | 976 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 977 | */ |
<> | 151:5eaa88a5bcc7 | 978 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 979 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 980 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 981 | void attach(R (*func)(volatile T*, A0), volatile U *arg) { |
<> | 149:156823d33999 | 982 | this->~Callback(); |
<> | 149:156823d33999 | 983 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 984 | } |
<> | 149:156823d33999 | 985 | |
<> | 149:156823d33999 | 986 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 987 | * @param func Static function to attach |
<> | 149:156823d33999 | 988 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 989 | * @deprecated |
<> | 160:d5399cc887bb | 990 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 991 | */ |
<> | 151:5eaa88a5bcc7 | 992 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 993 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 994 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 995 | void attach(R (*func)(const volatile T*, A0), const volatile U *arg) { |
<> | 149:156823d33999 | 996 | this->~Callback(); |
<> | 149:156823d33999 | 997 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 998 | } |
<> | 149:156823d33999 | 999 | |
<> | 149:156823d33999 | 1000 | /** Attach a function object |
<> | 149:156823d33999 | 1001 | * @param func Function object to attach |
<> | 149:156823d33999 | 1002 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 1003 | * @deprecated |
<> | 160:d5399cc887bb | 1004 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 1005 | */ |
<> | 149:156823d33999 | 1006 | template <typename F> |
<> | 160:d5399cc887bb | 1007 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 1008 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 1009 | void attach(F f, typename detail::enable_if< |
<> | 149:156823d33999 | 1010 | detail::is_type<R (F::*)(A0), &F::operator()>::value && |
<> | 149:156823d33999 | 1011 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 1012 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 1013 | this->~Callback(); |
<> | 149:156823d33999 | 1014 | new (this) Callback(f); |
<> | 149:156823d33999 | 1015 | } |
<> | 149:156823d33999 | 1016 | |
<> | 149:156823d33999 | 1017 | /** Attach a function object |
<> | 149:156823d33999 | 1018 | * @param func Function object to attach |
<> | 149:156823d33999 | 1019 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 1020 | * @deprecated |
<> | 160:d5399cc887bb | 1021 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 1022 | */ |
<> | 149:156823d33999 | 1023 | template <typename F> |
<> | 160:d5399cc887bb | 1024 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 1025 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 1026 | void attach(const F f, typename detail::enable_if< |
<> | 149:156823d33999 | 1027 | detail::is_type<R (F::*)(A0) const, &F::operator()>::value && |
<> | 149:156823d33999 | 1028 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 1029 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 1030 | this->~Callback(); |
<> | 149:156823d33999 | 1031 | new (this) Callback(f); |
<> | 149:156823d33999 | 1032 | } |
<> | 149:156823d33999 | 1033 | |
<> | 149:156823d33999 | 1034 | /** Attach a function object |
<> | 149:156823d33999 | 1035 | * @param func Function object to attach |
<> | 149:156823d33999 | 1036 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 1037 | * @deprecated |
<> | 160:d5399cc887bb | 1038 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 1039 | */ |
<> | 149:156823d33999 | 1040 | template <typename F> |
<> | 160:d5399cc887bb | 1041 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 1042 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 1043 | void attach(volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 1044 | detail::is_type<R (F::*)(A0) volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 1045 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 1046 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 1047 | this->~Callback(); |
<> | 149:156823d33999 | 1048 | new (this) Callback(f); |
<> | 149:156823d33999 | 1049 | } |
<> | 149:156823d33999 | 1050 | |
<> | 149:156823d33999 | 1051 | /** Attach a function object |
<> | 149:156823d33999 | 1052 | * @param func Function object to attach |
<> | 149:156823d33999 | 1053 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 1054 | * @deprecated |
<> | 160:d5399cc887bb | 1055 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 1056 | */ |
<> | 149:156823d33999 | 1057 | template <typename F> |
<> | 160:d5399cc887bb | 1058 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 1059 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 1060 | void attach(const volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 1061 | detail::is_type<R (F::*)(A0) const volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 1062 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 1063 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 1064 | this->~Callback(); |
<> | 149:156823d33999 | 1065 | new (this) Callback(f); |
<> | 149:156823d33999 | 1066 | } |
<> | 149:156823d33999 | 1067 | |
<> | 149:156823d33999 | 1068 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 1069 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 1070 | * @param func Static function to attach |
<> | 149:156823d33999 | 1071 | * @deprecated |
<> | 149:156823d33999 | 1072 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 1073 | */ |
<> | 151:5eaa88a5bcc7 | 1074 | template <typename T, typename U> |
<> | 149:156823d33999 | 1075 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 1076 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 1077 | void attach(U *obj, R (*func)(T*, A0)) { |
<> | 149:156823d33999 | 1078 | this->~Callback(); |
<> | 149:156823d33999 | 1079 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 1080 | } |
<> | 149:156823d33999 | 1081 | |
<> | 149:156823d33999 | 1082 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 1083 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 1084 | * @param func Static function to attach |
<> | 149:156823d33999 | 1085 | * @deprecated |
<> | 149:156823d33999 | 1086 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 1087 | */ |
<> | 151:5eaa88a5bcc7 | 1088 | template <typename T, typename U> |
<> | 149:156823d33999 | 1089 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 1090 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 1091 | void attach(const U *obj, R (*func)(const T*, A0)) { |
<> | 149:156823d33999 | 1092 | this->~Callback(); |
<> | 149:156823d33999 | 1093 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 1094 | } |
<> | 149:156823d33999 | 1095 | |
<> | 149:156823d33999 | 1096 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 1097 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 1098 | * @param func Static function to attach |
<> | 149:156823d33999 | 1099 | * @deprecated |
<> | 149:156823d33999 | 1100 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 1101 | */ |
<> | 151:5eaa88a5bcc7 | 1102 | template <typename T, typename U> |
<> | 149:156823d33999 | 1103 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 1104 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 1105 | void attach(volatile U *obj, R (*func)(volatile T*, A0)) { |
<> | 149:156823d33999 | 1106 | this->~Callback(); |
<> | 149:156823d33999 | 1107 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 1108 | } |
<> | 149:156823d33999 | 1109 | |
<> | 149:156823d33999 | 1110 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 1111 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 1112 | * @param func Static function to attach |
<> | 149:156823d33999 | 1113 | * @deprecated |
<> | 149:156823d33999 | 1114 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 1115 | */ |
<> | 151:5eaa88a5bcc7 | 1116 | template <typename T, typename U> |
<> | 149:156823d33999 | 1117 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 1118 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 1119 | void attach(const volatile U *obj, R (*func)(const volatile T*, A0)) { |
<> | 149:156823d33999 | 1120 | this->~Callback(); |
<> | 149:156823d33999 | 1121 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 1122 | } |
<> | 149:156823d33999 | 1123 | |
<> | 149:156823d33999 | 1124 | /** Assign a callback |
<> | 149:156823d33999 | 1125 | */ |
<> | 149:156823d33999 | 1126 | Callback &operator=(const Callback &that) { |
<> | 149:156823d33999 | 1127 | if (this != &that) { |
<> | 149:156823d33999 | 1128 | this->~Callback(); |
<> | 149:156823d33999 | 1129 | new (this) Callback(that); |
<> | 149:156823d33999 | 1130 | } |
<> | 149:156823d33999 | 1131 | |
<> | 149:156823d33999 | 1132 | return *this; |
<> | 149:156823d33999 | 1133 | } |
<> | 149:156823d33999 | 1134 | |
<> | 149:156823d33999 | 1135 | /** Call the attached function |
<> | 149:156823d33999 | 1136 | */ |
<> | 149:156823d33999 | 1137 | R call(A0 a0) const { |
<> | 149:156823d33999 | 1138 | MBED_ASSERT(_ops); |
<> | 149:156823d33999 | 1139 | return _ops->call(this, a0); |
<> | 149:156823d33999 | 1140 | } |
<> | 149:156823d33999 | 1141 | |
<> | 149:156823d33999 | 1142 | /** Call the attached function |
<> | 149:156823d33999 | 1143 | */ |
<> | 149:156823d33999 | 1144 | R operator()(A0 a0) const { |
<> | 149:156823d33999 | 1145 | return call(a0); |
<> | 149:156823d33999 | 1146 | } |
<> | 149:156823d33999 | 1147 | |
<> | 149:156823d33999 | 1148 | /** Test if function has been attached |
<> | 149:156823d33999 | 1149 | */ |
<> | 149:156823d33999 | 1150 | operator bool() const { |
<> | 149:156823d33999 | 1151 | return _ops; |
<> | 149:156823d33999 | 1152 | } |
<> | 149:156823d33999 | 1153 | |
<> | 149:156823d33999 | 1154 | /** Test for equality |
<> | 149:156823d33999 | 1155 | */ |
<> | 149:156823d33999 | 1156 | friend bool operator==(const Callback &l, const Callback &r) { |
<> | 149:156823d33999 | 1157 | return memcmp(&l, &r, sizeof(Callback)) == 0; |
<> | 149:156823d33999 | 1158 | } |
<> | 149:156823d33999 | 1159 | |
<> | 149:156823d33999 | 1160 | /** Test for inequality |
<> | 149:156823d33999 | 1161 | */ |
<> | 149:156823d33999 | 1162 | friend bool operator!=(const Callback &l, const Callback &r) { |
<> | 149:156823d33999 | 1163 | return !(l == r); |
<> | 149:156823d33999 | 1164 | } |
<> | 149:156823d33999 | 1165 | |
<> | 149:156823d33999 | 1166 | /** Static thunk for passing as C-style function |
<> | 149:156823d33999 | 1167 | * @param func Callback to call passed as void pointer |
<> | 149:156823d33999 | 1168 | */ |
<> | 149:156823d33999 | 1169 | static R thunk(void *func, A0 a0) { |
<> | 149:156823d33999 | 1170 | return static_cast<Callback*>(func)->call(a0); |
<> | 149:156823d33999 | 1171 | } |
<> | 149:156823d33999 | 1172 | |
<> | 149:156823d33999 | 1173 | private: |
<> | 149:156823d33999 | 1174 | // Stored as pointer to function and pointer to optional object |
<> | 149:156823d33999 | 1175 | // Function pointer is stored as union of possible function types |
<> | 149:156823d33999 | 1176 | // to garuntee proper size and alignment |
<> | 149:156823d33999 | 1177 | struct _class; |
<> | 149:156823d33999 | 1178 | union { |
<> | 149:156823d33999 | 1179 | void (*_staticfunc)(A0); |
<> | 149:156823d33999 | 1180 | void (*_boundfunc)(_class*, A0); |
<> | 149:156823d33999 | 1181 | void (_class::*_methodfunc)(A0); |
<> | 149:156823d33999 | 1182 | } _func; |
<> | 149:156823d33999 | 1183 | void *_obj; |
<> | 149:156823d33999 | 1184 | |
<> | 149:156823d33999 | 1185 | // Dynamically dispatched operations |
<> | 149:156823d33999 | 1186 | const struct ops { |
<> | 149:156823d33999 | 1187 | R (*call)(const void*, A0); |
<> | 149:156823d33999 | 1188 | void (*move)(void*, const void*); |
<> | 149:156823d33999 | 1189 | void (*dtor)(void*); |
<> | 149:156823d33999 | 1190 | } *_ops; |
<> | 149:156823d33999 | 1191 | |
<> | 149:156823d33999 | 1192 | // Generate operations for function object |
<> | 149:156823d33999 | 1193 | template <typename F> |
<> | 149:156823d33999 | 1194 | void generate(const F &f) { |
<> | 149:156823d33999 | 1195 | static const ops ops = { |
<> | 149:156823d33999 | 1196 | &Callback::function_call<F>, |
<> | 149:156823d33999 | 1197 | &Callback::function_move<F>, |
<> | 149:156823d33999 | 1198 | &Callback::function_dtor<F>, |
<> | 149:156823d33999 | 1199 | }; |
<> | 149:156823d33999 | 1200 | |
<> | 151:5eaa88a5bcc7 | 1201 | MBED_STATIC_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F), |
<> | 151:5eaa88a5bcc7 | 1202 | "Type F must not exceed the size of the Callback class"); |
<> | 149:156823d33999 | 1203 | new (this) F(f); |
<> | 149:156823d33999 | 1204 | _ops = &ops; |
<> | 149:156823d33999 | 1205 | } |
<> | 149:156823d33999 | 1206 | |
<> | 149:156823d33999 | 1207 | // Function attributes |
<> | 149:156823d33999 | 1208 | template <typename F> |
<> | 149:156823d33999 | 1209 | static R function_call(const void *p, A0 a0) { |
<> | 149:156823d33999 | 1210 | return (*(F*)p)(a0); |
<> | 149:156823d33999 | 1211 | } |
<> | 149:156823d33999 | 1212 | |
<> | 149:156823d33999 | 1213 | template <typename F> |
<> | 149:156823d33999 | 1214 | static void function_move(void *d, const void *p) { |
<> | 149:156823d33999 | 1215 | new (d) F(*(F*)p); |
<> | 149:156823d33999 | 1216 | } |
<> | 149:156823d33999 | 1217 | |
<> | 149:156823d33999 | 1218 | template <typename F> |
<> | 149:156823d33999 | 1219 | static void function_dtor(void *p) { |
<> | 149:156823d33999 | 1220 | ((F*)p)->~F(); |
<> | 149:156823d33999 | 1221 | } |
<> | 149:156823d33999 | 1222 | |
<> | 149:156823d33999 | 1223 | // Wrappers for functions with context |
<> | 149:156823d33999 | 1224 | template <typename O, typename M> |
<> | 149:156823d33999 | 1225 | struct method_context { |
<> | 149:156823d33999 | 1226 | M method; |
<> | 149:156823d33999 | 1227 | O *obj; |
<> | 149:156823d33999 | 1228 | |
<> | 149:156823d33999 | 1229 | method_context(O *obj, M method) |
<> | 149:156823d33999 | 1230 | : method(method), obj(obj) {} |
<> | 149:156823d33999 | 1231 | |
<> | 149:156823d33999 | 1232 | R operator()(A0 a0) const { |
<> | 149:156823d33999 | 1233 | return (obj->*method)(a0); |
<> | 149:156823d33999 | 1234 | } |
<> | 149:156823d33999 | 1235 | }; |
<> | 149:156823d33999 | 1236 | |
<> | 149:156823d33999 | 1237 | template <typename F, typename A> |
<> | 149:156823d33999 | 1238 | struct function_context { |
<> | 149:156823d33999 | 1239 | F func; |
<> | 149:156823d33999 | 1240 | A *arg; |
<> | 149:156823d33999 | 1241 | |
<> | 149:156823d33999 | 1242 | function_context(F func, A *arg) |
<> | 149:156823d33999 | 1243 | : func(func), arg(arg) {} |
<> | 149:156823d33999 | 1244 | |
<> | 149:156823d33999 | 1245 | R operator()(A0 a0) const { |
<> | 149:156823d33999 | 1246 | return func(arg, a0); |
<> | 149:156823d33999 | 1247 | } |
<> | 149:156823d33999 | 1248 | }; |
<> | 149:156823d33999 | 1249 | }; |
<> | 149:156823d33999 | 1250 | |
<> | 149:156823d33999 | 1251 | /** Callback class based on template specialization |
<> | 149:156823d33999 | 1252 | * |
<> | 149:156823d33999 | 1253 | * @Note Synchronization level: Not protected |
<> | 149:156823d33999 | 1254 | */ |
<> | 149:156823d33999 | 1255 | template <typename R, typename A0, typename A1> |
<> | 149:156823d33999 | 1256 | class Callback<R(A0, A1)> { |
<> | 149:156823d33999 | 1257 | public: |
<> | 149:156823d33999 | 1258 | /** Create a Callback with a static function |
<> | 149:156823d33999 | 1259 | * @param func Static function to attach |
<> | 149:156823d33999 | 1260 | */ |
<> | 149:156823d33999 | 1261 | Callback(R (*func)(A0, A1) = 0) { |
<> | 149:156823d33999 | 1262 | if (!func) { |
<> | 149:156823d33999 | 1263 | _ops = 0; |
<> | 149:156823d33999 | 1264 | } else { |
<> | 149:156823d33999 | 1265 | generate(func); |
<> | 149:156823d33999 | 1266 | } |
<> | 149:156823d33999 | 1267 | } |
<> | 149:156823d33999 | 1268 | |
<> | 149:156823d33999 | 1269 | /** Attach a Callback |
<> | 149:156823d33999 | 1270 | * @param func The Callback to attach |
<> | 149:156823d33999 | 1271 | */ |
<> | 149:156823d33999 | 1272 | Callback(const Callback<R(A0, A1)> &func) { |
<> | 149:156823d33999 | 1273 | if (func._ops) { |
<> | 149:156823d33999 | 1274 | func._ops->move(this, &func); |
<> | 149:156823d33999 | 1275 | } |
<> | 149:156823d33999 | 1276 | _ops = func._ops; |
<> | 149:156823d33999 | 1277 | } |
<> | 149:156823d33999 | 1278 | |
<> | 149:156823d33999 | 1279 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 1280 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 1281 | * @param method Member function to attach |
<> | 149:156823d33999 | 1282 | */ |
<> | 151:5eaa88a5bcc7 | 1283 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 1284 | Callback(U *obj, R (T::*method)(A0, A1)) { |
<> | 149:156823d33999 | 1285 | generate(method_context<T, R (T::*)(A0, A1)>(obj, method)); |
<> | 149:156823d33999 | 1286 | } |
<> | 149:156823d33999 | 1287 | |
<> | 149:156823d33999 | 1288 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 1289 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 1290 | * @param method Member function to attach |
<> | 149:156823d33999 | 1291 | */ |
<> | 151:5eaa88a5bcc7 | 1292 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 1293 | Callback(const U *obj, R (T::*method)(A0, A1) const) { |
<> | 149:156823d33999 | 1294 | generate(method_context<const T, R (T::*)(A0, A1) const>(obj, method)); |
<> | 149:156823d33999 | 1295 | } |
<> | 149:156823d33999 | 1296 | |
<> | 149:156823d33999 | 1297 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 1298 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 1299 | * @param method Member function to attach |
<> | 149:156823d33999 | 1300 | */ |
<> | 151:5eaa88a5bcc7 | 1301 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 1302 | Callback(volatile U *obj, R (T::*method)(A0, A1) volatile) { |
<> | 149:156823d33999 | 1303 | generate(method_context<volatile T, R (T::*)(A0, A1) volatile>(obj, method)); |
<> | 149:156823d33999 | 1304 | } |
<> | 149:156823d33999 | 1305 | |
<> | 149:156823d33999 | 1306 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 1307 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 1308 | * @param method Member function to attach |
<> | 149:156823d33999 | 1309 | */ |
<> | 151:5eaa88a5bcc7 | 1310 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 1311 | Callback(const volatile U *obj, R (T::*method)(A0, A1) const volatile) { |
<> | 149:156823d33999 | 1312 | generate(method_context<const volatile T, R (T::*)(A0, A1) const volatile>(obj, method)); |
<> | 149:156823d33999 | 1313 | } |
<> | 149:156823d33999 | 1314 | |
<> | 149:156823d33999 | 1315 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 1316 | * @param func Static function to attach |
<> | 149:156823d33999 | 1317 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 1318 | */ |
<> | 151:5eaa88a5bcc7 | 1319 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 1320 | Callback(R (*func)(T*, A0, A1), U *arg) { |
<> | 149:156823d33999 | 1321 | generate(function_context<R (*)(T*, A0, A1), T>(func, arg)); |
<> | 149:156823d33999 | 1322 | } |
<> | 149:156823d33999 | 1323 | |
<> | 149:156823d33999 | 1324 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 1325 | * @param func Static function to attach |
<> | 149:156823d33999 | 1326 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 1327 | */ |
<> | 151:5eaa88a5bcc7 | 1328 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 1329 | Callback(R (*func)(const T*, A0, A1), const U *arg) { |
<> | 149:156823d33999 | 1330 | generate(function_context<R (*)(const T*, A0, A1), const T>(func, arg)); |
<> | 149:156823d33999 | 1331 | } |
<> | 149:156823d33999 | 1332 | |
<> | 149:156823d33999 | 1333 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 1334 | * @param func Static function to attach |
<> | 149:156823d33999 | 1335 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 1336 | */ |
<> | 151:5eaa88a5bcc7 | 1337 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 1338 | Callback(R (*func)(volatile T*, A0, A1), volatile U *arg) { |
<> | 149:156823d33999 | 1339 | generate(function_context<R (*)(volatile T*, A0, A1), volatile T>(func, arg)); |
<> | 149:156823d33999 | 1340 | } |
<> | 149:156823d33999 | 1341 | |
<> | 149:156823d33999 | 1342 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 1343 | * @param func Static function to attach |
<> | 149:156823d33999 | 1344 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 1345 | */ |
<> | 151:5eaa88a5bcc7 | 1346 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 1347 | Callback(R (*func)(const volatile T*, A0, A1), const volatile U *arg) { |
<> | 149:156823d33999 | 1348 | generate(function_context<R (*)(const volatile T*, A0, A1), const volatile T>(func, arg)); |
<> | 149:156823d33999 | 1349 | } |
<> | 149:156823d33999 | 1350 | |
<> | 149:156823d33999 | 1351 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 1352 | * @param func Function object to attach |
<> | 149:156823d33999 | 1353 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 1354 | */ |
<> | 149:156823d33999 | 1355 | template <typename F> |
<> | 149:156823d33999 | 1356 | Callback(F f, typename detail::enable_if< |
<> | 149:156823d33999 | 1357 | detail::is_type<R (F::*)(A0, A1), &F::operator()>::value && |
<> | 149:156823d33999 | 1358 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 1359 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 1360 | generate(f); |
<> | 149:156823d33999 | 1361 | } |
<> | 149:156823d33999 | 1362 | |
<> | 149:156823d33999 | 1363 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 1364 | * @param func Function object to attach |
<> | 149:156823d33999 | 1365 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 1366 | */ |
<> | 149:156823d33999 | 1367 | template <typename F> |
<> | 149:156823d33999 | 1368 | Callback(const F f, typename detail::enable_if< |
<> | 149:156823d33999 | 1369 | detail::is_type<R (F::*)(A0, A1) const, &F::operator()>::value && |
<> | 149:156823d33999 | 1370 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 1371 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 1372 | generate(f); |
<> | 149:156823d33999 | 1373 | } |
<> | 149:156823d33999 | 1374 | |
<> | 149:156823d33999 | 1375 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 1376 | * @param func Function object to attach |
<> | 149:156823d33999 | 1377 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 1378 | */ |
<> | 149:156823d33999 | 1379 | template <typename F> |
<> | 149:156823d33999 | 1380 | Callback(volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 1381 | detail::is_type<R (F::*)(A0, A1) volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 1382 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 1383 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 1384 | generate(f); |
<> | 149:156823d33999 | 1385 | } |
<> | 149:156823d33999 | 1386 | |
<> | 149:156823d33999 | 1387 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 1388 | * @param func Function object to attach |
<> | 149:156823d33999 | 1389 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 1390 | */ |
<> | 149:156823d33999 | 1391 | template <typename F> |
<> | 149:156823d33999 | 1392 | Callback(const volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 1393 | detail::is_type<R (F::*)(A0, A1) const volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 1394 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 1395 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 1396 | generate(f); |
<> | 149:156823d33999 | 1397 | } |
<> | 149:156823d33999 | 1398 | |
<> | 149:156823d33999 | 1399 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 1400 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 1401 | * @param func Static function to attach |
<> | 149:156823d33999 | 1402 | * @deprecated |
<> | 149:156823d33999 | 1403 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 1404 | */ |
<> | 151:5eaa88a5bcc7 | 1405 | template<typename T, typename U> |
<> | 149:156823d33999 | 1406 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 1407 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 1408 | Callback(U *obj, R (*func)(T*, A0, A1)) { |
<> | 149:156823d33999 | 1409 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 1410 | } |
<> | 149:156823d33999 | 1411 | |
<> | 149:156823d33999 | 1412 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 1413 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 1414 | * @param func Static function to attach |
<> | 149:156823d33999 | 1415 | * @deprecated |
<> | 149:156823d33999 | 1416 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 1417 | */ |
<> | 151:5eaa88a5bcc7 | 1418 | template<typename T, typename U> |
<> | 149:156823d33999 | 1419 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 1420 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 1421 | Callback(const U *obj, R (*func)(const T*, A0, A1)) { |
<> | 149:156823d33999 | 1422 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 1423 | } |
<> | 149:156823d33999 | 1424 | |
<> | 149:156823d33999 | 1425 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 1426 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 1427 | * @param func Static function to attach |
<> | 149:156823d33999 | 1428 | * @deprecated |
<> | 149:156823d33999 | 1429 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 1430 | */ |
<> | 151:5eaa88a5bcc7 | 1431 | template<typename T, typename U> |
<> | 149:156823d33999 | 1432 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 1433 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 1434 | Callback(volatile U *obj, R (*func)(volatile T*, A0, A1)) { |
<> | 149:156823d33999 | 1435 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 1436 | } |
<> | 149:156823d33999 | 1437 | |
<> | 149:156823d33999 | 1438 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 1439 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 1440 | * @param func Static function to attach |
<> | 149:156823d33999 | 1441 | * @deprecated |
<> | 149:156823d33999 | 1442 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 1443 | */ |
<> | 151:5eaa88a5bcc7 | 1444 | template<typename T, typename U> |
<> | 149:156823d33999 | 1445 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 1446 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 1447 | Callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1)) { |
<> | 149:156823d33999 | 1448 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 1449 | } |
<> | 149:156823d33999 | 1450 | |
<> | 149:156823d33999 | 1451 | /** Destroy a callback |
<> | 149:156823d33999 | 1452 | */ |
<> | 149:156823d33999 | 1453 | ~Callback() { |
<> | 149:156823d33999 | 1454 | if (_ops) { |
<> | 149:156823d33999 | 1455 | _ops->dtor(this); |
<> | 149:156823d33999 | 1456 | } |
<> | 149:156823d33999 | 1457 | } |
<> | 149:156823d33999 | 1458 | |
<> | 149:156823d33999 | 1459 | /** Attach a static function |
<> | 149:156823d33999 | 1460 | * @param func Static function to attach |
<> | 160:d5399cc887bb | 1461 | * @deprecated |
<> | 160:d5399cc887bb | 1462 | * Replaced by simple assignment 'Callback cb = func' |
<> | 160:d5399cc887bb | 1463 | */ |
<> | 160:d5399cc887bb | 1464 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 1465 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 1466 | void attach(R (*func)(A0, A1)) { |
<> | 149:156823d33999 | 1467 | this->~Callback(); |
<> | 149:156823d33999 | 1468 | new (this) Callback(func); |
<> | 149:156823d33999 | 1469 | } |
<> | 149:156823d33999 | 1470 | |
<> | 149:156823d33999 | 1471 | /** Attach a Callback |
<> | 149:156823d33999 | 1472 | * @param func The Callback to attach |
<> | 160:d5399cc887bb | 1473 | * @deprecated |
<> | 160:d5399cc887bb | 1474 | * Replaced by simple assignment 'Callback cb = func' |
<> | 160:d5399cc887bb | 1475 | */ |
<> | 160:d5399cc887bb | 1476 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 1477 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 1478 | void attach(const Callback<R(A0, A1)> &func) { |
<> | 149:156823d33999 | 1479 | this->~Callback(); |
<> | 149:156823d33999 | 1480 | new (this) Callback(func); |
<> | 149:156823d33999 | 1481 | } |
<> | 149:156823d33999 | 1482 | |
<> | 149:156823d33999 | 1483 | /** Attach a member function |
<> | 149:156823d33999 | 1484 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 1485 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 1486 | * @deprecated |
<> | 160:d5399cc887bb | 1487 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 1488 | */ |
<> | 151:5eaa88a5bcc7 | 1489 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 1490 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 1491 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 1492 | void attach(U *obj, R (T::*method)(A0, A1)) { |
<> | 149:156823d33999 | 1493 | this->~Callback(); |
<> | 149:156823d33999 | 1494 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 1495 | } |
<> | 149:156823d33999 | 1496 | |
<> | 149:156823d33999 | 1497 | /** Attach a member function |
<> | 149:156823d33999 | 1498 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 1499 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 1500 | * @deprecated |
<> | 160:d5399cc887bb | 1501 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 1502 | */ |
<> | 151:5eaa88a5bcc7 | 1503 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 1504 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 1505 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 1506 | void attach(const U *obj, R (T::*method)(A0, A1) const) { |
<> | 149:156823d33999 | 1507 | this->~Callback(); |
<> | 149:156823d33999 | 1508 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 1509 | } |
<> | 149:156823d33999 | 1510 | |
<> | 149:156823d33999 | 1511 | /** Attach a member function |
<> | 149:156823d33999 | 1512 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 1513 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 1514 | * @deprecated |
<> | 160:d5399cc887bb | 1515 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 1516 | */ |
<> | 151:5eaa88a5bcc7 | 1517 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 1518 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 1519 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 1520 | void attach(volatile U *obj, R (T::*method)(A0, A1) volatile) { |
<> | 149:156823d33999 | 1521 | this->~Callback(); |
<> | 149:156823d33999 | 1522 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 1523 | } |
<> | 149:156823d33999 | 1524 | |
<> | 149:156823d33999 | 1525 | /** Attach a member function |
<> | 149:156823d33999 | 1526 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 1527 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 1528 | * @deprecated |
<> | 160:d5399cc887bb | 1529 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 1530 | */ |
<> | 151:5eaa88a5bcc7 | 1531 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 1532 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 1533 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 1534 | void attach(const volatile U *obj, R (T::*method)(A0, A1) const volatile) { |
<> | 149:156823d33999 | 1535 | this->~Callback(); |
<> | 149:156823d33999 | 1536 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 1537 | } |
<> | 149:156823d33999 | 1538 | |
<> | 149:156823d33999 | 1539 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 1540 | * @param func Static function to attach |
<> | 149:156823d33999 | 1541 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 1542 | * @deprecated |
<> | 160:d5399cc887bb | 1543 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 1544 | */ |
<> | 151:5eaa88a5bcc7 | 1545 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 1546 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 1547 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 1548 | void attach(R (*func)(T*, A0, A1), U *arg) { |
<> | 149:156823d33999 | 1549 | this->~Callback(); |
<> | 149:156823d33999 | 1550 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 1551 | } |
<> | 149:156823d33999 | 1552 | |
<> | 149:156823d33999 | 1553 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 1554 | * @param func Static function to attach |
<> | 149:156823d33999 | 1555 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 1556 | * @deprecated |
<> | 160:d5399cc887bb | 1557 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 1558 | */ |
<> | 151:5eaa88a5bcc7 | 1559 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 1560 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 1561 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 1562 | void attach(R (*func)(const T*, A0, A1), const U *arg) { |
<> | 149:156823d33999 | 1563 | this->~Callback(); |
<> | 149:156823d33999 | 1564 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 1565 | } |
<> | 149:156823d33999 | 1566 | |
<> | 149:156823d33999 | 1567 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 1568 | * @param func Static function to attach |
<> | 149:156823d33999 | 1569 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 1570 | * @deprecated |
<> | 160:d5399cc887bb | 1571 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 1572 | */ |
<> | 151:5eaa88a5bcc7 | 1573 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 1574 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 1575 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 1576 | void attach(R (*func)(volatile T*, A0, A1), volatile U *arg) { |
<> | 149:156823d33999 | 1577 | this->~Callback(); |
<> | 149:156823d33999 | 1578 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 1579 | } |
<> | 149:156823d33999 | 1580 | |
<> | 149:156823d33999 | 1581 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 1582 | * @param func Static function to attach |
<> | 149:156823d33999 | 1583 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 1584 | * @deprecated |
<> | 160:d5399cc887bb | 1585 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 1586 | */ |
<> | 151:5eaa88a5bcc7 | 1587 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 1588 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 1589 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 1590 | void attach(R (*func)(const volatile T*, A0, A1), const volatile U *arg) { |
<> | 149:156823d33999 | 1591 | this->~Callback(); |
<> | 149:156823d33999 | 1592 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 1593 | } |
<> | 149:156823d33999 | 1594 | |
<> | 149:156823d33999 | 1595 | /** Attach a function object |
<> | 149:156823d33999 | 1596 | * @param func Function object to attach |
<> | 149:156823d33999 | 1597 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 1598 | * @deprecated |
<> | 160:d5399cc887bb | 1599 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 1600 | */ |
<> | 149:156823d33999 | 1601 | template <typename F> |
<> | 160:d5399cc887bb | 1602 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 1603 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 1604 | void attach(F f, typename detail::enable_if< |
<> | 149:156823d33999 | 1605 | detail::is_type<R (F::*)(A0, A1), &F::operator()>::value && |
<> | 149:156823d33999 | 1606 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 1607 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 1608 | this->~Callback(); |
<> | 149:156823d33999 | 1609 | new (this) Callback(f); |
<> | 149:156823d33999 | 1610 | } |
<> | 149:156823d33999 | 1611 | |
<> | 149:156823d33999 | 1612 | /** Attach a function object |
<> | 149:156823d33999 | 1613 | * @param func Function object to attach |
<> | 149:156823d33999 | 1614 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 1615 | * @deprecated |
<> | 160:d5399cc887bb | 1616 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 1617 | */ |
<> | 149:156823d33999 | 1618 | template <typename F> |
<> | 160:d5399cc887bb | 1619 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 1620 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 1621 | void attach(const F f, typename detail::enable_if< |
<> | 149:156823d33999 | 1622 | detail::is_type<R (F::*)(A0, A1) const, &F::operator()>::value && |
<> | 149:156823d33999 | 1623 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 1624 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 1625 | this->~Callback(); |
<> | 149:156823d33999 | 1626 | new (this) Callback(f); |
<> | 149:156823d33999 | 1627 | } |
<> | 149:156823d33999 | 1628 | |
<> | 149:156823d33999 | 1629 | /** Attach a function object |
<> | 149:156823d33999 | 1630 | * @param func Function object to attach |
<> | 149:156823d33999 | 1631 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 1632 | * @deprecated |
<> | 160:d5399cc887bb | 1633 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 1634 | */ |
<> | 149:156823d33999 | 1635 | template <typename F> |
<> | 160:d5399cc887bb | 1636 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 1637 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 1638 | void attach(volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 1639 | detail::is_type<R (F::*)(A0, A1) volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 1640 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 1641 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 1642 | this->~Callback(); |
<> | 149:156823d33999 | 1643 | new (this) Callback(f); |
<> | 149:156823d33999 | 1644 | } |
<> | 149:156823d33999 | 1645 | |
<> | 149:156823d33999 | 1646 | /** Attach a function object |
<> | 149:156823d33999 | 1647 | * @param func Function object to attach |
<> | 149:156823d33999 | 1648 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 1649 | * @deprecated |
<> | 160:d5399cc887bb | 1650 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 1651 | */ |
<> | 149:156823d33999 | 1652 | template <typename F> |
<> | 160:d5399cc887bb | 1653 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 1654 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 1655 | void attach(const volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 1656 | detail::is_type<R (F::*)(A0, A1) const volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 1657 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 1658 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 1659 | this->~Callback(); |
<> | 149:156823d33999 | 1660 | new (this) Callback(f); |
<> | 149:156823d33999 | 1661 | } |
<> | 149:156823d33999 | 1662 | |
<> | 149:156823d33999 | 1663 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 1664 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 1665 | * @param func Static function to attach |
<> | 149:156823d33999 | 1666 | * @deprecated |
<> | 149:156823d33999 | 1667 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 1668 | */ |
<> | 151:5eaa88a5bcc7 | 1669 | template <typename T, typename U> |
<> | 149:156823d33999 | 1670 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 1671 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 1672 | void attach(U *obj, R (*func)(T*, A0, A1)) { |
<> | 149:156823d33999 | 1673 | this->~Callback(); |
<> | 149:156823d33999 | 1674 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 1675 | } |
<> | 149:156823d33999 | 1676 | |
<> | 149:156823d33999 | 1677 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 1678 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 1679 | * @param func Static function to attach |
<> | 149:156823d33999 | 1680 | * @deprecated |
<> | 149:156823d33999 | 1681 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 1682 | */ |
<> | 151:5eaa88a5bcc7 | 1683 | template <typename T, typename U> |
<> | 149:156823d33999 | 1684 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 1685 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 1686 | void attach(const U *obj, R (*func)(const T*, A0, A1)) { |
<> | 149:156823d33999 | 1687 | this->~Callback(); |
<> | 149:156823d33999 | 1688 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 1689 | } |
<> | 149:156823d33999 | 1690 | |
<> | 149:156823d33999 | 1691 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 1692 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 1693 | * @param func Static function to attach |
<> | 149:156823d33999 | 1694 | * @deprecated |
<> | 149:156823d33999 | 1695 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 1696 | */ |
<> | 151:5eaa88a5bcc7 | 1697 | template <typename T, typename U> |
<> | 149:156823d33999 | 1698 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 1699 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 1700 | void attach(volatile U *obj, R (*func)(volatile T*, A0, A1)) { |
<> | 149:156823d33999 | 1701 | this->~Callback(); |
<> | 149:156823d33999 | 1702 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 1703 | } |
<> | 149:156823d33999 | 1704 | |
<> | 149:156823d33999 | 1705 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 1706 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 1707 | * @param func Static function to attach |
<> | 149:156823d33999 | 1708 | * @deprecated |
<> | 149:156823d33999 | 1709 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 1710 | */ |
<> | 151:5eaa88a5bcc7 | 1711 | template <typename T, typename U> |
<> | 149:156823d33999 | 1712 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 1713 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 1714 | void attach(const volatile U *obj, R (*func)(const volatile T*, A0, A1)) { |
<> | 149:156823d33999 | 1715 | this->~Callback(); |
<> | 149:156823d33999 | 1716 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 1717 | } |
<> | 149:156823d33999 | 1718 | |
<> | 149:156823d33999 | 1719 | /** Assign a callback |
<> | 149:156823d33999 | 1720 | */ |
<> | 149:156823d33999 | 1721 | Callback &operator=(const Callback &that) { |
<> | 149:156823d33999 | 1722 | if (this != &that) { |
<> | 149:156823d33999 | 1723 | this->~Callback(); |
<> | 149:156823d33999 | 1724 | new (this) Callback(that); |
<> | 149:156823d33999 | 1725 | } |
<> | 149:156823d33999 | 1726 | |
<> | 149:156823d33999 | 1727 | return *this; |
<> | 149:156823d33999 | 1728 | } |
<> | 149:156823d33999 | 1729 | |
<> | 149:156823d33999 | 1730 | /** Call the attached function |
<> | 149:156823d33999 | 1731 | */ |
<> | 149:156823d33999 | 1732 | R call(A0 a0, A1 a1) const { |
<> | 149:156823d33999 | 1733 | MBED_ASSERT(_ops); |
<> | 149:156823d33999 | 1734 | return _ops->call(this, a0, a1); |
<> | 149:156823d33999 | 1735 | } |
<> | 149:156823d33999 | 1736 | |
<> | 149:156823d33999 | 1737 | /** Call the attached function |
<> | 149:156823d33999 | 1738 | */ |
<> | 149:156823d33999 | 1739 | R operator()(A0 a0, A1 a1) const { |
<> | 149:156823d33999 | 1740 | return call(a0, a1); |
<> | 149:156823d33999 | 1741 | } |
<> | 149:156823d33999 | 1742 | |
<> | 149:156823d33999 | 1743 | /** Test if function has been attached |
<> | 149:156823d33999 | 1744 | */ |
<> | 149:156823d33999 | 1745 | operator bool() const { |
<> | 149:156823d33999 | 1746 | return _ops; |
<> | 149:156823d33999 | 1747 | } |
<> | 149:156823d33999 | 1748 | |
<> | 149:156823d33999 | 1749 | /** Test for equality |
<> | 149:156823d33999 | 1750 | */ |
<> | 149:156823d33999 | 1751 | friend bool operator==(const Callback &l, const Callback &r) { |
<> | 149:156823d33999 | 1752 | return memcmp(&l, &r, sizeof(Callback)) == 0; |
<> | 149:156823d33999 | 1753 | } |
<> | 149:156823d33999 | 1754 | |
<> | 149:156823d33999 | 1755 | /** Test for inequality |
<> | 149:156823d33999 | 1756 | */ |
<> | 149:156823d33999 | 1757 | friend bool operator!=(const Callback &l, const Callback &r) { |
<> | 149:156823d33999 | 1758 | return !(l == r); |
<> | 149:156823d33999 | 1759 | } |
<> | 149:156823d33999 | 1760 | |
<> | 149:156823d33999 | 1761 | /** Static thunk for passing as C-style function |
<> | 149:156823d33999 | 1762 | * @param func Callback to call passed as void pointer |
<> | 149:156823d33999 | 1763 | */ |
<> | 149:156823d33999 | 1764 | static R thunk(void *func, A0 a0, A1 a1) { |
<> | 149:156823d33999 | 1765 | return static_cast<Callback*>(func)->call(a0, a1); |
<> | 149:156823d33999 | 1766 | } |
<> | 149:156823d33999 | 1767 | |
<> | 149:156823d33999 | 1768 | private: |
<> | 149:156823d33999 | 1769 | // Stored as pointer to function and pointer to optional object |
<> | 149:156823d33999 | 1770 | // Function pointer is stored as union of possible function types |
<> | 149:156823d33999 | 1771 | // to garuntee proper size and alignment |
<> | 149:156823d33999 | 1772 | struct _class; |
<> | 149:156823d33999 | 1773 | union { |
<> | 149:156823d33999 | 1774 | void (*_staticfunc)(A0, A1); |
<> | 149:156823d33999 | 1775 | void (*_boundfunc)(_class*, A0, A1); |
<> | 149:156823d33999 | 1776 | void (_class::*_methodfunc)(A0, A1); |
<> | 149:156823d33999 | 1777 | } _func; |
<> | 149:156823d33999 | 1778 | void *_obj; |
<> | 149:156823d33999 | 1779 | |
<> | 149:156823d33999 | 1780 | // Dynamically dispatched operations |
<> | 149:156823d33999 | 1781 | const struct ops { |
<> | 149:156823d33999 | 1782 | R (*call)(const void*, A0, A1); |
<> | 149:156823d33999 | 1783 | void (*move)(void*, const void*); |
<> | 149:156823d33999 | 1784 | void (*dtor)(void*); |
<> | 149:156823d33999 | 1785 | } *_ops; |
<> | 149:156823d33999 | 1786 | |
<> | 149:156823d33999 | 1787 | // Generate operations for function object |
<> | 149:156823d33999 | 1788 | template <typename F> |
<> | 149:156823d33999 | 1789 | void generate(const F &f) { |
<> | 149:156823d33999 | 1790 | static const ops ops = { |
<> | 149:156823d33999 | 1791 | &Callback::function_call<F>, |
<> | 149:156823d33999 | 1792 | &Callback::function_move<F>, |
<> | 149:156823d33999 | 1793 | &Callback::function_dtor<F>, |
<> | 149:156823d33999 | 1794 | }; |
<> | 149:156823d33999 | 1795 | |
<> | 151:5eaa88a5bcc7 | 1796 | MBED_STATIC_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F), |
<> | 151:5eaa88a5bcc7 | 1797 | "Type F must not exceed the size of the Callback class"); |
<> | 149:156823d33999 | 1798 | new (this) F(f); |
<> | 149:156823d33999 | 1799 | _ops = &ops; |
<> | 149:156823d33999 | 1800 | } |
<> | 149:156823d33999 | 1801 | |
<> | 149:156823d33999 | 1802 | // Function attributes |
<> | 149:156823d33999 | 1803 | template <typename F> |
<> | 149:156823d33999 | 1804 | static R function_call(const void *p, A0 a0, A1 a1) { |
<> | 149:156823d33999 | 1805 | return (*(F*)p)(a0, a1); |
<> | 149:156823d33999 | 1806 | } |
<> | 149:156823d33999 | 1807 | |
<> | 149:156823d33999 | 1808 | template <typename F> |
<> | 149:156823d33999 | 1809 | static void function_move(void *d, const void *p) { |
<> | 149:156823d33999 | 1810 | new (d) F(*(F*)p); |
<> | 149:156823d33999 | 1811 | } |
<> | 149:156823d33999 | 1812 | |
<> | 149:156823d33999 | 1813 | template <typename F> |
<> | 149:156823d33999 | 1814 | static void function_dtor(void *p) { |
<> | 149:156823d33999 | 1815 | ((F*)p)->~F(); |
<> | 149:156823d33999 | 1816 | } |
<> | 149:156823d33999 | 1817 | |
<> | 149:156823d33999 | 1818 | // Wrappers for functions with context |
<> | 149:156823d33999 | 1819 | template <typename O, typename M> |
<> | 149:156823d33999 | 1820 | struct method_context { |
<> | 149:156823d33999 | 1821 | M method; |
<> | 149:156823d33999 | 1822 | O *obj; |
<> | 149:156823d33999 | 1823 | |
<> | 149:156823d33999 | 1824 | method_context(O *obj, M method) |
<> | 149:156823d33999 | 1825 | : method(method), obj(obj) {} |
<> | 149:156823d33999 | 1826 | |
<> | 149:156823d33999 | 1827 | R operator()(A0 a0, A1 a1) const { |
<> | 149:156823d33999 | 1828 | return (obj->*method)(a0, a1); |
<> | 149:156823d33999 | 1829 | } |
<> | 149:156823d33999 | 1830 | }; |
<> | 149:156823d33999 | 1831 | |
<> | 149:156823d33999 | 1832 | template <typename F, typename A> |
<> | 149:156823d33999 | 1833 | struct function_context { |
<> | 149:156823d33999 | 1834 | F func; |
<> | 149:156823d33999 | 1835 | A *arg; |
<> | 149:156823d33999 | 1836 | |
<> | 149:156823d33999 | 1837 | function_context(F func, A *arg) |
<> | 149:156823d33999 | 1838 | : func(func), arg(arg) {} |
<> | 149:156823d33999 | 1839 | |
<> | 149:156823d33999 | 1840 | R operator()(A0 a0, A1 a1) const { |
<> | 149:156823d33999 | 1841 | return func(arg, a0, a1); |
<> | 149:156823d33999 | 1842 | } |
<> | 149:156823d33999 | 1843 | }; |
<> | 149:156823d33999 | 1844 | }; |
<> | 149:156823d33999 | 1845 | |
<> | 149:156823d33999 | 1846 | /** Callback class based on template specialization |
<> | 149:156823d33999 | 1847 | * |
<> | 149:156823d33999 | 1848 | * @Note Synchronization level: Not protected |
<> | 149:156823d33999 | 1849 | */ |
<> | 149:156823d33999 | 1850 | template <typename R, typename A0, typename A1, typename A2> |
<> | 149:156823d33999 | 1851 | class Callback<R(A0, A1, A2)> { |
<> | 149:156823d33999 | 1852 | public: |
<> | 149:156823d33999 | 1853 | /** Create a Callback with a static function |
<> | 149:156823d33999 | 1854 | * @param func Static function to attach |
<> | 149:156823d33999 | 1855 | */ |
<> | 149:156823d33999 | 1856 | Callback(R (*func)(A0, A1, A2) = 0) { |
<> | 149:156823d33999 | 1857 | if (!func) { |
<> | 149:156823d33999 | 1858 | _ops = 0; |
<> | 149:156823d33999 | 1859 | } else { |
<> | 149:156823d33999 | 1860 | generate(func); |
<> | 149:156823d33999 | 1861 | } |
<> | 149:156823d33999 | 1862 | } |
<> | 149:156823d33999 | 1863 | |
<> | 149:156823d33999 | 1864 | /** Attach a Callback |
<> | 149:156823d33999 | 1865 | * @param func The Callback to attach |
<> | 149:156823d33999 | 1866 | */ |
<> | 149:156823d33999 | 1867 | Callback(const Callback<R(A0, A1, A2)> &func) { |
<> | 149:156823d33999 | 1868 | if (func._ops) { |
<> | 149:156823d33999 | 1869 | func._ops->move(this, &func); |
<> | 149:156823d33999 | 1870 | } |
<> | 149:156823d33999 | 1871 | _ops = func._ops; |
<> | 149:156823d33999 | 1872 | } |
<> | 149:156823d33999 | 1873 | |
<> | 149:156823d33999 | 1874 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 1875 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 1876 | * @param method Member function to attach |
<> | 149:156823d33999 | 1877 | */ |
<> | 151:5eaa88a5bcc7 | 1878 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 1879 | Callback(U *obj, R (T::*method)(A0, A1, A2)) { |
<> | 149:156823d33999 | 1880 | generate(method_context<T, R (T::*)(A0, A1, A2)>(obj, method)); |
<> | 149:156823d33999 | 1881 | } |
<> | 149:156823d33999 | 1882 | |
<> | 149:156823d33999 | 1883 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 1884 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 1885 | * @param method Member function to attach |
<> | 149:156823d33999 | 1886 | */ |
<> | 151:5eaa88a5bcc7 | 1887 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 1888 | Callback(const U *obj, R (T::*method)(A0, A1, A2) const) { |
<> | 149:156823d33999 | 1889 | generate(method_context<const T, R (T::*)(A0, A1, A2) const>(obj, method)); |
<> | 149:156823d33999 | 1890 | } |
<> | 149:156823d33999 | 1891 | |
<> | 149:156823d33999 | 1892 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 1893 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 1894 | * @param method Member function to attach |
<> | 149:156823d33999 | 1895 | */ |
<> | 151:5eaa88a5bcc7 | 1896 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 1897 | Callback(volatile U *obj, R (T::*method)(A0, A1, A2) volatile) { |
<> | 149:156823d33999 | 1898 | generate(method_context<volatile T, R (T::*)(A0, A1, A2) volatile>(obj, method)); |
<> | 149:156823d33999 | 1899 | } |
<> | 149:156823d33999 | 1900 | |
<> | 149:156823d33999 | 1901 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 1902 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 1903 | * @param method Member function to attach |
<> | 149:156823d33999 | 1904 | */ |
<> | 151:5eaa88a5bcc7 | 1905 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 1906 | Callback(const volatile U *obj, R (T::*method)(A0, A1, A2) const volatile) { |
<> | 149:156823d33999 | 1907 | generate(method_context<const volatile T, R (T::*)(A0, A1, A2) const volatile>(obj, method)); |
<> | 149:156823d33999 | 1908 | } |
<> | 149:156823d33999 | 1909 | |
<> | 149:156823d33999 | 1910 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 1911 | * @param func Static function to attach |
<> | 149:156823d33999 | 1912 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 1913 | */ |
<> | 151:5eaa88a5bcc7 | 1914 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 1915 | Callback(R (*func)(T*, A0, A1, A2), U *arg) { |
<> | 149:156823d33999 | 1916 | generate(function_context<R (*)(T*, A0, A1, A2), T>(func, arg)); |
<> | 149:156823d33999 | 1917 | } |
<> | 149:156823d33999 | 1918 | |
<> | 149:156823d33999 | 1919 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 1920 | * @param func Static function to attach |
<> | 149:156823d33999 | 1921 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 1922 | */ |
<> | 151:5eaa88a5bcc7 | 1923 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 1924 | Callback(R (*func)(const T*, A0, A1, A2), const U *arg) { |
<> | 149:156823d33999 | 1925 | generate(function_context<R (*)(const T*, A0, A1, A2), const T>(func, arg)); |
<> | 149:156823d33999 | 1926 | } |
<> | 149:156823d33999 | 1927 | |
<> | 149:156823d33999 | 1928 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 1929 | * @param func Static function to attach |
<> | 149:156823d33999 | 1930 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 1931 | */ |
<> | 151:5eaa88a5bcc7 | 1932 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 1933 | Callback(R (*func)(volatile T*, A0, A1, A2), volatile U *arg) { |
<> | 149:156823d33999 | 1934 | generate(function_context<R (*)(volatile T*, A0, A1, A2), volatile T>(func, arg)); |
<> | 149:156823d33999 | 1935 | } |
<> | 149:156823d33999 | 1936 | |
<> | 149:156823d33999 | 1937 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 1938 | * @param func Static function to attach |
<> | 149:156823d33999 | 1939 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 1940 | */ |
<> | 151:5eaa88a5bcc7 | 1941 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 1942 | Callback(R (*func)(const volatile T*, A0, A1, A2), const volatile U *arg) { |
<> | 149:156823d33999 | 1943 | generate(function_context<R (*)(const volatile T*, A0, A1, A2), const volatile T>(func, arg)); |
<> | 149:156823d33999 | 1944 | } |
<> | 149:156823d33999 | 1945 | |
<> | 149:156823d33999 | 1946 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 1947 | * @param func Function object to attach |
<> | 149:156823d33999 | 1948 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 1949 | */ |
<> | 149:156823d33999 | 1950 | template <typename F> |
<> | 149:156823d33999 | 1951 | Callback(F f, typename detail::enable_if< |
<> | 149:156823d33999 | 1952 | detail::is_type<R (F::*)(A0, A1, A2), &F::operator()>::value && |
<> | 149:156823d33999 | 1953 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 1954 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 1955 | generate(f); |
<> | 149:156823d33999 | 1956 | } |
<> | 149:156823d33999 | 1957 | |
<> | 149:156823d33999 | 1958 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 1959 | * @param func Function object to attach |
<> | 149:156823d33999 | 1960 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 1961 | */ |
<> | 149:156823d33999 | 1962 | template <typename F> |
<> | 149:156823d33999 | 1963 | Callback(const F f, typename detail::enable_if< |
<> | 149:156823d33999 | 1964 | detail::is_type<R (F::*)(A0, A1, A2) const, &F::operator()>::value && |
<> | 149:156823d33999 | 1965 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 1966 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 1967 | generate(f); |
<> | 149:156823d33999 | 1968 | } |
<> | 149:156823d33999 | 1969 | |
<> | 149:156823d33999 | 1970 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 1971 | * @param func Function object to attach |
<> | 149:156823d33999 | 1972 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 1973 | */ |
<> | 149:156823d33999 | 1974 | template <typename F> |
<> | 149:156823d33999 | 1975 | Callback(volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 1976 | detail::is_type<R (F::*)(A0, A1, A2) volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 1977 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 1978 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 1979 | generate(f); |
<> | 149:156823d33999 | 1980 | } |
<> | 149:156823d33999 | 1981 | |
<> | 149:156823d33999 | 1982 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 1983 | * @param func Function object to attach |
<> | 149:156823d33999 | 1984 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 1985 | */ |
<> | 149:156823d33999 | 1986 | template <typename F> |
<> | 149:156823d33999 | 1987 | Callback(const volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 1988 | detail::is_type<R (F::*)(A0, A1, A2) const volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 1989 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 1990 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 1991 | generate(f); |
<> | 149:156823d33999 | 1992 | } |
<> | 149:156823d33999 | 1993 | |
<> | 149:156823d33999 | 1994 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 1995 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 1996 | * @param func Static function to attach |
<> | 149:156823d33999 | 1997 | * @deprecated |
<> | 149:156823d33999 | 1998 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 1999 | */ |
<> | 151:5eaa88a5bcc7 | 2000 | template<typename T, typename U> |
<> | 149:156823d33999 | 2001 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 2002 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 2003 | Callback(U *obj, R (*func)(T*, A0, A1, A2)) { |
<> | 149:156823d33999 | 2004 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 2005 | } |
<> | 149:156823d33999 | 2006 | |
<> | 149:156823d33999 | 2007 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 2008 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 2009 | * @param func Static function to attach |
<> | 149:156823d33999 | 2010 | * @deprecated |
<> | 149:156823d33999 | 2011 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 2012 | */ |
<> | 151:5eaa88a5bcc7 | 2013 | template<typename T, typename U> |
<> | 149:156823d33999 | 2014 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 2015 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 2016 | Callback(const U *obj, R (*func)(const T*, A0, A1, A2)) { |
<> | 149:156823d33999 | 2017 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 2018 | } |
<> | 149:156823d33999 | 2019 | |
<> | 149:156823d33999 | 2020 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 2021 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 2022 | * @param func Static function to attach |
<> | 149:156823d33999 | 2023 | * @deprecated |
<> | 149:156823d33999 | 2024 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 2025 | */ |
<> | 151:5eaa88a5bcc7 | 2026 | template<typename T, typename U> |
<> | 149:156823d33999 | 2027 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 2028 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 2029 | Callback(volatile U *obj, R (*func)(volatile T*, A0, A1, A2)) { |
<> | 149:156823d33999 | 2030 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 2031 | } |
<> | 149:156823d33999 | 2032 | |
<> | 149:156823d33999 | 2033 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 2034 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 2035 | * @param func Static function to attach |
<> | 149:156823d33999 | 2036 | * @deprecated |
<> | 149:156823d33999 | 2037 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 2038 | */ |
<> | 151:5eaa88a5bcc7 | 2039 | template<typename T, typename U> |
<> | 149:156823d33999 | 2040 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 2041 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 2042 | Callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2)) { |
<> | 149:156823d33999 | 2043 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 2044 | } |
<> | 149:156823d33999 | 2045 | |
<> | 149:156823d33999 | 2046 | /** Destroy a callback |
<> | 149:156823d33999 | 2047 | */ |
<> | 149:156823d33999 | 2048 | ~Callback() { |
<> | 149:156823d33999 | 2049 | if (_ops) { |
<> | 149:156823d33999 | 2050 | _ops->dtor(this); |
<> | 149:156823d33999 | 2051 | } |
<> | 149:156823d33999 | 2052 | } |
<> | 149:156823d33999 | 2053 | |
<> | 149:156823d33999 | 2054 | /** Attach a static function |
<> | 149:156823d33999 | 2055 | * @param func Static function to attach |
<> | 160:d5399cc887bb | 2056 | * @deprecated |
<> | 160:d5399cc887bb | 2057 | * Replaced by simple assignment 'Callback cb = func' |
<> | 160:d5399cc887bb | 2058 | */ |
<> | 160:d5399cc887bb | 2059 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2060 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 2061 | void attach(R (*func)(A0, A1, A2)) { |
<> | 149:156823d33999 | 2062 | this->~Callback(); |
<> | 149:156823d33999 | 2063 | new (this) Callback(func); |
<> | 149:156823d33999 | 2064 | } |
<> | 149:156823d33999 | 2065 | |
<> | 149:156823d33999 | 2066 | /** Attach a Callback |
<> | 149:156823d33999 | 2067 | * @param func The Callback to attach |
<> | 160:d5399cc887bb | 2068 | * @deprecated |
<> | 160:d5399cc887bb | 2069 | * Replaced by simple assignment 'Callback cb = func' |
<> | 160:d5399cc887bb | 2070 | */ |
<> | 160:d5399cc887bb | 2071 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2072 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 2073 | void attach(const Callback<R(A0, A1, A2)> &func) { |
<> | 149:156823d33999 | 2074 | this->~Callback(); |
<> | 149:156823d33999 | 2075 | new (this) Callback(func); |
<> | 149:156823d33999 | 2076 | } |
<> | 149:156823d33999 | 2077 | |
<> | 149:156823d33999 | 2078 | /** Attach a member function |
<> | 149:156823d33999 | 2079 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 2080 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 2081 | * @deprecated |
<> | 160:d5399cc887bb | 2082 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2083 | */ |
<> | 151:5eaa88a5bcc7 | 2084 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 2085 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2086 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 2087 | void attach(U *obj, R (T::*method)(A0, A1, A2)) { |
<> | 149:156823d33999 | 2088 | this->~Callback(); |
<> | 149:156823d33999 | 2089 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 2090 | } |
<> | 149:156823d33999 | 2091 | |
<> | 149:156823d33999 | 2092 | /** Attach a member function |
<> | 149:156823d33999 | 2093 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 2094 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 2095 | * @deprecated |
<> | 160:d5399cc887bb | 2096 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2097 | */ |
<> | 151:5eaa88a5bcc7 | 2098 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 2099 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2100 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 2101 | void attach(const U *obj, R (T::*method)(A0, A1, A2) const) { |
<> | 149:156823d33999 | 2102 | this->~Callback(); |
<> | 149:156823d33999 | 2103 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 2104 | } |
<> | 149:156823d33999 | 2105 | |
<> | 149:156823d33999 | 2106 | /** Attach a member function |
<> | 149:156823d33999 | 2107 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 2108 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 2109 | * @deprecated |
<> | 160:d5399cc887bb | 2110 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2111 | */ |
<> | 151:5eaa88a5bcc7 | 2112 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 2113 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2114 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 2115 | void attach(volatile U *obj, R (T::*method)(A0, A1, A2) volatile) { |
<> | 149:156823d33999 | 2116 | this->~Callback(); |
<> | 149:156823d33999 | 2117 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 2118 | } |
<> | 149:156823d33999 | 2119 | |
<> | 149:156823d33999 | 2120 | /** Attach a member function |
<> | 149:156823d33999 | 2121 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 2122 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 2123 | * @deprecated |
<> | 160:d5399cc887bb | 2124 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2125 | */ |
<> | 151:5eaa88a5bcc7 | 2126 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 2127 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2128 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 2129 | void attach(const volatile U *obj, R (T::*method)(A0, A1, A2) const volatile) { |
<> | 149:156823d33999 | 2130 | this->~Callback(); |
<> | 149:156823d33999 | 2131 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 2132 | } |
<> | 149:156823d33999 | 2133 | |
<> | 149:156823d33999 | 2134 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 2135 | * @param func Static function to attach |
<> | 149:156823d33999 | 2136 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 2137 | * @deprecated |
<> | 160:d5399cc887bb | 2138 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2139 | */ |
<> | 151:5eaa88a5bcc7 | 2140 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 2141 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2142 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 2143 | void attach(R (*func)(T*, A0, A1, A2), U *arg) { |
<> | 149:156823d33999 | 2144 | this->~Callback(); |
<> | 149:156823d33999 | 2145 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 2146 | } |
<> | 149:156823d33999 | 2147 | |
<> | 149:156823d33999 | 2148 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 2149 | * @param func Static function to attach |
<> | 149:156823d33999 | 2150 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 2151 | * @deprecated |
<> | 160:d5399cc887bb | 2152 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2153 | */ |
<> | 151:5eaa88a5bcc7 | 2154 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 2155 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2156 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 2157 | void attach(R (*func)(const T*, A0, A1, A2), const U *arg) { |
<> | 149:156823d33999 | 2158 | this->~Callback(); |
<> | 149:156823d33999 | 2159 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 2160 | } |
<> | 149:156823d33999 | 2161 | |
<> | 149:156823d33999 | 2162 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 2163 | * @param func Static function to attach |
<> | 149:156823d33999 | 2164 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 2165 | * @deprecated |
<> | 160:d5399cc887bb | 2166 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2167 | */ |
<> | 151:5eaa88a5bcc7 | 2168 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 2169 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2170 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 2171 | void attach(R (*func)(volatile T*, A0, A1, A2), volatile U *arg) { |
<> | 149:156823d33999 | 2172 | this->~Callback(); |
<> | 149:156823d33999 | 2173 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 2174 | } |
<> | 149:156823d33999 | 2175 | |
<> | 149:156823d33999 | 2176 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 2177 | * @param func Static function to attach |
<> | 149:156823d33999 | 2178 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 2179 | * @deprecated |
<> | 160:d5399cc887bb | 2180 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2181 | */ |
<> | 151:5eaa88a5bcc7 | 2182 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 2183 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2184 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 2185 | void attach(R (*func)(const volatile T*, A0, A1, A2), const volatile U *arg) { |
<> | 149:156823d33999 | 2186 | this->~Callback(); |
<> | 149:156823d33999 | 2187 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 2188 | } |
<> | 149:156823d33999 | 2189 | |
<> | 149:156823d33999 | 2190 | /** Attach a function object |
<> | 149:156823d33999 | 2191 | * @param func Function object to attach |
<> | 149:156823d33999 | 2192 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 2193 | * @deprecated |
<> | 160:d5399cc887bb | 2194 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2195 | */ |
<> | 149:156823d33999 | 2196 | template <typename F> |
<> | 160:d5399cc887bb | 2197 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2198 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 2199 | void attach(F f, typename detail::enable_if< |
<> | 149:156823d33999 | 2200 | detail::is_type<R (F::*)(A0, A1, A2), &F::operator()>::value && |
<> | 149:156823d33999 | 2201 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 2202 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 2203 | this->~Callback(); |
<> | 149:156823d33999 | 2204 | new (this) Callback(f); |
<> | 149:156823d33999 | 2205 | } |
<> | 149:156823d33999 | 2206 | |
<> | 149:156823d33999 | 2207 | /** Attach a function object |
<> | 149:156823d33999 | 2208 | * @param func Function object to attach |
<> | 149:156823d33999 | 2209 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 2210 | * @deprecated |
<> | 160:d5399cc887bb | 2211 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2212 | */ |
<> | 149:156823d33999 | 2213 | template <typename F> |
<> | 160:d5399cc887bb | 2214 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2215 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 2216 | void attach(const F f, typename detail::enable_if< |
<> | 149:156823d33999 | 2217 | detail::is_type<R (F::*)(A0, A1, A2) const, &F::operator()>::value && |
<> | 149:156823d33999 | 2218 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 2219 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 2220 | this->~Callback(); |
<> | 149:156823d33999 | 2221 | new (this) Callback(f); |
<> | 149:156823d33999 | 2222 | } |
<> | 149:156823d33999 | 2223 | |
<> | 149:156823d33999 | 2224 | /** Attach a function object |
<> | 149:156823d33999 | 2225 | * @param func Function object to attach |
<> | 149:156823d33999 | 2226 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 2227 | * @deprecated |
<> | 160:d5399cc887bb | 2228 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2229 | */ |
<> | 149:156823d33999 | 2230 | template <typename F> |
<> | 160:d5399cc887bb | 2231 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2232 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 2233 | void attach(volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 2234 | detail::is_type<R (F::*)(A0, A1, A2) volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 2235 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 2236 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 2237 | this->~Callback(); |
<> | 149:156823d33999 | 2238 | new (this) Callback(f); |
<> | 149:156823d33999 | 2239 | } |
<> | 149:156823d33999 | 2240 | |
<> | 149:156823d33999 | 2241 | /** Attach a function object |
<> | 149:156823d33999 | 2242 | * @param func Function object to attach |
<> | 149:156823d33999 | 2243 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 2244 | * @deprecated |
<> | 160:d5399cc887bb | 2245 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2246 | */ |
<> | 149:156823d33999 | 2247 | template <typename F> |
<> | 160:d5399cc887bb | 2248 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2249 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 2250 | void attach(const volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 2251 | detail::is_type<R (F::*)(A0, A1, A2) const volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 2252 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 2253 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 2254 | this->~Callback(); |
<> | 149:156823d33999 | 2255 | new (this) Callback(f); |
<> | 149:156823d33999 | 2256 | } |
<> | 149:156823d33999 | 2257 | |
<> | 149:156823d33999 | 2258 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 2259 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 2260 | * @param func Static function to attach |
<> | 149:156823d33999 | 2261 | * @deprecated |
<> | 149:156823d33999 | 2262 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 2263 | */ |
<> | 151:5eaa88a5bcc7 | 2264 | template <typename T, typename U> |
<> | 149:156823d33999 | 2265 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 2266 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 2267 | void attach(U *obj, R (*func)(T*, A0, A1, A2)) { |
<> | 149:156823d33999 | 2268 | this->~Callback(); |
<> | 149:156823d33999 | 2269 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 2270 | } |
<> | 149:156823d33999 | 2271 | |
<> | 149:156823d33999 | 2272 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 2273 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 2274 | * @param func Static function to attach |
<> | 149:156823d33999 | 2275 | * @deprecated |
<> | 149:156823d33999 | 2276 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 2277 | */ |
<> | 151:5eaa88a5bcc7 | 2278 | template <typename T, typename U> |
<> | 149:156823d33999 | 2279 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 2280 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 2281 | void attach(const U *obj, R (*func)(const T*, A0, A1, A2)) { |
<> | 149:156823d33999 | 2282 | this->~Callback(); |
<> | 149:156823d33999 | 2283 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 2284 | } |
<> | 149:156823d33999 | 2285 | |
<> | 149:156823d33999 | 2286 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 2287 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 2288 | * @param func Static function to attach |
<> | 149:156823d33999 | 2289 | * @deprecated |
<> | 149:156823d33999 | 2290 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 2291 | */ |
<> | 151:5eaa88a5bcc7 | 2292 | template <typename T, typename U> |
<> | 149:156823d33999 | 2293 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 2294 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 2295 | void attach(volatile U *obj, R (*func)(volatile T*, A0, A1, A2)) { |
<> | 149:156823d33999 | 2296 | this->~Callback(); |
<> | 149:156823d33999 | 2297 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 2298 | } |
<> | 149:156823d33999 | 2299 | |
<> | 149:156823d33999 | 2300 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 2301 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 2302 | * @param func Static function to attach |
<> | 149:156823d33999 | 2303 | * @deprecated |
<> | 149:156823d33999 | 2304 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 2305 | */ |
<> | 151:5eaa88a5bcc7 | 2306 | template <typename T, typename U> |
<> | 149:156823d33999 | 2307 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 2308 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 2309 | void attach(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2)) { |
<> | 149:156823d33999 | 2310 | this->~Callback(); |
<> | 149:156823d33999 | 2311 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 2312 | } |
<> | 149:156823d33999 | 2313 | |
<> | 149:156823d33999 | 2314 | /** Assign a callback |
<> | 149:156823d33999 | 2315 | */ |
<> | 149:156823d33999 | 2316 | Callback &operator=(const Callback &that) { |
<> | 149:156823d33999 | 2317 | if (this != &that) { |
<> | 149:156823d33999 | 2318 | this->~Callback(); |
<> | 149:156823d33999 | 2319 | new (this) Callback(that); |
<> | 149:156823d33999 | 2320 | } |
<> | 149:156823d33999 | 2321 | |
<> | 149:156823d33999 | 2322 | return *this; |
<> | 149:156823d33999 | 2323 | } |
<> | 149:156823d33999 | 2324 | |
<> | 149:156823d33999 | 2325 | /** Call the attached function |
<> | 149:156823d33999 | 2326 | */ |
<> | 149:156823d33999 | 2327 | R call(A0 a0, A1 a1, A2 a2) const { |
<> | 149:156823d33999 | 2328 | MBED_ASSERT(_ops); |
<> | 149:156823d33999 | 2329 | return _ops->call(this, a0, a1, a2); |
<> | 149:156823d33999 | 2330 | } |
<> | 149:156823d33999 | 2331 | |
<> | 149:156823d33999 | 2332 | /** Call the attached function |
<> | 149:156823d33999 | 2333 | */ |
<> | 149:156823d33999 | 2334 | R operator()(A0 a0, A1 a1, A2 a2) const { |
<> | 149:156823d33999 | 2335 | return call(a0, a1, a2); |
<> | 149:156823d33999 | 2336 | } |
<> | 149:156823d33999 | 2337 | |
<> | 149:156823d33999 | 2338 | /** Test if function has been attached |
<> | 149:156823d33999 | 2339 | */ |
<> | 149:156823d33999 | 2340 | operator bool() const { |
<> | 149:156823d33999 | 2341 | return _ops; |
<> | 149:156823d33999 | 2342 | } |
<> | 149:156823d33999 | 2343 | |
<> | 149:156823d33999 | 2344 | /** Test for equality |
<> | 149:156823d33999 | 2345 | */ |
<> | 149:156823d33999 | 2346 | friend bool operator==(const Callback &l, const Callback &r) { |
<> | 149:156823d33999 | 2347 | return memcmp(&l, &r, sizeof(Callback)) == 0; |
<> | 149:156823d33999 | 2348 | } |
<> | 149:156823d33999 | 2349 | |
<> | 149:156823d33999 | 2350 | /** Test for inequality |
<> | 149:156823d33999 | 2351 | */ |
<> | 149:156823d33999 | 2352 | friend bool operator!=(const Callback &l, const Callback &r) { |
<> | 149:156823d33999 | 2353 | return !(l == r); |
<> | 149:156823d33999 | 2354 | } |
<> | 149:156823d33999 | 2355 | |
<> | 149:156823d33999 | 2356 | /** Static thunk for passing as C-style function |
<> | 149:156823d33999 | 2357 | * @param func Callback to call passed as void pointer |
<> | 149:156823d33999 | 2358 | */ |
<> | 149:156823d33999 | 2359 | static R thunk(void *func, A0 a0, A1 a1, A2 a2) { |
<> | 149:156823d33999 | 2360 | return static_cast<Callback*>(func)->call(a0, a1, a2); |
<> | 149:156823d33999 | 2361 | } |
<> | 149:156823d33999 | 2362 | |
<> | 149:156823d33999 | 2363 | private: |
<> | 149:156823d33999 | 2364 | // Stored as pointer to function and pointer to optional object |
<> | 149:156823d33999 | 2365 | // Function pointer is stored as union of possible function types |
<> | 149:156823d33999 | 2366 | // to garuntee proper size and alignment |
<> | 149:156823d33999 | 2367 | struct _class; |
<> | 149:156823d33999 | 2368 | union { |
<> | 149:156823d33999 | 2369 | void (*_staticfunc)(A0, A1, A2); |
<> | 149:156823d33999 | 2370 | void (*_boundfunc)(_class*, A0, A1, A2); |
<> | 149:156823d33999 | 2371 | void (_class::*_methodfunc)(A0, A1, A2); |
<> | 149:156823d33999 | 2372 | } _func; |
<> | 149:156823d33999 | 2373 | void *_obj; |
<> | 149:156823d33999 | 2374 | |
<> | 149:156823d33999 | 2375 | // Dynamically dispatched operations |
<> | 149:156823d33999 | 2376 | const struct ops { |
<> | 149:156823d33999 | 2377 | R (*call)(const void*, A0, A1, A2); |
<> | 149:156823d33999 | 2378 | void (*move)(void*, const void*); |
<> | 149:156823d33999 | 2379 | void (*dtor)(void*); |
<> | 149:156823d33999 | 2380 | } *_ops; |
<> | 149:156823d33999 | 2381 | |
<> | 149:156823d33999 | 2382 | // Generate operations for function object |
<> | 149:156823d33999 | 2383 | template <typename F> |
<> | 149:156823d33999 | 2384 | void generate(const F &f) { |
<> | 149:156823d33999 | 2385 | static const ops ops = { |
<> | 149:156823d33999 | 2386 | &Callback::function_call<F>, |
<> | 149:156823d33999 | 2387 | &Callback::function_move<F>, |
<> | 149:156823d33999 | 2388 | &Callback::function_dtor<F>, |
<> | 149:156823d33999 | 2389 | }; |
<> | 149:156823d33999 | 2390 | |
<> | 151:5eaa88a5bcc7 | 2391 | MBED_STATIC_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F), |
<> | 151:5eaa88a5bcc7 | 2392 | "Type F must not exceed the size of the Callback class"); |
<> | 149:156823d33999 | 2393 | new (this) F(f); |
<> | 149:156823d33999 | 2394 | _ops = &ops; |
<> | 149:156823d33999 | 2395 | } |
<> | 149:156823d33999 | 2396 | |
<> | 149:156823d33999 | 2397 | // Function attributes |
<> | 149:156823d33999 | 2398 | template <typename F> |
<> | 149:156823d33999 | 2399 | static R function_call(const void *p, A0 a0, A1 a1, A2 a2) { |
<> | 149:156823d33999 | 2400 | return (*(F*)p)(a0, a1, a2); |
<> | 149:156823d33999 | 2401 | } |
<> | 149:156823d33999 | 2402 | |
<> | 149:156823d33999 | 2403 | template <typename F> |
<> | 149:156823d33999 | 2404 | static void function_move(void *d, const void *p) { |
<> | 149:156823d33999 | 2405 | new (d) F(*(F*)p); |
<> | 149:156823d33999 | 2406 | } |
<> | 149:156823d33999 | 2407 | |
<> | 149:156823d33999 | 2408 | template <typename F> |
<> | 149:156823d33999 | 2409 | static void function_dtor(void *p) { |
<> | 149:156823d33999 | 2410 | ((F*)p)->~F(); |
<> | 149:156823d33999 | 2411 | } |
<> | 149:156823d33999 | 2412 | |
<> | 149:156823d33999 | 2413 | // Wrappers for functions with context |
<> | 149:156823d33999 | 2414 | template <typename O, typename M> |
<> | 149:156823d33999 | 2415 | struct method_context { |
<> | 149:156823d33999 | 2416 | M method; |
<> | 149:156823d33999 | 2417 | O *obj; |
<> | 149:156823d33999 | 2418 | |
<> | 149:156823d33999 | 2419 | method_context(O *obj, M method) |
<> | 149:156823d33999 | 2420 | : method(method), obj(obj) {} |
<> | 149:156823d33999 | 2421 | |
<> | 149:156823d33999 | 2422 | R operator()(A0 a0, A1 a1, A2 a2) const { |
<> | 149:156823d33999 | 2423 | return (obj->*method)(a0, a1, a2); |
<> | 149:156823d33999 | 2424 | } |
<> | 149:156823d33999 | 2425 | }; |
<> | 149:156823d33999 | 2426 | |
<> | 149:156823d33999 | 2427 | template <typename F, typename A> |
<> | 149:156823d33999 | 2428 | struct function_context { |
<> | 149:156823d33999 | 2429 | F func; |
<> | 149:156823d33999 | 2430 | A *arg; |
<> | 149:156823d33999 | 2431 | |
<> | 149:156823d33999 | 2432 | function_context(F func, A *arg) |
<> | 149:156823d33999 | 2433 | : func(func), arg(arg) {} |
<> | 149:156823d33999 | 2434 | |
<> | 149:156823d33999 | 2435 | R operator()(A0 a0, A1 a1, A2 a2) const { |
<> | 149:156823d33999 | 2436 | return func(arg, a0, a1, a2); |
<> | 149:156823d33999 | 2437 | } |
<> | 149:156823d33999 | 2438 | }; |
<> | 149:156823d33999 | 2439 | }; |
<> | 149:156823d33999 | 2440 | |
<> | 149:156823d33999 | 2441 | /** Callback class based on template specialization |
<> | 149:156823d33999 | 2442 | * |
<> | 149:156823d33999 | 2443 | * @Note Synchronization level: Not protected |
<> | 149:156823d33999 | 2444 | */ |
<> | 149:156823d33999 | 2445 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
<> | 149:156823d33999 | 2446 | class Callback<R(A0, A1, A2, A3)> { |
<> | 149:156823d33999 | 2447 | public: |
<> | 149:156823d33999 | 2448 | /** Create a Callback with a static function |
<> | 149:156823d33999 | 2449 | * @param func Static function to attach |
<> | 149:156823d33999 | 2450 | */ |
<> | 149:156823d33999 | 2451 | Callback(R (*func)(A0, A1, A2, A3) = 0) { |
<> | 149:156823d33999 | 2452 | if (!func) { |
<> | 149:156823d33999 | 2453 | _ops = 0; |
<> | 149:156823d33999 | 2454 | } else { |
<> | 149:156823d33999 | 2455 | generate(func); |
<> | 149:156823d33999 | 2456 | } |
<> | 149:156823d33999 | 2457 | } |
<> | 149:156823d33999 | 2458 | |
<> | 149:156823d33999 | 2459 | /** Attach a Callback |
<> | 149:156823d33999 | 2460 | * @param func The Callback to attach |
<> | 149:156823d33999 | 2461 | */ |
<> | 149:156823d33999 | 2462 | Callback(const Callback<R(A0, A1, A2, A3)> &func) { |
<> | 149:156823d33999 | 2463 | if (func._ops) { |
<> | 149:156823d33999 | 2464 | func._ops->move(this, &func); |
<> | 149:156823d33999 | 2465 | } |
<> | 149:156823d33999 | 2466 | _ops = func._ops; |
<> | 149:156823d33999 | 2467 | } |
<> | 149:156823d33999 | 2468 | |
<> | 149:156823d33999 | 2469 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 2470 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 2471 | * @param method Member function to attach |
<> | 149:156823d33999 | 2472 | */ |
<> | 151:5eaa88a5bcc7 | 2473 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 2474 | Callback(U *obj, R (T::*method)(A0, A1, A2, A3)) { |
<> | 149:156823d33999 | 2475 | generate(method_context<T, R (T::*)(A0, A1, A2, A3)>(obj, method)); |
<> | 149:156823d33999 | 2476 | } |
<> | 149:156823d33999 | 2477 | |
<> | 149:156823d33999 | 2478 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 2479 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 2480 | * @param method Member function to attach |
<> | 149:156823d33999 | 2481 | */ |
<> | 151:5eaa88a5bcc7 | 2482 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 2483 | Callback(const U *obj, R (T::*method)(A0, A1, A2, A3) const) { |
<> | 149:156823d33999 | 2484 | generate(method_context<const T, R (T::*)(A0, A1, A2, A3) const>(obj, method)); |
<> | 149:156823d33999 | 2485 | } |
<> | 149:156823d33999 | 2486 | |
<> | 149:156823d33999 | 2487 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 2488 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 2489 | * @param method Member function to attach |
<> | 149:156823d33999 | 2490 | */ |
<> | 151:5eaa88a5bcc7 | 2491 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 2492 | Callback(volatile U *obj, R (T::*method)(A0, A1, A2, A3) volatile) { |
<> | 149:156823d33999 | 2493 | generate(method_context<volatile T, R (T::*)(A0, A1, A2, A3) volatile>(obj, method)); |
<> | 149:156823d33999 | 2494 | } |
<> | 149:156823d33999 | 2495 | |
<> | 149:156823d33999 | 2496 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 2497 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 2498 | * @param method Member function to attach |
<> | 149:156823d33999 | 2499 | */ |
<> | 151:5eaa88a5bcc7 | 2500 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 2501 | Callback(const volatile U *obj, R (T::*method)(A0, A1, A2, A3) const volatile) { |
<> | 149:156823d33999 | 2502 | generate(method_context<const volatile T, R (T::*)(A0, A1, A2, A3) const volatile>(obj, method)); |
<> | 149:156823d33999 | 2503 | } |
<> | 149:156823d33999 | 2504 | |
<> | 149:156823d33999 | 2505 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 2506 | * @param func Static function to attach |
<> | 149:156823d33999 | 2507 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 2508 | */ |
<> | 151:5eaa88a5bcc7 | 2509 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 2510 | Callback(R (*func)(T*, A0, A1, A2, A3), U *arg) { |
<> | 149:156823d33999 | 2511 | generate(function_context<R (*)(T*, A0, A1, A2, A3), T>(func, arg)); |
<> | 149:156823d33999 | 2512 | } |
<> | 149:156823d33999 | 2513 | |
<> | 149:156823d33999 | 2514 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 2515 | * @param func Static function to attach |
<> | 149:156823d33999 | 2516 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 2517 | */ |
<> | 151:5eaa88a5bcc7 | 2518 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 2519 | Callback(R (*func)(const T*, A0, A1, A2, A3), const U *arg) { |
<> | 149:156823d33999 | 2520 | generate(function_context<R (*)(const T*, A0, A1, A2, A3), const T>(func, arg)); |
<> | 149:156823d33999 | 2521 | } |
<> | 149:156823d33999 | 2522 | |
<> | 149:156823d33999 | 2523 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 2524 | * @param func Static function to attach |
<> | 149:156823d33999 | 2525 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 2526 | */ |
<> | 151:5eaa88a5bcc7 | 2527 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 2528 | Callback(R (*func)(volatile T*, A0, A1, A2, A3), volatile U *arg) { |
<> | 149:156823d33999 | 2529 | generate(function_context<R (*)(volatile T*, A0, A1, A2, A3), volatile T>(func, arg)); |
<> | 149:156823d33999 | 2530 | } |
<> | 149:156823d33999 | 2531 | |
<> | 149:156823d33999 | 2532 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 2533 | * @param func Static function to attach |
<> | 149:156823d33999 | 2534 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 2535 | */ |
<> | 151:5eaa88a5bcc7 | 2536 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 2537 | Callback(R (*func)(const volatile T*, A0, A1, A2, A3), const volatile U *arg) { |
<> | 149:156823d33999 | 2538 | generate(function_context<R (*)(const volatile T*, A0, A1, A2, A3), const volatile T>(func, arg)); |
<> | 149:156823d33999 | 2539 | } |
<> | 149:156823d33999 | 2540 | |
<> | 149:156823d33999 | 2541 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 2542 | * @param func Function object to attach |
<> | 149:156823d33999 | 2543 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 2544 | */ |
<> | 149:156823d33999 | 2545 | template <typename F> |
<> | 149:156823d33999 | 2546 | Callback(F f, typename detail::enable_if< |
<> | 149:156823d33999 | 2547 | detail::is_type<R (F::*)(A0, A1, A2, A3), &F::operator()>::value && |
<> | 149:156823d33999 | 2548 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 2549 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 2550 | generate(f); |
<> | 149:156823d33999 | 2551 | } |
<> | 149:156823d33999 | 2552 | |
<> | 149:156823d33999 | 2553 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 2554 | * @param func Function object to attach |
<> | 149:156823d33999 | 2555 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 2556 | */ |
<> | 149:156823d33999 | 2557 | template <typename F> |
<> | 149:156823d33999 | 2558 | Callback(const F f, typename detail::enable_if< |
<> | 149:156823d33999 | 2559 | detail::is_type<R (F::*)(A0, A1, A2, A3) const, &F::operator()>::value && |
<> | 149:156823d33999 | 2560 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 2561 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 2562 | generate(f); |
<> | 149:156823d33999 | 2563 | } |
<> | 149:156823d33999 | 2564 | |
<> | 149:156823d33999 | 2565 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 2566 | * @param func Function object to attach |
<> | 149:156823d33999 | 2567 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 2568 | */ |
<> | 149:156823d33999 | 2569 | template <typename F> |
<> | 149:156823d33999 | 2570 | Callback(volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 2571 | detail::is_type<R (F::*)(A0, A1, A2, A3) volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 2572 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 2573 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 2574 | generate(f); |
<> | 149:156823d33999 | 2575 | } |
<> | 149:156823d33999 | 2576 | |
<> | 149:156823d33999 | 2577 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 2578 | * @param func Function object to attach |
<> | 149:156823d33999 | 2579 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 2580 | */ |
<> | 149:156823d33999 | 2581 | template <typename F> |
<> | 149:156823d33999 | 2582 | Callback(const volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 2583 | detail::is_type<R (F::*)(A0, A1, A2, A3) const volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 2584 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 2585 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 2586 | generate(f); |
<> | 149:156823d33999 | 2587 | } |
<> | 149:156823d33999 | 2588 | |
<> | 149:156823d33999 | 2589 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 2590 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 2591 | * @param func Static function to attach |
<> | 149:156823d33999 | 2592 | * @deprecated |
<> | 149:156823d33999 | 2593 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 2594 | */ |
<> | 151:5eaa88a5bcc7 | 2595 | template<typename T, typename U> |
<> | 149:156823d33999 | 2596 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 2597 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 2598 | Callback(U *obj, R (*func)(T*, A0, A1, A2, A3)) { |
<> | 149:156823d33999 | 2599 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 2600 | } |
<> | 149:156823d33999 | 2601 | |
<> | 149:156823d33999 | 2602 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 2603 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 2604 | * @param func Static function to attach |
<> | 149:156823d33999 | 2605 | * @deprecated |
<> | 149:156823d33999 | 2606 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 2607 | */ |
<> | 151:5eaa88a5bcc7 | 2608 | template<typename T, typename U> |
<> | 149:156823d33999 | 2609 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 2610 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 2611 | Callback(const U *obj, R (*func)(const T*, A0, A1, A2, A3)) { |
<> | 149:156823d33999 | 2612 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 2613 | } |
<> | 149:156823d33999 | 2614 | |
<> | 149:156823d33999 | 2615 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 2616 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 2617 | * @param func Static function to attach |
<> | 149:156823d33999 | 2618 | * @deprecated |
<> | 149:156823d33999 | 2619 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 2620 | */ |
<> | 151:5eaa88a5bcc7 | 2621 | template<typename T, typename U> |
<> | 149:156823d33999 | 2622 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 2623 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 2624 | Callback(volatile U *obj, R (*func)(volatile T*, A0, A1, A2, A3)) { |
<> | 149:156823d33999 | 2625 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 2626 | } |
<> | 149:156823d33999 | 2627 | |
<> | 149:156823d33999 | 2628 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 2629 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 2630 | * @param func Static function to attach |
<> | 149:156823d33999 | 2631 | * @deprecated |
<> | 149:156823d33999 | 2632 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 2633 | */ |
<> | 151:5eaa88a5bcc7 | 2634 | template<typename T, typename U> |
<> | 149:156823d33999 | 2635 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 2636 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 2637 | Callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2, A3)) { |
<> | 149:156823d33999 | 2638 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 2639 | } |
<> | 149:156823d33999 | 2640 | |
<> | 149:156823d33999 | 2641 | /** Destroy a callback |
<> | 149:156823d33999 | 2642 | */ |
<> | 149:156823d33999 | 2643 | ~Callback() { |
<> | 149:156823d33999 | 2644 | if (_ops) { |
<> | 149:156823d33999 | 2645 | _ops->dtor(this); |
<> | 149:156823d33999 | 2646 | } |
<> | 149:156823d33999 | 2647 | } |
<> | 149:156823d33999 | 2648 | |
<> | 149:156823d33999 | 2649 | /** Attach a static function |
<> | 149:156823d33999 | 2650 | * @param func Static function to attach |
<> | 160:d5399cc887bb | 2651 | * @deprecated |
<> | 160:d5399cc887bb | 2652 | * Replaced by simple assignment 'Callback cb = func' |
<> | 160:d5399cc887bb | 2653 | */ |
<> | 160:d5399cc887bb | 2654 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2655 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 2656 | void attach(R (*func)(A0, A1, A2, A3)) { |
<> | 149:156823d33999 | 2657 | this->~Callback(); |
<> | 149:156823d33999 | 2658 | new (this) Callback(func); |
<> | 149:156823d33999 | 2659 | } |
<> | 149:156823d33999 | 2660 | |
<> | 149:156823d33999 | 2661 | /** Attach a Callback |
<> | 149:156823d33999 | 2662 | * @param func The Callback to attach |
<> | 160:d5399cc887bb | 2663 | * @deprecated |
<> | 160:d5399cc887bb | 2664 | * Replaced by simple assignment 'Callback cb = func' |
<> | 160:d5399cc887bb | 2665 | */ |
<> | 160:d5399cc887bb | 2666 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2667 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 2668 | void attach(const Callback<R(A0, A1, A2, A3)> &func) { |
<> | 149:156823d33999 | 2669 | this->~Callback(); |
<> | 149:156823d33999 | 2670 | new (this) Callback(func); |
<> | 149:156823d33999 | 2671 | } |
<> | 149:156823d33999 | 2672 | |
<> | 149:156823d33999 | 2673 | /** Attach a member function |
<> | 149:156823d33999 | 2674 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 2675 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 2676 | * @deprecated |
<> | 160:d5399cc887bb | 2677 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2678 | */ |
<> | 151:5eaa88a5bcc7 | 2679 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 2680 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2681 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 2682 | void attach(U *obj, R (T::*method)(A0, A1, A2, A3)) { |
<> | 149:156823d33999 | 2683 | this->~Callback(); |
<> | 149:156823d33999 | 2684 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 2685 | } |
<> | 149:156823d33999 | 2686 | |
<> | 149:156823d33999 | 2687 | /** Attach a member function |
<> | 149:156823d33999 | 2688 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 2689 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 2690 | * @deprecated |
<> | 160:d5399cc887bb | 2691 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2692 | */ |
<> | 151:5eaa88a5bcc7 | 2693 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 2694 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2695 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 2696 | void attach(const U *obj, R (T::*method)(A0, A1, A2, A3) const) { |
<> | 149:156823d33999 | 2697 | this->~Callback(); |
<> | 149:156823d33999 | 2698 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 2699 | } |
<> | 149:156823d33999 | 2700 | |
<> | 149:156823d33999 | 2701 | /** Attach a member function |
<> | 149:156823d33999 | 2702 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 2703 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 2704 | * @deprecated |
<> | 160:d5399cc887bb | 2705 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2706 | */ |
<> | 151:5eaa88a5bcc7 | 2707 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 2708 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2709 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 2710 | void attach(volatile U *obj, R (T::*method)(A0, A1, A2, A3) volatile) { |
<> | 149:156823d33999 | 2711 | this->~Callback(); |
<> | 149:156823d33999 | 2712 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 2713 | } |
<> | 149:156823d33999 | 2714 | |
<> | 149:156823d33999 | 2715 | /** Attach a member function |
<> | 149:156823d33999 | 2716 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 2717 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 2718 | * @deprecated |
<> | 160:d5399cc887bb | 2719 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2720 | */ |
<> | 151:5eaa88a5bcc7 | 2721 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 2722 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2723 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 2724 | void attach(const volatile U *obj, R (T::*method)(A0, A1, A2, A3) const volatile) { |
<> | 149:156823d33999 | 2725 | this->~Callback(); |
<> | 149:156823d33999 | 2726 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 2727 | } |
<> | 149:156823d33999 | 2728 | |
<> | 149:156823d33999 | 2729 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 2730 | * @param func Static function to attach |
<> | 149:156823d33999 | 2731 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 2732 | * @deprecated |
<> | 160:d5399cc887bb | 2733 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2734 | */ |
<> | 151:5eaa88a5bcc7 | 2735 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 2736 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2737 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 2738 | void attach(R (*func)(T*, A0, A1, A2, A3), U *arg) { |
<> | 149:156823d33999 | 2739 | this->~Callback(); |
<> | 149:156823d33999 | 2740 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 2741 | } |
<> | 149:156823d33999 | 2742 | |
<> | 149:156823d33999 | 2743 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 2744 | * @param func Static function to attach |
<> | 149:156823d33999 | 2745 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 2746 | * @deprecated |
<> | 160:d5399cc887bb | 2747 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2748 | */ |
<> | 151:5eaa88a5bcc7 | 2749 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 2750 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2751 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 2752 | void attach(R (*func)(const T*, A0, A1, A2, A3), const U *arg) { |
<> | 149:156823d33999 | 2753 | this->~Callback(); |
<> | 149:156823d33999 | 2754 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 2755 | } |
<> | 149:156823d33999 | 2756 | |
<> | 149:156823d33999 | 2757 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 2758 | * @param func Static function to attach |
<> | 149:156823d33999 | 2759 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 2760 | * @deprecated |
<> | 160:d5399cc887bb | 2761 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2762 | */ |
<> | 151:5eaa88a5bcc7 | 2763 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 2764 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2765 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 2766 | void attach(R (*func)(volatile T*, A0, A1, A2, A3), volatile U *arg) { |
<> | 149:156823d33999 | 2767 | this->~Callback(); |
<> | 149:156823d33999 | 2768 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 2769 | } |
<> | 149:156823d33999 | 2770 | |
<> | 149:156823d33999 | 2771 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 2772 | * @param func Static function to attach |
<> | 149:156823d33999 | 2773 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 2774 | * @deprecated |
<> | 160:d5399cc887bb | 2775 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2776 | */ |
<> | 151:5eaa88a5bcc7 | 2777 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 2778 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2779 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 2780 | void attach(R (*func)(const volatile T*, A0, A1, A2, A3), const volatile U *arg) { |
<> | 149:156823d33999 | 2781 | this->~Callback(); |
<> | 149:156823d33999 | 2782 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 2783 | } |
<> | 149:156823d33999 | 2784 | |
<> | 149:156823d33999 | 2785 | /** Attach a function object |
<> | 149:156823d33999 | 2786 | * @param func Function object to attach |
<> | 149:156823d33999 | 2787 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 2788 | * @deprecated |
<> | 160:d5399cc887bb | 2789 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2790 | */ |
<> | 149:156823d33999 | 2791 | template <typename F> |
<> | 160:d5399cc887bb | 2792 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2793 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 2794 | void attach(F f, typename detail::enable_if< |
<> | 149:156823d33999 | 2795 | detail::is_type<R (F::*)(A0, A1, A2, A3), &F::operator()>::value && |
<> | 149:156823d33999 | 2796 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 2797 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 2798 | this->~Callback(); |
<> | 149:156823d33999 | 2799 | new (this) Callback(f); |
<> | 149:156823d33999 | 2800 | } |
<> | 149:156823d33999 | 2801 | |
<> | 149:156823d33999 | 2802 | /** Attach a function object |
<> | 149:156823d33999 | 2803 | * @param func Function object to attach |
<> | 149:156823d33999 | 2804 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 2805 | * @deprecated |
<> | 160:d5399cc887bb | 2806 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2807 | */ |
<> | 149:156823d33999 | 2808 | template <typename F> |
<> | 160:d5399cc887bb | 2809 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2810 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 2811 | void attach(const F f, typename detail::enable_if< |
<> | 149:156823d33999 | 2812 | detail::is_type<R (F::*)(A0, A1, A2, A3) const, &F::operator()>::value && |
<> | 149:156823d33999 | 2813 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 2814 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 2815 | this->~Callback(); |
<> | 149:156823d33999 | 2816 | new (this) Callback(f); |
<> | 149:156823d33999 | 2817 | } |
<> | 149:156823d33999 | 2818 | |
<> | 149:156823d33999 | 2819 | /** Attach a function object |
<> | 149:156823d33999 | 2820 | * @param func Function object to attach |
<> | 149:156823d33999 | 2821 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 2822 | * @deprecated |
<> | 160:d5399cc887bb | 2823 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2824 | */ |
<> | 149:156823d33999 | 2825 | template <typename F> |
<> | 160:d5399cc887bb | 2826 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2827 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 2828 | void attach(volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 2829 | detail::is_type<R (F::*)(A0, A1, A2, A3) volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 2830 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 2831 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 2832 | this->~Callback(); |
<> | 149:156823d33999 | 2833 | new (this) Callback(f); |
<> | 149:156823d33999 | 2834 | } |
<> | 149:156823d33999 | 2835 | |
<> | 149:156823d33999 | 2836 | /** Attach a function object |
<> | 149:156823d33999 | 2837 | * @param func Function object to attach |
<> | 149:156823d33999 | 2838 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 2839 | * @deprecated |
<> | 160:d5399cc887bb | 2840 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 2841 | */ |
<> | 149:156823d33999 | 2842 | template <typename F> |
<> | 160:d5399cc887bb | 2843 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 2844 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 2845 | void attach(const volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 2846 | detail::is_type<R (F::*)(A0, A1, A2, A3) const volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 2847 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 2848 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 2849 | this->~Callback(); |
<> | 149:156823d33999 | 2850 | new (this) Callback(f); |
<> | 149:156823d33999 | 2851 | } |
<> | 149:156823d33999 | 2852 | |
<> | 149:156823d33999 | 2853 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 2854 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 2855 | * @param func Static function to attach |
<> | 149:156823d33999 | 2856 | * @deprecated |
<> | 149:156823d33999 | 2857 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 2858 | */ |
<> | 151:5eaa88a5bcc7 | 2859 | template <typename T, typename U> |
<> | 149:156823d33999 | 2860 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 2861 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 2862 | void attach(U *obj, R (*func)(T*, A0, A1, A2, A3)) { |
<> | 149:156823d33999 | 2863 | this->~Callback(); |
<> | 149:156823d33999 | 2864 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 2865 | } |
<> | 149:156823d33999 | 2866 | |
<> | 149:156823d33999 | 2867 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 2868 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 2869 | * @param func Static function to attach |
<> | 149:156823d33999 | 2870 | * @deprecated |
<> | 149:156823d33999 | 2871 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 2872 | */ |
<> | 151:5eaa88a5bcc7 | 2873 | template <typename T, typename U> |
<> | 149:156823d33999 | 2874 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 2875 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 2876 | void attach(const U *obj, R (*func)(const T*, A0, A1, A2, A3)) { |
<> | 149:156823d33999 | 2877 | this->~Callback(); |
<> | 149:156823d33999 | 2878 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 2879 | } |
<> | 149:156823d33999 | 2880 | |
<> | 149:156823d33999 | 2881 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 2882 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 2883 | * @param func Static function to attach |
<> | 149:156823d33999 | 2884 | * @deprecated |
<> | 149:156823d33999 | 2885 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 2886 | */ |
<> | 151:5eaa88a5bcc7 | 2887 | template <typename T, typename U> |
<> | 149:156823d33999 | 2888 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 2889 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 2890 | void attach(volatile U *obj, R (*func)(volatile T*, A0, A1, A2, A3)) { |
<> | 149:156823d33999 | 2891 | this->~Callback(); |
<> | 149:156823d33999 | 2892 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 2893 | } |
<> | 149:156823d33999 | 2894 | |
<> | 149:156823d33999 | 2895 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 2896 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 2897 | * @param func Static function to attach |
<> | 149:156823d33999 | 2898 | * @deprecated |
<> | 149:156823d33999 | 2899 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 2900 | */ |
<> | 151:5eaa88a5bcc7 | 2901 | template <typename T, typename U> |
<> | 149:156823d33999 | 2902 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 2903 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 2904 | void attach(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2, A3)) { |
<> | 149:156823d33999 | 2905 | this->~Callback(); |
<> | 149:156823d33999 | 2906 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 2907 | } |
<> | 149:156823d33999 | 2908 | |
<> | 149:156823d33999 | 2909 | /** Assign a callback |
<> | 149:156823d33999 | 2910 | */ |
<> | 149:156823d33999 | 2911 | Callback &operator=(const Callback &that) { |
<> | 149:156823d33999 | 2912 | if (this != &that) { |
<> | 149:156823d33999 | 2913 | this->~Callback(); |
<> | 149:156823d33999 | 2914 | new (this) Callback(that); |
<> | 149:156823d33999 | 2915 | } |
<> | 149:156823d33999 | 2916 | |
<> | 149:156823d33999 | 2917 | return *this; |
<> | 149:156823d33999 | 2918 | } |
<> | 149:156823d33999 | 2919 | |
<> | 149:156823d33999 | 2920 | /** Call the attached function |
<> | 149:156823d33999 | 2921 | */ |
<> | 149:156823d33999 | 2922 | R call(A0 a0, A1 a1, A2 a2, A3 a3) const { |
<> | 149:156823d33999 | 2923 | MBED_ASSERT(_ops); |
<> | 149:156823d33999 | 2924 | return _ops->call(this, a0, a1, a2, a3); |
<> | 149:156823d33999 | 2925 | } |
<> | 149:156823d33999 | 2926 | |
<> | 149:156823d33999 | 2927 | /** Call the attached function |
<> | 149:156823d33999 | 2928 | */ |
<> | 149:156823d33999 | 2929 | R operator()(A0 a0, A1 a1, A2 a2, A3 a3) const { |
<> | 149:156823d33999 | 2930 | return call(a0, a1, a2, a3); |
<> | 149:156823d33999 | 2931 | } |
<> | 149:156823d33999 | 2932 | |
<> | 149:156823d33999 | 2933 | /** Test if function has been attached |
<> | 149:156823d33999 | 2934 | */ |
<> | 149:156823d33999 | 2935 | operator bool() const { |
<> | 149:156823d33999 | 2936 | return _ops; |
<> | 149:156823d33999 | 2937 | } |
<> | 149:156823d33999 | 2938 | |
<> | 149:156823d33999 | 2939 | /** Test for equality |
<> | 149:156823d33999 | 2940 | */ |
<> | 149:156823d33999 | 2941 | friend bool operator==(const Callback &l, const Callback &r) { |
<> | 149:156823d33999 | 2942 | return memcmp(&l, &r, sizeof(Callback)) == 0; |
<> | 149:156823d33999 | 2943 | } |
<> | 149:156823d33999 | 2944 | |
<> | 149:156823d33999 | 2945 | /** Test for inequality |
<> | 149:156823d33999 | 2946 | */ |
<> | 149:156823d33999 | 2947 | friend bool operator!=(const Callback &l, const Callback &r) { |
<> | 149:156823d33999 | 2948 | return !(l == r); |
<> | 149:156823d33999 | 2949 | } |
<> | 149:156823d33999 | 2950 | |
<> | 149:156823d33999 | 2951 | /** Static thunk for passing as C-style function |
<> | 149:156823d33999 | 2952 | * @param func Callback to call passed as void pointer |
<> | 149:156823d33999 | 2953 | */ |
<> | 149:156823d33999 | 2954 | static R thunk(void *func, A0 a0, A1 a1, A2 a2, A3 a3) { |
<> | 149:156823d33999 | 2955 | return static_cast<Callback*>(func)->call(a0, a1, a2, a3); |
<> | 149:156823d33999 | 2956 | } |
<> | 149:156823d33999 | 2957 | |
<> | 149:156823d33999 | 2958 | private: |
<> | 149:156823d33999 | 2959 | // Stored as pointer to function and pointer to optional object |
<> | 149:156823d33999 | 2960 | // Function pointer is stored as union of possible function types |
<> | 149:156823d33999 | 2961 | // to garuntee proper size and alignment |
<> | 149:156823d33999 | 2962 | struct _class; |
<> | 149:156823d33999 | 2963 | union { |
<> | 149:156823d33999 | 2964 | void (*_staticfunc)(A0, A1, A2, A3); |
<> | 149:156823d33999 | 2965 | void (*_boundfunc)(_class*, A0, A1, A2, A3); |
<> | 149:156823d33999 | 2966 | void (_class::*_methodfunc)(A0, A1, A2, A3); |
<> | 149:156823d33999 | 2967 | } _func; |
<> | 149:156823d33999 | 2968 | void *_obj; |
<> | 149:156823d33999 | 2969 | |
<> | 149:156823d33999 | 2970 | // Dynamically dispatched operations |
<> | 149:156823d33999 | 2971 | const struct ops { |
<> | 149:156823d33999 | 2972 | R (*call)(const void*, A0, A1, A2, A3); |
<> | 149:156823d33999 | 2973 | void (*move)(void*, const void*); |
<> | 149:156823d33999 | 2974 | void (*dtor)(void*); |
<> | 149:156823d33999 | 2975 | } *_ops; |
<> | 149:156823d33999 | 2976 | |
<> | 149:156823d33999 | 2977 | // Generate operations for function object |
<> | 149:156823d33999 | 2978 | template <typename F> |
<> | 149:156823d33999 | 2979 | void generate(const F &f) { |
<> | 149:156823d33999 | 2980 | static const ops ops = { |
<> | 149:156823d33999 | 2981 | &Callback::function_call<F>, |
<> | 149:156823d33999 | 2982 | &Callback::function_move<F>, |
<> | 149:156823d33999 | 2983 | &Callback::function_dtor<F>, |
<> | 149:156823d33999 | 2984 | }; |
<> | 149:156823d33999 | 2985 | |
<> | 151:5eaa88a5bcc7 | 2986 | MBED_STATIC_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F), |
<> | 151:5eaa88a5bcc7 | 2987 | "Type F must not exceed the size of the Callback class"); |
<> | 149:156823d33999 | 2988 | new (this) F(f); |
<> | 149:156823d33999 | 2989 | _ops = &ops; |
<> | 149:156823d33999 | 2990 | } |
<> | 149:156823d33999 | 2991 | |
<> | 149:156823d33999 | 2992 | // Function attributes |
<> | 149:156823d33999 | 2993 | template <typename F> |
<> | 149:156823d33999 | 2994 | static R function_call(const void *p, A0 a0, A1 a1, A2 a2, A3 a3) { |
<> | 149:156823d33999 | 2995 | return (*(F*)p)(a0, a1, a2, a3); |
<> | 149:156823d33999 | 2996 | } |
<> | 149:156823d33999 | 2997 | |
<> | 149:156823d33999 | 2998 | template <typename F> |
<> | 149:156823d33999 | 2999 | static void function_move(void *d, const void *p) { |
<> | 149:156823d33999 | 3000 | new (d) F(*(F*)p); |
<> | 149:156823d33999 | 3001 | } |
<> | 149:156823d33999 | 3002 | |
<> | 149:156823d33999 | 3003 | template <typename F> |
<> | 149:156823d33999 | 3004 | static void function_dtor(void *p) { |
<> | 149:156823d33999 | 3005 | ((F*)p)->~F(); |
<> | 149:156823d33999 | 3006 | } |
<> | 149:156823d33999 | 3007 | |
<> | 149:156823d33999 | 3008 | // Wrappers for functions with context |
<> | 149:156823d33999 | 3009 | template <typename O, typename M> |
<> | 149:156823d33999 | 3010 | struct method_context { |
<> | 149:156823d33999 | 3011 | M method; |
<> | 149:156823d33999 | 3012 | O *obj; |
<> | 149:156823d33999 | 3013 | |
<> | 149:156823d33999 | 3014 | method_context(O *obj, M method) |
<> | 149:156823d33999 | 3015 | : method(method), obj(obj) {} |
<> | 149:156823d33999 | 3016 | |
<> | 149:156823d33999 | 3017 | R operator()(A0 a0, A1 a1, A2 a2, A3 a3) const { |
<> | 149:156823d33999 | 3018 | return (obj->*method)(a0, a1, a2, a3); |
<> | 149:156823d33999 | 3019 | } |
<> | 149:156823d33999 | 3020 | }; |
<> | 149:156823d33999 | 3021 | |
<> | 149:156823d33999 | 3022 | template <typename F, typename A> |
<> | 149:156823d33999 | 3023 | struct function_context { |
<> | 149:156823d33999 | 3024 | F func; |
<> | 149:156823d33999 | 3025 | A *arg; |
<> | 149:156823d33999 | 3026 | |
<> | 149:156823d33999 | 3027 | function_context(F func, A *arg) |
<> | 149:156823d33999 | 3028 | : func(func), arg(arg) {} |
<> | 149:156823d33999 | 3029 | |
<> | 149:156823d33999 | 3030 | R operator()(A0 a0, A1 a1, A2 a2, A3 a3) const { |
<> | 149:156823d33999 | 3031 | return func(arg, a0, a1, a2, a3); |
<> | 149:156823d33999 | 3032 | } |
<> | 149:156823d33999 | 3033 | }; |
<> | 149:156823d33999 | 3034 | }; |
<> | 149:156823d33999 | 3035 | |
<> | 149:156823d33999 | 3036 | /** Callback class based on template specialization |
<> | 149:156823d33999 | 3037 | * |
<> | 149:156823d33999 | 3038 | * @Note Synchronization level: Not protected |
<> | 149:156823d33999 | 3039 | */ |
<> | 149:156823d33999 | 3040 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
<> | 149:156823d33999 | 3041 | class Callback<R(A0, A1, A2, A3, A4)> { |
<> | 149:156823d33999 | 3042 | public: |
<> | 149:156823d33999 | 3043 | /** Create a Callback with a static function |
<> | 149:156823d33999 | 3044 | * @param func Static function to attach |
<> | 149:156823d33999 | 3045 | */ |
<> | 149:156823d33999 | 3046 | Callback(R (*func)(A0, A1, A2, A3, A4) = 0) { |
<> | 149:156823d33999 | 3047 | if (!func) { |
<> | 149:156823d33999 | 3048 | _ops = 0; |
<> | 149:156823d33999 | 3049 | } else { |
<> | 149:156823d33999 | 3050 | generate(func); |
<> | 149:156823d33999 | 3051 | } |
<> | 149:156823d33999 | 3052 | } |
<> | 149:156823d33999 | 3053 | |
<> | 149:156823d33999 | 3054 | /** Attach a Callback |
<> | 149:156823d33999 | 3055 | * @param func The Callback to attach |
<> | 149:156823d33999 | 3056 | */ |
<> | 149:156823d33999 | 3057 | Callback(const Callback<R(A0, A1, A2, A3, A4)> &func) { |
<> | 149:156823d33999 | 3058 | if (func._ops) { |
<> | 149:156823d33999 | 3059 | func._ops->move(this, &func); |
<> | 149:156823d33999 | 3060 | } |
<> | 149:156823d33999 | 3061 | _ops = func._ops; |
<> | 149:156823d33999 | 3062 | } |
<> | 149:156823d33999 | 3063 | |
<> | 149:156823d33999 | 3064 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 3065 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 3066 | * @param method Member function to attach |
<> | 149:156823d33999 | 3067 | */ |
<> | 151:5eaa88a5bcc7 | 3068 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 3069 | Callback(U *obj, R (T::*method)(A0, A1, A2, A3, A4)) { |
<> | 149:156823d33999 | 3070 | generate(method_context<T, R (T::*)(A0, A1, A2, A3, A4)>(obj, method)); |
<> | 149:156823d33999 | 3071 | } |
<> | 149:156823d33999 | 3072 | |
<> | 149:156823d33999 | 3073 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 3074 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 3075 | * @param method Member function to attach |
<> | 149:156823d33999 | 3076 | */ |
<> | 151:5eaa88a5bcc7 | 3077 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 3078 | Callback(const U *obj, R (T::*method)(A0, A1, A2, A3, A4) const) { |
<> | 149:156823d33999 | 3079 | generate(method_context<const T, R (T::*)(A0, A1, A2, A3, A4) const>(obj, method)); |
<> | 149:156823d33999 | 3080 | } |
<> | 149:156823d33999 | 3081 | |
<> | 149:156823d33999 | 3082 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 3083 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 3084 | * @param method Member function to attach |
<> | 149:156823d33999 | 3085 | */ |
<> | 151:5eaa88a5bcc7 | 3086 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 3087 | Callback(volatile U *obj, R (T::*method)(A0, A1, A2, A3, A4) volatile) { |
<> | 149:156823d33999 | 3088 | generate(method_context<volatile T, R (T::*)(A0, A1, A2, A3, A4) volatile>(obj, method)); |
<> | 149:156823d33999 | 3089 | } |
<> | 149:156823d33999 | 3090 | |
<> | 149:156823d33999 | 3091 | /** Create a Callback with a member function |
<> | 149:156823d33999 | 3092 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 3093 | * @param method Member function to attach |
<> | 149:156823d33999 | 3094 | */ |
<> | 151:5eaa88a5bcc7 | 3095 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 3096 | Callback(const volatile U *obj, R (T::*method)(A0, A1, A2, A3, A4) const volatile) { |
<> | 149:156823d33999 | 3097 | generate(method_context<const volatile T, R (T::*)(A0, A1, A2, A3, A4) const volatile>(obj, method)); |
<> | 149:156823d33999 | 3098 | } |
<> | 149:156823d33999 | 3099 | |
<> | 149:156823d33999 | 3100 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 3101 | * @param func Static function to attach |
<> | 149:156823d33999 | 3102 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 3103 | */ |
<> | 151:5eaa88a5bcc7 | 3104 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 3105 | Callback(R (*func)(T*, A0, A1, A2, A3, A4), U *arg) { |
<> | 149:156823d33999 | 3106 | generate(function_context<R (*)(T*, A0, A1, A2, A3, A4), T>(func, arg)); |
<> | 149:156823d33999 | 3107 | } |
<> | 149:156823d33999 | 3108 | |
<> | 149:156823d33999 | 3109 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 3110 | * @param func Static function to attach |
<> | 149:156823d33999 | 3111 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 3112 | */ |
<> | 151:5eaa88a5bcc7 | 3113 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 3114 | Callback(R (*func)(const T*, A0, A1, A2, A3, A4), const U *arg) { |
<> | 149:156823d33999 | 3115 | generate(function_context<R (*)(const T*, A0, A1, A2, A3, A4), const T>(func, arg)); |
<> | 149:156823d33999 | 3116 | } |
<> | 149:156823d33999 | 3117 | |
<> | 149:156823d33999 | 3118 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 3119 | * @param func Static function to attach |
<> | 149:156823d33999 | 3120 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 3121 | */ |
<> | 151:5eaa88a5bcc7 | 3122 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 3123 | Callback(R (*func)(volatile T*, A0, A1, A2, A3, A4), volatile U *arg) { |
<> | 149:156823d33999 | 3124 | generate(function_context<R (*)(volatile T*, A0, A1, A2, A3, A4), volatile T>(func, arg)); |
<> | 149:156823d33999 | 3125 | } |
<> | 149:156823d33999 | 3126 | |
<> | 149:156823d33999 | 3127 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 3128 | * @param func Static function to attach |
<> | 149:156823d33999 | 3129 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 3130 | */ |
<> | 151:5eaa88a5bcc7 | 3131 | template<typename T, typename U> |
<> | 151:5eaa88a5bcc7 | 3132 | Callback(R (*func)(const volatile T*, A0, A1, A2, A3, A4), const volatile U *arg) { |
<> | 149:156823d33999 | 3133 | generate(function_context<R (*)(const volatile T*, A0, A1, A2, A3, A4), const volatile T>(func, arg)); |
<> | 149:156823d33999 | 3134 | } |
<> | 149:156823d33999 | 3135 | |
<> | 149:156823d33999 | 3136 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 3137 | * @param func Function object to attach |
<> | 149:156823d33999 | 3138 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 3139 | */ |
<> | 149:156823d33999 | 3140 | template <typename F> |
<> | 149:156823d33999 | 3141 | Callback(F f, typename detail::enable_if< |
<> | 149:156823d33999 | 3142 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4), &F::operator()>::value && |
<> | 149:156823d33999 | 3143 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 3144 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 3145 | generate(f); |
<> | 149:156823d33999 | 3146 | } |
<> | 149:156823d33999 | 3147 | |
<> | 149:156823d33999 | 3148 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 3149 | * @param func Function object to attach |
<> | 149:156823d33999 | 3150 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 3151 | */ |
<> | 149:156823d33999 | 3152 | template <typename F> |
<> | 149:156823d33999 | 3153 | Callback(const F f, typename detail::enable_if< |
<> | 149:156823d33999 | 3154 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4) const, &F::operator()>::value && |
<> | 149:156823d33999 | 3155 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 3156 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 3157 | generate(f); |
<> | 149:156823d33999 | 3158 | } |
<> | 149:156823d33999 | 3159 | |
<> | 149:156823d33999 | 3160 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 3161 | * @param func Function object to attach |
<> | 149:156823d33999 | 3162 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 3163 | */ |
<> | 149:156823d33999 | 3164 | template <typename F> |
<> | 149:156823d33999 | 3165 | Callback(volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 3166 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4) volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 3167 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 3168 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 3169 | generate(f); |
<> | 149:156823d33999 | 3170 | } |
<> | 149:156823d33999 | 3171 | |
<> | 149:156823d33999 | 3172 | /** Create a Callback with a function object |
<> | 149:156823d33999 | 3173 | * @param func Function object to attach |
<> | 149:156823d33999 | 3174 | * @note The function object is limited to a single word of storage |
<> | 149:156823d33999 | 3175 | */ |
<> | 149:156823d33999 | 3176 | template <typename F> |
<> | 149:156823d33999 | 3177 | Callback(const volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 3178 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4) const volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 3179 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 3180 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 3181 | generate(f); |
<> | 149:156823d33999 | 3182 | } |
<> | 149:156823d33999 | 3183 | |
<> | 149:156823d33999 | 3184 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 3185 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 3186 | * @param func Static function to attach |
<> | 149:156823d33999 | 3187 | * @deprecated |
<> | 149:156823d33999 | 3188 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 3189 | */ |
<> | 151:5eaa88a5bcc7 | 3190 | template<typename T, typename U> |
<> | 149:156823d33999 | 3191 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 3192 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 3193 | Callback(U *obj, R (*func)(T*, A0, A1, A2, A3, A4)) { |
<> | 149:156823d33999 | 3194 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 3195 | } |
<> | 149:156823d33999 | 3196 | |
<> | 149:156823d33999 | 3197 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 3198 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 3199 | * @param func Static function to attach |
<> | 149:156823d33999 | 3200 | * @deprecated |
<> | 149:156823d33999 | 3201 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 3202 | */ |
<> | 151:5eaa88a5bcc7 | 3203 | template<typename T, typename U> |
<> | 149:156823d33999 | 3204 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 3205 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 3206 | Callback(const U *obj, R (*func)(const T*, A0, A1, A2, A3, A4)) { |
<> | 149:156823d33999 | 3207 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 3208 | } |
<> | 149:156823d33999 | 3209 | |
<> | 149:156823d33999 | 3210 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 3211 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 3212 | * @param func Static function to attach |
<> | 149:156823d33999 | 3213 | * @deprecated |
<> | 149:156823d33999 | 3214 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 3215 | */ |
<> | 151:5eaa88a5bcc7 | 3216 | template<typename T, typename U> |
<> | 149:156823d33999 | 3217 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 3218 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 3219 | Callback(volatile U *obj, R (*func)(volatile T*, A0, A1, A2, A3, A4)) { |
<> | 149:156823d33999 | 3220 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 3221 | } |
<> | 149:156823d33999 | 3222 | |
<> | 149:156823d33999 | 3223 | /** Create a Callback with a static function and bound pointer |
<> | 149:156823d33999 | 3224 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 3225 | * @param func Static function to attach |
<> | 149:156823d33999 | 3226 | * @deprecated |
<> | 149:156823d33999 | 3227 | * Arguments to callback have been reordered to Callback(func, arg) |
<> | 149:156823d33999 | 3228 | */ |
<> | 151:5eaa88a5bcc7 | 3229 | template<typename T, typename U> |
<> | 149:156823d33999 | 3230 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 3231 | "Arguments to callback have been reordered to Callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 3232 | Callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2, A3, A4)) { |
<> | 149:156823d33999 | 3233 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 3234 | } |
<> | 149:156823d33999 | 3235 | |
<> | 149:156823d33999 | 3236 | /** Destroy a callback |
<> | 149:156823d33999 | 3237 | */ |
<> | 149:156823d33999 | 3238 | ~Callback() { |
<> | 149:156823d33999 | 3239 | if (_ops) { |
<> | 149:156823d33999 | 3240 | _ops->dtor(this); |
<> | 149:156823d33999 | 3241 | } |
<> | 149:156823d33999 | 3242 | } |
<> | 149:156823d33999 | 3243 | |
<> | 149:156823d33999 | 3244 | /** Attach a static function |
<> | 149:156823d33999 | 3245 | * @param func Static function to attach |
<> | 160:d5399cc887bb | 3246 | * @deprecated |
<> | 160:d5399cc887bb | 3247 | * Replaced by simple assignment 'Callback cb = func' |
<> | 160:d5399cc887bb | 3248 | */ |
<> | 160:d5399cc887bb | 3249 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 3250 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 3251 | void attach(R (*func)(A0, A1, A2, A3, A4)) { |
<> | 149:156823d33999 | 3252 | this->~Callback(); |
<> | 149:156823d33999 | 3253 | new (this) Callback(func); |
<> | 149:156823d33999 | 3254 | } |
<> | 149:156823d33999 | 3255 | |
<> | 149:156823d33999 | 3256 | /** Attach a Callback |
<> | 149:156823d33999 | 3257 | * @param func The Callback to attach |
<> | 160:d5399cc887bb | 3258 | * @deprecated |
<> | 160:d5399cc887bb | 3259 | * Replaced by simple assignment 'Callback cb = func' |
<> | 160:d5399cc887bb | 3260 | */ |
<> | 160:d5399cc887bb | 3261 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 3262 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 3263 | void attach(const Callback<R(A0, A1, A2, A3, A4)> &func) { |
<> | 149:156823d33999 | 3264 | this->~Callback(); |
<> | 149:156823d33999 | 3265 | new (this) Callback(func); |
<> | 149:156823d33999 | 3266 | } |
<> | 149:156823d33999 | 3267 | |
<> | 149:156823d33999 | 3268 | /** Attach a member function |
<> | 149:156823d33999 | 3269 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 3270 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 3271 | * @deprecated |
<> | 160:d5399cc887bb | 3272 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 3273 | */ |
<> | 151:5eaa88a5bcc7 | 3274 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 3275 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 3276 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 3277 | void attach(U *obj, R (T::*method)(A0, A1, A2, A3, A4)) { |
<> | 149:156823d33999 | 3278 | this->~Callback(); |
<> | 149:156823d33999 | 3279 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 3280 | } |
<> | 149:156823d33999 | 3281 | |
<> | 149:156823d33999 | 3282 | /** Attach a member function |
<> | 149:156823d33999 | 3283 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 3284 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 3285 | * @deprecated |
<> | 160:d5399cc887bb | 3286 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 3287 | */ |
<> | 151:5eaa88a5bcc7 | 3288 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 3289 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 3290 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 3291 | void attach(const U *obj, R (T::*method)(A0, A1, A2, A3, A4) const) { |
<> | 149:156823d33999 | 3292 | this->~Callback(); |
<> | 149:156823d33999 | 3293 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 3294 | } |
<> | 149:156823d33999 | 3295 | |
<> | 149:156823d33999 | 3296 | /** Attach a member function |
<> | 149:156823d33999 | 3297 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 3298 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 3299 | * @deprecated |
<> | 160:d5399cc887bb | 3300 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 3301 | */ |
<> | 151:5eaa88a5bcc7 | 3302 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 3303 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 3304 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 3305 | void attach(volatile U *obj, R (T::*method)(A0, A1, A2, A3, A4) volatile) { |
<> | 149:156823d33999 | 3306 | this->~Callback(); |
<> | 149:156823d33999 | 3307 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 3308 | } |
<> | 149:156823d33999 | 3309 | |
<> | 149:156823d33999 | 3310 | /** Attach a member function |
<> | 149:156823d33999 | 3311 | * @param obj Pointer to object to invoke member function on |
<> | 149:156823d33999 | 3312 | * @param method Member function to attach |
<> | 160:d5399cc887bb | 3313 | * @deprecated |
<> | 160:d5399cc887bb | 3314 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 3315 | */ |
<> | 151:5eaa88a5bcc7 | 3316 | template<typename T, typename U> |
<> | 160:d5399cc887bb | 3317 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 3318 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 3319 | void attach(const volatile U *obj, R (T::*method)(A0, A1, A2, A3, A4) const volatile) { |
<> | 149:156823d33999 | 3320 | this->~Callback(); |
<> | 149:156823d33999 | 3321 | new (this) Callback(obj, method); |
<> | 149:156823d33999 | 3322 | } |
<> | 149:156823d33999 | 3323 | |
<> | 149:156823d33999 | 3324 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 3325 | * @param func Static function to attach |
<> | 149:156823d33999 | 3326 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 3327 | * @deprecated |
<> | 160:d5399cc887bb | 3328 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 3329 | */ |
<> | 151:5eaa88a5bcc7 | 3330 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 3331 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 3332 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 3333 | void attach(R (*func)(T*, A0, A1, A2, A3, A4), U *arg) { |
<> | 149:156823d33999 | 3334 | this->~Callback(); |
<> | 149:156823d33999 | 3335 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 3336 | } |
<> | 149:156823d33999 | 3337 | |
<> | 149:156823d33999 | 3338 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 3339 | * @param func Static function to attach |
<> | 149:156823d33999 | 3340 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 3341 | * @deprecated |
<> | 160:d5399cc887bb | 3342 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 3343 | */ |
<> | 151:5eaa88a5bcc7 | 3344 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 3345 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 3346 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 3347 | void attach(R (*func)(const T*, A0, A1, A2, A3, A4), const U *arg) { |
<> | 149:156823d33999 | 3348 | this->~Callback(); |
<> | 149:156823d33999 | 3349 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 3350 | } |
<> | 149:156823d33999 | 3351 | |
<> | 149:156823d33999 | 3352 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 3353 | * @param func Static function to attach |
<> | 149:156823d33999 | 3354 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 3355 | * @deprecated |
<> | 160:d5399cc887bb | 3356 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 3357 | */ |
<> | 151:5eaa88a5bcc7 | 3358 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 3359 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 3360 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 3361 | void attach(R (*func)(volatile T*, A0, A1, A2, A3, A4), volatile U *arg) { |
<> | 149:156823d33999 | 3362 | this->~Callback(); |
<> | 149:156823d33999 | 3363 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 3364 | } |
<> | 149:156823d33999 | 3365 | |
<> | 149:156823d33999 | 3366 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 3367 | * @param func Static function to attach |
<> | 149:156823d33999 | 3368 | * @param arg Pointer argument to function |
<> | 160:d5399cc887bb | 3369 | * @deprecated |
<> | 160:d5399cc887bb | 3370 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 3371 | */ |
<> | 151:5eaa88a5bcc7 | 3372 | template <typename T, typename U> |
<> | 160:d5399cc887bb | 3373 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 3374 | "Replaced by simple assignment 'Callback cb = func") |
<> | 151:5eaa88a5bcc7 | 3375 | void attach(R (*func)(const volatile T*, A0, A1, A2, A3, A4), const volatile U *arg) { |
<> | 149:156823d33999 | 3376 | this->~Callback(); |
<> | 149:156823d33999 | 3377 | new (this) Callback(func, arg); |
<> | 149:156823d33999 | 3378 | } |
<> | 149:156823d33999 | 3379 | |
<> | 149:156823d33999 | 3380 | /** Attach a function object |
<> | 149:156823d33999 | 3381 | * @param func Function object to attach |
<> | 149:156823d33999 | 3382 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 3383 | * @deprecated |
<> | 160:d5399cc887bb | 3384 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 3385 | */ |
<> | 149:156823d33999 | 3386 | template <typename F> |
<> | 160:d5399cc887bb | 3387 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 3388 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 3389 | void attach(F f, typename detail::enable_if< |
<> | 149:156823d33999 | 3390 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4), &F::operator()>::value && |
<> | 149:156823d33999 | 3391 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 3392 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 3393 | this->~Callback(); |
<> | 149:156823d33999 | 3394 | new (this) Callback(f); |
<> | 149:156823d33999 | 3395 | } |
<> | 149:156823d33999 | 3396 | |
<> | 149:156823d33999 | 3397 | /** Attach a function object |
<> | 149:156823d33999 | 3398 | * @param func Function object to attach |
<> | 149:156823d33999 | 3399 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 3400 | * @deprecated |
<> | 160:d5399cc887bb | 3401 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 3402 | */ |
<> | 149:156823d33999 | 3403 | template <typename F> |
<> | 160:d5399cc887bb | 3404 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 3405 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 3406 | void attach(const F f, typename detail::enable_if< |
<> | 149:156823d33999 | 3407 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4) const, &F::operator()>::value && |
<> | 149:156823d33999 | 3408 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 3409 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 3410 | this->~Callback(); |
<> | 149:156823d33999 | 3411 | new (this) Callback(f); |
<> | 149:156823d33999 | 3412 | } |
<> | 149:156823d33999 | 3413 | |
<> | 149:156823d33999 | 3414 | /** Attach a function object |
<> | 149:156823d33999 | 3415 | * @param func Function object to attach |
<> | 149:156823d33999 | 3416 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 3417 | * @deprecated |
<> | 160:d5399cc887bb | 3418 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 3419 | */ |
<> | 149:156823d33999 | 3420 | template <typename F> |
<> | 160:d5399cc887bb | 3421 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 3422 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 3423 | void attach(volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 3424 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4) volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 3425 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 3426 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 3427 | this->~Callback(); |
<> | 149:156823d33999 | 3428 | new (this) Callback(f); |
<> | 149:156823d33999 | 3429 | } |
<> | 149:156823d33999 | 3430 | |
<> | 149:156823d33999 | 3431 | /** Attach a function object |
<> | 149:156823d33999 | 3432 | * @param func Function object to attach |
<> | 149:156823d33999 | 3433 | * @note The function object is limited to a single word of storage |
<> | 160:d5399cc887bb | 3434 | * @deprecated |
<> | 160:d5399cc887bb | 3435 | * Replaced by simple assignment 'Callback cb = func' |
<> | 149:156823d33999 | 3436 | */ |
<> | 149:156823d33999 | 3437 | template <typename F> |
<> | 160:d5399cc887bb | 3438 | MBED_DEPRECATED_SINCE("mbed-os-5.4", |
<> | 160:d5399cc887bb | 3439 | "Replaced by simple assignment 'Callback cb = func") |
<> | 149:156823d33999 | 3440 | void attach(const volatile F f, typename detail::enable_if< |
<> | 149:156823d33999 | 3441 | detail::is_type<R (F::*)(A0, A1, A2, A3, A4) const volatile, &F::operator()>::value && |
<> | 149:156823d33999 | 3442 | sizeof(F) <= sizeof(uintptr_t) |
<> | 149:156823d33999 | 3443 | >::type = detail::nil()) { |
<> | 149:156823d33999 | 3444 | this->~Callback(); |
<> | 149:156823d33999 | 3445 | new (this) Callback(f); |
<> | 149:156823d33999 | 3446 | } |
<> | 149:156823d33999 | 3447 | |
<> | 149:156823d33999 | 3448 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 3449 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 3450 | * @param func Static function to attach |
<> | 149:156823d33999 | 3451 | * @deprecated |
<> | 149:156823d33999 | 3452 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 3453 | */ |
<> | 151:5eaa88a5bcc7 | 3454 | template <typename T, typename U> |
<> | 149:156823d33999 | 3455 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 3456 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 3457 | void attach(U *obj, R (*func)(T*, A0, A1, A2, A3, A4)) { |
<> | 149:156823d33999 | 3458 | this->~Callback(); |
<> | 149:156823d33999 | 3459 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 3460 | } |
<> | 149:156823d33999 | 3461 | |
<> | 149:156823d33999 | 3462 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 3463 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 3464 | * @param func Static function to attach |
<> | 149:156823d33999 | 3465 | * @deprecated |
<> | 149:156823d33999 | 3466 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 3467 | */ |
<> | 151:5eaa88a5bcc7 | 3468 | template <typename T, typename U> |
<> | 149:156823d33999 | 3469 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 3470 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 3471 | void attach(const U *obj, R (*func)(const T*, A0, A1, A2, A3, A4)) { |
<> | 149:156823d33999 | 3472 | this->~Callback(); |
<> | 149:156823d33999 | 3473 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 3474 | } |
<> | 149:156823d33999 | 3475 | |
<> | 149:156823d33999 | 3476 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 3477 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 3478 | * @param func Static function to attach |
<> | 149:156823d33999 | 3479 | * @deprecated |
<> | 149:156823d33999 | 3480 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 3481 | */ |
<> | 151:5eaa88a5bcc7 | 3482 | template <typename T, typename U> |
<> | 149:156823d33999 | 3483 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 3484 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 3485 | void attach(volatile U *obj, R (*func)(volatile T*, A0, A1, A2, A3, A4)) { |
<> | 149:156823d33999 | 3486 | this->~Callback(); |
<> | 149:156823d33999 | 3487 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 3488 | } |
<> | 149:156823d33999 | 3489 | |
<> | 149:156823d33999 | 3490 | /** Attach a static function with a bound pointer |
<> | 149:156823d33999 | 3491 | * @param obj Pointer to object to bind to function |
<> | 149:156823d33999 | 3492 | * @param func Static function to attach |
<> | 149:156823d33999 | 3493 | * @deprecated |
<> | 149:156823d33999 | 3494 | * Arguments to callback have been reordered to attach(func, arg) |
<> | 149:156823d33999 | 3495 | */ |
<> | 151:5eaa88a5bcc7 | 3496 | template <typename T, typename U> |
<> | 149:156823d33999 | 3497 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 3498 | "Arguments to callback have been reordered to attach(func, arg)") |
<> | 151:5eaa88a5bcc7 | 3499 | void attach(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2, A3, A4)) { |
<> | 149:156823d33999 | 3500 | this->~Callback(); |
<> | 149:156823d33999 | 3501 | new (this) Callback(func, obj); |
<> | 149:156823d33999 | 3502 | } |
<> | 149:156823d33999 | 3503 | |
<> | 149:156823d33999 | 3504 | /** Assign a callback |
<> | 149:156823d33999 | 3505 | */ |
<> | 149:156823d33999 | 3506 | Callback &operator=(const Callback &that) { |
<> | 149:156823d33999 | 3507 | if (this != &that) { |
<> | 149:156823d33999 | 3508 | this->~Callback(); |
<> | 149:156823d33999 | 3509 | new (this) Callback(that); |
<> | 149:156823d33999 | 3510 | } |
<> | 149:156823d33999 | 3511 | |
<> | 149:156823d33999 | 3512 | return *this; |
<> | 149:156823d33999 | 3513 | } |
<> | 149:156823d33999 | 3514 | |
<> | 149:156823d33999 | 3515 | /** Call the attached function |
<> | 149:156823d33999 | 3516 | */ |
<> | 149:156823d33999 | 3517 | R call(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const { |
<> | 149:156823d33999 | 3518 | MBED_ASSERT(_ops); |
<> | 149:156823d33999 | 3519 | return _ops->call(this, a0, a1, a2, a3, a4); |
<> | 149:156823d33999 | 3520 | } |
<> | 149:156823d33999 | 3521 | |
<> | 149:156823d33999 | 3522 | /** Call the attached function |
<> | 149:156823d33999 | 3523 | */ |
<> | 149:156823d33999 | 3524 | R operator()(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const { |
<> | 149:156823d33999 | 3525 | return call(a0, a1, a2, a3, a4); |
<> | 149:156823d33999 | 3526 | } |
<> | 149:156823d33999 | 3527 | |
<> | 149:156823d33999 | 3528 | /** Test if function has been attached |
<> | 149:156823d33999 | 3529 | */ |
<> | 149:156823d33999 | 3530 | operator bool() const { |
<> | 149:156823d33999 | 3531 | return _ops; |
<> | 149:156823d33999 | 3532 | } |
<> | 149:156823d33999 | 3533 | |
<> | 149:156823d33999 | 3534 | /** Test for equality |
<> | 149:156823d33999 | 3535 | */ |
<> | 149:156823d33999 | 3536 | friend bool operator==(const Callback &l, const Callback &r) { |
<> | 149:156823d33999 | 3537 | return memcmp(&l, &r, sizeof(Callback)) == 0; |
<> | 149:156823d33999 | 3538 | } |
<> | 149:156823d33999 | 3539 | |
<> | 149:156823d33999 | 3540 | /** Test for inequality |
<> | 149:156823d33999 | 3541 | */ |
<> | 149:156823d33999 | 3542 | friend bool operator!=(const Callback &l, const Callback &r) { |
<> | 149:156823d33999 | 3543 | return !(l == r); |
<> | 149:156823d33999 | 3544 | } |
<> | 149:156823d33999 | 3545 | |
<> | 149:156823d33999 | 3546 | /** Static thunk for passing as C-style function |
<> | 149:156823d33999 | 3547 | * @param func Callback to call passed as void pointer |
<> | 149:156823d33999 | 3548 | */ |
<> | 149:156823d33999 | 3549 | static R thunk(void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { |
<> | 149:156823d33999 | 3550 | return static_cast<Callback*>(func)->call(a0, a1, a2, a3, a4); |
<> | 149:156823d33999 | 3551 | } |
<> | 149:156823d33999 | 3552 | |
<> | 149:156823d33999 | 3553 | private: |
<> | 149:156823d33999 | 3554 | // Stored as pointer to function and pointer to optional object |
<> | 149:156823d33999 | 3555 | // Function pointer is stored as union of possible function types |
<> | 149:156823d33999 | 3556 | // to garuntee proper size and alignment |
<> | 149:156823d33999 | 3557 | struct _class; |
<> | 149:156823d33999 | 3558 | union { |
<> | 149:156823d33999 | 3559 | void (*_staticfunc)(A0, A1, A2, A3, A4); |
<> | 149:156823d33999 | 3560 | void (*_boundfunc)(_class*, A0, A1, A2, A3, A4); |
<> | 149:156823d33999 | 3561 | void (_class::*_methodfunc)(A0, A1, A2, A3, A4); |
<> | 149:156823d33999 | 3562 | } _func; |
<> | 149:156823d33999 | 3563 | void *_obj; |
<> | 149:156823d33999 | 3564 | |
<> | 149:156823d33999 | 3565 | // Dynamically dispatched operations |
<> | 149:156823d33999 | 3566 | const struct ops { |
<> | 149:156823d33999 | 3567 | R (*call)(const void*, A0, A1, A2, A3, A4); |
<> | 149:156823d33999 | 3568 | void (*move)(void*, const void*); |
<> | 149:156823d33999 | 3569 | void (*dtor)(void*); |
<> | 149:156823d33999 | 3570 | } *_ops; |
<> | 149:156823d33999 | 3571 | |
<> | 149:156823d33999 | 3572 | // Generate operations for function object |
<> | 149:156823d33999 | 3573 | template <typename F> |
<> | 149:156823d33999 | 3574 | void generate(const F &f) { |
<> | 149:156823d33999 | 3575 | static const ops ops = { |
<> | 149:156823d33999 | 3576 | &Callback::function_call<F>, |
<> | 149:156823d33999 | 3577 | &Callback::function_move<F>, |
<> | 149:156823d33999 | 3578 | &Callback::function_dtor<F>, |
<> | 149:156823d33999 | 3579 | }; |
<> | 149:156823d33999 | 3580 | |
<> | 151:5eaa88a5bcc7 | 3581 | MBED_STATIC_ASSERT(sizeof(Callback) - sizeof(_ops) >= sizeof(F), |
<> | 151:5eaa88a5bcc7 | 3582 | "Type F must not exceed the size of the Callback class"); |
<> | 149:156823d33999 | 3583 | new (this) F(f); |
<> | 149:156823d33999 | 3584 | _ops = &ops; |
<> | 149:156823d33999 | 3585 | } |
<> | 149:156823d33999 | 3586 | |
<> | 149:156823d33999 | 3587 | // Function attributes |
<> | 149:156823d33999 | 3588 | template <typename F> |
<> | 149:156823d33999 | 3589 | static R function_call(const void *p, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) { |
<> | 149:156823d33999 | 3590 | return (*(F*)p)(a0, a1, a2, a3, a4); |
<> | 149:156823d33999 | 3591 | } |
<> | 149:156823d33999 | 3592 | |
<> | 149:156823d33999 | 3593 | template <typename F> |
<> | 149:156823d33999 | 3594 | static void function_move(void *d, const void *p) { |
<> | 149:156823d33999 | 3595 | new (d) F(*(F*)p); |
<> | 149:156823d33999 | 3596 | } |
<> | 149:156823d33999 | 3597 | |
<> | 149:156823d33999 | 3598 | template <typename F> |
<> | 149:156823d33999 | 3599 | static void function_dtor(void *p) { |
<> | 149:156823d33999 | 3600 | ((F*)p)->~F(); |
<> | 149:156823d33999 | 3601 | } |
<> | 149:156823d33999 | 3602 | |
<> | 149:156823d33999 | 3603 | // Wrappers for functions with context |
<> | 149:156823d33999 | 3604 | template <typename O, typename M> |
<> | 149:156823d33999 | 3605 | struct method_context { |
<> | 149:156823d33999 | 3606 | M method; |
<> | 149:156823d33999 | 3607 | O *obj; |
<> | 149:156823d33999 | 3608 | |
<> | 149:156823d33999 | 3609 | method_context(O *obj, M method) |
<> | 149:156823d33999 | 3610 | : method(method), obj(obj) {} |
<> | 149:156823d33999 | 3611 | |
<> | 149:156823d33999 | 3612 | R operator()(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const { |
<> | 149:156823d33999 | 3613 | return (obj->*method)(a0, a1, a2, a3, a4); |
<> | 149:156823d33999 | 3614 | } |
<> | 149:156823d33999 | 3615 | }; |
<> | 149:156823d33999 | 3616 | |
<> | 149:156823d33999 | 3617 | template <typename F, typename A> |
<> | 149:156823d33999 | 3618 | struct function_context { |
<> | 149:156823d33999 | 3619 | F func; |
<> | 149:156823d33999 | 3620 | A *arg; |
<> | 149:156823d33999 | 3621 | |
<> | 149:156823d33999 | 3622 | function_context(F func, A *arg) |
<> | 149:156823d33999 | 3623 | : func(func), arg(arg) {} |
<> | 149:156823d33999 | 3624 | |
<> | 149:156823d33999 | 3625 | R operator()(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const { |
<> | 149:156823d33999 | 3626 | return func(arg, a0, a1, a2, a3, a4); |
<> | 149:156823d33999 | 3627 | } |
<> | 149:156823d33999 | 3628 | }; |
<> | 149:156823d33999 | 3629 | }; |
<> | 149:156823d33999 | 3630 | |
<> | 149:156823d33999 | 3631 | // Internally used event type |
<> | 149:156823d33999 | 3632 | typedef Callback<void(int)> event_callback_t; |
<> | 149:156823d33999 | 3633 | |
<> | 149:156823d33999 | 3634 | |
<> | 149:156823d33999 | 3635 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3636 | * |
<> | 149:156823d33999 | 3637 | * @param func Static function to attach |
<> | 149:156823d33999 | 3638 | * @return Callback with infered type |
<> | 149:156823d33999 | 3639 | */ |
<> | 149:156823d33999 | 3640 | template <typename R> |
<> | 149:156823d33999 | 3641 | Callback<R()> callback(R (*func)() = 0) { |
<> | 149:156823d33999 | 3642 | return Callback<R()>(func); |
<> | 149:156823d33999 | 3643 | } |
<> | 149:156823d33999 | 3644 | |
<> | 149:156823d33999 | 3645 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3646 | * |
<> | 149:156823d33999 | 3647 | * @param func Static function to attach |
<> | 149:156823d33999 | 3648 | * @return Callback with infered type |
<> | 149:156823d33999 | 3649 | */ |
<> | 149:156823d33999 | 3650 | template <typename R> |
<> | 149:156823d33999 | 3651 | Callback<R()> callback(const Callback<R()> &func) { |
<> | 149:156823d33999 | 3652 | return Callback<R()>(func); |
<> | 149:156823d33999 | 3653 | } |
<> | 149:156823d33999 | 3654 | |
<> | 149:156823d33999 | 3655 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3656 | * |
<> | 149:156823d33999 | 3657 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 3658 | * @param method Member function to attach |
<> | 149:156823d33999 | 3659 | * @return Callback with infered type |
<> | 149:156823d33999 | 3660 | */ |
<> | 151:5eaa88a5bcc7 | 3661 | template<typename T, typename U, typename R> |
<> | 151:5eaa88a5bcc7 | 3662 | Callback<R()> callback(U *obj, R (T::*method)()) { |
<> | 151:5eaa88a5bcc7 | 3663 | return Callback<R()>(obj, method); |
<> | 149:156823d33999 | 3664 | } |
<> | 149:156823d33999 | 3665 | |
<> | 149:156823d33999 | 3666 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3667 | * |
<> | 149:156823d33999 | 3668 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 3669 | * @param method Member function to attach |
<> | 149:156823d33999 | 3670 | * @return Callback with infered type |
<> | 149:156823d33999 | 3671 | */ |
<> | 151:5eaa88a5bcc7 | 3672 | template<typename T, typename U, typename R> |
<> | 151:5eaa88a5bcc7 | 3673 | Callback<R()> callback(const U *obj, R (T::*method)() const) { |
<> | 151:5eaa88a5bcc7 | 3674 | return Callback<R()>(obj, method); |
<> | 149:156823d33999 | 3675 | } |
<> | 149:156823d33999 | 3676 | |
<> | 149:156823d33999 | 3677 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3678 | * |
<> | 149:156823d33999 | 3679 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 3680 | * @param method Member function to attach |
<> | 149:156823d33999 | 3681 | * @return Callback with infered type |
<> | 149:156823d33999 | 3682 | */ |
<> | 151:5eaa88a5bcc7 | 3683 | template<typename T, typename U, typename R> |
<> | 151:5eaa88a5bcc7 | 3684 | Callback<R()> callback(volatile U *obj, R (T::*method)() volatile) { |
<> | 151:5eaa88a5bcc7 | 3685 | return Callback<R()>(obj, method); |
<> | 149:156823d33999 | 3686 | } |
<> | 149:156823d33999 | 3687 | |
<> | 149:156823d33999 | 3688 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3689 | * |
<> | 149:156823d33999 | 3690 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 3691 | * @param method Member function to attach |
<> | 149:156823d33999 | 3692 | * @return Callback with infered type |
<> | 149:156823d33999 | 3693 | */ |
<> | 151:5eaa88a5bcc7 | 3694 | template<typename T, typename U, typename R> |
<> | 151:5eaa88a5bcc7 | 3695 | Callback<R()> callback(const volatile U *obj, R (T::*method)() const volatile) { |
<> | 151:5eaa88a5bcc7 | 3696 | return Callback<R()>(obj, method); |
<> | 149:156823d33999 | 3697 | } |
<> | 149:156823d33999 | 3698 | |
<> | 149:156823d33999 | 3699 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3700 | * |
<> | 149:156823d33999 | 3701 | * @param func Static function to attach |
<> | 149:156823d33999 | 3702 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 3703 | * @return Callback with infered type |
<> | 149:156823d33999 | 3704 | */ |
<> | 151:5eaa88a5bcc7 | 3705 | template <typename T, typename U, typename R> |
<> | 151:5eaa88a5bcc7 | 3706 | Callback<R()> callback(R (*func)(T*), U *arg) { |
<> | 149:156823d33999 | 3707 | return Callback<R()>(func, arg); |
<> | 149:156823d33999 | 3708 | } |
<> | 149:156823d33999 | 3709 | |
<> | 149:156823d33999 | 3710 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3711 | * |
<> | 149:156823d33999 | 3712 | * @param func Static function to attach |
<> | 149:156823d33999 | 3713 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 3714 | * @return Callback with infered type |
<> | 149:156823d33999 | 3715 | */ |
<> | 151:5eaa88a5bcc7 | 3716 | template <typename T, typename U, typename R> |
<> | 151:5eaa88a5bcc7 | 3717 | Callback<R()> callback(R (*func)(const T*), const U *arg) { |
<> | 149:156823d33999 | 3718 | return Callback<R()>(func, arg); |
<> | 149:156823d33999 | 3719 | } |
<> | 149:156823d33999 | 3720 | |
<> | 149:156823d33999 | 3721 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3722 | * |
<> | 149:156823d33999 | 3723 | * @param func Static function to attach |
<> | 149:156823d33999 | 3724 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 3725 | * @return Callback with infered type |
<> | 149:156823d33999 | 3726 | */ |
<> | 151:5eaa88a5bcc7 | 3727 | template <typename T, typename U, typename R> |
<> | 151:5eaa88a5bcc7 | 3728 | Callback<R()> callback(R (*func)(volatile T*), volatile U *arg) { |
<> | 149:156823d33999 | 3729 | return Callback<R()>(func, arg); |
<> | 149:156823d33999 | 3730 | } |
<> | 149:156823d33999 | 3731 | |
<> | 149:156823d33999 | 3732 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3733 | * |
<> | 149:156823d33999 | 3734 | * @param func Static function to attach |
<> | 149:156823d33999 | 3735 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 3736 | * @return Callback with infered type |
<> | 149:156823d33999 | 3737 | */ |
<> | 151:5eaa88a5bcc7 | 3738 | template <typename T, typename U, typename R> |
<> | 151:5eaa88a5bcc7 | 3739 | Callback<R()> callback(R (*func)(const volatile T*), const volatile U *arg) { |
<> | 149:156823d33999 | 3740 | return Callback<R()>(func, arg); |
<> | 149:156823d33999 | 3741 | } |
<> | 149:156823d33999 | 3742 | |
<> | 149:156823d33999 | 3743 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3744 | * |
<> | 149:156823d33999 | 3745 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 3746 | * @param func Static function to attach |
<> | 149:156823d33999 | 3747 | * @return Callback with infered type |
<> | 149:156823d33999 | 3748 | * @deprecated |
<> | 149:156823d33999 | 3749 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 3750 | */ |
<> | 151:5eaa88a5bcc7 | 3751 | template <typename T, typename U, typename R> |
<> | 149:156823d33999 | 3752 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 3753 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 3754 | Callback<R()> callback(U *obj, R (*func)(T*)) { |
<> | 149:156823d33999 | 3755 | return Callback<R()>(func, obj); |
<> | 149:156823d33999 | 3756 | } |
<> | 149:156823d33999 | 3757 | |
<> | 149:156823d33999 | 3758 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3759 | * |
<> | 149:156823d33999 | 3760 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 3761 | * @param func Static function to attach |
<> | 149:156823d33999 | 3762 | * @return Callback with infered type |
<> | 149:156823d33999 | 3763 | * @deprecated |
<> | 149:156823d33999 | 3764 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 3765 | */ |
<> | 151:5eaa88a5bcc7 | 3766 | template <typename T, typename U, typename R> |
<> | 149:156823d33999 | 3767 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 3768 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 3769 | Callback<R()> callback(const U *obj, R (*func)(const T*)) { |
<> | 149:156823d33999 | 3770 | return Callback<R()>(func, obj); |
<> | 149:156823d33999 | 3771 | } |
<> | 149:156823d33999 | 3772 | |
<> | 149:156823d33999 | 3773 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3774 | * |
<> | 149:156823d33999 | 3775 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 3776 | * @param func Static function to attach |
<> | 149:156823d33999 | 3777 | * @return Callback with infered type |
<> | 149:156823d33999 | 3778 | * @deprecated |
<> | 149:156823d33999 | 3779 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 3780 | */ |
<> | 151:5eaa88a5bcc7 | 3781 | template <typename T, typename U, typename R> |
<> | 149:156823d33999 | 3782 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 3783 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 3784 | Callback<R()> callback(volatile U *obj, R (*func)(volatile T*)) { |
<> | 149:156823d33999 | 3785 | return Callback<R()>(func, obj); |
<> | 149:156823d33999 | 3786 | } |
<> | 149:156823d33999 | 3787 | |
<> | 149:156823d33999 | 3788 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3789 | * |
<> | 149:156823d33999 | 3790 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 3791 | * @param func Static function to attach |
<> | 149:156823d33999 | 3792 | * @return Callback with infered type |
<> | 149:156823d33999 | 3793 | * @deprecated |
<> | 149:156823d33999 | 3794 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 3795 | */ |
<> | 151:5eaa88a5bcc7 | 3796 | template <typename T, typename U, typename R> |
<> | 149:156823d33999 | 3797 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 3798 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 3799 | Callback<R()> callback(const volatile U *obj, R (*func)(const volatile T*)) { |
<> | 149:156823d33999 | 3800 | return Callback<R()>(func, obj); |
<> | 149:156823d33999 | 3801 | } |
<> | 149:156823d33999 | 3802 | |
<> | 149:156823d33999 | 3803 | |
<> | 149:156823d33999 | 3804 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3805 | * |
<> | 149:156823d33999 | 3806 | * @param func Static function to attach |
<> | 149:156823d33999 | 3807 | * @return Callback with infered type |
<> | 149:156823d33999 | 3808 | */ |
<> | 149:156823d33999 | 3809 | template <typename R, typename A0> |
<> | 149:156823d33999 | 3810 | Callback<R(A0)> callback(R (*func)(A0) = 0) { |
<> | 149:156823d33999 | 3811 | return Callback<R(A0)>(func); |
<> | 149:156823d33999 | 3812 | } |
<> | 149:156823d33999 | 3813 | |
<> | 149:156823d33999 | 3814 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3815 | * |
<> | 149:156823d33999 | 3816 | * @param func Static function to attach |
<> | 149:156823d33999 | 3817 | * @return Callback with infered type |
<> | 149:156823d33999 | 3818 | */ |
<> | 149:156823d33999 | 3819 | template <typename R, typename A0> |
<> | 149:156823d33999 | 3820 | Callback<R(A0)> callback(const Callback<R(A0)> &func) { |
<> | 149:156823d33999 | 3821 | return Callback<R(A0)>(func); |
<> | 149:156823d33999 | 3822 | } |
<> | 149:156823d33999 | 3823 | |
<> | 149:156823d33999 | 3824 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3825 | * |
<> | 149:156823d33999 | 3826 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 3827 | * @param method Member function to attach |
<> | 149:156823d33999 | 3828 | * @return Callback with infered type |
<> | 149:156823d33999 | 3829 | */ |
<> | 151:5eaa88a5bcc7 | 3830 | template<typename T, typename U, typename R, typename A0> |
<> | 151:5eaa88a5bcc7 | 3831 | Callback<R(A0)> callback(U *obj, R (T::*method)(A0)) { |
<> | 151:5eaa88a5bcc7 | 3832 | return Callback<R(A0)>(obj, method); |
<> | 149:156823d33999 | 3833 | } |
<> | 149:156823d33999 | 3834 | |
<> | 149:156823d33999 | 3835 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3836 | * |
<> | 149:156823d33999 | 3837 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 3838 | * @param method Member function to attach |
<> | 149:156823d33999 | 3839 | * @return Callback with infered type |
<> | 149:156823d33999 | 3840 | */ |
<> | 151:5eaa88a5bcc7 | 3841 | template<typename T, typename U, typename R, typename A0> |
<> | 151:5eaa88a5bcc7 | 3842 | Callback<R(A0)> callback(const U *obj, R (T::*method)(A0) const) { |
<> | 151:5eaa88a5bcc7 | 3843 | return Callback<R(A0)>(obj, method); |
<> | 149:156823d33999 | 3844 | } |
<> | 149:156823d33999 | 3845 | |
<> | 149:156823d33999 | 3846 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3847 | * |
<> | 149:156823d33999 | 3848 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 3849 | * @param method Member function to attach |
<> | 149:156823d33999 | 3850 | * @return Callback with infered type |
<> | 149:156823d33999 | 3851 | */ |
<> | 151:5eaa88a5bcc7 | 3852 | template<typename T, typename U, typename R, typename A0> |
<> | 151:5eaa88a5bcc7 | 3853 | Callback<R(A0)> callback(volatile U *obj, R (T::*method)(A0) volatile) { |
<> | 151:5eaa88a5bcc7 | 3854 | return Callback<R(A0)>(obj, method); |
<> | 149:156823d33999 | 3855 | } |
<> | 149:156823d33999 | 3856 | |
<> | 149:156823d33999 | 3857 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3858 | * |
<> | 149:156823d33999 | 3859 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 3860 | * @param method Member function to attach |
<> | 149:156823d33999 | 3861 | * @return Callback with infered type |
<> | 149:156823d33999 | 3862 | */ |
<> | 151:5eaa88a5bcc7 | 3863 | template<typename T, typename U, typename R, typename A0> |
<> | 151:5eaa88a5bcc7 | 3864 | Callback<R(A0)> callback(const volatile U *obj, R (T::*method)(A0) const volatile) { |
<> | 151:5eaa88a5bcc7 | 3865 | return Callback<R(A0)>(obj, method); |
<> | 149:156823d33999 | 3866 | } |
<> | 149:156823d33999 | 3867 | |
<> | 149:156823d33999 | 3868 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3869 | * |
<> | 149:156823d33999 | 3870 | * @param func Static function to attach |
<> | 149:156823d33999 | 3871 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 3872 | * @return Callback with infered type |
<> | 149:156823d33999 | 3873 | */ |
<> | 151:5eaa88a5bcc7 | 3874 | template <typename T, typename U, typename R, typename A0> |
<> | 151:5eaa88a5bcc7 | 3875 | Callback<R(A0)> callback(R (*func)(T*, A0), U *arg) { |
<> | 149:156823d33999 | 3876 | return Callback<R(A0)>(func, arg); |
<> | 149:156823d33999 | 3877 | } |
<> | 149:156823d33999 | 3878 | |
<> | 149:156823d33999 | 3879 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3880 | * |
<> | 149:156823d33999 | 3881 | * @param func Static function to attach |
<> | 149:156823d33999 | 3882 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 3883 | * @return Callback with infered type |
<> | 149:156823d33999 | 3884 | */ |
<> | 151:5eaa88a5bcc7 | 3885 | template <typename T, typename U, typename R, typename A0> |
<> | 151:5eaa88a5bcc7 | 3886 | Callback<R(A0)> callback(R (*func)(const T*, A0), const U *arg) { |
<> | 149:156823d33999 | 3887 | return Callback<R(A0)>(func, arg); |
<> | 149:156823d33999 | 3888 | } |
<> | 149:156823d33999 | 3889 | |
<> | 149:156823d33999 | 3890 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3891 | * |
<> | 149:156823d33999 | 3892 | * @param func Static function to attach |
<> | 149:156823d33999 | 3893 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 3894 | * @return Callback with infered type |
<> | 149:156823d33999 | 3895 | */ |
<> | 151:5eaa88a5bcc7 | 3896 | template <typename T, typename U, typename R, typename A0> |
<> | 151:5eaa88a5bcc7 | 3897 | Callback<R(A0)> callback(R (*func)(volatile T*, A0), volatile U *arg) { |
<> | 149:156823d33999 | 3898 | return Callback<R(A0)>(func, arg); |
<> | 149:156823d33999 | 3899 | } |
<> | 149:156823d33999 | 3900 | |
<> | 149:156823d33999 | 3901 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3902 | * |
<> | 149:156823d33999 | 3903 | * @param func Static function to attach |
<> | 149:156823d33999 | 3904 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 3905 | * @return Callback with infered type |
<> | 149:156823d33999 | 3906 | */ |
<> | 151:5eaa88a5bcc7 | 3907 | template <typename T, typename U, typename R, typename A0> |
<> | 151:5eaa88a5bcc7 | 3908 | Callback<R(A0)> callback(R (*func)(const volatile T*, A0), const volatile U *arg) { |
<> | 149:156823d33999 | 3909 | return Callback<R(A0)>(func, arg); |
<> | 149:156823d33999 | 3910 | } |
<> | 149:156823d33999 | 3911 | |
<> | 149:156823d33999 | 3912 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3913 | * |
<> | 149:156823d33999 | 3914 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 3915 | * @param func Static function to attach |
<> | 149:156823d33999 | 3916 | * @return Callback with infered type |
<> | 149:156823d33999 | 3917 | * @deprecated |
<> | 149:156823d33999 | 3918 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 3919 | */ |
<> | 151:5eaa88a5bcc7 | 3920 | template <typename T, typename U, typename R, typename A0> |
<> | 149:156823d33999 | 3921 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 3922 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 3923 | Callback<R(A0)> callback(U *obj, R (*func)(T*, A0)) { |
<> | 149:156823d33999 | 3924 | return Callback<R(A0)>(func, obj); |
<> | 149:156823d33999 | 3925 | } |
<> | 149:156823d33999 | 3926 | |
<> | 149:156823d33999 | 3927 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3928 | * |
<> | 149:156823d33999 | 3929 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 3930 | * @param func Static function to attach |
<> | 149:156823d33999 | 3931 | * @return Callback with infered type |
<> | 149:156823d33999 | 3932 | * @deprecated |
<> | 149:156823d33999 | 3933 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 3934 | */ |
<> | 151:5eaa88a5bcc7 | 3935 | template <typename T, typename U, typename R, typename A0> |
<> | 149:156823d33999 | 3936 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 3937 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 3938 | Callback<R(A0)> callback(const U *obj, R (*func)(const T*, A0)) { |
<> | 149:156823d33999 | 3939 | return Callback<R(A0)>(func, obj); |
<> | 149:156823d33999 | 3940 | } |
<> | 149:156823d33999 | 3941 | |
<> | 149:156823d33999 | 3942 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3943 | * |
<> | 149:156823d33999 | 3944 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 3945 | * @param func Static function to attach |
<> | 149:156823d33999 | 3946 | * @return Callback with infered type |
<> | 149:156823d33999 | 3947 | * @deprecated |
<> | 149:156823d33999 | 3948 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 3949 | */ |
<> | 151:5eaa88a5bcc7 | 3950 | template <typename T, typename U, typename R, typename A0> |
<> | 149:156823d33999 | 3951 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 3952 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 3953 | Callback<R(A0)> callback(volatile U *obj, R (*func)(volatile T*, A0)) { |
<> | 149:156823d33999 | 3954 | return Callback<R(A0)>(func, obj); |
<> | 149:156823d33999 | 3955 | } |
<> | 149:156823d33999 | 3956 | |
<> | 149:156823d33999 | 3957 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3958 | * |
<> | 149:156823d33999 | 3959 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 3960 | * @param func Static function to attach |
<> | 149:156823d33999 | 3961 | * @return Callback with infered type |
<> | 149:156823d33999 | 3962 | * @deprecated |
<> | 149:156823d33999 | 3963 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 3964 | */ |
<> | 151:5eaa88a5bcc7 | 3965 | template <typename T, typename U, typename R, typename A0> |
<> | 149:156823d33999 | 3966 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 3967 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 3968 | Callback<R(A0)> callback(const volatile U *obj, R (*func)(const volatile T*, A0)) { |
<> | 149:156823d33999 | 3969 | return Callback<R(A0)>(func, obj); |
<> | 149:156823d33999 | 3970 | } |
<> | 149:156823d33999 | 3971 | |
<> | 149:156823d33999 | 3972 | |
<> | 149:156823d33999 | 3973 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3974 | * |
<> | 149:156823d33999 | 3975 | * @param func Static function to attach |
<> | 149:156823d33999 | 3976 | * @return Callback with infered type |
<> | 149:156823d33999 | 3977 | */ |
<> | 149:156823d33999 | 3978 | template <typename R, typename A0, typename A1> |
<> | 149:156823d33999 | 3979 | Callback<R(A0, A1)> callback(R (*func)(A0, A1) = 0) { |
<> | 149:156823d33999 | 3980 | return Callback<R(A0, A1)>(func); |
<> | 149:156823d33999 | 3981 | } |
<> | 149:156823d33999 | 3982 | |
<> | 149:156823d33999 | 3983 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3984 | * |
<> | 149:156823d33999 | 3985 | * @param func Static function to attach |
<> | 149:156823d33999 | 3986 | * @return Callback with infered type |
<> | 149:156823d33999 | 3987 | */ |
<> | 149:156823d33999 | 3988 | template <typename R, typename A0, typename A1> |
<> | 149:156823d33999 | 3989 | Callback<R(A0, A1)> callback(const Callback<R(A0, A1)> &func) { |
<> | 149:156823d33999 | 3990 | return Callback<R(A0, A1)>(func); |
<> | 149:156823d33999 | 3991 | } |
<> | 149:156823d33999 | 3992 | |
<> | 149:156823d33999 | 3993 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 3994 | * |
<> | 149:156823d33999 | 3995 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 3996 | * @param method Member function to attach |
<> | 149:156823d33999 | 3997 | * @return Callback with infered type |
<> | 149:156823d33999 | 3998 | */ |
<> | 151:5eaa88a5bcc7 | 3999 | template<typename T, typename U, typename R, typename A0, typename A1> |
<> | 151:5eaa88a5bcc7 | 4000 | Callback<R(A0, A1)> callback(U *obj, R (T::*method)(A0, A1)) { |
<> | 151:5eaa88a5bcc7 | 4001 | return Callback<R(A0, A1)>(obj, method); |
<> | 149:156823d33999 | 4002 | } |
<> | 149:156823d33999 | 4003 | |
<> | 149:156823d33999 | 4004 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4005 | * |
<> | 149:156823d33999 | 4006 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4007 | * @param method Member function to attach |
<> | 149:156823d33999 | 4008 | * @return Callback with infered type |
<> | 149:156823d33999 | 4009 | */ |
<> | 151:5eaa88a5bcc7 | 4010 | template<typename T, typename U, typename R, typename A0, typename A1> |
<> | 151:5eaa88a5bcc7 | 4011 | Callback<R(A0, A1)> callback(const U *obj, R (T::*method)(A0, A1) const) { |
<> | 151:5eaa88a5bcc7 | 4012 | return Callback<R(A0, A1)>(obj, method); |
<> | 149:156823d33999 | 4013 | } |
<> | 149:156823d33999 | 4014 | |
<> | 149:156823d33999 | 4015 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4016 | * |
<> | 149:156823d33999 | 4017 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4018 | * @param method Member function to attach |
<> | 149:156823d33999 | 4019 | * @return Callback with infered type |
<> | 149:156823d33999 | 4020 | */ |
<> | 151:5eaa88a5bcc7 | 4021 | template<typename T, typename U, typename R, typename A0, typename A1> |
<> | 151:5eaa88a5bcc7 | 4022 | Callback<R(A0, A1)> callback(volatile U *obj, R (T::*method)(A0, A1) volatile) { |
<> | 151:5eaa88a5bcc7 | 4023 | return Callback<R(A0, A1)>(obj, method); |
<> | 149:156823d33999 | 4024 | } |
<> | 149:156823d33999 | 4025 | |
<> | 149:156823d33999 | 4026 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4027 | * |
<> | 149:156823d33999 | 4028 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4029 | * @param method Member function to attach |
<> | 149:156823d33999 | 4030 | * @return Callback with infered type |
<> | 149:156823d33999 | 4031 | */ |
<> | 151:5eaa88a5bcc7 | 4032 | template<typename T, typename U, typename R, typename A0, typename A1> |
<> | 151:5eaa88a5bcc7 | 4033 | Callback<R(A0, A1)> callback(const volatile U *obj, R (T::*method)(A0, A1) const volatile) { |
<> | 151:5eaa88a5bcc7 | 4034 | return Callback<R(A0, A1)>(obj, method); |
<> | 149:156823d33999 | 4035 | } |
<> | 149:156823d33999 | 4036 | |
<> | 149:156823d33999 | 4037 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4038 | * |
<> | 149:156823d33999 | 4039 | * @param func Static function to attach |
<> | 149:156823d33999 | 4040 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 4041 | * @return Callback with infered type |
<> | 149:156823d33999 | 4042 | */ |
<> | 151:5eaa88a5bcc7 | 4043 | template <typename T, typename U, typename R, typename A0, typename A1> |
<> | 151:5eaa88a5bcc7 | 4044 | Callback<R(A0, A1)> callback(R (*func)(T*, A0, A1), U *arg) { |
<> | 149:156823d33999 | 4045 | return Callback<R(A0, A1)>(func, arg); |
<> | 149:156823d33999 | 4046 | } |
<> | 149:156823d33999 | 4047 | |
<> | 149:156823d33999 | 4048 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4049 | * |
<> | 149:156823d33999 | 4050 | * @param func Static function to attach |
<> | 149:156823d33999 | 4051 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 4052 | * @return Callback with infered type |
<> | 149:156823d33999 | 4053 | */ |
<> | 151:5eaa88a5bcc7 | 4054 | template <typename T, typename U, typename R, typename A0, typename A1> |
<> | 151:5eaa88a5bcc7 | 4055 | Callback<R(A0, A1)> callback(R (*func)(const T*, A0, A1), const U *arg) { |
<> | 149:156823d33999 | 4056 | return Callback<R(A0, A1)>(func, arg); |
<> | 149:156823d33999 | 4057 | } |
<> | 149:156823d33999 | 4058 | |
<> | 149:156823d33999 | 4059 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4060 | * |
<> | 149:156823d33999 | 4061 | * @param func Static function to attach |
<> | 149:156823d33999 | 4062 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 4063 | * @return Callback with infered type |
<> | 149:156823d33999 | 4064 | */ |
<> | 151:5eaa88a5bcc7 | 4065 | template <typename T, typename U, typename R, typename A0, typename A1> |
<> | 151:5eaa88a5bcc7 | 4066 | Callback<R(A0, A1)> callback(R (*func)(volatile T*, A0, A1), volatile U *arg) { |
<> | 149:156823d33999 | 4067 | return Callback<R(A0, A1)>(func, arg); |
<> | 149:156823d33999 | 4068 | } |
<> | 149:156823d33999 | 4069 | |
<> | 149:156823d33999 | 4070 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4071 | * |
<> | 149:156823d33999 | 4072 | * @param func Static function to attach |
<> | 149:156823d33999 | 4073 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 4074 | * @return Callback with infered type |
<> | 149:156823d33999 | 4075 | */ |
<> | 151:5eaa88a5bcc7 | 4076 | template <typename T, typename U, typename R, typename A0, typename A1> |
<> | 151:5eaa88a5bcc7 | 4077 | Callback<R(A0, A1)> callback(R (*func)(const volatile T*, A0, A1), const volatile U *arg) { |
<> | 149:156823d33999 | 4078 | return Callback<R(A0, A1)>(func, arg); |
<> | 149:156823d33999 | 4079 | } |
<> | 149:156823d33999 | 4080 | |
<> | 149:156823d33999 | 4081 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4082 | * |
<> | 149:156823d33999 | 4083 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4084 | * @param func Static function to attach |
<> | 149:156823d33999 | 4085 | * @return Callback with infered type |
<> | 149:156823d33999 | 4086 | * @deprecated |
<> | 149:156823d33999 | 4087 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 4088 | */ |
<> | 151:5eaa88a5bcc7 | 4089 | template <typename T, typename U, typename R, typename A0, typename A1> |
<> | 149:156823d33999 | 4090 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 4091 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 4092 | Callback<R(A0, A1)> callback(U *obj, R (*func)(T*, A0, A1)) { |
<> | 149:156823d33999 | 4093 | return Callback<R(A0, A1)>(func, obj); |
<> | 149:156823d33999 | 4094 | } |
<> | 149:156823d33999 | 4095 | |
<> | 149:156823d33999 | 4096 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4097 | * |
<> | 149:156823d33999 | 4098 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4099 | * @param func Static function to attach |
<> | 149:156823d33999 | 4100 | * @return Callback with infered type |
<> | 149:156823d33999 | 4101 | * @deprecated |
<> | 149:156823d33999 | 4102 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 4103 | */ |
<> | 151:5eaa88a5bcc7 | 4104 | template <typename T, typename U, typename R, typename A0, typename A1> |
<> | 149:156823d33999 | 4105 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 4106 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 4107 | Callback<R(A0, A1)> callback(const U *obj, R (*func)(const T*, A0, A1)) { |
<> | 149:156823d33999 | 4108 | return Callback<R(A0, A1)>(func, obj); |
<> | 149:156823d33999 | 4109 | } |
<> | 149:156823d33999 | 4110 | |
<> | 149:156823d33999 | 4111 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4112 | * |
<> | 149:156823d33999 | 4113 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4114 | * @param func Static function to attach |
<> | 149:156823d33999 | 4115 | * @return Callback with infered type |
<> | 149:156823d33999 | 4116 | * @deprecated |
<> | 149:156823d33999 | 4117 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 4118 | */ |
<> | 151:5eaa88a5bcc7 | 4119 | template <typename T, typename U, typename R, typename A0, typename A1> |
<> | 149:156823d33999 | 4120 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 4121 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 4122 | Callback<R(A0, A1)> callback(volatile U *obj, R (*func)(volatile T*, A0, A1)) { |
<> | 149:156823d33999 | 4123 | return Callback<R(A0, A1)>(func, obj); |
<> | 149:156823d33999 | 4124 | } |
<> | 149:156823d33999 | 4125 | |
<> | 149:156823d33999 | 4126 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4127 | * |
<> | 149:156823d33999 | 4128 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4129 | * @param func Static function to attach |
<> | 149:156823d33999 | 4130 | * @return Callback with infered type |
<> | 149:156823d33999 | 4131 | * @deprecated |
<> | 149:156823d33999 | 4132 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 4133 | */ |
<> | 151:5eaa88a5bcc7 | 4134 | template <typename T, typename U, typename R, typename A0, typename A1> |
<> | 149:156823d33999 | 4135 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 4136 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 4137 | Callback<R(A0, A1)> callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1)) { |
<> | 149:156823d33999 | 4138 | return Callback<R(A0, A1)>(func, obj); |
<> | 149:156823d33999 | 4139 | } |
<> | 149:156823d33999 | 4140 | |
<> | 149:156823d33999 | 4141 | |
<> | 149:156823d33999 | 4142 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4143 | * |
<> | 149:156823d33999 | 4144 | * @param func Static function to attach |
<> | 149:156823d33999 | 4145 | * @return Callback with infered type |
<> | 149:156823d33999 | 4146 | */ |
<> | 149:156823d33999 | 4147 | template <typename R, typename A0, typename A1, typename A2> |
<> | 149:156823d33999 | 4148 | Callback<R(A0, A1, A2)> callback(R (*func)(A0, A1, A2) = 0) { |
<> | 149:156823d33999 | 4149 | return Callback<R(A0, A1, A2)>(func); |
<> | 149:156823d33999 | 4150 | } |
<> | 149:156823d33999 | 4151 | |
<> | 149:156823d33999 | 4152 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4153 | * |
<> | 149:156823d33999 | 4154 | * @param func Static function to attach |
<> | 149:156823d33999 | 4155 | * @return Callback with infered type |
<> | 149:156823d33999 | 4156 | */ |
<> | 149:156823d33999 | 4157 | template <typename R, typename A0, typename A1, typename A2> |
<> | 149:156823d33999 | 4158 | Callback<R(A0, A1, A2)> callback(const Callback<R(A0, A1, A2)> &func) { |
<> | 149:156823d33999 | 4159 | return Callback<R(A0, A1, A2)>(func); |
<> | 149:156823d33999 | 4160 | } |
<> | 149:156823d33999 | 4161 | |
<> | 149:156823d33999 | 4162 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4163 | * |
<> | 149:156823d33999 | 4164 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4165 | * @param method Member function to attach |
<> | 149:156823d33999 | 4166 | * @return Callback with infered type |
<> | 149:156823d33999 | 4167 | */ |
<> | 151:5eaa88a5bcc7 | 4168 | template<typename T, typename U, typename R, typename A0, typename A1, typename A2> |
<> | 151:5eaa88a5bcc7 | 4169 | Callback<R(A0, A1, A2)> callback(U *obj, R (T::*method)(A0, A1, A2)) { |
<> | 151:5eaa88a5bcc7 | 4170 | return Callback<R(A0, A1, A2)>(obj, method); |
<> | 149:156823d33999 | 4171 | } |
<> | 149:156823d33999 | 4172 | |
<> | 149:156823d33999 | 4173 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4174 | * |
<> | 149:156823d33999 | 4175 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4176 | * @param method Member function to attach |
<> | 149:156823d33999 | 4177 | * @return Callback with infered type |
<> | 149:156823d33999 | 4178 | */ |
<> | 151:5eaa88a5bcc7 | 4179 | template<typename T, typename U, typename R, typename A0, typename A1, typename A2> |
<> | 151:5eaa88a5bcc7 | 4180 | Callback<R(A0, A1, A2)> callback(const U *obj, R (T::*method)(A0, A1, A2) const) { |
<> | 151:5eaa88a5bcc7 | 4181 | return Callback<R(A0, A1, A2)>(obj, method); |
<> | 149:156823d33999 | 4182 | } |
<> | 149:156823d33999 | 4183 | |
<> | 149:156823d33999 | 4184 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4185 | * |
<> | 149:156823d33999 | 4186 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4187 | * @param method Member function to attach |
<> | 149:156823d33999 | 4188 | * @return Callback with infered type |
<> | 149:156823d33999 | 4189 | */ |
<> | 151:5eaa88a5bcc7 | 4190 | template<typename T, typename U, typename R, typename A0, typename A1, typename A2> |
<> | 151:5eaa88a5bcc7 | 4191 | Callback<R(A0, A1, A2)> callback(volatile U *obj, R (T::*method)(A0, A1, A2) volatile) { |
<> | 151:5eaa88a5bcc7 | 4192 | return Callback<R(A0, A1, A2)>(obj, method); |
<> | 149:156823d33999 | 4193 | } |
<> | 149:156823d33999 | 4194 | |
<> | 149:156823d33999 | 4195 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4196 | * |
<> | 149:156823d33999 | 4197 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4198 | * @param method Member function to attach |
<> | 149:156823d33999 | 4199 | * @return Callback with infered type |
<> | 149:156823d33999 | 4200 | */ |
<> | 151:5eaa88a5bcc7 | 4201 | template<typename T, typename U, typename R, typename A0, typename A1, typename A2> |
<> | 151:5eaa88a5bcc7 | 4202 | Callback<R(A0, A1, A2)> callback(const volatile U *obj, R (T::*method)(A0, A1, A2) const volatile) { |
<> | 151:5eaa88a5bcc7 | 4203 | return Callback<R(A0, A1, A2)>(obj, method); |
<> | 149:156823d33999 | 4204 | } |
<> | 149:156823d33999 | 4205 | |
<> | 149:156823d33999 | 4206 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4207 | * |
<> | 149:156823d33999 | 4208 | * @param func Static function to attach |
<> | 149:156823d33999 | 4209 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 4210 | * @return Callback with infered type |
<> | 149:156823d33999 | 4211 | */ |
<> | 151:5eaa88a5bcc7 | 4212 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2> |
<> | 151:5eaa88a5bcc7 | 4213 | Callback<R(A0, A1, A2)> callback(R (*func)(T*, A0, A1, A2), U *arg) { |
<> | 149:156823d33999 | 4214 | return Callback<R(A0, A1, A2)>(func, arg); |
<> | 149:156823d33999 | 4215 | } |
<> | 149:156823d33999 | 4216 | |
<> | 149:156823d33999 | 4217 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4218 | * |
<> | 149:156823d33999 | 4219 | * @param func Static function to attach |
<> | 149:156823d33999 | 4220 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 4221 | * @return Callback with infered type |
<> | 149:156823d33999 | 4222 | */ |
<> | 151:5eaa88a5bcc7 | 4223 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2> |
<> | 151:5eaa88a5bcc7 | 4224 | Callback<R(A0, A1, A2)> callback(R (*func)(const T*, A0, A1, A2), const U *arg) { |
<> | 149:156823d33999 | 4225 | return Callback<R(A0, A1, A2)>(func, arg); |
<> | 149:156823d33999 | 4226 | } |
<> | 149:156823d33999 | 4227 | |
<> | 149:156823d33999 | 4228 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4229 | * |
<> | 149:156823d33999 | 4230 | * @param func Static function to attach |
<> | 149:156823d33999 | 4231 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 4232 | * @return Callback with infered type |
<> | 149:156823d33999 | 4233 | */ |
<> | 151:5eaa88a5bcc7 | 4234 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2> |
<> | 151:5eaa88a5bcc7 | 4235 | Callback<R(A0, A1, A2)> callback(R (*func)(volatile T*, A0, A1, A2), volatile U *arg) { |
<> | 149:156823d33999 | 4236 | return Callback<R(A0, A1, A2)>(func, arg); |
<> | 149:156823d33999 | 4237 | } |
<> | 149:156823d33999 | 4238 | |
<> | 149:156823d33999 | 4239 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4240 | * |
<> | 149:156823d33999 | 4241 | * @param func Static function to attach |
<> | 149:156823d33999 | 4242 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 4243 | * @return Callback with infered type |
<> | 149:156823d33999 | 4244 | */ |
<> | 151:5eaa88a5bcc7 | 4245 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2> |
<> | 151:5eaa88a5bcc7 | 4246 | Callback<R(A0, A1, A2)> callback(R (*func)(const volatile T*, A0, A1, A2), const volatile U *arg) { |
<> | 149:156823d33999 | 4247 | return Callback<R(A0, A1, A2)>(func, arg); |
<> | 149:156823d33999 | 4248 | } |
<> | 149:156823d33999 | 4249 | |
<> | 149:156823d33999 | 4250 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4251 | * |
<> | 149:156823d33999 | 4252 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4253 | * @param func Static function to attach |
<> | 149:156823d33999 | 4254 | * @return Callback with infered type |
<> | 149:156823d33999 | 4255 | * @deprecated |
<> | 149:156823d33999 | 4256 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 4257 | */ |
<> | 151:5eaa88a5bcc7 | 4258 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2> |
<> | 149:156823d33999 | 4259 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 4260 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 4261 | Callback<R(A0, A1, A2)> callback(U *obj, R (*func)(T*, A0, A1, A2)) { |
<> | 149:156823d33999 | 4262 | return Callback<R(A0, A1, A2)>(func, obj); |
<> | 149:156823d33999 | 4263 | } |
<> | 149:156823d33999 | 4264 | |
<> | 149:156823d33999 | 4265 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4266 | * |
<> | 149:156823d33999 | 4267 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4268 | * @param func Static function to attach |
<> | 149:156823d33999 | 4269 | * @return Callback with infered type |
<> | 149:156823d33999 | 4270 | * @deprecated |
<> | 149:156823d33999 | 4271 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 4272 | */ |
<> | 151:5eaa88a5bcc7 | 4273 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2> |
<> | 149:156823d33999 | 4274 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 4275 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 4276 | Callback<R(A0, A1, A2)> callback(const U *obj, R (*func)(const T*, A0, A1, A2)) { |
<> | 149:156823d33999 | 4277 | return Callback<R(A0, A1, A2)>(func, obj); |
<> | 149:156823d33999 | 4278 | } |
<> | 149:156823d33999 | 4279 | |
<> | 149:156823d33999 | 4280 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4281 | * |
<> | 149:156823d33999 | 4282 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4283 | * @param func Static function to attach |
<> | 149:156823d33999 | 4284 | * @return Callback with infered type |
<> | 149:156823d33999 | 4285 | * @deprecated |
<> | 149:156823d33999 | 4286 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 4287 | */ |
<> | 151:5eaa88a5bcc7 | 4288 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2> |
<> | 149:156823d33999 | 4289 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 4290 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 4291 | Callback<R(A0, A1, A2)> callback(volatile U *obj, R (*func)(volatile T*, A0, A1, A2)) { |
<> | 149:156823d33999 | 4292 | return Callback<R(A0, A1, A2)>(func, obj); |
<> | 149:156823d33999 | 4293 | } |
<> | 149:156823d33999 | 4294 | |
<> | 149:156823d33999 | 4295 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4296 | * |
<> | 149:156823d33999 | 4297 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4298 | * @param func Static function to attach |
<> | 149:156823d33999 | 4299 | * @return Callback with infered type |
<> | 149:156823d33999 | 4300 | * @deprecated |
<> | 149:156823d33999 | 4301 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 4302 | */ |
<> | 151:5eaa88a5bcc7 | 4303 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2> |
<> | 149:156823d33999 | 4304 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 4305 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 4306 | Callback<R(A0, A1, A2)> callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2)) { |
<> | 149:156823d33999 | 4307 | return Callback<R(A0, A1, A2)>(func, obj); |
<> | 149:156823d33999 | 4308 | } |
<> | 149:156823d33999 | 4309 | |
<> | 149:156823d33999 | 4310 | |
<> | 149:156823d33999 | 4311 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4312 | * |
<> | 149:156823d33999 | 4313 | * @param func Static function to attach |
<> | 149:156823d33999 | 4314 | * @return Callback with infered type |
<> | 149:156823d33999 | 4315 | */ |
<> | 149:156823d33999 | 4316 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
<> | 149:156823d33999 | 4317 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(A0, A1, A2, A3) = 0) { |
<> | 149:156823d33999 | 4318 | return Callback<R(A0, A1, A2, A3)>(func); |
<> | 149:156823d33999 | 4319 | } |
<> | 149:156823d33999 | 4320 | |
<> | 149:156823d33999 | 4321 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4322 | * |
<> | 149:156823d33999 | 4323 | * @param func Static function to attach |
<> | 149:156823d33999 | 4324 | * @return Callback with infered type |
<> | 149:156823d33999 | 4325 | */ |
<> | 149:156823d33999 | 4326 | template <typename R, typename A0, typename A1, typename A2, typename A3> |
<> | 149:156823d33999 | 4327 | Callback<R(A0, A1, A2, A3)> callback(const Callback<R(A0, A1, A2, A3)> &func) { |
<> | 149:156823d33999 | 4328 | return Callback<R(A0, A1, A2, A3)>(func); |
<> | 149:156823d33999 | 4329 | } |
<> | 149:156823d33999 | 4330 | |
<> | 149:156823d33999 | 4331 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4332 | * |
<> | 149:156823d33999 | 4333 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4334 | * @param method Member function to attach |
<> | 149:156823d33999 | 4335 | * @return Callback with infered type |
<> | 149:156823d33999 | 4336 | */ |
<> | 151:5eaa88a5bcc7 | 4337 | template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> |
<> | 151:5eaa88a5bcc7 | 4338 | Callback<R(A0, A1, A2, A3)> callback(U *obj, R (T::*method)(A0, A1, A2, A3)) { |
<> | 151:5eaa88a5bcc7 | 4339 | return Callback<R(A0, A1, A2, A3)>(obj, method); |
<> | 149:156823d33999 | 4340 | } |
<> | 149:156823d33999 | 4341 | |
<> | 149:156823d33999 | 4342 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4343 | * |
<> | 149:156823d33999 | 4344 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4345 | * @param method Member function to attach |
<> | 149:156823d33999 | 4346 | * @return Callback with infered type |
<> | 149:156823d33999 | 4347 | */ |
<> | 151:5eaa88a5bcc7 | 4348 | template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> |
<> | 151:5eaa88a5bcc7 | 4349 | Callback<R(A0, A1, A2, A3)> callback(const U *obj, R (T::*method)(A0, A1, A2, A3) const) { |
<> | 151:5eaa88a5bcc7 | 4350 | return Callback<R(A0, A1, A2, A3)>(obj, method); |
<> | 149:156823d33999 | 4351 | } |
<> | 149:156823d33999 | 4352 | |
<> | 149:156823d33999 | 4353 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4354 | * |
<> | 149:156823d33999 | 4355 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4356 | * @param method Member function to attach |
<> | 149:156823d33999 | 4357 | * @return Callback with infered type |
<> | 149:156823d33999 | 4358 | */ |
<> | 151:5eaa88a5bcc7 | 4359 | template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> |
<> | 151:5eaa88a5bcc7 | 4360 | Callback<R(A0, A1, A2, A3)> callback(volatile U *obj, R (T::*method)(A0, A1, A2, A3) volatile) { |
<> | 151:5eaa88a5bcc7 | 4361 | return Callback<R(A0, A1, A2, A3)>(obj, method); |
<> | 149:156823d33999 | 4362 | } |
<> | 149:156823d33999 | 4363 | |
<> | 149:156823d33999 | 4364 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4365 | * |
<> | 149:156823d33999 | 4366 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4367 | * @param method Member function to attach |
<> | 149:156823d33999 | 4368 | * @return Callback with infered type |
<> | 149:156823d33999 | 4369 | */ |
<> | 151:5eaa88a5bcc7 | 4370 | template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> |
<> | 151:5eaa88a5bcc7 | 4371 | Callback<R(A0, A1, A2, A3)> callback(const volatile U *obj, R (T::*method)(A0, A1, A2, A3) const volatile) { |
<> | 151:5eaa88a5bcc7 | 4372 | return Callback<R(A0, A1, A2, A3)>(obj, method); |
<> | 149:156823d33999 | 4373 | } |
<> | 149:156823d33999 | 4374 | |
<> | 149:156823d33999 | 4375 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4376 | * |
<> | 149:156823d33999 | 4377 | * @param func Static function to attach |
<> | 149:156823d33999 | 4378 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 4379 | * @return Callback with infered type |
<> | 149:156823d33999 | 4380 | */ |
<> | 151:5eaa88a5bcc7 | 4381 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> |
<> | 151:5eaa88a5bcc7 | 4382 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(T*, A0, A1, A2, A3), U *arg) { |
<> | 149:156823d33999 | 4383 | return Callback<R(A0, A1, A2, A3)>(func, arg); |
<> | 149:156823d33999 | 4384 | } |
<> | 149:156823d33999 | 4385 | |
<> | 149:156823d33999 | 4386 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4387 | * |
<> | 149:156823d33999 | 4388 | * @param func Static function to attach |
<> | 149:156823d33999 | 4389 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 4390 | * @return Callback with infered type |
<> | 149:156823d33999 | 4391 | */ |
<> | 151:5eaa88a5bcc7 | 4392 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> |
<> | 151:5eaa88a5bcc7 | 4393 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(const T*, A0, A1, A2, A3), const U *arg) { |
<> | 149:156823d33999 | 4394 | return Callback<R(A0, A1, A2, A3)>(func, arg); |
<> | 149:156823d33999 | 4395 | } |
<> | 149:156823d33999 | 4396 | |
<> | 149:156823d33999 | 4397 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4398 | * |
<> | 149:156823d33999 | 4399 | * @param func Static function to attach |
<> | 149:156823d33999 | 4400 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 4401 | * @return Callback with infered type |
<> | 149:156823d33999 | 4402 | */ |
<> | 151:5eaa88a5bcc7 | 4403 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> |
<> | 151:5eaa88a5bcc7 | 4404 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(volatile T*, A0, A1, A2, A3), volatile U *arg) { |
<> | 149:156823d33999 | 4405 | return Callback<R(A0, A1, A2, A3)>(func, arg); |
<> | 149:156823d33999 | 4406 | } |
<> | 149:156823d33999 | 4407 | |
<> | 149:156823d33999 | 4408 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4409 | * |
<> | 149:156823d33999 | 4410 | * @param func Static function to attach |
<> | 149:156823d33999 | 4411 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 4412 | * @return Callback with infered type |
<> | 149:156823d33999 | 4413 | */ |
<> | 151:5eaa88a5bcc7 | 4414 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> |
<> | 151:5eaa88a5bcc7 | 4415 | Callback<R(A0, A1, A2, A3)> callback(R (*func)(const volatile T*, A0, A1, A2, A3), const volatile U *arg) { |
<> | 149:156823d33999 | 4416 | return Callback<R(A0, A1, A2, A3)>(func, arg); |
<> | 149:156823d33999 | 4417 | } |
<> | 149:156823d33999 | 4418 | |
<> | 149:156823d33999 | 4419 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4420 | * |
<> | 149:156823d33999 | 4421 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4422 | * @param func Static function to attach |
<> | 149:156823d33999 | 4423 | * @return Callback with infered type |
<> | 149:156823d33999 | 4424 | * @deprecated |
<> | 149:156823d33999 | 4425 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 4426 | */ |
<> | 151:5eaa88a5bcc7 | 4427 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> |
<> | 149:156823d33999 | 4428 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 4429 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 4430 | Callback<R(A0, A1, A2, A3)> callback(U *obj, R (*func)(T*, A0, A1, A2, A3)) { |
<> | 149:156823d33999 | 4431 | return Callback<R(A0, A1, A2, A3)>(func, obj); |
<> | 149:156823d33999 | 4432 | } |
<> | 149:156823d33999 | 4433 | |
<> | 149:156823d33999 | 4434 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4435 | * |
<> | 149:156823d33999 | 4436 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4437 | * @param func Static function to attach |
<> | 149:156823d33999 | 4438 | * @return Callback with infered type |
<> | 149:156823d33999 | 4439 | * @deprecated |
<> | 149:156823d33999 | 4440 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 4441 | */ |
<> | 151:5eaa88a5bcc7 | 4442 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> |
<> | 149:156823d33999 | 4443 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 4444 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 4445 | Callback<R(A0, A1, A2, A3)> callback(const U *obj, R (*func)(const T*, A0, A1, A2, A3)) { |
<> | 149:156823d33999 | 4446 | return Callback<R(A0, A1, A2, A3)>(func, obj); |
<> | 149:156823d33999 | 4447 | } |
<> | 149:156823d33999 | 4448 | |
<> | 149:156823d33999 | 4449 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4450 | * |
<> | 149:156823d33999 | 4451 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4452 | * @param func Static function to attach |
<> | 149:156823d33999 | 4453 | * @return Callback with infered type |
<> | 149:156823d33999 | 4454 | * @deprecated |
<> | 149:156823d33999 | 4455 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 4456 | */ |
<> | 151:5eaa88a5bcc7 | 4457 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> |
<> | 149:156823d33999 | 4458 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 4459 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 4460 | Callback<R(A0, A1, A2, A3)> callback(volatile U *obj, R (*func)(volatile T*, A0, A1, A2, A3)) { |
<> | 149:156823d33999 | 4461 | return Callback<R(A0, A1, A2, A3)>(func, obj); |
<> | 149:156823d33999 | 4462 | } |
<> | 149:156823d33999 | 4463 | |
<> | 149:156823d33999 | 4464 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4465 | * |
<> | 149:156823d33999 | 4466 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4467 | * @param func Static function to attach |
<> | 149:156823d33999 | 4468 | * @return Callback with infered type |
<> | 149:156823d33999 | 4469 | * @deprecated |
<> | 149:156823d33999 | 4470 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 4471 | */ |
<> | 151:5eaa88a5bcc7 | 4472 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3> |
<> | 149:156823d33999 | 4473 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 4474 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 4475 | Callback<R(A0, A1, A2, A3)> callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2, A3)) { |
<> | 149:156823d33999 | 4476 | return Callback<R(A0, A1, A2, A3)>(func, obj); |
<> | 149:156823d33999 | 4477 | } |
<> | 149:156823d33999 | 4478 | |
<> | 149:156823d33999 | 4479 | |
<> | 149:156823d33999 | 4480 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4481 | * |
<> | 149:156823d33999 | 4482 | * @param func Static function to attach |
<> | 149:156823d33999 | 4483 | * @return Callback with infered type |
<> | 149:156823d33999 | 4484 | */ |
<> | 149:156823d33999 | 4485 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
<> | 149:156823d33999 | 4486 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(A0, A1, A2, A3, A4) = 0) { |
<> | 149:156823d33999 | 4487 | return Callback<R(A0, A1, A2, A3, A4)>(func); |
<> | 149:156823d33999 | 4488 | } |
<> | 149:156823d33999 | 4489 | |
<> | 149:156823d33999 | 4490 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4491 | * |
<> | 149:156823d33999 | 4492 | * @param func Static function to attach |
<> | 149:156823d33999 | 4493 | * @return Callback with infered type |
<> | 149:156823d33999 | 4494 | */ |
<> | 149:156823d33999 | 4495 | template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
<> | 149:156823d33999 | 4496 | Callback<R(A0, A1, A2, A3, A4)> callback(const Callback<R(A0, A1, A2, A3, A4)> &func) { |
<> | 149:156823d33999 | 4497 | return Callback<R(A0, A1, A2, A3, A4)>(func); |
<> | 149:156823d33999 | 4498 | } |
<> | 149:156823d33999 | 4499 | |
<> | 149:156823d33999 | 4500 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4501 | * |
<> | 149:156823d33999 | 4502 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4503 | * @param method Member function to attach |
<> | 149:156823d33999 | 4504 | * @return Callback with infered type |
<> | 149:156823d33999 | 4505 | */ |
<> | 151:5eaa88a5bcc7 | 4506 | template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
<> | 151:5eaa88a5bcc7 | 4507 | Callback<R(A0, A1, A2, A3, A4)> callback(U *obj, R (T::*method)(A0, A1, A2, A3, A4)) { |
<> | 151:5eaa88a5bcc7 | 4508 | return Callback<R(A0, A1, A2, A3, A4)>(obj, method); |
<> | 149:156823d33999 | 4509 | } |
<> | 149:156823d33999 | 4510 | |
<> | 149:156823d33999 | 4511 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4512 | * |
<> | 149:156823d33999 | 4513 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4514 | * @param method Member function to attach |
<> | 149:156823d33999 | 4515 | * @return Callback with infered type |
<> | 149:156823d33999 | 4516 | */ |
<> | 151:5eaa88a5bcc7 | 4517 | template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
<> | 151:5eaa88a5bcc7 | 4518 | Callback<R(A0, A1, A2, A3, A4)> callback(const U *obj, R (T::*method)(A0, A1, A2, A3, A4) const) { |
<> | 151:5eaa88a5bcc7 | 4519 | return Callback<R(A0, A1, A2, A3, A4)>(obj, method); |
<> | 149:156823d33999 | 4520 | } |
<> | 149:156823d33999 | 4521 | |
<> | 149:156823d33999 | 4522 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4523 | * |
<> | 149:156823d33999 | 4524 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4525 | * @param method Member function to attach |
<> | 149:156823d33999 | 4526 | * @return Callback with infered type |
<> | 149:156823d33999 | 4527 | */ |
<> | 151:5eaa88a5bcc7 | 4528 | template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
<> | 151:5eaa88a5bcc7 | 4529 | Callback<R(A0, A1, A2, A3, A4)> callback(volatile U *obj, R (T::*method)(A0, A1, A2, A3, A4) volatile) { |
<> | 151:5eaa88a5bcc7 | 4530 | return Callback<R(A0, A1, A2, A3, A4)>(obj, method); |
<> | 149:156823d33999 | 4531 | } |
<> | 149:156823d33999 | 4532 | |
<> | 149:156823d33999 | 4533 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4534 | * |
<> | 149:156823d33999 | 4535 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4536 | * @param method Member function to attach |
<> | 149:156823d33999 | 4537 | * @return Callback with infered type |
<> | 149:156823d33999 | 4538 | */ |
<> | 151:5eaa88a5bcc7 | 4539 | template<typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
<> | 151:5eaa88a5bcc7 | 4540 | Callback<R(A0, A1, A2, A3, A4)> callback(const volatile U *obj, R (T::*method)(A0, A1, A2, A3, A4) const volatile) { |
<> | 151:5eaa88a5bcc7 | 4541 | return Callback<R(A0, A1, A2, A3, A4)>(obj, method); |
<> | 149:156823d33999 | 4542 | } |
<> | 149:156823d33999 | 4543 | |
<> | 149:156823d33999 | 4544 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4545 | * |
<> | 149:156823d33999 | 4546 | * @param func Static function to attach |
<> | 149:156823d33999 | 4547 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 4548 | * @return Callback with infered type |
<> | 149:156823d33999 | 4549 | */ |
<> | 151:5eaa88a5bcc7 | 4550 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
<> | 151:5eaa88a5bcc7 | 4551 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(T*, A0, A1, A2, A3, A4), U *arg) { |
<> | 149:156823d33999 | 4552 | return Callback<R(A0, A1, A2, A3, A4)>(func, arg); |
<> | 149:156823d33999 | 4553 | } |
<> | 149:156823d33999 | 4554 | |
<> | 149:156823d33999 | 4555 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4556 | * |
<> | 149:156823d33999 | 4557 | * @param func Static function to attach |
<> | 149:156823d33999 | 4558 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 4559 | * @return Callback with infered type |
<> | 149:156823d33999 | 4560 | */ |
<> | 151:5eaa88a5bcc7 | 4561 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
<> | 151:5eaa88a5bcc7 | 4562 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(const T*, A0, A1, A2, A3, A4), const U *arg) { |
<> | 149:156823d33999 | 4563 | return Callback<R(A0, A1, A2, A3, A4)>(func, arg); |
<> | 149:156823d33999 | 4564 | } |
<> | 149:156823d33999 | 4565 | |
<> | 149:156823d33999 | 4566 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4567 | * |
<> | 149:156823d33999 | 4568 | * @param func Static function to attach |
<> | 149:156823d33999 | 4569 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 4570 | * @return Callback with infered type |
<> | 149:156823d33999 | 4571 | */ |
<> | 151:5eaa88a5bcc7 | 4572 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
<> | 151:5eaa88a5bcc7 | 4573 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(volatile T*, A0, A1, A2, A3, A4), volatile U *arg) { |
<> | 149:156823d33999 | 4574 | return Callback<R(A0, A1, A2, A3, A4)>(func, arg); |
<> | 149:156823d33999 | 4575 | } |
<> | 149:156823d33999 | 4576 | |
<> | 149:156823d33999 | 4577 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4578 | * |
<> | 149:156823d33999 | 4579 | * @param func Static function to attach |
<> | 149:156823d33999 | 4580 | * @param arg Pointer argument to function |
<> | 149:156823d33999 | 4581 | * @return Callback with infered type |
<> | 149:156823d33999 | 4582 | */ |
<> | 151:5eaa88a5bcc7 | 4583 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
<> | 151:5eaa88a5bcc7 | 4584 | Callback<R(A0, A1, A2, A3, A4)> callback(R (*func)(const volatile T*, A0, A1, A2, A3, A4), const volatile U *arg) { |
<> | 149:156823d33999 | 4585 | return Callback<R(A0, A1, A2, A3, A4)>(func, arg); |
<> | 149:156823d33999 | 4586 | } |
<> | 149:156823d33999 | 4587 | |
<> | 149:156823d33999 | 4588 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4589 | * |
<> | 149:156823d33999 | 4590 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4591 | * @param func Static function to attach |
<> | 149:156823d33999 | 4592 | * @return Callback with infered type |
<> | 149:156823d33999 | 4593 | * @deprecated |
<> | 149:156823d33999 | 4594 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 4595 | */ |
<> | 151:5eaa88a5bcc7 | 4596 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
<> | 149:156823d33999 | 4597 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 4598 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 4599 | Callback<R(A0, A1, A2, A3, A4)> callback(U *obj, R (*func)(T*, A0, A1, A2, A3, A4)) { |
<> | 149:156823d33999 | 4600 | return Callback<R(A0, A1, A2, A3, A4)>(func, obj); |
<> | 149:156823d33999 | 4601 | } |
<> | 149:156823d33999 | 4602 | |
<> | 149:156823d33999 | 4603 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4604 | * |
<> | 149:156823d33999 | 4605 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4606 | * @param func Static function to attach |
<> | 149:156823d33999 | 4607 | * @return Callback with infered type |
<> | 149:156823d33999 | 4608 | * @deprecated |
<> | 149:156823d33999 | 4609 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 4610 | */ |
<> | 151:5eaa88a5bcc7 | 4611 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
<> | 149:156823d33999 | 4612 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 4613 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 4614 | Callback<R(A0, A1, A2, A3, A4)> callback(const U *obj, R (*func)(const T*, A0, A1, A2, A3, A4)) { |
<> | 149:156823d33999 | 4615 | return Callback<R(A0, A1, A2, A3, A4)>(func, obj); |
<> | 149:156823d33999 | 4616 | } |
<> | 149:156823d33999 | 4617 | |
<> | 149:156823d33999 | 4618 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4619 | * |
<> | 149:156823d33999 | 4620 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4621 | * @param func Static function to attach |
<> | 149:156823d33999 | 4622 | * @return Callback with infered type |
<> | 149:156823d33999 | 4623 | * @deprecated |
<> | 149:156823d33999 | 4624 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 4625 | */ |
<> | 151:5eaa88a5bcc7 | 4626 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
<> | 149:156823d33999 | 4627 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 4628 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 4629 | Callback<R(A0, A1, A2, A3, A4)> callback(volatile U *obj, R (*func)(volatile T*, A0, A1, A2, A3, A4)) { |
<> | 149:156823d33999 | 4630 | return Callback<R(A0, A1, A2, A3, A4)>(func, obj); |
<> | 149:156823d33999 | 4631 | } |
<> | 149:156823d33999 | 4632 | |
<> | 149:156823d33999 | 4633 | /** Create a callback class with type infered from the arguments |
<> | 149:156823d33999 | 4634 | * |
<> | 149:156823d33999 | 4635 | * @param obj Optional pointer to object to bind to function |
<> | 149:156823d33999 | 4636 | * @param func Static function to attach |
<> | 149:156823d33999 | 4637 | * @return Callback with infered type |
<> | 149:156823d33999 | 4638 | * @deprecated |
<> | 149:156823d33999 | 4639 | * Arguments to callback have been reordered to callback(func, arg) |
<> | 149:156823d33999 | 4640 | */ |
<> | 151:5eaa88a5bcc7 | 4641 | template <typename T, typename U, typename R, typename A0, typename A1, typename A2, typename A3, typename A4> |
<> | 149:156823d33999 | 4642 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
<> | 149:156823d33999 | 4643 | "Arguments to callback have been reordered to callback(func, arg)") |
<> | 151:5eaa88a5bcc7 | 4644 | Callback<R(A0, A1, A2, A3, A4)> callback(const volatile U *obj, R (*func)(const volatile T*, A0, A1, A2, A3, A4)) { |
<> | 149:156823d33999 | 4645 | return Callback<R(A0, A1, A2, A3, A4)>(func, obj); |
<> | 149:156823d33999 | 4646 | } |
<> | 149:156823d33999 | 4647 | |
<> | 149:156823d33999 | 4648 | |
<> | 149:156823d33999 | 4649 | } // namespace mbed |
<> | 149:156823d33999 | 4650 | |
<> | 149:156823d33999 | 4651 | #endif |
<> | 149:156823d33999 | 4652 | |
<> | 149:156823d33999 | 4653 | |
<> | 149:156823d33999 | 4654 | /** @}*/ |