|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef AGGREGATE_H_ |
|
17 #define AGGREGATE_H_ |
|
18 |
|
19 #include <e32base.h> |
|
20 |
|
21 const TInt KMaxNumItems = 6; |
|
22 |
|
23 class CAggregateCollection; |
|
24 |
|
25 /** These are individual items that need to comple and are awaiting completion of their TRequestStatus as |
|
26 when they complete they let the collection know that they have complteted and allow the collection object to take |
|
27 appropriate action. Objects of this class are created and then owned by the CAgregateCollection. They are then |
|
28 deleted when the CAgregateCollection object is destroyed (hence the protected destructor) |
|
29 */ |
|
30 NONSHARABLE_CLASS(CAggregateItem) : public CActive |
|
31 { |
|
32 friend class CAggregateCollection; |
|
33 public: |
|
34 void Start(); |
|
35 TInt ReturnCode(); |
|
36 protected: |
|
37 static CAggregateItem *NewL(CAggregateCollection* aColl); |
|
38 CAggregateItem(CAggregateCollection* aColl); |
|
39 ~CAggregateItem(); |
|
40 virtual void RunL(); |
|
41 virtual void DoCancel(); |
|
42 private: |
|
43 CAggregateCollection* iCollection; |
|
44 TBool iIsAdded; |
|
45 }; |
|
46 |
|
47 /** This is a collection of CAggregateItems. The basic use of this class is to allow for waiting for completion of more than |
|
48 one TRequestStatus. This is does by creating a collection of active objects with iStatuses to wait upon. These need to be |
|
49 used in some asynchronous call. and the control then needs to be given back to the active scheduler. |
|
50 The object will either wait for the completion of any of the items or all of the items before compltetion some |
|
51 TRequestStatus. The decision on whether to wait for any or whether to wait for all set up on construction |
|
52 */ |
|
53 NONSHARABLE_CLASS(CAggregateCollection): public CBase |
|
54 { |
|
55 friend class CAggregateItem; |
|
56 public: |
|
57 enum TType {EAny,EAll}; |
|
58 static CAggregateCollection* NewL(TRequestStatus &aStatus,TType aType); |
|
59 ~CAggregateCollection(); |
|
60 CAggregateItem* GetNewItemL(); |
|
61 void Kick(); |
|
62 private: |
|
63 CAggregateCollection(TRequestStatus &aStatus,TType aType); |
|
64 void UpdateCompletion(); |
|
65 TRequestStatus& iStatusToComplete; |
|
66 CAggregateItem* iItems[KMaxNumItems]; |
|
67 TInt iNumItems; |
|
68 TInt iNumItemsCompleted; //The number of CAggregateItems Completed |
|
69 TType iType; |
|
70 }; |
|
71 |
|
72 |
|
73 #endif |
|
74 |
|
75 |