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