|
1 /* |
|
2 * Copyright (c) 2006-2008 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: Contains CNcdNodeIdentifierIdentifier class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef NCD_NODE_IDENTIFIER_H |
|
20 #define NCD_NODE_IDENTIFIER_H |
|
21 |
|
22 |
|
23 #include <e32base.h> |
|
24 |
|
25 class RReadStream; |
|
26 class RWriteStream; |
|
27 |
|
28 class CCatalogsRefString; |
|
29 |
|
30 #define DLNODEID( nodeId ) DLTRACE(( _L("id: %S, ns: %S, uid: %x, uri: %S"), &nodeId.NodeId(), &nodeId.NodeNameSpace(), nodeId.ClientUid().iUid, &nodeId.ServerUri() )) |
|
31 |
|
32 /** |
|
33 * ?one_line_short_description |
|
34 * |
|
35 * ?more_complete_description |
|
36 * |
|
37 * @lib ?library |
|
38 * @since S60 ?S60_version *** for example, S60 v3.0 |
|
39 */ |
|
40 class CNcdNodeIdentifier : public CBase |
|
41 { |
|
42 |
|
43 public: |
|
44 |
|
45 /** |
|
46 * Destructor |
|
47 */ |
|
48 virtual ~CNcdNodeIdentifier(); |
|
49 |
|
50 /** |
|
51 * NewL |
|
52 * Sets the namespace, id and server URI values to KNullDesC and the |
|
53 * UID value to Null() value. |
|
54 * |
|
55 * @return CNcdNodeIdentifier* Pointer to the created object |
|
56 * of this class. |
|
57 */ |
|
58 static CNcdNodeIdentifier* NewL(); |
|
59 |
|
60 /** |
|
61 * NewLC |
|
62 * Sets the namespace, id and server URI values to KNullDesC and the |
|
63 * UID value to Null() value. |
|
64 * |
|
65 * @return CNcdNodeIdentifier* Pointer to the created object |
|
66 * of this class. |
|
67 */ |
|
68 static CNcdNodeIdentifier* NewLC(); |
|
69 |
|
70 |
|
71 /** |
|
72 * NewL |
|
73 * Server URI is set to KNullDesC. |
|
74 * |
|
75 * @param aNodeNameSpace |
|
76 * @param aNodeId This class does not take ownership. |
|
77 * @param aClientUid |
|
78 * @return CNcdNodeIdentifier* Pointer to the created object |
|
79 * of this class. |
|
80 */ |
|
81 static CNcdNodeIdentifier* NewL( const TDesC& aNodeNameSpace, |
|
82 const TDesC& aNodeId, |
|
83 const TUid& aClientUid ); |
|
84 |
|
85 /** |
|
86 * NewLC |
|
87 * Server URI is set to KNullDesC. |
|
88 * |
|
89 * @param aNodeNameSpace |
|
90 * @param aNodeId |
|
91 * @param aClientUid |
|
92 * @return CNcdNodeIdentifier* Pointer to the created object |
|
93 * of this class. |
|
94 */ |
|
95 static CNcdNodeIdentifier* NewLC( const TDesC& aNodeNameSpace, |
|
96 const TDesC& aNodeId, |
|
97 const TUid& aClientUid ); |
|
98 |
|
99 |
|
100 /** |
|
101 * NewL |
|
102 * |
|
103 * @param aNodeNameSpace |
|
104 * @param aNodeId |
|
105 * @param aServerUri |
|
106 * @param aClientUid |
|
107 * @return CNcdNodeIdentifier* Pointer to the created object |
|
108 * of this class. |
|
109 */ |
|
110 static CNcdNodeIdentifier* NewL( const TDesC& aNodeNameSpace, |
|
111 const TDesC& aNodeId, |
|
112 const TDesC& aServerUri, |
|
113 const TUid& aClientUid ); |
|
114 |
|
115 /** |
|
116 * NewLC |
|
117 * |
|
118 * @param aNodeNameSpace |
|
119 * @param aNodeId |
|
120 * @param aServerUri |
|
121 * @param aClientUid |
|
122 * @return CNcdNodeIdentifier* Pointer to the created object |
|
123 * of this class. |
|
124 */ |
|
125 static CNcdNodeIdentifier* NewLC( const TDesC& aNodeNameSpace, |
|
126 const TDesC& aNodeId, |
|
127 const TDesC& aServerUri, |
|
128 const TUid& aClientUid ); |
|
129 |
|
130 |
|
131 /** |
|
132 * NewL |
|
133 * |
|
134 * @param aNodeIdentifier This class does not take ownership. |
|
135 * @return CNcdNodeIdentifier* Pointer to the created object |
|
136 * of this class. |
|
137 */ |
|
138 static CNcdNodeIdentifier* NewL( const CNcdNodeIdentifier& aNodeIdentifier ); |
|
139 |
|
140 /** |
|
141 * NewLC |
|
142 * |
|
143 * @param aNodeIdentifier This class does not take ownership. |
|
144 * @return CNcdNodeIdentifier* Pointer to the created object |
|
145 * of this class. |
|
146 */ |
|
147 static CNcdNodeIdentifier* NewLC( const CNcdNodeIdentifier& aNodeIdentifier ); |
|
148 |
|
149 |
|
150 /** |
|
151 * NewL |
|
152 * |
|
153 * @param aNodeIdentifierData |
|
154 * @return CNcdNodeIdentifier* Pointer to the created object |
|
155 * of this class. |
|
156 */ |
|
157 static CNcdNodeIdentifier* NewL( const TDesC8& aNodeIdentifierData ); |
|
158 |
|
159 /** |
|
160 * NewLC |
|
161 * |
|
162 * @param aNodeIdentifierData |
|
163 * @return CNcdNodeIdentifier* Pointer to the created object |
|
164 * of this class. |
|
165 */ |
|
166 static CNcdNodeIdentifier* NewLC( const TDesC8& aNodeIdentifierData ); |
|
167 |
|
168 |
|
169 static CNcdNodeIdentifier* NewL( RReadStream& aReadStream ); |
|
170 static CNcdNodeIdentifier* NewLC( RReadStream& aReadStream ); |
|
171 |
|
172 virtual void InternalizeL( RReadStream& aReadStream ); |
|
173 virtual void ExternalizeL( RWriteStream& aWriteStream ) const; |
|
174 |
|
175 |
|
176 |
|
177 /** |
|
178 * @return TDesc& Namespace of the node |
|
179 */ |
|
180 const TDesC& NodeNameSpace() const; |
|
181 |
|
182 /** |
|
183 * @return TDesc& Id of the node which is unique in a namespace |
|
184 */ |
|
185 const TDesC& NodeId() const; |
|
186 |
|
187 /** |
|
188 * @return TDesc& Server URI of the node |
|
189 */ |
|
190 const TDesC& ServerUri() const; |
|
191 |
|
192 /** |
|
193 * @return Client UID. |
|
194 */ |
|
195 const TUid& ClientUid() const; |
|
196 |
|
197 |
|
198 /** |
|
199 * This function recreates the data everytime this function is asked. |
|
200 * The data will contain: |
|
201 * @return HBufC8* Identifying data that contains all the nodeidentifier data. |
|
202 * in one. Ownership is transferred. |
|
203 */ |
|
204 HBufC8* NodeIdentifierDataL() const; |
|
205 |
|
206 |
|
207 /** |
|
208 * @note As a default the uri is not included for the checking. |
|
209 * |
|
210 * @param aCheckNameSpace Informs if the identifier namespace should be included |
|
211 * to the checking. |
|
212 * @param aCheckId Informs if the identifier id should be included |
|
213 * to the checking. |
|
214 * @param aCheckUri Informs if the identifier server uri should be included |
|
215 * to the checking. |
|
216 * @param aCheckUid Informs if the identifier Uid should be included |
|
217 * to the checking. |
|
218 * @return ETrue if at least one of the identifier fields |
|
219 * is empty. EFalse, if all of the fields contain some data. |
|
220 */ |
|
221 TBool ContainsEmptyFields( TBool aCheckNameSpace = ETrue, |
|
222 TBool aCheckId = ETrue, |
|
223 TBool aCheckUri = EFalse, |
|
224 TBool aCheckUid = ETrue ) const; |
|
225 |
|
226 |
|
227 /** |
|
228 * Can be used to compare this node identifier to another. |
|
229 * If all the identifier values are same then ETrue is returned. |
|
230 * |
|
231 * @note This compares also UID values. Different applications may have |
|
232 * same ids, namespaces and URIs for the nodes, but the UID can be used to |
|
233 * make corresponding nodes unique. |
|
234 * |
|
235 * @note As a default Uri is left out of the comparison. |
|
236 * |
|
237 * @param aObject1 Identifier object whose data is compared |
|
238 * @param aCompareNameSpace Informs if the identifier namespace should be |
|
239 * included to the comparison. |
|
240 * @param aCompareId Informs if the identifier id should be |
|
241 * included to the comparison. |
|
242 * @param aCompareUri Informs if the identifier server uri should be |
|
243 * included to the comparison. |
|
244 * @param aCompareUid Informs if the identifier Uid should be |
|
245 * included to the comparison. |
|
246 * @return TBool ETrue if identifiers contains same info. Else EFalse. |
|
247 */ |
|
248 TBool Equals( const CNcdNodeIdentifier& aObject, |
|
249 TBool aCompareNameSpace = ETrue, |
|
250 TBool aCompareId = ETrue, |
|
251 TBool aCompareUri = EFalse, |
|
252 TBool aCompareUid = ETrue ) const; |
|
253 |
|
254 /** |
|
255 * Static function that can be used to compare two node identifiers. |
|
256 * If all the identifier values are same then ETrue is returned. |
|
257 * |
|
258 * @note This compares also UID values. Different applications may have |
|
259 * same ids, namespaces and URIs for the nodes, but the UID can be used to |
|
260 * make corresponding nodes unique. |
|
261 * |
|
262 * @note As a default Uri is left out of the comparison. |
|
263 * |
|
264 * @param aObject1 Identifier object whose data is compared |
|
265 * @param aObject2 Identifier object whose data is compared |
|
266 * @param aCompareNameSpace Informs if the identifier namespace should be |
|
267 * included to the comparison. |
|
268 * @param aCompareId Informs if the identifier id should be |
|
269 * included to the comparison. |
|
270 * @param aCompareUri Informs if the identifier server uri should be |
|
271 * included to the comparison. |
|
272 * @param aCompareUid Informs if the identifier Uid should be |
|
273 * included to the comparison. |
|
274 * @return TBool ETrue if identifiers contains same info. Else EFalse. |
|
275 */ |
|
276 static TBool Equals( const CNcdNodeIdentifier& aObject1, |
|
277 const CNcdNodeIdentifier& aObject2, |
|
278 TBool aCompareNameSpace = ETrue, |
|
279 TBool aCompareId = ETrue, |
|
280 TBool aCompareUri = EFalse, |
|
281 TBool aCompareUid = ETrue ); |
|
282 |
|
283 |
|
284 /** |
|
285 * Node id comparison |
|
286 * |
|
287 * @param aObject1 First id |
|
288 * @param aObject2 Second id |
|
289 * @return a negative value if aObject1 < aObject2, |
|
290 * 0 if aObject1 == aObject2 and a positive value if |
|
291 * aObject1 > aObject2 |
|
292 * @note Only node id, namespace and client UID are used for comparison |
|
293 */ |
|
294 static TInt Compare( const CNcdNodeIdentifier& aObject1, |
|
295 const CNcdNodeIdentifier& aObject2 ); |
|
296 |
|
297 |
|
298 /** |
|
299 * Node id comparison |
|
300 * |
|
301 * Orders first by client UID then by namespace and finally node id |
|
302 * |
|
303 * @param aObject1 First id |
|
304 * @param aObject2 Second id |
|
305 * @return a negative value if aObject1 < aObject2, |
|
306 * 0 if aObject1 == aObject2 and a positive value if |
|
307 * aObject1 > aObject2 |
|
308 * @note Only node id, namespace and client UID are used for comparison |
|
309 */ |
|
310 static TInt CNcdNodeIdentifier::CompareOrderByUid( |
|
311 const CNcdNodeIdentifier& aObject1, |
|
312 const CNcdNodeIdentifier& aObject2 ); |
|
313 |
|
314 #if defined (COMPONENT_CATALOGSSERVEREXE) && defined (LOG_MEMORY_USAGE) |
|
315 |
|
316 static TInt64 iCurrentMemory; |
|
317 static TInt64 iMaxMemory; |
|
318 static TInt iIdCount; |
|
319 static TInt iMaxCount; |
|
320 |
|
321 static void AddId( const CNcdNodeIdentifier& aId, TInt64& aMemory ); |
|
322 static void RemoveId( const CNcdNodeIdentifier& aId, const TInt64& aMemory ); |
|
323 |
|
324 TInt64 iMyMemory; |
|
325 #endif |
|
326 |
|
327 #ifdef COMPONENT_CATALOGSSERVEREXE |
|
328 /** |
|
329 * Sets node id |
|
330 */ |
|
331 void SetNodeIdL( const TDesC& aNodeId ); |
|
332 #endif |
|
333 |
|
334 protected: |
|
335 |
|
336 /** |
|
337 * Constructor |
|
338 * |
|
339 */ |
|
340 CNcdNodeIdentifier(); |
|
341 |
|
342 /** |
|
343 * ConstructL |
|
344 */ |
|
345 void ConstructL( |
|
346 const TDesC& aNodeNameSpace, |
|
347 const TDesC& aNodeId, |
|
348 const TDesC& aServerUri, |
|
349 const TUid& aClientUid ); |
|
350 |
|
351 /** |
|
352 * ConstructL |
|
353 */ |
|
354 void ConstructL( const TDesC8& aNodeIdentifierData ); |
|
355 |
|
356 |
|
357 private: |
|
358 |
|
359 // Prevent if not implemented |
|
360 //CNcdNodeIdentifier( const CNcdNodeIdentifier& aObject ); |
|
361 CNcdNodeIdentifier& operator =( const CNcdNodeIdentifier& aObject ); |
|
362 |
|
363 |
|
364 protected: // data |
|
365 |
|
366 #ifdef COMPONENT_CATALOGSSERVEREXE |
|
367 |
|
368 CNcdNodeIdentifier( const CNcdNodeIdentifier& aId ); |
|
369 void ReleaseStrings(); |
|
370 |
|
371 const CCatalogsRefString* iNodeNameSpace; |
|
372 const CCatalogsRefString* iNodeId; |
|
373 const CCatalogsRefString* iServerUri; |
|
374 |
|
375 #else |
|
376 // This is the name space of the node. Owns. |
|
377 HBufC* iNodeNameSpace; |
|
378 |
|
379 // This is the id of the node. Owns. |
|
380 HBufC* iNodeId; |
|
381 |
|
382 // This is the id of the node. Owns. |
|
383 HBufC* iServerUri; |
|
384 |
|
385 #endif |
|
386 // This is the UID of the client. |
|
387 TUid iClientUid; |
|
388 |
|
389 }; |
|
390 |
|
391 #endif // NCD_NODE_IDENTIFIER_H |