mbed library sources. Supersedes mbed-src.

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

Committer:
AnnaBridge
Date:
Thu Sep 06 13:40:20 2018 +0100
Revision:
187:0387e8f68319
Parent:
184:08ed48f1de7f
Child:
189:f392fc9709a3
mbed-dev library. Release version 163

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