mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Wed Feb 20 22:31:08 2019 +0000
Revision:
189:f392fc9709a3
Parent:
187:0387e8f68319
mbed library release version 165

Who changed what in which revision?

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