Gbox 4.20
Grow box automation and monitoring - <a href='https://sites.google.com/site/growboxguy/'>https://sites.google.com/site/growboxguy/</a>
 
Loading...
Searching...
No Matches
FP< retT, argT > Class Template Reference

API abstraction for a Function Pointers. More...

#include <FP.h>

Public Member Functions

 FP ()
 
template<class T >
void attach (T *item, retT(T::*method)(argT))
 
void attach (retT(*function)(argT))
 
retT operator() (argT arg) const
 
bool attached ()
 
void detach ()
 

Detailed Description

template<class retT, class argT>
class FP< retT, argT >

API abstraction for a Function Pointers.

Example using the FP Class with global functions

#include "mbed.h"
#include "FP.h"
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);
}
}
Core Utility - Templated Function Pointer Class.
API abstraction for a Function Pointers.
Definition FP.h:136
void attach(T *item, retT(T::*method)(argT))
Definition FP.h:147
uint32_t wait

Example using the FP Class with different class member functions

#include "mbed.h"
#include "FP.h"
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;
}
};
int main()
{
Wrapper wrapped;
while(1)
{
wrapped.fp(1);
wait(0.2);
wrapped.fp(0);
wait(0.2);
}
}

Definition at line 135 of file FP.h.

Constructor & Destructor Documentation

◆ FP()

template<class retT , class argT >
FP< retT, argT >::FP ( )

Create the FP object

Definition at line 27 of file FP.cpp.

Member Function Documentation

◆ attach() [1/2]

template<class retT , class argT >
void FP< retT, argT >::attach ( retT(*)(argT)  function)

Add a callback function to the class

Parameters
function- The address of a globally defined function

Definition at line 49 of file FP.cpp.

◆ attach() [2/2]

template<class retT , class argT >
template<class T >
void FP< retT, argT >::attach ( T *  item,
retT(T::*)(argT)  method 
)
inline

Add a callback function to the class

Parameters
item- Address of the initialized class
method- Address of the member function (dont forget the scope that the function is defined in)

Definition at line 147 of file FP.h.

Here is the caller graph for this function:

◆ attached()

template<class retT , class argT >
bool FP< retT, argT >::attached ( )

Definition at line 34 of file FP.cpp.

Here is the caller graph for this function:

◆ detach()

template<class retT , class argT >
void FP< retT, argT >::detach ( )

Definition at line 41 of file FP.cpp.

◆ operator()()

template<class retT , class argT >
retT FP< retT, argT >::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 55 of file FP.cpp.

Field Documentation

◆ c_callback

template<class retT , class argT >
retT(* FP< retT, argT >::c_callback) (argT)

Footprint for a global function

Definition at line 182 of file FP.h.

◆ method_callback

template<class retT , class argT >
retT(FPtrDummy::* FP< retT, argT >::method_callback) (argT)

Footprint for a member function

Definition at line 183 of file FP.h.


The documentation for this class was generated from the following files: