CppELib 1.7.0
Loading...
Searching...
No Matches
TestDoubleThreadFactory.h
Go to the documentation of this file.
1#ifndef TEST_DOUBLE_OS_WRAPPER_TEST_DOUBLE_THREAD_FACTORY_H_INCLUDED
2#define TEST_DOUBLE_OS_WRAPPER_TEST_DOUBLE_THREAD_FACTORY_H_INCLUDED
3
5#include "OSWrapper/Thread.h"
7
8namespace TestDoubleOSWrapper {
9
11protected:
15 std::size_t m_stackSize;
17 const char* m_name;
18
19public:
21 : Thread(0)
22 , m_runnable(0)
23 , m_priority(0)
25 , m_stackSize(0U)
27 , m_name(0)
28 {
29 }
30
31 void setCreateArgs(OSWrapper::Runnable* r, int priority, std::size_t stackSize, void* stackAddress, const char* name)
32 {
33 m_runnable = r;
34 m_priority = priority;
35 m_initialPriority = priority;
36 m_stackSize = stackSize;
37 m_stackAddress = stackAddress;
38 m_name = name;
39 }
40
41 virtual ~TestDoubleThread() {}
42
43 virtual void start()
44 {
45 }
46
48 {
49 return OSWrapper::OK;
50 }
51
53 {
54 return OSWrapper::OK;
55 }
56
58 {
59 (void) tmout;
60 return OSWrapper::OK;
61 }
62
63 virtual bool isFinished() const
64 {
65 return false;
66 }
67
68 virtual void setName(const char* name)
69 {
70 m_name = name;
71 }
72
73 virtual const char* getName() const
74 {
75 return m_name;
76 }
77
78 virtual void setPriority(int priority)
79 {
80 m_priority = priority;
81 }
82
83 virtual int getPriority() const
84 {
85 return m_priority;
86 }
87
88 virtual int getInitialPriority() const
89 {
90 return m_initialPriority;
91 }
92
93 virtual std::size_t getStackSize() const
94 {
95 return m_stackSize;
96 }
97
98 virtual void* getNativeHandle()
99 {
100 return 0;
101 }
102};
103
104template <typename T = TestDoubleThread>
106public:
109
110 virtual OSWrapper::Thread* create(OSWrapper::Runnable* r, int priority, std::size_t stackSize, void* stackAddress, const char* name)
111 {
112 T* obj = new T();
113 obj->setCreateArgs(r, priority, stackSize, stackAddress, name);
114 return obj;
115 }
116
117 virtual void destroy(OSWrapper::Thread* t)
118 {
119 delete static_cast<T*>(t);
120 }
121
122 virtual void sleep(unsigned long millis)
123 {
124 (void) millis;
125 }
126
127 virtual void yield()
128 {
129 }
130
132 {
133 return 0;
134 }
135
136 virtual int getMaxPriority() const
137 {
138 return 0;
139 }
140
141 virtual int getMinPriority() const
142 {
143 return 0;
144 }
145
146 virtual int getHighestPriority() const
147 {
148 return 0;
149 }
150
151 virtual int getLowestPriority() const
152 {
153 return 0;
154 }
155
156private:
159};
160
161}
162
163#endif // TEST_DOUBLE_OS_WRAPPER_TEST_DOUBLE_THREAD_FACTORY_H_INCLUDED
Interface for implementing an active class.
Definition Runnable.h:9
Definition ThreadFactory.h:11
Abstract class that has functions of common RTOS's thread.
Definition Thread.h:50
Thread(Runnable *r)
Definition Thread.h:52
Value object for the timeout.
Definition Timeout.h:11
Definition TestDoubleThreadFactory.h:105
virtual int getHighestPriority() const
Definition TestDoubleThreadFactory.h:146
virtual int getMinPriority() const
Definition TestDoubleThreadFactory.h:141
virtual void sleep(unsigned long millis)
Definition TestDoubleThreadFactory.h:122
TestDoubleThreadFactory()
Definition TestDoubleThreadFactory.h:107
virtual ~TestDoubleThreadFactory()
Definition TestDoubleThreadFactory.h:108
virtual int getLowestPriority() const
Definition TestDoubleThreadFactory.h:151
virtual OSWrapper::Thread * create(OSWrapper::Runnable *r, int priority, std::size_t stackSize, void *stackAddress, const char *name)
Definition TestDoubleThreadFactory.h:110
virtual void destroy(OSWrapper::Thread *t)
Definition TestDoubleThreadFactory.h:117
virtual int getMaxPriority() const
Definition TestDoubleThreadFactory.h:136
virtual void yield()
Definition TestDoubleThreadFactory.h:127
virtual OSWrapper::Thread * getCurrentThread()
Definition TestDoubleThreadFactory.h:131
Definition TestDoubleThreadFactory.h:10
virtual void setName(const char *name)
Set the object's name.
Definition TestDoubleThreadFactory.h:68
virtual std::size_t getStackSize() const
Get the stack size of this thread.
Definition TestDoubleThreadFactory.h:93
void * m_stackAddress
Definition TestDoubleThreadFactory.h:16
virtual OSWrapper::Error tryWait()
Query without blocking whether this thread is in the FINISHED state.
Definition TestDoubleThreadFactory.h:52
virtual OSWrapper::Error wait()
Block the current thread until this thread transits to the FINISHED state.
Definition TestDoubleThreadFactory.h:47
TestDoubleThread()
Definition TestDoubleThreadFactory.h:20
virtual void start()
Transit this thread to the READY state.
Definition TestDoubleThreadFactory.h:43
virtual void * getNativeHandle()
Get the native handle of RTOS's thread.
Definition TestDoubleThreadFactory.h:98
int m_priority
Definition TestDoubleThreadFactory.h:13
virtual bool isFinished() const
Return true if this thread is in the FINISHED state.
Definition TestDoubleThreadFactory.h:63
const char * m_name
Definition TestDoubleThreadFactory.h:17
int m_initialPriority
Definition TestDoubleThreadFactory.h:14
virtual OSWrapper::Error timedWait(OSWrapper::Timeout tmout)
Block the current thread until this thread transits to the FINISHED state but only within the limited...
Definition TestDoubleThreadFactory.h:57
virtual const char * getName() const
Get the object's name.
Definition TestDoubleThreadFactory.h:73
virtual int getPriority() const
Get this thread priority.
Definition TestDoubleThreadFactory.h:83
void setCreateArgs(OSWrapper::Runnable *r, int priority, std::size_t stackSize, void *stackAddress, const char *name)
Definition TestDoubleThreadFactory.h:31
std::size_t m_stackSize
Definition TestDoubleThreadFactory.h:15
OSWrapper::Runnable * m_runnable
Definition TestDoubleThreadFactory.h:12
virtual void setPriority(int priority)
Change this thread priority.
Definition TestDoubleThreadFactory.h:78
virtual ~TestDoubleThread()
Definition TestDoubleThreadFactory.h:41
virtual int getInitialPriority() const
Get this thread priority when this thread was created.
Definition TestDoubleThreadFactory.h:88
Error
Kinds of errors of the OS objects.
Definition OSWrapperError.h:9
@ OK
Definition OSWrapperError.h:10
Implementation of OSWrapper for Test Double.
Definition TestDoubleEventFlagFactory.h:7