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