AP_HAL: implement AP_HAL::MemberProc via FastDelegate.h
this provides a more portable way to encapsulate member functions in variables
This commit is contained in:
parent
56d33cd3a7
commit
f2de4bb7b0
@ -2,6 +2,9 @@
|
||||
#ifndef __AP_HAL_NAMESPACE_H__
|
||||
#define __AP_HAL_NAMESPACE_H__
|
||||
|
||||
#include "string.h"
|
||||
#include "utility/FastDelegate.h"
|
||||
|
||||
namespace AP_HAL {
|
||||
|
||||
/* Toplevel pure virtual class Hal.*/
|
||||
@ -32,9 +35,13 @@ namespace AP_HAL {
|
||||
class Stream;
|
||||
class BetterStream;
|
||||
|
||||
/* Typdefs for function pointers (Procedure, Timed Procedure) */
|
||||
/* Typdefs for function pointers (Procedure, Member Procedure)
|
||||
|
||||
For member functions we use the FastDelegate delegates class
|
||||
which allows us to encapculate a member function as a type
|
||||
*/
|
||||
typedef void(*Proc)(void);
|
||||
typedef void(*TimedProc)(void *);
|
||||
typedef fastdelegate::FastDelegate0<> MemberProc;
|
||||
|
||||
/**
|
||||
* Global names for all of the existing SPI devices on all platforms.
|
||||
@ -51,5 +58,7 @@ namespace AP_HAL {
|
||||
|
||||
}
|
||||
|
||||
// macro to hide the details of AP_HAL::MemberProc
|
||||
#define AP_HAL_MEMBERPROC(func) fastdelegate::MakeDelegate(this, func)
|
||||
|
||||
#endif // __AP_HAL_NAMESPACE_H__
|
||||
|
@ -19,10 +19,10 @@ public:
|
||||
uint16_t min_time_ms) = 0;
|
||||
|
||||
// register a high priority timer task
|
||||
virtual void register_timer_process(AP_HAL::TimedProc, void *) = 0;
|
||||
virtual void register_timer_process(AP_HAL::MemberProc) = 0;
|
||||
|
||||
// register a low priority IO task
|
||||
virtual void register_io_process(AP_HAL::TimedProc, void *) = 0;
|
||||
virtual void register_io_process(AP_HAL::MemberProc) = 0;
|
||||
|
||||
// suspend and resume both timer and IO processes
|
||||
virtual void suspend_timer_procs() = 0;
|
||||
@ -30,7 +30,7 @@ public:
|
||||
|
||||
virtual bool in_timerprocess() = 0;
|
||||
|
||||
virtual void register_timer_failsafe(AP_HAL::TimedProc,
|
||||
virtual void register_timer_failsafe(AP_HAL::Proc,
|
||||
uint32_t period_us) = 0;
|
||||
|
||||
virtual bool system_initializing() = 0;
|
||||
|
2108
libraries/AP_HAL/utility/FastDelegate.h
Normal file
2108
libraries/AP_HAL/utility/FastDelegate.h
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user