Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-dev by
CallChain Class Reference
[CallChain class]
  Group one or more functions in an instance of a CallChain, then call them in sequence using CallChain::call(). More...
#include <CallChain.h>
Inherits NonCopyable< CallChain >.
| Public Member Functions | |
| CallChain (int size=4) | |
| Create an empty chain. | |
| pFunctionPointer_t | add (Callback< void()> func) | 
| Add a function at the end of the chain. | |
| template<typename T , typename M > | |
| MBED_DEPRECATED_SINCE ("mbed-os-5.1","The add function does not support cv-qualifiers. Replaced by ""add(callback(obj, method)).") pFunctionPointer_t add(T *obj | |
| Add a function at the end of the chain. | |
| template<typename T , typename M > | |
| MBED_DEPRECATED_SINCE ("mbed-os-5.1","The add_front function does not support cv-qualifiers. Replaced by ""add_front(callback(obj, method)).") pFunctionPointer_t add_front(T *obj | |
| Add a function at the beginning of the chain. | |
| pFunctionPointer_t | get (int i) const | 
| Get a function object from the chain. | |
| int | find (pFunctionPointer_t f) const | 
| Look for a function object in the call chain. | |
| void | clear () | 
| Clear the call chain (remove all functions in the chain). | |
| bool | remove (pFunctionPointer_t f) | 
| Remove a function object from the chain. | |
| void | call () | 
| Call all the functions in the chain in sequence. | |
Detailed Description
Group one or more functions in an instance of a CallChain, then call them in sequence using CallChain::call().
Used mostly by the interrupt chaining code, but can be used for other purposes.
- Note:
- Synchronization level: Not protected
Example:
#include "mbed.h" CallChain chain; void first(void) { printf("'first' function.\n"); } void second(void) { printf("'second' function.\n"); } class Test { public: void f(void) { printf("A::f (class member).\n"); } }; int main() { Test test; chain.add(second); chain.add_front(first); chain.add(&test, &Test::f); chain.call(); }
Definition at line 74 of file CallChain.h.
Constructor & Destructor Documentation
| CallChain | ( | int | size = 4) | 
Create an empty chain.
- Parameters:
- 
  size (optional) Initial size of the chain 
Definition at line 20 of file CallChain.cpp.
Member Function Documentation
| pFunctionPointer_t add | ( | Callback< void()> | func ) | 
Add a function at the end of the chain.
- Parameters:
- 
  func A pointer to a void function 
- Returns:
- The function object created for 'func'
Definition at line 28 of file CallChain.cpp.
| void call | ( | ) | 
Call all the functions in the chain in sequence.
Definition at line 108 of file CallChain.cpp.
| void clear | ( | ) | 
Clear the call chain (remove all functions in the chain).
Definition at line 86 of file CallChain.cpp.
| int find | ( | pFunctionPointer_t | f ) | const | 
Look for a function object in the call chain.
- Parameters:
- 
  f the function object to search 
- Returns:
- The index of the function object if found, -1 otherwise.
Definition at line 73 of file CallChain.cpp.
| pFunctionPointer_t get | ( | int | i ) | const | 
Get a function object from the chain.
- Parameters:
- 
  i function object index 
- Returns:
- The function object at position 'i' in the chain
Definition at line 62 of file CallChain.cpp.
| MBED_DEPRECATED_SINCE | ( | "mbed-os-5.1" | , | 
| "The add function does not support cv-qualifiers. Replaced by ""add(callback(obj, method))." | |||
| ) | 
Add a function at the end of the chain.
- Parameters:
- 
  obj pointer to the object to call the member function on method pointer to the member function to be called 
- Returns:
- The function object created for 'obj' and 'method'
| MBED_DEPRECATED_SINCE | ( | "mbed-os-5.1" | , | 
| "The add_front function does not support cv-qualifiers. Replaced by ""add_front(callback(obj, method))." | |||
| ) | 
Add a function at the beginning of the chain.
- Parameters:
- 
  obj pointer to the object to call the member function on method pointer to the member function to be called 
- Returns:
- The function object created for 'tptr' and 'mptr'
| bool remove | ( | pFunctionPointer_t | f ) | 
Remove a function object from the chain.
- f the function object to remove
- Returns:
- true if the function object was found and removed, false otherwise.
Definition at line 96 of file CallChain.cpp.
Generated on Tue Jul 12 2022 20:08:05 by
 1.7.2
 1.7.2 
    