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