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

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.