Backup 1

Committer:
borlanic
Date:
Tue Apr 24 11:45:18 2018 +0000
Revision:
0:02dd72d1d465
BaBoRo_test2 - backup 1

Who changed what in which revision?

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