|
1 /* |
|
2 * Copyright (c) 2007 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: SEARCH data cache implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CSEARCHDATACACHEIMP_H |
|
19 #define CSEARCHDATACACHEIMP_H |
|
20 |
|
21 #include <ximpapiobjbase.h> |
|
22 #include "searchapiobjbase.h" |
|
23 |
|
24 #include "searchitemparent.h" |
|
25 #include "searchtypehelpers.h" |
|
26 |
|
27 |
|
28 class MXIMPHost; |
|
29 class CCSearchSubscriptionItem; |
|
30 class CXIMPIdentityImp; |
|
31 class MXIMPPscContext; |
|
32 class CXIMPSubscriptionItemBase; |
|
33 class MXIMPStatus; |
|
34 class MXIMPIdentity; |
|
35 class CSearchKeysSubscriptionItem; |
|
36 /** |
|
37 * search data cache implementation |
|
38 * |
|
39 * @lib searchdatamodel.dll |
|
40 */ |
|
41 class CSearchDataCache : public CBase, |
|
42 public MSearchItemParent |
|
43 { |
|
44 public: // Definitions |
|
45 |
|
46 /** The class ID. */ |
|
47 enum { KClassId = IMP_CLSID_CSEARCHDATACACHE }; |
|
48 |
|
49 |
|
50 public: // Construction and destruction |
|
51 |
|
52 /** |
|
53 * Construction |
|
54 */ |
|
55 IMPORT_C static CSearchDataCache * NewL( MXIMPHost& aHost ); |
|
56 |
|
57 /** |
|
58 * Destruction |
|
59 */ |
|
60 virtual ~CSearchDataCache (); |
|
61 |
|
62 private: |
|
63 /** |
|
64 * construction |
|
65 */ |
|
66 CSearchDataCache ( MXIMPHost& aHost ); |
|
67 /** |
|
68 * leaving constructor |
|
69 */ |
|
70 void ConstructL(); |
|
71 |
|
72 private: // MXIMPItemParentBase |
|
73 /** |
|
74 * @see MXIMPItemParentBase |
|
75 */ |
|
76 |
|
77 TAny* GetInterface(TInt aInterfaceId); |
|
78 /** |
|
79 * @see MXIMPItemParentBase |
|
80 */ |
|
81 void RegisterExpiringItemL( CXIMPSubscriptionItemBase* aExpireItem ); |
|
82 /** |
|
83 * @see MXIMPItemParentBase |
|
84 */ |
|
85 void UnregisterExpiringItem( CXIMPSubscriptionItemBase* aExpireItem ); |
|
86 |
|
87 private: // From MSearchItemParent |
|
88 |
|
89 /** |
|
90 * @see MSearchItemParent |
|
91 */ |
|
92 void RemoveMe( CSearchSubscriptionItem* aChild ); |
|
93 |
|
94 void RemoveMe( CSearchKeysSubscriptionItem* aChild ); |
|
95 |
|
96 /** |
|
97 * @see MSearchItemParent |
|
98 */ |
|
99 void AddEventL( CXIMPApiEventBase& aEvent, MXIMPPscContext* aContext ); |
|
100 |
|
101 public: // New methods |
|
102 |
|
103 /** |
|
104 * - If CSearchSubscriptionItem is not found, data cache |
|
105 * initializes new one and returns ownership to caller |
|
106 * - If CSearchSubscriptionItem is found, data cache increases |
|
107 * refcount by one, and returns the old object |
|
108 */ |
|
109 IMPORT_C CSearchSubscriptionItem& SearchSubscriptionItemLC(); |
|
110 |
|
111 /** |
|
112 * - If CSearchKeysSubscriptionItem is not found, data cache |
|
113 * initializes new one and returns ownership to caller |
|
114 * - If CSearchKeysSubscriptionItem is found, data cache increases |
|
115 * refcount by one, and returns the old object |
|
116 */ |
|
117 IMPORT_C CSearchKeysSubscriptionItem& SearchKeysSubscriptionItemLC(); |
|
118 |
|
119 /** |
|
120 * Clean resources concerning context. |
|
121 */ |
|
122 IMPORT_C void CleanResources( MXIMPPscContext& aContext ); |
|
123 |
|
124 /** |
|
125 * |
|
126 */ |
|
127 IMPORT_C void CleanExpired(); |
|
128 |
|
129 private: // Helper methods |
|
130 |
|
131 /** |
|
132 * Template method for removeMe when one subscription item is target. |
|
133 * @param aItem Reference to subscription item pointer to remove. |
|
134 * @param Pointer of item to remove. |
|
135 */ |
|
136 template< class Type > |
|
137 IMPORT_C static void RemoveMe( Type*& aItem, Type* aChild ); |
|
138 |
|
139 |
|
140 /** |
|
141 * Templated item instance creation. If item is not found it is created. |
|
142 * @param aItem Reference to pointer where new item should be saved. |
|
143 * @return Reference to item created. |
|
144 */ |
|
145 template< class Type > |
|
146 Type& ItemLC( Type*& aItem ); |
|
147 |
|
148 |
|
149 |
|
150 private: // Data |
|
151 |
|
152 /** |
|
153 * Access to host. not owned |
|
154 */ |
|
155 MXIMPHost& iHost; |
|
156 |
|
157 /** |
|
158 * Does not own. Removed when RemoveMe called. |
|
159 */ |
|
160 CSearchSubscriptionItem* iSearchSubscriptionItem; |
|
161 CSearchKeysSubscriptionItem* iSearchKeySubscriptionItem; |
|
162 }; |
|
163 |
|
164 #endif // CSearchDataCache IMP_H |