CppELib 1.7.0
Loading...
Searching...
No Matches
TestDoublePeriodicTimerFactory.h
Go to the documentation of this file.
1#ifndef TEST_DOUBLE_OS_WRAPPER_TEST_DOUBLE_PERIODIC_TIMER_FACTORY_H_INCLUDED
2#define TEST_DOUBLE_OS_WRAPPER_TEST_DOUBLE_PERIODIC_TIMER_FACTORY_H_INCLUDED
3
7
8namespace TestDoubleOSWrapper {
9
11protected:
13 unsigned long m_periodInMillis;
14 const char* m_name;
15
16public:
18 : PeriodicTimer(0)
19 , m_runnable(0)
21 , m_name(0)
22 {
23 }
24
25 void setCreateArgs(OSWrapper::Runnable* r, unsigned long periodInMillis, const char* name)
26 {
27 m_runnable = r;
28 m_periodInMillis = periodInMillis;
29 m_name = name;
30 }
31
33 {
34 }
35
36 virtual void start()
37 {
38 }
39
40 virtual void stop()
41 {
42 }
43
44 virtual bool isStarted() const
45 {
46 return false;
47 }
48
49 virtual unsigned long getPeriodInMillis() const
50 {
51 return m_periodInMillis;
52 }
53
54 virtual void setName(const char* name)
55 {
56 m_name = name;
57 }
58
59 virtual const char* getName() const
60 {
61 return m_name;
62 }
63};
64
65template <typename T = TestDoublePeriodicTimer>
67public:
70
71 virtual OSWrapper::PeriodicTimer* create(OSWrapper::Runnable* r, unsigned long periodInMillis, const char* name)
72 {
73 T* obj = new T();
74 obj->setCreateArgs(r, periodInMillis, name);
75 return obj;
76 }
77
79 {
80 delete static_cast<T*>(t);
81 }
82
83private:
86};
87
88}
89
90#endif // TEST_DOUBLE_OS_WRAPPER_TEST_DOUBLE_PERIODIC_TIMER_FACTORY_H_INCLUDED
Definition PeriodicTimerFactory.h:9
Abstract class that has functions of common RTOS's periodic timer.
Definition PeriodicTimer.h:20
PeriodicTimer(Runnable *r)
Definition PeriodicTimer.h:22
Interface for implementing an active class.
Definition Runnable.h:9
Definition TestDoublePeriodicTimerFactory.h:66
virtual void destroy(OSWrapper::PeriodicTimer *t)
Definition TestDoublePeriodicTimerFactory.h:78
TestDoublePeriodicTimerFactory()
Definition TestDoublePeriodicTimerFactory.h:68
virtual ~TestDoublePeriodicTimerFactory()
Definition TestDoublePeriodicTimerFactory.h:69
virtual OSWrapper::PeriodicTimer * create(OSWrapper::Runnable *r, unsigned long periodInMillis, const char *name)
Definition TestDoublePeriodicTimerFactory.h:71
Definition TestDoublePeriodicTimerFactory.h:10
virtual void stop()
Stop the timer.
Definition TestDoublePeriodicTimerFactory.h:40
unsigned long m_periodInMillis
Definition TestDoublePeriodicTimerFactory.h:13
OSWrapper::Runnable * m_runnable
Definition TestDoublePeriodicTimerFactory.h:12
virtual unsigned long getPeriodInMillis() const
Get the timer period (in milliseconds)
Definition TestDoublePeriodicTimerFactory.h:49
virtual ~TestDoublePeriodicTimer()
Definition TestDoublePeriodicTimerFactory.h:32
virtual const char * getName() const
Get the object's name.
Definition TestDoublePeriodicTimerFactory.h:59
virtual void setName(const char *name)
Set the object's name.
Definition TestDoublePeriodicTimerFactory.h:54
virtual void start()
Start the timer.
Definition TestDoublePeriodicTimerFactory.h:36
void setCreateArgs(OSWrapper::Runnable *r, unsigned long periodInMillis, const char *name)
Definition TestDoublePeriodicTimerFactory.h:25
TestDoublePeriodicTimer()
Definition TestDoublePeriodicTimerFactory.h:17
const char * m_name
Definition TestDoublePeriodicTimerFactory.h:14
virtual bool isStarted() const
Return true if the timer is started.
Definition TestDoublePeriodicTimerFactory.h:44
Implementation of OSWrapper for Test Double.
Definition TestDoubleEventFlagFactory.h:7