RTC auf true
platform/CallChain.h@2:7aab896b1a3b, 2019-03-13 (annotated)
- Committer:
- kevman
- Date:
- Wed Mar 13 11:03:24 2019 +0000
- Revision:
- 2:7aab896b1a3b
- Parent:
- 0:38ceb79fef03
2019-03-13
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kevman | 0:38ceb79fef03 | 1 | /* mbed Microcontroller Library |
kevman | 0:38ceb79fef03 | 2 | * Copyright (c) 2006-2013 ARM Limited |
kevman | 0:38ceb79fef03 | 3 | * |
kevman | 0:38ceb79fef03 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
kevman | 0:38ceb79fef03 | 5 | * you may not use this file except in compliance with the License. |
kevman | 0:38ceb79fef03 | 6 | * You may obtain a copy of the License at |
kevman | 0:38ceb79fef03 | 7 | * |
kevman | 0:38ceb79fef03 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
kevman | 0:38ceb79fef03 | 9 | * |
kevman | 0:38ceb79fef03 | 10 | * Unless required by applicable law or agreed to in writing, software |
kevman | 0:38ceb79fef03 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
kevman | 0:38ceb79fef03 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
kevman | 0:38ceb79fef03 | 13 | * See the License for the specific language governing permissions and |
kevman | 0:38ceb79fef03 | 14 | * limitations under the License. |
kevman | 0:38ceb79fef03 | 15 | */ |
kevman | 0:38ceb79fef03 | 16 | #ifndef MBED_CALLCHAIN_H |
kevman | 0:38ceb79fef03 | 17 | #define MBED_CALLCHAIN_H |
kevman | 0:38ceb79fef03 | 18 | |
kevman | 0:38ceb79fef03 | 19 | #include "platform/Callback.h" |
kevman | 0:38ceb79fef03 | 20 | #include "platform/mbed_toolchain.h" |
kevman | 0:38ceb79fef03 | 21 | #include "platform/NonCopyable.h" |
kevman | 0:38ceb79fef03 | 22 | #include <string.h> |
kevman | 0:38ceb79fef03 | 23 | |
kevman | 0:38ceb79fef03 | 24 | namespace mbed { |
kevman | 0:38ceb79fef03 | 25 | |
kevman | 0:38ceb79fef03 | 26 | |
kevman | 0:38ceb79fef03 | 27 | typedef Callback<void()> *pFunctionPointer_t; |
kevman | 0:38ceb79fef03 | 28 | class CallChainLink; |
kevman | 0:38ceb79fef03 | 29 | |
kevman | 0:38ceb79fef03 | 30 | /** \addtogroup platform */ |
kevman | 0:38ceb79fef03 | 31 | /** @{*/ |
kevman | 0:38ceb79fef03 | 32 | /** |
kevman | 0:38ceb79fef03 | 33 | * \defgroup platform_CallChain CallChain class |
kevman | 0:38ceb79fef03 | 34 | * @{ |
kevman | 0:38ceb79fef03 | 35 | */ |
kevman | 0:38ceb79fef03 | 36 | |
kevman | 0:38ceb79fef03 | 37 | /** Group one or more functions in an instance of a CallChain, then call them in |
kevman | 0:38ceb79fef03 | 38 | * sequence using CallChain::call(). Used mostly by the interrupt chaining code, |
kevman | 0:38ceb79fef03 | 39 | * but can be used for other purposes. |
kevman | 0:38ceb79fef03 | 40 | * |
kevman | 0:38ceb79fef03 | 41 | * @deprecated Do not use this class. This class is not part of the public API of mbed-os and is being removed in the future. |
kevman | 0:38ceb79fef03 | 42 | * @note Synchronization level: Not protected |
kevman | 0:38ceb79fef03 | 43 | * |
kevman | 0:38ceb79fef03 | 44 | * Example: |
kevman | 0:38ceb79fef03 | 45 | * @code |
kevman | 0:38ceb79fef03 | 46 | * #include "mbed.h" |
kevman | 0:38ceb79fef03 | 47 | * |
kevman | 0:38ceb79fef03 | 48 | * CallChain chain; |
kevman | 0:38ceb79fef03 | 49 | * |
kevman | 0:38ceb79fef03 | 50 | * void first(void) { |
kevman | 0:38ceb79fef03 | 51 | * printf("'first' function.\n"); |
kevman | 0:38ceb79fef03 | 52 | * } |
kevman | 0:38ceb79fef03 | 53 | * |
kevman | 0:38ceb79fef03 | 54 | * void second(void) { |
kevman | 0:38ceb79fef03 | 55 | * printf("'second' function.\n"); |
kevman | 0:38ceb79fef03 | 56 | * } |
kevman | 0:38ceb79fef03 | 57 | * |
kevman | 0:38ceb79fef03 | 58 | * class Test { |
kevman | 0:38ceb79fef03 | 59 | * public: |
kevman | 0:38ceb79fef03 | 60 | * void f(void) { |
kevman | 0:38ceb79fef03 | 61 | * printf("A::f (class member).\n"); |
kevman | 0:38ceb79fef03 | 62 | * } |
kevman | 0:38ceb79fef03 | 63 | * }; |
kevman | 0:38ceb79fef03 | 64 | * |
kevman | 0:38ceb79fef03 | 65 | * int main() { |
kevman | 0:38ceb79fef03 | 66 | * Test test; |
kevman | 0:38ceb79fef03 | 67 | * |
kevman | 0:38ceb79fef03 | 68 | * chain.add(second); |
kevman | 0:38ceb79fef03 | 69 | * chain.add_front(first); |
kevman | 0:38ceb79fef03 | 70 | * chain.add(&test, &Test::f); |
kevman | 0:38ceb79fef03 | 71 | * chain.call(); |
kevman | 0:38ceb79fef03 | 72 | * } |
kevman | 0:38ceb79fef03 | 73 | * @endcode |
kevman | 0:38ceb79fef03 | 74 | */ |
kevman | 0:38ceb79fef03 | 75 | class CallChain : private NonCopyable<CallChain> { |
kevman | 0:38ceb79fef03 | 76 | public: |
kevman | 0:38ceb79fef03 | 77 | /** Create an empty chain |
kevman | 0:38ceb79fef03 | 78 | * @deprecated |
kevman | 0:38ceb79fef03 | 79 | * Do not use this function, this class is not part of the public API of mbed-os and is being removed in the future. |
kevman | 0:38ceb79fef03 | 80 | * |
kevman | 0:38ceb79fef03 | 81 | * @param size (optional) Initial size of the chain |
kevman | 0:38ceb79fef03 | 82 | */ |
kevman | 0:38ceb79fef03 | 83 | MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the " |
kevman | 0:38ceb79fef03 | 84 | "public API of mbed-os and is being removed in the future.") |
kevman | 0:38ceb79fef03 | 85 | CallChain(int size = 4); |
kevman | 0:38ceb79fef03 | 86 | |
kevman | 0:38ceb79fef03 | 87 | /** Create an empty chain |
kevman | 0:38ceb79fef03 | 88 | * @deprecated |
kevman | 0:38ceb79fef03 | 89 | * Do not use this function, this class is not part of the public API of mbed-os and is being removed in the future. |
kevman | 0:38ceb79fef03 | 90 | */ |
kevman | 0:38ceb79fef03 | 91 | MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the " |
kevman | 0:38ceb79fef03 | 92 | "public API of mbed-os and is being removed in the future.") |
kevman | 0:38ceb79fef03 | 93 | virtual ~CallChain(); |
kevman | 0:38ceb79fef03 | 94 | |
kevman | 0:38ceb79fef03 | 95 | /** Add a function at the end of the chain |
kevman | 0:38ceb79fef03 | 96 | * |
kevman | 0:38ceb79fef03 | 97 | * @deprecated |
kevman | 0:38ceb79fef03 | 98 | * Do not use this function, this class is not part of the public API of mbed-os and is being removed in the future. |
kevman | 0:38ceb79fef03 | 99 | * |
kevman | 0:38ceb79fef03 | 100 | * @param func A pointer to a void function |
kevman | 0:38ceb79fef03 | 101 | * |
kevman | 0:38ceb79fef03 | 102 | * @returns |
kevman | 0:38ceb79fef03 | 103 | * The function object created for 'func' |
kevman | 0:38ceb79fef03 | 104 | */ |
kevman | 0:38ceb79fef03 | 105 | MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the " |
kevman | 0:38ceb79fef03 | 106 | "public API of mbed-os and is being removed in the future.") |
kevman | 0:38ceb79fef03 | 107 | pFunctionPointer_t add(Callback<void()> func); |
kevman | 0:38ceb79fef03 | 108 | |
kevman | 0:38ceb79fef03 | 109 | /** Add a function at the end of the chain |
kevman | 0:38ceb79fef03 | 110 | * |
kevman | 0:38ceb79fef03 | 111 | * @param obj pointer to the object to call the member function on |
kevman | 0:38ceb79fef03 | 112 | * @param method pointer to the member function to be called |
kevman | 0:38ceb79fef03 | 113 | * |
kevman | 0:38ceb79fef03 | 114 | * @returns |
kevman | 0:38ceb79fef03 | 115 | * The function object created for 'obj' and 'method' |
kevman | 0:38ceb79fef03 | 116 | * |
kevman | 0:38ceb79fef03 | 117 | * @deprecated |
kevman | 0:38ceb79fef03 | 118 | * The add function does not support cv-qualifiers. Replaced by |
kevman | 0:38ceb79fef03 | 119 | * add(callback(obj, method)). |
kevman | 0:38ceb79fef03 | 120 | */ |
kevman | 0:38ceb79fef03 | 121 | template<typename T, typename M> |
kevman | 0:38ceb79fef03 | 122 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
kevman | 0:38ceb79fef03 | 123 | "The add function does not support cv-qualifiers. Replaced by " |
kevman | 0:38ceb79fef03 | 124 | "add(callback(obj, method)).") |
kevman | 0:38ceb79fef03 | 125 | pFunctionPointer_t add(T *obj, M method) |
kevman | 0:38ceb79fef03 | 126 | { |
kevman | 0:38ceb79fef03 | 127 | return add(callback(obj, method)); |
kevman | 0:38ceb79fef03 | 128 | } |
kevman | 0:38ceb79fef03 | 129 | |
kevman | 0:38ceb79fef03 | 130 | /** Add a function at the beginning of the chain |
kevman | 0:38ceb79fef03 | 131 | * @deprecated |
kevman | 0:38ceb79fef03 | 132 | * Do not use this function, this class is not part of the public API of mbed-os and is being removed in the future. |
kevman | 0:38ceb79fef03 | 133 | * |
kevman | 0:38ceb79fef03 | 134 | * |
kevman | 0:38ceb79fef03 | 135 | * @param func A pointer to a void function |
kevman | 0:38ceb79fef03 | 136 | * |
kevman | 0:38ceb79fef03 | 137 | * @returns |
kevman | 0:38ceb79fef03 | 138 | * The function object created for 'func' |
kevman | 0:38ceb79fef03 | 139 | */ |
kevman | 0:38ceb79fef03 | 140 | MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the " |
kevman | 0:38ceb79fef03 | 141 | "public API of mbed-os and is being removed in the future.") |
kevman | 0:38ceb79fef03 | 142 | pFunctionPointer_t add_front(Callback<void()> func); |
kevman | 0:38ceb79fef03 | 143 | |
kevman | 0:38ceb79fef03 | 144 | /** Add a function at the beginning of the chain |
kevman | 0:38ceb79fef03 | 145 | * |
kevman | 0:38ceb79fef03 | 146 | * @param obj pointer to the object to call the member function on |
kevman | 0:38ceb79fef03 | 147 | * @param method pointer to the member function to be called |
kevman | 0:38ceb79fef03 | 148 | * |
kevman | 0:38ceb79fef03 | 149 | * @returns |
kevman | 0:38ceb79fef03 | 150 | * The function object created for 'tptr' and 'mptr' |
kevman | 0:38ceb79fef03 | 151 | * |
kevman | 0:38ceb79fef03 | 152 | * @deprecated |
kevman | 0:38ceb79fef03 | 153 | * The add_front function does not support cv-qualifiers. Replaced by |
kevman | 0:38ceb79fef03 | 154 | * add_front(callback(obj, method)). |
kevman | 0:38ceb79fef03 | 155 | */ |
kevman | 0:38ceb79fef03 | 156 | template<typename T, typename M> |
kevman | 0:38ceb79fef03 | 157 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
kevman | 0:38ceb79fef03 | 158 | "The add_front function does not support cv-qualifiers. Replaced by " |
kevman | 0:38ceb79fef03 | 159 | "add_front(callback(obj, method)).") |
kevman | 0:38ceb79fef03 | 160 | pFunctionPointer_t add_front(T *obj, M method) |
kevman | 0:38ceb79fef03 | 161 | { |
kevman | 0:38ceb79fef03 | 162 | return add_front(callback(obj, method)); |
kevman | 0:38ceb79fef03 | 163 | } |
kevman | 0:38ceb79fef03 | 164 | |
kevman | 0:38ceb79fef03 | 165 | /** Get the number of functions in the chain |
kevman | 0:38ceb79fef03 | 166 | * @deprecated |
kevman | 0:38ceb79fef03 | 167 | * Do not use this function, this class is not part of the public API of mbed-os and is being removed in the future. |
kevman | 0:38ceb79fef03 | 168 | * |
kevman | 0:38ceb79fef03 | 169 | */ |
kevman | 0:38ceb79fef03 | 170 | MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the " |
kevman | 0:38ceb79fef03 | 171 | "public API of mbed-os and is being removed in the future.") |
kevman | 0:38ceb79fef03 | 172 | int size() const; |
kevman | 0:38ceb79fef03 | 173 | |
kevman | 0:38ceb79fef03 | 174 | /** Get a function object from the chain |
kevman | 0:38ceb79fef03 | 175 | * @deprecated |
kevman | 0:38ceb79fef03 | 176 | * Do not use this function, this class is not part of the public API of mbed-os and is being removed in the future. |
kevman | 0:38ceb79fef03 | 177 | * |
kevman | 0:38ceb79fef03 | 178 | * @param i function object index |
kevman | 0:38ceb79fef03 | 179 | * |
kevman | 0:38ceb79fef03 | 180 | * @returns |
kevman | 0:38ceb79fef03 | 181 | * The function object at position 'i' in the chain |
kevman | 0:38ceb79fef03 | 182 | */ |
kevman | 0:38ceb79fef03 | 183 | MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the " |
kevman | 0:38ceb79fef03 | 184 | "public API of mbed-os and is being removed in the future.") |
kevman | 0:38ceb79fef03 | 185 | pFunctionPointer_t get(int i) const; |
kevman | 0:38ceb79fef03 | 186 | |
kevman | 0:38ceb79fef03 | 187 | /** Look for a function object in the call chain |
kevman | 0:38ceb79fef03 | 188 | * @deprecated |
kevman | 0:38ceb79fef03 | 189 | * Do not use this function, this class is not part of the public API of mbed-os and is being removed in the future. |
kevman | 0:38ceb79fef03 | 190 | * |
kevman | 0:38ceb79fef03 | 191 | * @param f the function object to search |
kevman | 0:38ceb79fef03 | 192 | * |
kevman | 0:38ceb79fef03 | 193 | * @returns |
kevman | 0:38ceb79fef03 | 194 | * The index of the function object if found, -1 otherwise. |
kevman | 0:38ceb79fef03 | 195 | */ |
kevman | 0:38ceb79fef03 | 196 | MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the " |
kevman | 0:38ceb79fef03 | 197 | "public API of mbed-os and is being removed in the future.") |
kevman | 0:38ceb79fef03 | 198 | int find(pFunctionPointer_t f) const; |
kevman | 0:38ceb79fef03 | 199 | |
kevman | 0:38ceb79fef03 | 200 | /** Clear the call chain (remove all functions in the chain). |
kevman | 0:38ceb79fef03 | 201 | * @deprecated Do not use this function. This class is not part of the public API of mbed-os and is being removed in the future. |
kevman | 0:38ceb79fef03 | 202 | */ |
kevman | 0:38ceb79fef03 | 203 | MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the " |
kevman | 0:38ceb79fef03 | 204 | "public API of mbed-os and is being removed in the future.") |
kevman | 0:38ceb79fef03 | 205 | void clear(); |
kevman | 0:38ceb79fef03 | 206 | |
kevman | 0:38ceb79fef03 | 207 | /** Remove a function object from the chain |
kevman | 0:38ceb79fef03 | 208 | * @deprecated |
kevman | 0:38ceb79fef03 | 209 | * Do not use this function, this class is not part of the public API of mbed-os and is being removed in the future. |
kevman | 0:38ceb79fef03 | 210 | * |
kevman | 0:38ceb79fef03 | 211 | * @arg f the function object to remove |
kevman | 0:38ceb79fef03 | 212 | * |
kevman | 0:38ceb79fef03 | 213 | * @returns |
kevman | 0:38ceb79fef03 | 214 | * true if the function object was found and removed, false otherwise. |
kevman | 0:38ceb79fef03 | 215 | */ |
kevman | 0:38ceb79fef03 | 216 | MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the " |
kevman | 0:38ceb79fef03 | 217 | "public API of mbed-os and is being removed in the future.") |
kevman | 0:38ceb79fef03 | 218 | bool remove(pFunctionPointer_t f); |
kevman | 0:38ceb79fef03 | 219 | |
kevman | 0:38ceb79fef03 | 220 | /** Call all the functions in the chain in sequence |
kevman | 0:38ceb79fef03 | 221 | * @deprecated |
kevman | 0:38ceb79fef03 | 222 | * Do not use this function, this class is not part of the public API of mbed-os and is being removed in the future. |
kevman | 0:38ceb79fef03 | 223 | * |
kevman | 0:38ceb79fef03 | 224 | */ |
kevman | 0:38ceb79fef03 | 225 | MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the " |
kevman | 0:38ceb79fef03 | 226 | "public API of mbed-os and is being removed in the future.") |
kevman | 0:38ceb79fef03 | 227 | void call(); |
kevman | 0:38ceb79fef03 | 228 | |
kevman | 0:38ceb79fef03 | 229 | /** |
kevman | 0:38ceb79fef03 | 230 | * @deprecated |
kevman | 0:38ceb79fef03 | 231 | * Do not use this function, this class is not part of the public API of mbed-os and is being removed in the future. |
kevman | 0:38ceb79fef03 | 232 | * |
kevman | 0:38ceb79fef03 | 233 | */ |
kevman | 0:38ceb79fef03 | 234 | MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the " |
kevman | 0:38ceb79fef03 | 235 | "public API of mbed-os and is being removed in the future.") |
kevman | 0:38ceb79fef03 | 236 | void operator()(void) |
kevman | 0:38ceb79fef03 | 237 | { |
kevman | 0:38ceb79fef03 | 238 | call(); |
kevman | 0:38ceb79fef03 | 239 | } |
kevman | 0:38ceb79fef03 | 240 | |
kevman | 0:38ceb79fef03 | 241 | /** |
kevman | 0:38ceb79fef03 | 242 | * @deprecated |
kevman | 0:38ceb79fef03 | 243 | * Do not use this function, this class is not part of the public API of mbed-os and is being removed in the future. |
kevman | 0:38ceb79fef03 | 244 | * |
kevman | 0:38ceb79fef03 | 245 | */ |
kevman | 0:38ceb79fef03 | 246 | MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the " |
kevman | 0:38ceb79fef03 | 247 | "public API of mbed-os and is being removed in the future.") |
kevman | 0:38ceb79fef03 | 248 | pFunctionPointer_t operator [](int i) const |
kevman | 0:38ceb79fef03 | 249 | { |
kevman | 0:38ceb79fef03 | 250 | return get(i); |
kevman | 0:38ceb79fef03 | 251 | } |
kevman | 0:38ceb79fef03 | 252 | |
kevman | 0:38ceb79fef03 | 253 | private: |
kevman | 0:38ceb79fef03 | 254 | CallChainLink *_chain; |
kevman | 0:38ceb79fef03 | 255 | }; |
kevman | 0:38ceb79fef03 | 256 | |
kevman | 0:38ceb79fef03 | 257 | /**@}*/ |
kevman | 0:38ceb79fef03 | 258 | |
kevman | 0:38ceb79fef03 | 259 | /**@}*/ |
kevman | 0:38ceb79fef03 | 260 | |
kevman | 0:38ceb79fef03 | 261 | } // namespace mbed |
kevman | 0:38ceb79fef03 | 262 | |
kevman | 0:38ceb79fef03 | 263 | #endif |
kevman | 0:38ceb79fef03 | 264 |