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.
FP< retT, argT > Class Template Reference
Example using the FP Class with global functions. More...
#include <FP.h>
Public Member Functions | |
FP () | |
Create the FP object - only one callback can be attached to the object, that is a member function or a global function, not both at the same time. | |
template<class T > | |
void | attach (T *item, retT(T::*method)(argT)) |
Add a callback function to the object. | |
void | attach (retT(*function)(argT)) |
Add a callback function to the object. | |
retT | operator() (argT arg) const |
Invoke the function attached to the class. | |
bool | attached () |
Determine if an callback is currently hooked. | |
void | detach () |
Release a function from the callback hook. | |
FP () | |
Create the FP object - only one callback can be attached to the object, that is a member function or a global function, not both at the same time. | |
template<class T > | |
void | attach (T *item, retT(T::*method)(argT)) |
Add a callback function to the object. | |
void | attach (retT(*function)(argT)) |
Add a callback function to the object. | |
retT | operator() (argT arg) const |
Invoke the function attached to the class. | |
bool | attached () |
Determine if an callback is currently hooked. | |
void | detach () |
Release a function from the callback hook. | |
FP () | |
Create the FP object - only one callback can be attached to the object, that is a member function or a global function, not both at the same time. | |
template<class T > | |
void | attach (T *item, retT(T::*method)(argT)) |
Add a callback function to the object. | |
void | attach (retT(*function)(argT)) |
Add a callback function to the object. | |
retT | operator() (argT arg) const |
Invoke the function attached to the class. | |
bool | attached () |
Determine if an callback is currently hooked. | |
void | detach () |
Release a function from the callback hook. |
Detailed Description
template<class retT, class argT>
class FP< retT, argT >
Example using the FP Class with global functions.
#include "mbed.h" #include "FP.h" FP<void,bool>fp; DigitalOut myled(LED1); void handler(bool value) { myled = value; return; } int main() { fp.attach(&handler); while(1) { fp(1); wait(0.2); fp(0); wait(0.2); } }
Example using the FP Class with different class member functions
#include "mbed.h" #include "FP.h" FP<void,bool>fp; DigitalOut myled(LED4); class Wrapper { public: Wrapper(){} void handler(bool value) { myled = value; return; } }; int main() { Wrapper wrapped; fp.attach(&wrapped, &Wrapper::handler); while(1) { fp(1); wait(0.2); fp(0); wait(0.2); } }
Example using the FP Class with member FP and member function
#include "mbed.h" #include "FP.h" DigitalOut myled(LED2); class Wrapper { public: Wrapper() { fp.attach(this, &Wrapper::handler); } void handler(bool value) { myled = value; return; } FP<void,bool>fp; }; int main() { Wrapper wrapped; while(1) { wrapped.fp(1); wait(0.2); wrapped.fp(0); wait(0.2); } }
API for managing Function Pointers
Definition at line 131 of file FP.h.
Constructor & Destructor Documentation
FP | ( | ) |
FP | ( | ) |
Create the FP object - only one callback can be attached to the object, that is a member function or a global function, not both at the same time.
Definition at line 137 of file MQTTClient/src/FP.h.
FP | ( | ) |
Create the FP object - only one callback can be attached to the object, that is a member function or a global function, not both at the same time.
Definition at line 137 of file MQTTSNClient/src/FP.h.
Member Function Documentation
void attach | ( | T * | item, |
retT(T::*)(argT) | method | ||
) |
void attach | ( | retT(*)(argT) | function ) |
void attach | ( | T * | item, |
retT(T::*)(argT) | method | ||
) |
Add a callback function to the object.
- Parameters:
-
item - Address of the initialized object member - Address of the member function (dont forget the scope that the function is defined in)
Definition at line 148 of file MQTTSNClient/src/FP.h.
void attach | ( | T * | item, |
retT(T::*)(argT) | method | ||
) |
Add a callback function to the object.
- Parameters:
-
item - Address of the initialized object member - Address of the member function (dont forget the scope that the function is defined in)
Definition at line 148 of file MQTTClient/src/FP.h.
void attach | ( | retT(*)(argT) | function ) |
Add a callback function to the object.
- Parameters:
-
function - The address of a globally defined function
Definition at line 158 of file MQTTSNClient/src/FP.h.
void attach | ( | retT(*)(argT) | function ) |
Add a callback function to the object.
- Parameters:
-
function - The address of a globally defined function
Definition at line 158 of file MQTTClient/src/FP.h.
bool attached | ( | ) |
Determine if an callback is currently hooked.
- Returns:
- 1 if a method is hooked, 0 otherwise
Definition at line 178 of file MQTTSNClient/src/FP.h.
bool attached | ( | ) |
bool attached | ( | ) |
Determine if an callback is currently hooked.
- Returns:
- 1 if a method is hooked, 0 otherwise
Definition at line 178 of file MQTTClient/src/FP.h.
void detach | ( | ) |
Release a function from the callback hook.
Definition at line 185 of file MQTTClient/src/FP.h.
void detach | ( | ) |
Release a function from the callback hook.
Definition at line 185 of file MQTTSNClient/src/FP.h.
retT operator() | ( | argT | arg ) | const |
Invoke the function attached to the class.
- Parameters:
-
arg - An argument that is passed into the function handler that is called
- Returns:
- The return from the function hanlder called by this class
Definition at line 167 of file MQTTClient/src/FP.h.
retT operator() | ( | argT | arg ) | const |
retT operator() | ( | argT | arg ) | const |
Invoke the function attached to the class.
- Parameters:
-
arg - An argument that is passed into the function handler that is called
- Returns:
- The return from the function hanlder called by this class
Definition at line 167 of file MQTTSNClient/src/FP.h.
Field Documentation
retT(* c_callback)(argT) |
retT(FPtrDummy::* method_callback)(argT) |
Generated on Thu Jul 14 2022 12:58:44 by
