|
1 /* |
|
2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef TC_TESTSCHEDULER_H |
|
21 #define TC_TESTSCHEDULER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <e32std.h> |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 // MACROS |
|
30 |
|
31 // DATA TYPES |
|
32 |
|
33 // FUNCTION PROTOTYPES |
|
34 |
|
35 // FORWARD DECLARATIONS |
|
36 |
|
37 // CLASS DECLARATION |
|
38 |
|
39 /** |
|
40 * Activeobject that is used to break scheduling on timeout |
|
41 * |
|
42 */ |
|
43 class CTimeout : public CActive |
|
44 { |
|
45 public: |
|
46 |
|
47 // returns true if timeout has expired |
|
48 TBool Timed() const |
|
49 { |
|
50 return iTimed; |
|
51 } |
|
52 |
|
53 /** |
|
54 * Constructor. |
|
55 */ |
|
56 CTimeout(); |
|
57 |
|
58 /** |
|
59 * Destructor. |
|
60 */ |
|
61 ~CTimeout(); |
|
62 |
|
63 /** |
|
64 * Starts waiting. |
|
65 * |
|
66 * @param TInt aTimeoutInMilliSecs: in: timeout in milliseconds |
|
67 * @return none |
|
68 */ |
|
69 void Start(TInt aTimeoutInMilliSecs); |
|
70 |
|
71 /** |
|
72 * Cancels waiting. |
|
73 * |
|
74 * @param none |
|
75 * @return none |
|
76 */ |
|
77 virtual void DoCancel(); |
|
78 |
|
79 /** |
|
80 * Stops ActiveScheduler and sets iTimed to true. |
|
81 * |
|
82 * @param none |
|
83 * @return none |
|
84 */ |
|
85 virtual void RunL(); |
|
86 |
|
87 protected: // New functions |
|
88 |
|
89 |
|
90 protected: // Functions from base classes |
|
91 |
|
92 |
|
93 private: |
|
94 |
|
95 /** |
|
96 * C++ default constructor. |
|
97 */ |
|
98 //Cvibractrltest(); |
|
99 |
|
100 /** |
|
101 * By default Symbian 2nd phase constructor is private. |
|
102 */ |
|
103 //void ConstructL(); |
|
104 |
|
105 |
|
106 public: // Data |
|
107 |
|
108 |
|
109 protected: // Data |
|
110 |
|
111 |
|
112 private: // Data |
|
113 |
|
114 // Timer |
|
115 RTimer iTimer; |
|
116 |
|
117 // notifies is the timer stopped by timeout |
|
118 TBool iTimed; |
|
119 |
|
120 |
|
121 public: // Friend classes |
|
122 |
|
123 |
|
124 protected: // Friend classes |
|
125 |
|
126 |
|
127 private: // Friend classes |
|
128 |
|
129 }; |
|
130 |
|
131 /** |
|
132 * Controls the handling of asynchronous requests as represented by active objects. |
|
133 * |
|
134 */ |
|
135 class CTestScheduler : public CActiveScheduler |
|
136 { |
|
137 protected: |
|
138 |
|
139 |
|
140 private: |
|
141 |
|
142 |
|
143 public: |
|
144 |
|
145 /** |
|
146 * Constructor. |
|
147 */ |
|
148 CTestScheduler(); |
|
149 |
|
150 /** |
|
151 * Destructor. |
|
152 */ |
|
153 virtual ~CTestScheduler(); |
|
154 |
|
155 /** |
|
156 * Waits for any request from user |
|
157 * |
|
158 * @param none |
|
159 * @return none |
|
160 */ |
|
161 virtual void WaitForAnyRequest(); // jlof 13-12-2001 |
|
162 |
|
163 /** |
|
164 * Handles the result of a leave occurring in an active object's RunL() function. |
|
165 * |
|
166 * @param TInt anError: error reason |
|
167 * @return none |
|
168 */ |
|
169 virtual void Error(TInt anError) const; |
|
170 |
|
171 /** |
|
172 * Start scheduler for given amount of time |
|
173 * |
|
174 * @param TInt aMillisecs: time to run the scheduler |
|
175 * @return none |
|
176 */ |
|
177 static TBool StartAndStopL( TInt aMillisecs ); |
|
178 |
|
179 /** |
|
180 * Two-phased constructor. |
|
181 */ |
|
182 static CTestScheduler* NewL(); |
|
183 |
|
184 |
|
185 protected: // New functions |
|
186 |
|
187 |
|
188 protected: // Functions from base classes |
|
189 |
|
190 |
|
191 private: |
|
192 |
|
193 /** |
|
194 * By default Symbian 2nd phase constructor is private. |
|
195 */ |
|
196 void ConstructL(); |
|
197 |
|
198 |
|
199 public: // Data |
|
200 |
|
201 |
|
202 protected: // Data |
|
203 |
|
204 |
|
205 private: // Data |
|
206 |
|
207 //timer |
|
208 CTimeout *iTimeout; |
|
209 |
|
210 |
|
211 public: // Friend classes |
|
212 |
|
213 |
|
214 protected: // Friend classes |
|
215 |
|
216 |
|
217 private: // Friend classes |
|
218 |
|
219 }; |
|
220 |
|
221 |
|
222 #endif // TC_CTESTSCHEDULER_H |