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