Rahul Dahiya / Mbed OS STM32F7 Ethernet
Committer:
rahul_dahiya
Date:
Wed Jan 15 15:57:15 2020 +0530
Revision:
0:fb8047b156bb
STM32F7 LWIP

Who changed what in which revision?

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