The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
170:e95d10626187
mbed library release version 165

Who changed what in which revision?

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