CppELib 1.7.0
Loading...
Searching...
No Matches
OneShotTimer.h
Go to the documentation of this file.
1#ifndef OS_WRAPPER_ONESHOT_TIMER_H_INCLUDED
2#define OS_WRAPPER_ONESHOT_TIMER_H_INCLUDED
3
4namespace OSWrapper {
5
6class Runnable;
7class OneShotTimerFactory;
8
15void registerOneShotTimerFactory(OneShotTimerFactory* factory);
16
21protected:
23 : m_runnable(r), m_uncaughtExceptionHandler(0) {}
24 virtual ~OneShotTimer() {}
25
26 void timerMain();
27
28public:
37 public:
44 virtual void handle(OneShotTimer* t, const char* msg) = 0;
45 };
46
52
58
67 static OneShotTimer* create(Runnable* r, const char* name = "");
68
75 static void destroy(OneShotTimer* t);
76
88 virtual void start(unsigned long timeInMillis) = 0;
89
97 virtual void stop() = 0;
98
104 virtual bool isStarted() const = 0;
105
110 virtual void setName(const char* name) = 0;
111
116 virtual const char* getName() const = 0;
117
126
132
133private:
134 Runnable* m_runnable;
135 UncaughtExceptionHandler* m_uncaughtExceptionHandler;
136 static UncaughtExceptionHandler* m_defaultUncaughtExceptionHandler;
137
138 void handleException(const char* msg);
139
140};
141
142}
143
144#endif // OS_WRAPPER_ONESHOT_TIMER_H_INCLUDED
Interface for handling uncaught exception.
Definition OneShotTimer.h:36
virtual ~UncaughtExceptionHandler()
Definition OneShotTimer.h:38
virtual void handle(OneShotTimer *t, const char *msg)=0
Handle uncaught exception thrown in the OneShotTimer.
Abstract class that has functions of common RTOS's one-shot timer.
Definition OneShotTimer.h:20
static void destroy(OneShotTimer *t)
Destroy an OneShotTimer object.
Definition OneShotTimer.cpp:93
virtual void stop()=0
Stop the timer.
static UncaughtExceptionHandler * getDefaultUncaughtExceptionHandler()
Get the default UncaughtExceptionHandler.
Definition OneShotTimer.cpp:24
UncaughtExceptionHandler * getUncaughtExceptionHandler() const
Get the UncaughtExceptionHandler for this OneShotTimer.
Definition OneShotTimer.cpp:34
OneShotTimer(Runnable *r)
Definition OneShotTimer.h:22
void timerMain()
Common timer main method.
Definition OneShotTimer.cpp:62
virtual ~OneShotTimer()
Definition OneShotTimer.h:24
static OneShotTimer * create(Runnable *r, const char *name="")
Create an OneShotTimer object.
Definition OneShotTimer.cpp:84
virtual bool isStarted() const =0
Return true if the timer is started.
virtual void setName(const char *name)=0
Set the object's name.
virtual void start(unsigned long timeInMillis)=0
Start the timer.
static void setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler *handler)
Set the default UncaughtExceptionHandler for all the OneShotTimer.
Definition OneShotTimer.cpp:19
virtual const char * getName() const =0
Get the object's name.
void setUncaughtExceptionHandler(UncaughtExceptionHandler *handler)
Set the UncaughtExceptionHandler for this OneShotTimer.
Definition OneShotTimer.cpp:29
Interface for implementing an active class.
Definition Runnable.h:9
OSWrapper provides abstract C++ interface of common RTOS: thread, mutex, event flag,...
Definition EventFlag.cpp:5
void registerOneShotTimerFactory(OneShotTimerFactory *factory)
Register the OneShotTimerFactory.
Definition OneShotTimer.cpp:11