BBR 1 Ebene

Committer:
borlanic
Date:
Mon May 14 11:29:06 2018 +0000
Revision:
0:fbdae7e6d805
BBR

Who changed what in which revision?

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