|
1 /* |
|
2 * Copyright (c) 2005 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: array for storing dataproviders and datastores. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __NSMLDSDATAPROVIDERARRAY_H__ |
|
20 #define __NSMLDSDATAPROVIDERARRAY_H__ |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <stringpool.h> |
|
25 #include <nsmldsconstants.h> |
|
26 #include <nsmlconstants.h> |
|
27 |
|
28 #include "nsmldshostconstants.h" |
|
29 #include "nsmldshostitem.h" |
|
30 #include "nsmldsitemmodificationset.h" |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CSmlDataProvider; |
|
34 class CSmlDataStore; |
|
35 class CNSmlDSAsyncRequestHandler; |
|
36 class CNSmlAdapterLog; |
|
37 class CSmlDataStoreFormat; |
|
38 |
|
39 // CLASS DECLARATION |
|
40 |
|
41 // ------------------------------------------------------------------------------------------------ |
|
42 // Container for CSmlDataStore. |
|
43 // |
|
44 // @lib nsmldshostserver.lib |
|
45 // ------------------------------------------------------------------------------------------------ |
|
46 typedef RPointerArray<TSmlDbItemUid> RBatchItemUidArray; |
|
47 |
|
48 struct TNSmlDSDataStoreElement |
|
49 { |
|
50 public: |
|
51 /** |
|
52 * deletes iBatchItemUids and its objects. |
|
53 */ |
|
54 void FreeBatchItemArray(); |
|
55 |
|
56 /** |
|
57 * is iDataStore opened. |
|
58 * @return TBool. ETrue if iDataStore is opened, EFalse otherwise. |
|
59 */ |
|
60 TBool IsOpen() const; |
|
61 |
|
62 /** |
|
63 * sets iDataStore as opened. |
|
64 */ |
|
65 void SetOpened(); |
|
66 |
|
67 /** |
|
68 * The name of iDataStore. |
|
69 * @return const TDesC&. The name of iDataStore |
|
70 */ |
|
71 const TDesC& StoreName() const; |
|
72 |
|
73 void setStoreFormat( CSmlDataStoreFormat* aDSFormat ); |
|
74 private: |
|
75 |
|
76 /** |
|
77 * C++ default constructor. |
|
78 */ |
|
79 TNSmlDSDataStoreElement( const HBufC* aStoreName ); |
|
80 |
|
81 public: //Data |
|
82 |
|
83 //This class doesn't free memory reserved for member variable pointers. |
|
84 |
|
85 CNSmlDSAsyncRequestHandler* iDSAO; //async handler for the data store. |
|
86 //Null if no asynch call outstanding |
|
87 CSmlDataStore* iDataStore; //contained data store |
|
88 RBatchItemUidArray* iBatchItemUids; //array of item uid when in batch mode. |
|
89 CNSmlAdapterLog* iAdpLog; //sync relationship |
|
90 TSmlDbItemUid iCreatedUid; //uid for CSmlDataStore::CreateItemL |
|
91 TNSmlHostMode iHostMode; //data store mode |
|
92 private: //Data |
|
93 |
|
94 const HBufC* iStoreName; //Only temporary. Contains store name only when created but not yet opened. |
|
95 CSmlDataStoreFormat* iDSFormat; //data store format. |
|
96 private: |
|
97 |
|
98 friend class RNSmlDSDataProviderArray; |
|
99 }; |
|
100 |
|
101 // ------------------------------------------------------------------------------------------------ |
|
102 // Container for CSmlDataProvider. |
|
103 // |
|
104 // @lib nsmldshostserver.lib |
|
105 // ------------------------------------------------------------------------------------------------ |
|
106 typedef RPointerArray<TNSmlDSDataStoreElement> RDataStoreElementArray; |
|
107 |
|
108 struct TNSmlDSDataProviderElement |
|
109 { |
|
110 //This class doesn't free memory reserved for member variable pointers. |
|
111 CSmlDataProvider* iDataprovider; |
|
112 RDataStoreElementArray* iDataStores; //created data stores for data provider. |
|
113 }; |
|
114 |
|
115 // ------------------------------------------------------------------------------------------------ |
|
116 // Array for created data providers and created and opened data stores. |
|
117 // |
|
118 // @lib nsmldshostserver.lib |
|
119 // ------------------------------------------------------------------------------------------------ |
|
120 class RNSmlDSDataProviderArray : protected RPointerArray<TNSmlDSDataProviderElement> |
|
121 { |
|
122 public: //Constructor and destructor |
|
123 |
|
124 /** |
|
125 * A C++ constructor of this class. |
|
126 */ |
|
127 RNSmlDSDataProviderArray(); |
|
128 |
|
129 public: |
|
130 |
|
131 /** |
|
132 * Destroys all the the elements and resets the array. |
|
133 */ |
|
134 void ResetAndDestroy(); |
|
135 |
|
136 /** |
|
137 * Finds and returns the dataprovider using data provider id. |
|
138 * @param aId. Search key. |
|
139 * @return CSmlDataProvider*. The object found or NULL if no match. |
|
140 */ |
|
141 CSmlDataProvider* DataProvider( TSmlDataProviderId aId ); |
|
142 |
|
143 /** |
|
144 * Finds and returns the dataprovider element using data provider id. |
|
145 * @param aId. Search key. |
|
146 * @return TNSmlDSDataProviderElement*. The object found or NULL if no match. |
|
147 */ |
|
148 TNSmlDSDataProviderElement* DataProviderElement( TSmlDataProviderId aId ); |
|
149 |
|
150 /** |
|
151 * Finds and returns the datastore using data provider id and store name. |
|
152 * @param aId. Search key. data provider id |
|
153 * @param aId. Search key. Store name. |
|
154 * @return CSmlDataStore*. The object found or NULL if no match. |
|
155 */ |
|
156 CSmlDataStore* DataStore( TSmlDataProviderId aId, const TDesC& aStoreName ); |
|
157 |
|
158 /** |
|
159 * Finds and returns the datastore element from data provider element |
|
160 * using data provider id and store name. |
|
161 * @param aId. Search key. data provider id |
|
162 * @param aId. Search key. Store name. |
|
163 * @return TNSmlDSDataStoreElement*. The object found or NULL if no match. |
|
164 */ |
|
165 static TNSmlDSDataStoreElement* DataStoreElement( const TNSmlDSDataProviderElement* aItem, |
|
166 const TDesC& aStoreName ); |
|
167 |
|
168 /** |
|
169 * Inserts data provider to the array. Leaves if fails. |
|
170 * @param aDataprovider. Data provider to add. |
|
171 * @return TInt. KErrNone if object is inserted. |
|
172 * KErrAlreadyExists if object is already inserted. |
|
173 */ |
|
174 TInt InsertL( CSmlDataProvider* aDataprovider ); |
|
175 |
|
176 /** |
|
177 * Inserts created data store to data provider element. |
|
178 * @param aDataproviderItem. object where to add. |
|
179 * @param aDataStore. datastore to add. |
|
180 * @param aDataStoreName. store name for aDataStore. |
|
181 * @return TNSmlDSDataStoreElement*. Newly created data store element, that contains aDataStore. |
|
182 */ |
|
183 TNSmlDSDataStoreElement* InsertL( TNSmlDSDataProviderElement* aDataproviderItem, |
|
184 CSmlDataStore* aDataStore, HBufC* aDataStoreName ); |
|
185 |
|
186 /** |
|
187 * Removes and frees the memory reserved to data store element. |
|
188 * Doesn't free the returned object. Caller must take the ownership of that. |
|
189 * @param aDataproviderItem. data provider element where to remove. |
|
190 * @param aDataStoreItem. data store to remove. |
|
191 * @return CNSmlDSAsyncRequestHandler*. Request handler for aDataStoreItem. |
|
192 * NULL if no asynchronous request is outstanding. |
|
193 */ |
|
194 CNSmlDSAsyncRequestHandler* Remove( TNSmlDSDataProviderElement* aDataproviderItem, |
|
195 TNSmlDSDataStoreElement* aDataStoreItem ); |
|
196 |
|
197 protected: |
|
198 |
|
199 /** |
|
200 * Destroys data store element. |
|
201 * @param aDataStoreItem. data store element to destroy. After destruction points to NULL. |
|
202 * @return CNSmlDSAsyncRequestHandler*. Request handler for aDataStoreItem. |
|
203 * NULL if no asynchronous request is outstanding. |
|
204 */ |
|
205 static CNSmlDSAsyncRequestHandler* Destroy( TNSmlDSDataStoreElement*& aDataStoreItem ); |
|
206 }; |
|
207 |
|
208 #endif //__NSMLDSDATAPROVIDERARRAY_H__ |
|
209 |
|
210 // End of File |