|
1 /* |
|
2 * Copyright (c) 2006 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: Serializing the task |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CMPXTASKQUEUE_H |
|
20 #define CMPXTASKQUEUE_H |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 class MMPXTaskQueueObserver; |
|
25 class CMPXTaskQueueScheduler; |
|
26 class CTask; |
|
27 |
|
28 /** |
|
29 * Encapsulates a task queue. |
|
30 * |
|
31 * @lib MPXCommon.lib |
|
32 */ |
|
33 class CMPXTaskQueue : public CBase |
|
34 { |
|
35 public: |
|
36 /** |
|
37 * Two-phased constructor. |
|
38 * |
|
39 * @since S60 3.2.3 |
|
40 * @return object of constructed |
|
41 */ |
|
42 IMPORT_C static CMPXTaskQueue* NewL(); |
|
43 |
|
44 /** |
|
45 * Destructor. |
|
46 * |
|
47 * @since S60 3.2.3 |
|
48 */ |
|
49 IMPORT_C virtual ~CMPXTaskQueue(); |
|
50 |
|
51 /** |
|
52 * Add a task into the queue. |
|
53 * |
|
54 * @since S60 3.2.3 |
|
55 * @param aTask task id |
|
56 * @param aCallback callback |
|
57 * @param aParamData parameter data of the task |
|
58 * @param aBuf extra data in buffer, ownership transferred. |
|
59 * @param aPtrData object pointer, owership not transferred. |
|
60 * @param aCObject1 pointer to CBased object, ownership transferred |
|
61 * @param aCObject2 pointer to CBased object, ownership transferred |
|
62 */ |
|
63 IMPORT_C void AddTaskL(TInt aTask, |
|
64 TAny* aCallback, |
|
65 TInt aParamData=0, |
|
66 CBufBase* aBuf=NULL, |
|
67 TAny* aPtrData=NULL, |
|
68 CBase* aCObject1=NULL, |
|
69 CBase* aCObject2=NULL); |
|
70 |
|
71 /** |
|
72 * Remove current task, return callback function. |
|
73 * |
|
74 * @since S60 3.2.3 |
|
75 * @return callback object |
|
76 */ |
|
77 IMPORT_C TAny* RemoveTask(); |
|
78 |
|
79 /** |
|
80 * Remove task for one client. |
|
81 * |
|
82 * @since S60 3.2.3 |
|
83 */ |
|
84 IMPORT_C void RemoveTask(TAny* aCallback); |
|
85 |
|
86 /** |
|
87 * Return if the queue is empty. |
|
88 * |
|
89 * @since S60 3.2.3 |
|
90 * @return ETrue empty |
|
91 */ |
|
92 IMPORT_C TBool IsEmpty(); |
|
93 |
|
94 /** |
|
95 * Reset task queue. |
|
96 * |
|
97 * @since S60 3.2.3 |
|
98 */ |
|
99 IMPORT_C void Reset(); |
|
100 |
|
101 /** |
|
102 * Get current task id. |
|
103 * |
|
104 * @since S60 3.2.3 |
|
105 * @return task id |
|
106 */ |
|
107 IMPORT_C TInt Task(); |
|
108 |
|
109 /** |
|
110 * Get current call back. |
|
111 * |
|
112 * @since S60 3.2.3 |
|
113 * @return call back |
|
114 */ |
|
115 IMPORT_C TAny* Callback(); |
|
116 |
|
117 /** |
|
118 * Get current parameter data. |
|
119 * |
|
120 * @since S60 3.2.3 |
|
121 * @return parameter data |
|
122 */ |
|
123 IMPORT_C TInt Param(); |
|
124 |
|
125 /** |
|
126 * Get pointer parameter data. Client has ownership of this data. |
|
127 * |
|
128 * @since S60 3.2.3 |
|
129 * @return pointer paramter |
|
130 */ |
|
131 IMPORT_C TAny* PtrData(); |
|
132 |
|
133 /** |
|
134 * Get pointer to buffer data. Task Queue has ownership of this buffer. |
|
135 * |
|
136 * @since S60 3.2.3 |
|
137 * @return buffer paramter |
|
138 */ |
|
139 IMPORT_C const TDesC8& BufData(); |
|
140 |
|
141 protected: |
|
142 /** |
|
143 * C++ constructor. |
|
144 * |
|
145 * @since S60 3.2.3 |
|
146 */ |
|
147 CMPXTaskQueue(); |
|
148 |
|
149 /** |
|
150 * 2nd phase contructor. |
|
151 * |
|
152 * @since S60 3.2.3 |
|
153 */ |
|
154 void ConstructL(); |
|
155 |
|
156 protected: //data |
|
157 TSglQue<CTask> iTaskList; |
|
158 }; |
|
159 |
|
160 /** |
|
161 * Encapsulates a task queue which will auto schedule the task |
|
162 * |
|
163 * @lib MPXCommon.lib |
|
164 */ |
|
165 class CMPXActiveTaskQueue : public CMPXTaskQueue |
|
166 { |
|
167 public: |
|
168 /** |
|
169 * Two-phased constructor. |
|
170 * |
|
171 * @since S60 3.2.3 |
|
172 * @param aObserver the observer |
|
173 * @return object of constructed |
|
174 */ |
|
175 IMPORT_C static CMPXActiveTaskQueue* NewL(); |
|
176 |
|
177 /** |
|
178 * Destructor. |
|
179 * |
|
180 * @since S60 3.2.3 |
|
181 */ |
|
182 IMPORT_C virtual ~CMPXActiveTaskQueue(); |
|
183 |
|
184 /** |
|
185 * Add a task and automatically schedule task. |
|
186 * |
|
187 * @since S60 3.2.3 |
|
188 * @param aTask task id |
|
189 * @param aCallback callback |
|
190 * @param aHandler task handler |
|
191 * @param aParamData data |
|
192 * @param aBuf pointer to the buffer containing |
|
193 * externalized parameter data. |
|
194 * Client passes ownership of the buffer |
|
195 * to TaskQueue. |
|
196 * @param aPtrData object pointer |
|
197 * @param aCObject1 pointer to CBased object, ownership transferred |
|
198 * @param aCObject2 pointer to CBased object, ownership transferred |
|
199 */ |
|
200 IMPORT_C void AddTaskL(TInt aTask, |
|
201 TAny* aCallback, |
|
202 MMPXTaskQueueObserver* aHandler, |
|
203 TInt aParamData=0, |
|
204 CBufBase* aBuf=NULL, |
|
205 TAny* aPtrData=NULL, |
|
206 CBase* aCObject1=NULL, |
|
207 CBase* aCObject2=NULL); |
|
208 |
|
209 /** |
|
210 * Schedule to execute next task. |
|
211 * |
|
212 * @since S60 3.2.3 |
|
213 */ |
|
214 IMPORT_C void ScheduleNextTask(); |
|
215 |
|
216 /** |
|
217 * Cancel all outstanding, asynchronous requests. |
|
218 * |
|
219 * @since S60 3.2.3 |
|
220 */ |
|
221 IMPORT_C void CancelRequests(); |
|
222 |
|
223 /** |
|
224 * Complete current task. |
|
225 * |
|
226 * @since S60 3.2.3 |
|
227 */ |
|
228 IMPORT_C void CompleteTask(); |
|
229 |
|
230 /** |
|
231 * Completes all outstanding tasks with an error code. |
|
232 * |
|
233 * @since S60 3.2.3 |
|
234 */ |
|
235 IMPORT_C void CompleteAllTasks(TInt aError); |
|
236 |
|
237 private: |
|
238 /** |
|
239 * C++ constructor. |
|
240 * |
|
241 * @since S60 3.2.3 |
|
242 */ |
|
243 CMPXActiveTaskQueue(); |
|
244 |
|
245 /** |
|
246 * 2nd phase contructor. |
|
247 * |
|
248 * @since S60 3.2.3 |
|
249 */ |
|
250 void ConstructL(); |
|
251 |
|
252 private: // Data |
|
253 CMPXTaskQueueScheduler* iScheduler; |
|
254 |
|
255 }; |
|
256 |
|
257 #endif // CMPXTASKQUEUE_H |