williamr@2
|
1 |
/*
|
williamr@2
|
2 |
* Copyright (c) 2003-2005 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
3 |
* All rights reserved.
|
williamr@2
|
4 |
* This component and the accompanying materials are made available
|
williamr@4
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
williamr@2
|
6 |
* which accompanies this distribution, and is available
|
williamr@4
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
williamr@2
|
8 |
*
|
williamr@2
|
9 |
* Initial Contributors:
|
williamr@2
|
10 |
* Nokia Corporation - initial contribution.
|
williamr@2
|
11 |
*
|
williamr@2
|
12 |
* Contributors:
|
williamr@2
|
13 |
*
|
williamr@2
|
14 |
* Description: A generic parameter class.
|
williamr@2
|
15 |
*
|
williamr@2
|
16 |
*/
|
williamr@2
|
17 |
|
williamr@2
|
18 |
|
williamr@2
|
19 |
|
williamr@2
|
20 |
|
williamr@2
|
21 |
|
williamr@2
|
22 |
#ifndef AIW_GENERIC_PARAM_H
|
williamr@2
|
23 |
#define AIW_GENERIC_PARAM_H
|
williamr@2
|
24 |
|
williamr@2
|
25 |
// INCLUDES
|
williamr@2
|
26 |
#include <e32base.h>
|
williamr@4
|
27 |
#include "AiwGenericParam.hrh"
|
williamr@4
|
28 |
#include "AiwVariant.h"
|
williamr@2
|
29 |
|
williamr@2
|
30 |
/**
|
williamr@2
|
31 |
* AIW generic parameter id. This data type should always be used when dealing
|
williamr@2
|
32 |
* with AIW generic parameters. UIDs can be used as AIW generic parameter IDs.
|
williamr@2
|
33 |
* However, values from 0 to 131071 are reserved.
|
williamr@2
|
34 |
* @see TAiwGenericParam
|
williamr@2
|
35 |
* @see TGenericParamIdValue
|
williamr@2
|
36 |
*/
|
williamr@2
|
37 |
typedef TInt TGenericParamId;
|
williamr@2
|
38 |
|
williamr@2
|
39 |
// CLASS DECLARATION
|
williamr@2
|
40 |
|
williamr@2
|
41 |
/**
|
williamr@2
|
42 |
* Generic parameter class for passing data between applications.
|
williamr@2
|
43 |
* A generic parameter is a pair of semantic ID and
|
williamr@2
|
44 |
* variant value. The semantic ID tells the purpose of the parameter,
|
williamr@2
|
45 |
* for example a file name, URL or phone number. The variant value contains
|
williamr@2
|
46 |
* the data format and actual value. This class does not implement any
|
williamr@2
|
47 |
* consistency checks between the semantic ID and value's data format.
|
williamr@2
|
48 |
* So one semantic ID can be expressed as alternative data formats.
|
williamr@2
|
49 |
*
|
williamr@2
|
50 |
* @lib ServiceHandler.lib
|
williamr@2
|
51 |
* @since Series 60 2.6
|
williamr@2
|
52 |
* @see TAiwVariant
|
williamr@2
|
53 |
* @see CAiwGenericParamList
|
williamr@2
|
54 |
*/
|
williamr@2
|
55 |
class TAiwGenericParam
|
williamr@2
|
56 |
{
|
williamr@2
|
57 |
public: // Constructors and destructor
|
williamr@2
|
58 |
/**
|
williamr@2
|
59 |
* Constructs a generic parameter.
|
williamr@2
|
60 |
*/
|
williamr@2
|
61 |
inline TAiwGenericParam();
|
williamr@2
|
62 |
|
williamr@2
|
63 |
/**
|
williamr@2
|
64 |
* Constructs a generic parameter.
|
williamr@2
|
65 |
*
|
williamr@2
|
66 |
* @param aSemanticId The semantic ID of the parameter, one of TGenericParamId values.
|
williamr@2
|
67 |
*/
|
williamr@2
|
68 |
inline TAiwGenericParam(TGenericParamId aSemanticId);
|
williamr@2
|
69 |
|
williamr@2
|
70 |
/**
|
williamr@2
|
71 |
* Constructs a generic parameter.
|
williamr@2
|
72 |
*
|
williamr@2
|
73 |
* @param aSemanticId The semantic ID of the parameter, one of TGenericParamId values.
|
williamr@2
|
74 |
* @param aValue The parameter value.
|
williamr@2
|
75 |
*/
|
williamr@2
|
76 |
inline TAiwGenericParam(TGenericParamId aSemanticId, const TAiwVariant& aValue);
|
williamr@2
|
77 |
|
williamr@2
|
78 |
public: // Interface
|
williamr@2
|
79 |
/**
|
williamr@2
|
80 |
* Sets the semantic ID. Possibly set previous ID is overwritten.
|
williamr@2
|
81 |
*
|
williamr@2
|
82 |
* @param aSemanticId The semantic ID of the parameter.
|
williamr@2
|
83 |
*/
|
williamr@2
|
84 |
inline void SetSemanticId(TGenericParamId aSemanticId);
|
williamr@2
|
85 |
|
williamr@2
|
86 |
/**
|
williamr@2
|
87 |
* Returns the semantic ID of this parameter.
|
williamr@2
|
88 |
*
|
williamr@2
|
89 |
* @return The semantic ID.
|
williamr@2
|
90 |
*/
|
williamr@2
|
91 |
inline TGenericParamId SemanticId() const;
|
williamr@2
|
92 |
|
williamr@2
|
93 |
/**
|
williamr@2
|
94 |
* Returns the value of this parameter.
|
williamr@2
|
95 |
*
|
williamr@2
|
96 |
* @return The value of the parameter.
|
williamr@2
|
97 |
*/
|
williamr@2
|
98 |
inline TAiwVariant& Value();
|
williamr@2
|
99 |
|
williamr@2
|
100 |
/**
|
williamr@2
|
101 |
* Returns the const value of this parameter.
|
williamr@2
|
102 |
*
|
williamr@2
|
103 |
* @return The const value of the parameter.
|
williamr@2
|
104 |
*/
|
williamr@2
|
105 |
inline const TAiwVariant& Value() const;
|
williamr@2
|
106 |
|
williamr@2
|
107 |
/**
|
williamr@2
|
108 |
* Resets the semantic ID and the value of this parameter.
|
williamr@2
|
109 |
*/
|
williamr@2
|
110 |
inline void Reset();
|
williamr@2
|
111 |
|
williamr@2
|
112 |
private: // Interface for friend classes
|
williamr@2
|
113 |
void Destroy();
|
williamr@2
|
114 |
void CopyLC(const TAiwGenericParam& aParam);
|
williamr@2
|
115 |
static void CleanupDestroy(TAny* aObj);
|
williamr@2
|
116 |
operator TCleanupItem();
|
williamr@2
|
117 |
void InternalizeL(RReadStream& aStream);
|
williamr@2
|
118 |
void ExternalizeL(RWriteStream& aStream) const;
|
williamr@2
|
119 |
TInt Size() const;
|
williamr@2
|
120 |
|
williamr@2
|
121 |
private: // Data
|
williamr@2
|
122 |
/// Own: semantic ID of this parameter
|
williamr@2
|
123 |
TGenericParamId iSemanticId;
|
williamr@2
|
124 |
/// Own: value of this parameter
|
williamr@2
|
125 |
TAiwVariant iValue;
|
williamr@2
|
126 |
/// Reserved member
|
williamr@2
|
127 |
TAny* iReserved;
|
williamr@2
|
128 |
|
williamr@2
|
129 |
private: // friend declarations
|
williamr@2
|
130 |
friend class CAiwGenericParamList;
|
williamr@2
|
131 |
};
|
williamr@2
|
132 |
|
williamr@2
|
133 |
|
williamr@2
|
134 |
// FUNCTIONS
|
williamr@2
|
135 |
|
williamr@2
|
136 |
/**
|
williamr@2
|
137 |
* Returns ETrue if two generic params are equal.
|
williamr@2
|
138 |
*
|
williamr@2
|
139 |
* @param aLhs Left hand side.
|
williamr@2
|
140 |
* @param aRhs Right hand side.
|
williamr@2
|
141 |
* @return ETrue if equal, EFalse otherwise.
|
williamr@2
|
142 |
*/
|
williamr@2
|
143 |
IMPORT_C TBool operator==(const TAiwGenericParam& aLhs, const TAiwGenericParam& aRhs);
|
williamr@2
|
144 |
|
williamr@2
|
145 |
/**
|
williamr@2
|
146 |
* Returns ETrue if two generic params are not equal.
|
williamr@2
|
147 |
*
|
williamr@2
|
148 |
* @param aLhs Left hand side.
|
williamr@2
|
149 |
* @param aRhs Right hand side.
|
williamr@2
|
150 |
* @return ETrue if not equal, EFalse otherwise.
|
williamr@2
|
151 |
*/
|
williamr@2
|
152 |
inline TBool operator!=(const TAiwGenericParam& aLhs, const TAiwGenericParam& aRhs);
|
williamr@2
|
153 |
|
williamr@2
|
154 |
|
williamr@2
|
155 |
/**
|
williamr@2
|
156 |
* Generic parameter list.
|
williamr@2
|
157 |
* A list containing TAiwGenericParam objects. Used for passing parameters
|
williamr@2
|
158 |
* between consumers and providers.
|
williamr@2
|
159 |
*
|
williamr@2
|
160 |
* @lib ServiceHandler.lib
|
williamr@2
|
161 |
* @since Series 60 2.6
|
williamr@2
|
162 |
*/
|
williamr@2
|
163 |
NONSHARABLE_CLASS(CAiwGenericParamList): public CBase
|
williamr@2
|
164 |
{
|
williamr@2
|
165 |
public: // Constructors and destructor
|
williamr@2
|
166 |
/**
|
williamr@2
|
167 |
* Creates an instance of this class.
|
williamr@2
|
168 |
*
|
williamr@2
|
169 |
* @return A pointer to the new instance.
|
williamr@2
|
170 |
*/
|
williamr@2
|
171 |
IMPORT_C static CAiwGenericParamList* NewL();
|
williamr@2
|
172 |
|
williamr@2
|
173 |
/**
|
williamr@2
|
174 |
* Creates an instance of this class.
|
williamr@2
|
175 |
*
|
williamr@2
|
176 |
* @param aReadStream A stream to initialize this parameter list from.
|
williamr@2
|
177 |
* @return A pointer to the new instance.
|
williamr@2
|
178 |
*/
|
williamr@2
|
179 |
IMPORT_C static CAiwGenericParamList* NewL(RReadStream& aReadStream);
|
williamr@2
|
180 |
|
williamr@2
|
181 |
/**
|
williamr@2
|
182 |
* Creates an instance of this class. Leaves the created instance on the
|
williamr@2
|
183 |
* cleanup stack.
|
williamr@2
|
184 |
*
|
williamr@2
|
185 |
* @return A pointer to the new instance.
|
williamr@2
|
186 |
*/
|
williamr@2
|
187 |
IMPORT_C static CAiwGenericParamList* NewLC();
|
williamr@2
|
188 |
|
williamr@2
|
189 |
/**
|
williamr@2
|
190 |
* Creates an instance of this class. Leaves the created instance on the
|
williamr@2
|
191 |
* cleanup stack.
|
williamr@2
|
192 |
*
|
williamr@2
|
193 |
* @param aReadStream A stream to initialize this parameter list from.
|
williamr@2
|
194 |
* @return A pointer to the new instance.
|
williamr@2
|
195 |
*/
|
williamr@2
|
196 |
IMPORT_C static CAiwGenericParamList* NewLC(RReadStream& aReadStream);
|
williamr@2
|
197 |
|
williamr@2
|
198 |
/**
|
williamr@2
|
199 |
* Destructor.
|
williamr@2
|
200 |
*/
|
williamr@2
|
201 |
virtual ~CAiwGenericParamList();
|
williamr@2
|
202 |
|
williamr@2
|
203 |
public: // Interface
|
williamr@2
|
204 |
/**
|
williamr@2
|
205 |
* Returns the number of parameters in the list.
|
williamr@2
|
206 |
*
|
williamr@2
|
207 |
* @return The number of parameters in the list.
|
williamr@2
|
208 |
*/
|
williamr@2
|
209 |
IMPORT_C TInt Count() const;
|
williamr@2
|
210 |
|
williamr@2
|
211 |
/**
|
williamr@2
|
212 |
* Returns the number of the parameters in the list by semantic id and datatype.
|
williamr@2
|
213 |
*
|
williamr@2
|
214 |
* @param aSemanticId The semantic ID of the parameter.
|
williamr@2
|
215 |
* @param aDataType The type id of data. Default is any type.
|
williamr@2
|
216 |
* @return The number of parameters in the list by semantic id and datatype.
|
williamr@2
|
217 |
*/
|
williamr@2
|
218 |
IMPORT_C TInt Count(TGenericParamId aSemanticId,
|
williamr@2
|
219 |
TVariantTypeId aDataType = EVariantTypeAny) const;
|
williamr@2
|
220 |
|
williamr@2
|
221 |
/**
|
williamr@2
|
222 |
* Returns a parameter from this list.
|
williamr@2
|
223 |
*
|
williamr@2
|
224 |
* @param aIndex Index of the parameter.
|
williamr@2
|
225 |
* @return The parameter at the aIndex position.
|
williamr@2
|
226 |
* @pre aIndex>=0 && aIndex<Count()
|
williamr@2
|
227 |
*/
|
williamr@2
|
228 |
IMPORT_C const TAiwGenericParam& operator[](TInt aIndex) const;
|
williamr@2
|
229 |
|
williamr@2
|
230 |
/**
|
williamr@2
|
231 |
* Appends a parameter to this list.
|
williamr@2
|
232 |
*
|
williamr@2
|
233 |
* @param aParam The parameter to append to this list. This object takes
|
williamr@2
|
234 |
* an own copy of the data in aParam.
|
williamr@2
|
235 |
*/
|
williamr@2
|
236 |
IMPORT_C void AppendL(const TAiwGenericParam& aParam);
|
williamr@2
|
237 |
|
williamr@2
|
238 |
/**
|
williamr@2
|
239 |
* Copies the given list and appends it to end of this list.
|
williamr@2
|
240 |
*
|
williamr@2
|
241 |
* @since Series 60 2.8
|
williamr@2
|
242 |
* @param aList A list to be copied and appended.
|
williamr@2
|
243 |
*/
|
williamr@2
|
244 |
IMPORT_C void AppendL(const CAiwGenericParamList& aList);
|
williamr@2
|
245 |
|
williamr@2
|
246 |
/**
|
williamr@2
|
247 |
* Removes the first found item with given semantic id from the list.
|
williamr@2
|
248 |
*
|
williamr@2
|
249 |
* @param aSemanticId Semantic id for the item to be removed.
|
williamr@2
|
250 |
* @return ETrue if an item for the given semantic id was found and removed.
|
williamr@2
|
251 |
* EFalse otherwise.
|
williamr@2
|
252 |
*/
|
williamr@2
|
253 |
IMPORT_C TBool Remove(TInt aSemanticId);
|
williamr@2
|
254 |
|
williamr@2
|
255 |
/**
|
williamr@2
|
256 |
* Deletes all parameters in the list and resets the list.
|
williamr@2
|
257 |
*/
|
williamr@2
|
258 |
IMPORT_C void Reset();
|
williamr@2
|
259 |
|
williamr@2
|
260 |
/**
|
williamr@2
|
261 |
* Returns the first item matching the given semantic ID.
|
williamr@2
|
262 |
*
|
williamr@2
|
263 |
* @param aIndex Position in which to start searching. On return it contains
|
williamr@2
|
264 |
* the position of the found parameter. It is set to KErrNotFound,
|
williamr@2
|
265 |
* if no matching items were found.
|
williamr@2
|
266 |
* @param aSemanticId The semantic ID of the parameter.
|
williamr@2
|
267 |
* @param aDataType The type id of data. Default is any type.
|
williamr@2
|
268 |
* @return The first matching item.
|
williamr@2
|
269 |
*/
|
williamr@2
|
270 |
IMPORT_C const TAiwGenericParam* FindFirst(
|
williamr@2
|
271 |
TInt& aIndex,
|
williamr@2
|
272 |
TGenericParamId aSemanticId,
|
williamr@2
|
273 |
TVariantTypeId aDataType = EVariantTypeAny) const;
|
williamr@2
|
274 |
/**
|
williamr@2
|
275 |
* Returns the next item matching the given semantic ID.
|
williamr@2
|
276 |
*
|
williamr@2
|
277 |
* @param aIndex Position after which to start searching. On return it contains
|
williamr@2
|
278 |
* the position of the found parameter. It is set to KErrNotFound,
|
williamr@2
|
279 |
* if no matching items were found.
|
williamr@2
|
280 |
* @param aSemanticId The semantic ID of the parameter.
|
williamr@2
|
281 |
* @param aDataType The type id of data. Default is any type.
|
williamr@2
|
282 |
* @return The next matching item.
|
williamr@2
|
283 |
*/
|
williamr@2
|
284 |
IMPORT_C const TAiwGenericParam* FindNext(
|
williamr@2
|
285 |
TInt& aIndex,
|
williamr@2
|
286 |
TGenericParamId aSemanticId,
|
williamr@2
|
287 |
TVariantTypeId aDataType = EVariantTypeAny) const;
|
williamr@2
|
288 |
|
williamr@2
|
289 |
/**
|
williamr@2
|
290 |
* Externalizes this parameter list to a stream.
|
williamr@2
|
291 |
*
|
williamr@2
|
292 |
* @param aStream The stream.
|
williamr@2
|
293 |
* @see NewL(RReadStream& aStream)
|
williamr@2
|
294 |
* @see NewLC(RReadStream& aStream)
|
williamr@2
|
295 |
*/
|
williamr@2
|
296 |
IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
|
williamr@2
|
297 |
|
williamr@2
|
298 |
/**
|
williamr@2
|
299 |
* Returns the externalized size of the parameter list in bytes.
|
williamr@2
|
300 |
*
|
williamr@2
|
301 |
* @return The size.
|
williamr@2
|
302 |
*/
|
williamr@2
|
303 |
IMPORT_C TInt Size() const;
|
williamr@2
|
304 |
|
williamr@2
|
305 |
/**
|
williamr@2
|
306 |
* Internalizes the parameter list from a stream.
|
williamr@2
|
307 |
*
|
williamr@2
|
308 |
* @since Series60 2.8
|
williamr@2
|
309 |
* @param aStream The stream.
|
williamr@2
|
310 |
*/
|
williamr@2
|
311 |
IMPORT_C void InternalizeL(RReadStream& aStream);
|
williamr@2
|
312 |
|
williamr@2
|
313 |
/**
|
williamr@2
|
314 |
* Packs the parameter list to TIpcArgs structure for
|
williamr@2
|
315 |
* passing the generic param list to server over process boundary.
|
williamr@2
|
316 |
* Only one RFile handle parameter can be passed over process boundary.
|
williamr@2
|
317 |
*
|
williamr@2
|
318 |
* @since Series60 3.0
|
williamr@2
|
319 |
* @param aArgs Inter process call arguments.
|
williamr@2
|
320 |
* @return Packed parameter list.
|
williamr@2
|
321 |
*/
|
williamr@2
|
322 |
IMPORT_C HBufC8* PackForServerL(TIpcArgs& aArgs);
|
williamr@2
|
323 |
|
williamr@2
|
324 |
/**
|
williamr@2
|
325 |
* Unpacks the list from client message structure.
|
williamr@2
|
326 |
*
|
williamr@2
|
327 |
* @since Series60 3.0
|
williamr@2
|
328 |
* @param aArgs The list to be unpacked.
|
williamr@2
|
329 |
*/
|
williamr@2
|
330 |
IMPORT_C void UnpackFromClientL(const RMessage2& aArgs);
|
williamr@2
|
331 |
|
williamr@2
|
332 |
private: // Implementation
|
williamr@2
|
333 |
CAiwGenericParamList();
|
williamr@2
|
334 |
void ConstructL();
|
williamr@2
|
335 |
void AppendL(RReadStream& aReadStream);
|
williamr@2
|
336 |
|
williamr@2
|
337 |
private: // Data
|
williamr@2
|
338 |
/// Own: the parameter list
|
williamr@2
|
339 |
RArray<TAiwGenericParam> iParameters;
|
williamr@2
|
340 |
};
|
williamr@2
|
341 |
|
williamr@2
|
342 |
|
williamr@2
|
343 |
// INLINE FUNCTIONS
|
williamr@4
|
344 |
#include "AiwGenericParam.inl"
|
williamr@2
|
345 |
|
williamr@2
|
346 |
#endif // AIW_GENERIC_PARAM_H
|
williamr@2
|
347 |
|
williamr@2
|
348 |
// End of File
|