|
1 /* |
|
2 * Copyright (c) 2004 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: This interface defines a generic data type |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef ALFVARIANTTYPE_H |
|
21 #define ALFVARIANTTYPE_H |
|
22 |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32def.h> |
|
26 #include <osn/osndefines.h> |
|
27 #include <osn/osncommon.h> |
|
28 #include <alf/ialfvarianttype.h> |
|
29 #include <alf/ialfcontainer.h> |
|
30 #include <alf/ialfmap.h> |
|
31 #include <alf/ialfbranch.h> |
|
32 #include <memory> |
|
33 #include <alf/ialfsortfunction.h> |
|
34 |
|
35 |
|
36 namespace osncore |
|
37 { |
|
38 class UString; |
|
39 } |
|
40 namespace std |
|
41 { |
|
42 template <class T> class auto_ptr; |
|
43 } |
|
44 |
|
45 using namespace osncore; |
|
46 using std::auto_ptr; |
|
47 |
|
48 namespace Alf |
|
49 { |
|
50 |
|
51 // FORWARD DECLARATIONS |
|
52 class IAlfContainer; |
|
53 class IAlfMap; |
|
54 class AlfBranch; |
|
55 class AlfVariantDataImpl; |
|
56 class AlfContainerDataImpl; |
|
57 class AlfMapDataImpl; |
|
58 class AlfBranchDataImpl; |
|
59 class IAlfModelBase; |
|
60 // CLASS DECLARATIONS |
|
61 |
|
62 /** |
|
63 * @class AlfVariantType alfvarianttype.h "alf/alfvarianttype.h" |
|
64 * Concrete implementation of the variant data type interface. |
|
65 * AlfVariantType can hold data of integer,real,string and unsigned integer types. |
|
66 * @see IAlfVariantType |
|
67 * |
|
68 * @lib alfwidgetmodel.lib |
|
69 * @since S60 ?S60_version |
|
70 * @status Draft |
|
71 */ |
|
72 class AlfVariantType: public IAlfVariantType |
|
73 { |
|
74 public: |
|
75 |
|
76 /** |
|
77 * Constructor for variant data type creation for a descriprtor type of data |
|
78 * @exception std::bad_alloc |
|
79 * |
|
80 * @param aValue - Descriptor to be assigned for the variant data |
|
81 * @since S60 ?S60_version |
|
82 */ |
|
83 OSN_IMPORT AlfVariantType(const UString& aValue); |
|
84 |
|
85 |
|
86 /** |
|
87 * Constructor for variant data type creation for a integer type of data |
|
88 * @exception std::bad_alloc |
|
89 * |
|
90 * @param aValue - integer to be assigned for the variant data |
|
91 * @since S60 ?S60_version |
|
92 */ |
|
93 OSN_IMPORT AlfVariantType(const int& aValue); |
|
94 |
|
95 |
|
96 /** |
|
97 * Constructor for variant data type creation for a Unsigned integer type of data |
|
98 * @exception std::bad_alloc |
|
99 * |
|
100 * @param aValue - unsigned integer to be assigned for the variant data |
|
101 * @since S60 ?S60_version |
|
102 */ |
|
103 OSN_IMPORT AlfVariantType(const uint& aValue); |
|
104 |
|
105 |
|
106 /** |
|
107 * Constructor for variant data type creation for a real type of data |
|
108 * @exception std::bad_alloc |
|
109 * |
|
110 * @param aValue - Real value to be assigned for the variant data |
|
111 * @since S60 ?S60_version |
|
112 */ |
|
113 OSN_IMPORT AlfVariantType(const double& aValue); |
|
114 |
|
115 |
|
116 /** |
|
117 * Constructor for variant data type creation for a user defined type of data |
|
118 * @exception std::bad_alloc |
|
119 * |
|
120 * @param aValue - IAlfModelBase* to be assigned for the variant data |
|
121 * @since S60 ?S60_version |
|
122 */ |
|
123 OSN_IMPORT AlfVariantType(IAlfModelBase* aValue) ; |
|
124 |
|
125 /** |
|
126 * Constructor for variant data type creation for a bool type of data |
|
127 * @exception std::bad_alloc |
|
128 * |
|
129 * @param aValue - Boolean value to be assigned for the variant data |
|
130 * @since S60 ?S60_version |
|
131 */ |
|
132 OSN_IMPORT AlfVariantType(const bool& aValue); |
|
133 |
|
134 //from IAlfVariantType Interface |
|
135 /** |
|
136 * Set the Data the variantData. From IAlfVariantType Interface |
|
137 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType if aValue |
|
138 * is of invalid type. |
|
139 * @exception std::bad_alloc |
|
140 * |
|
141 * @param aValue The new value. |
|
142 * @return void |
|
143 * @since S60 ?S60_version |
|
144 */ |
|
145 OSN_IMPORT void set(IAlfVariantType& aValue); |
|
146 |
|
147 /** |
|
148 * Get the data type.From IAlfVariantType Interface |
|
149 * |
|
150 * @since S60 ?S60_version |
|
151 * @return The data type. |
|
152 */ |
|
153 OSN_IMPORT IAlfVariantType::Type type() const; |
|
154 |
|
155 /** |
|
156 * Get the data value as an bool .From IAlfVariantType Interface |
|
157 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType if aValue |
|
158 * is not of boolean type. |
|
159 * |
|
160 * @return bool data value. |
|
161 * @since S60 ?S60_version |
|
162 */ |
|
163 OSN_IMPORT bool boolean() const; |
|
164 |
|
165 /** |
|
166 * Get the data value as an Integer .From IAlfVariantType Interface |
|
167 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType if aValue |
|
168 * is not of integer type. |
|
169 * |
|
170 * @return Integer data value. |
|
171 * @since S60 ?S60_version |
|
172 */ |
|
173 OSN_IMPORT int integer() const; |
|
174 |
|
175 /** |
|
176 * Get the data value as unsigned int.From IAlfVariantType Interface |
|
177 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType if aValue |
|
178 * is not of unsigned integer type. |
|
179 * |
|
180 * @return unsigned integer value. |
|
181 * @since S60 ?S60_version |
|
182 */ |
|
183 OSN_IMPORT uint uinteger() const; |
|
184 |
|
185 /** |
|
186 * Get the data value as an bool .From IAlfVariantType Interface |
|
187 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType if aValue |
|
188 * is not of real type. |
|
189 * |
|
190 * @return real data value. |
|
191 * @since S60 ?S60_version |
|
192 */ |
|
193 OSN_IMPORT double real() const; |
|
194 |
|
195 /** |
|
196 * Get the data value as an Descriptor .From IAlfVariantType Interface |
|
197 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType if aValue |
|
198 * is not of string type. |
|
199 * |
|
200 * @return string data value. |
|
201 * @since S60 ?S60_version |
|
202 */ |
|
203 OSN_IMPORT const UString& string() const; |
|
204 |
|
205 /** |
|
206 * Get the data value as an Container .From IAlfVariantType Interface. |
|
207 * Always throws an exception. |
|
208 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
209 * since AlfVariantType is not a container. |
|
210 * |
|
211 * @return AlfContainer . |
|
212 * @since S60 ?S60_version |
|
213 */ |
|
214 OSN_IMPORT IAlfContainer* container(); |
|
215 |
|
216 /** |
|
217 * Get the data value as Map .From IAlfVariantType Interface. |
|
218 * Always throws an exception. |
|
219 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
220 * since AlfVariantType is not a map. |
|
221 * |
|
222 * @return Map |
|
223 * @since S60 ?S60_version |
|
224 */ |
|
225 OSN_IMPORT IAlfMap* map() ; |
|
226 |
|
227 /** |
|
228 * Get the data value as Branch .From IAlfVariantType Interface |
|
229 * Always throws an exception. |
|
230 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
231 * since AlfVariantType is not a branch. |
|
232 * |
|
233 * @return Map |
|
234 * @since S60 ?S60_version |
|
235 */ |
|
236 OSN_IMPORT IAlfBranch* branch() ; |
|
237 |
|
238 /** |
|
239 * Get the data value as a User Defined Data Pointer. |
|
240 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType if aValue |
|
241 * is not of custom type. |
|
242 * |
|
243 * @return IAlfModelBase interface. |
|
244 * @since S60 ?S60_version |
|
245 */ |
|
246 OSN_IMPORT IAlfModelBase* customData(); |
|
247 |
|
248 /** |
|
249 * Destructor |
|
250 * |
|
251 * @return |
|
252 * @since S60 ?S60_version |
|
253 */ |
|
254 OSN_IMPORT ~AlfVariantType(); |
|
255 |
|
256 |
|
257 /** |
|
258 * The default constructor. |
|
259 * |
|
260 * @since S60 ?S60_version |
|
261 */ |
|
262 OSN_IMPORT AlfVariantType(); |
|
263 |
|
264 /** |
|
265 * Equality comparison operator. |
|
266 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType if aValue |
|
267 * is of invalid type. |
|
268 * |
|
269 * @param aOther object to compare against. |
|
270 * @since S60 ?S60_version |
|
271 */ |
|
272 OSN_IMPORT bool operator==(const IAlfVariantType& aOther) const; |
|
273 |
|
274 private: |
|
275 |
|
276 |
|
277 /** |
|
278 * 2nd Phase Constructor |
|
279 * |
|
280 * @since S60 ?S60_version |
|
281 * @param aType |
|
282 */ |
|
283 void construct(Type aType); |
|
284 |
|
285 |
|
286 private: |
|
287 //data owned |
|
288 auto_ptr<AlfVariantDataImpl> mVarData; |
|
289 |
|
290 }; |
|
291 |
|
292 |
|
293 /** |
|
294 * @class AlfVariantType alfvarianttype.h "alf/alfvarianttype.h" |
|
295 * Concrete implementation of the variant data type interface. |
|
296 * Simple default container of variant types. |
|
297 * @see IAlfContainer |
|
298 * |
|
299 * @lib alfwidgetmodel.lib |
|
300 * @since S60 ?S60_version |
|
301 * @status Draft |
|
302 */ |
|
303 class AlfContainer : public IAlfContainer |
|
304 { |
|
305 public: |
|
306 |
|
307 /** |
|
308 * Constructor for creating a variant data type which can store a alfcontainer |
|
309 * @exception std::bad_alloc |
|
310 * |
|
311 * @since S60 ?S60_version |
|
312 */ |
|
313 OSN_IMPORT AlfContainer(); |
|
314 |
|
315 /** |
|
316 * Destructor |
|
317 * @since S60 ?S60_version |
|
318 */ |
|
319 OSN_IMPORT ~AlfContainer(); |
|
320 |
|
321 //IAlfContainer APIs |
|
322 |
|
323 /** |
|
324 * Adds a variantData item into the container .From IAlfContainer interface |
|
325 * @aData variant data to be added into the container. Ownership is transferred |
|
326 * if the method completes without exceptions. If there is an exception |
|
327 * (e.g. due to out of memory), the client code is responsible for cleaning up the object. |
|
328 * @exception std::bad_alloc |
|
329 * |
|
330 * @return void. |
|
331 * @since S60 ?S60_version |
|
332 */ |
|
333 OSN_IMPORT void addItem(IAlfVariantType* aData); |
|
334 |
|
335 /** |
|
336 * Adds a variantData item into the container .From IAlfContainer interface |
|
337 * @aIndex index where the data is added |
|
338 * @aData variant data to be added into the container. Ownership is transferred |
|
339 * if the method completes without exceptions. If there is an exception |
|
340 * (e.g. due to out of memory), the client code is responsible for cleaning up the object. |
|
341 * @exception std::bad_alloc |
|
342 * |
|
343 * @return void. |
|
344 * @since S60 ?S60_version |
|
345 */ |
|
346 OSN_IMPORT void addItem(uint aIndex, IAlfVariantType* aData); |
|
347 |
|
348 /** |
|
349 * Gets the Number of items in the container . From IAlfContainer interface |
|
350 * |
|
351 * @return number of items in the container |
|
352 * @since S60 ?S60_version |
|
353 */ |
|
354 OSN_IMPORT int count(); |
|
355 |
|
356 /** |
|
357 * Gets the Item at a given index in the container From IAlfContainer interface |
|
358 * @param aIndex - index at which the element is required |
|
359 * @return item as a MlfVariantType |
|
360 * @since S60 ?S60_version |
|
361 */ |
|
362 OSN_IMPORT IAlfVariantType* item(uint aIndex); |
|
363 |
|
364 /** |
|
365 * Clones the entire container From IAlfContainer interface |
|
366 * @exception std::bad_alloc |
|
367 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType if |
|
368 * there is an invalid data type in the container. |
|
369 * |
|
370 * @return the cloned container |
|
371 * @since S60 ?S60_version |
|
372 */ |
|
373 OSN_IMPORT IAlfContainer* clone(); |
|
374 |
|
375 |
|
376 /** |
|
377 * Removes an item from given index in the container. From IAlfContainer interface |
|
378 * @param aIndex - index at which the element is to be removed. |
|
379 * @return item as a IAlfVariantType |
|
380 * @since S60 ?S60_version |
|
381 */ |
|
382 OSN_IMPORT void removeItem(uint aIndex); |
|
383 |
|
384 /** |
|
385 * Clear the Container. From IAlfContainer interface |
|
386 * |
|
387 * @return void |
|
388 * @since S60 ?S60_version |
|
389 */ |
|
390 OSN_IMPORT void clear() ; |
|
391 |
|
392 /** |
|
393 * Replace an item from given index in the container. |
|
394 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidContainerOperation if |
|
395 * the replaceItem fails. |
|
396 * |
|
397 * @param aIndex - index at which the element is to be replaced |
|
398 * @param aNewData - new Data to be replaced |
|
399 * @return void |
|
400 * @since S60 ?S60_version |
|
401 */ |
|
402 OSN_IMPORT void replaceItem(uint aIndex, IAlfVariantType* aNewData ); |
|
403 |
|
404 /** |
|
405 * sorts the container using user defined sort function. |
|
406 * |
|
407 * @param aSortFunction - sort function. |
|
408 * @since S60 ?S60_version |
|
409 */ |
|
410 OSN_IMPORT void sort( const IAlfSortFunction& aSortFunction ); |
|
411 |
|
412 //from IAlfVariantType Interface |
|
413 /** |
|
414 * Set the Data the variantData. From IAlfVariantType Interface. |
|
415 * Always throws an exception always. |
|
416 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidContainerOperation always. |
|
417 * Use the addItem API. |
|
418 * |
|
419 * @param aValue The new value. |
|
420 * @return void |
|
421 * @since S60 ?S60_version |
|
422 */ |
|
423 OSN_IMPORT void set(IAlfVariantType& aValue); |
|
424 |
|
425 /** |
|
426 * Get the data type.From IAlfVariantType Interface |
|
427 * |
|
428 * @return The data type. |
|
429 * @since S60 ?S60_version |
|
430 */ |
|
431 OSN_IMPORT IAlfVariantType::Type type() const; |
|
432 |
|
433 /** |
|
434 * Get the data value as an bool .From IAlfVariantType Interface. |
|
435 * Always throws an exception. |
|
436 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
437 * since AlfContainer is not boolean. |
|
438 * |
|
439 * @return bool data value. |
|
440 * @since S60 ?S60_version |
|
441 */ |
|
442 OSN_IMPORT bool boolean() const; |
|
443 |
|
444 /** |
|
445 * Get the data value as an Integer .From IAlfVariantType Interface. |
|
446 * Always throws an exception. |
|
447 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
448 * since AlfContainer is not an integer. |
|
449 * |
|
450 * @return Integer data value. |
|
451 * @since S60 ?S60_version |
|
452 */ |
|
453 OSN_IMPORT int integer() const; |
|
454 |
|
455 /** |
|
456 * Get the data value as unsigned int.From IAlfVariantType Interface. |
|
457 * Always throws an exception. |
|
458 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
459 * since AlfContainer is not an unsigned integer. |
|
460 * |
|
461 * @return unsigned integer data value. |
|
462 * @since S60 ?S60_version |
|
463 */ |
|
464 OSN_IMPORT uint uinteger() const; |
|
465 |
|
466 /** |
|
467 * Get the data value as an bool .From IAlfVariantType Interface. |
|
468 * Always throws an exception. |
|
469 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
470 * since AlfContainer is not a real value. |
|
471 * |
|
472 * @return real data value. |
|
473 * @since S60 ?S60_version |
|
474 */ |
|
475 OSN_IMPORT double real() const; |
|
476 |
|
477 /** |
|
478 * Get the data value as an Descriptor .From IAlfVariantType Interface. |
|
479 * Always throws an exception. |
|
480 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
481 * since AlfContainer is not a string. |
|
482 * |
|
483 * @return string data value. |
|
484 * @since S60 ?S60_version |
|
485 */ |
|
486 OSN_IMPORT const UString& string() const; |
|
487 |
|
488 /** |
|
489 * Get the data value as an Conatiner .From IAlfVariantType Interface. |
|
490 * |
|
491 * @return AlfContainer . |
|
492 * @since S60 ?S60_version |
|
493 */ |
|
494 OSN_IMPORT IAlfContainer* container(); |
|
495 |
|
496 /** |
|
497 * Get the data value as Map .From IAlfVariantType Interface. |
|
498 * Always throws an exception. |
|
499 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
500 * since AlfContainer is not a map. |
|
501 * |
|
502 * @return Map |
|
503 * @since S60 ?S60_version |
|
504 */ |
|
505 OSN_IMPORT IAlfMap* map(); |
|
506 |
|
507 /** |
|
508 * Get the data value as Branch .From IAlfVariantType Interface. |
|
509 * Always throws an exception. |
|
510 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
511 * since AlfContainer is not a map. |
|
512 * |
|
513 * @return Map |
|
514 * @since S60 ?S60_version |
|
515 */ |
|
516 OSN_IMPORT IAlfBranch* branch(); |
|
517 |
|
518 /** |
|
519 * Get the data value as a User Defined Data Pointer. |
|
520 * Always throws an exception. |
|
521 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
522 * since AlfContainer is not a custom data type. |
|
523 * |
|
524 * @return IAlfModelBase interface. |
|
525 * @since S60 ?S60_version |
|
526 */ |
|
527 OSN_IMPORT IAlfModelBase* customData(); |
|
528 |
|
529 /** |
|
530 * Equality comparison operator. |
|
531 * Always throws an exception. |
|
532 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidContainerOperation always. |
|
533 * |
|
534 * @param aOther object to compare against. |
|
535 * @since S60 ?S60_version |
|
536 */ |
|
537 OSN_IMPORT bool operator==(const IAlfVariantType& aOther) const; |
|
538 private: |
|
539 void construct(); |
|
540 //Data owned |
|
541 auto_ptr<AlfContainerDataImpl> mContainerData; |
|
542 |
|
543 }; |
|
544 |
|
545 /** |
|
546 * @class AlfMap alfvarianttype.h "alf/alfvarianttype.h" |
|
547 * Concrete implementation of the variant data type interface. |
|
548 * Simple map of variant types.The map is contains data and a key. |
|
549 * @see IAlfMap |
|
550 * |
|
551 * @lib alfwidgetmodel.lib |
|
552 * @since S60 ?S60_version |
|
553 * @status Draft |
|
554 */ |
|
555 class AlfMap : public IAlfMap |
|
556 { |
|
557 public: |
|
558 |
|
559 |
|
560 /** |
|
561 * 1st phase Constructor for creating a variant data type which can store a AlfMap |
|
562 * @exception std::bad_alloc |
|
563 * |
|
564 * @since S60 ?S60_version |
|
565 */ |
|
566 OSN_IMPORT AlfMap(); |
|
567 |
|
568 |
|
569 |
|
570 //IAlfContainer APIs |
|
571 |
|
572 /** |
|
573 * Gets the Number of items in the container . From IAlfContainer interface |
|
574 * |
|
575 * @return number of items in the container |
|
576 * @since S60 ?S60_version |
|
577 */ |
|
578 OSN_IMPORT int count() const; |
|
579 |
|
580 /** |
|
581 * Gets the Item at a given index in the container From IAlfContainer interface |
|
582 * @param aIndex - index at which the element is required |
|
583 * @return item as a MlfVariantType |
|
584 * @since S60 ?S60_version |
|
585 */ |
|
586 OSN_IMPORT IAlfVariantType* item(uint aIndex); |
|
587 |
|
588 /** |
|
589 * Clones the entire container From IAlfContainer interface |
|
590 * @exception std::bad_alloc |
|
591 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType if |
|
592 * there is an invalid data type in the container. |
|
593 * |
|
594 * @return the cloned container |
|
595 * @since S60 ?S60_version |
|
596 */ |
|
597 OSN_IMPORT IAlfMap* clone(); |
|
598 |
|
599 |
|
600 /** |
|
601 * Removes an item from given index in the container. From IAlfContainer interface. |
|
602 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidMapOperation if |
|
603 * the removeItem fails. |
|
604 * |
|
605 * @param aIndex - index at which the element is to be removed |
|
606 * @return void |
|
607 * @since S60 ?S60_version |
|
608 */ |
|
609 OSN_IMPORT void removeItem(uint aIndex); |
|
610 |
|
611 /** |
|
612 * Clear the Container. From IAlfContainer interface |
|
613 * |
|
614 * @return void |
|
615 * @since S60 ?S60_version |
|
616 */ |
|
617 OSN_IMPORT void clear() ; |
|
618 |
|
619 /** |
|
620 * Replace an item from given index in the container |
|
621 * @exception std::bad_alloc |
|
622 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidMapOperation if |
|
623 * the replaceItem fails. |
|
624 * @param aIndex - index at which the element is to be replaced |
|
625 * @param aNewData - new Data to be replaced |
|
626 * @return void |
|
627 * @since S60 ?S60_version |
|
628 */ |
|
629 OSN_IMPORT void replaceItem(uint aIndex, IAlfVariantType* aNewData ); |
|
630 |
|
631 |
|
632 |
|
633 //IAlfMap Interface APis |
|
634 |
|
635 /** |
|
636 * Gets the Item for a given name in the map. From IAlfContainer interface |
|
637 * @param aName - name of the element that is required |
|
638 * @return item as a IAlfVariantType |
|
639 * @since S60 ?S60_version |
|
640 */ |
|
641 OSN_IMPORT IAlfVariantType* item(const UString& aName); |
|
642 |
|
643 /** |
|
644 * Gets the index of the item by the given name. |
|
645 * @param aName The name associated with requested item. |
|
646 * @return The index corresponding to the name of the item. |
|
647 * @since S60 ?S60_version |
|
648 */ |
|
649 OSN_IMPORT int itemIndex(const UString& aName); |
|
650 |
|
651 /** |
|
652 * Removes an item for a given Name in map. From IAlfContainer interface |
|
653 * @exception std::bad_alloc |
|
654 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidMapOperation if |
|
655 * the removeItem fails. |
|
656 * |
|
657 * @param aName - name of the element that is to be removed |
|
658 * @return item as a MlfVariantType |
|
659 * @since S60 ?S60_version |
|
660 */ |
|
661 OSN_IMPORT void removeItem(const UString& aName); |
|
662 |
|
663 /** |
|
664 * Replace an item for a given name in the container |
|
665 * @exception std::bad_alloc |
|
666 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidMapOperation if |
|
667 * the replaceItem fails. |
|
668 * |
|
669 * @param aName - name of the element that is to be replaced |
|
670 * @param aNewData - new Data to be replaced |
|
671 * @return void |
|
672 * @since S60 ?S60_version |
|
673 */ |
|
674 OSN_IMPORT void replaceItem(const UString& aName,IAlfVariantType* aNewData); |
|
675 |
|
676 /** |
|
677 * Adds a variantData item into the container .From IAlfContainer interface |
|
678 * @exception std::bad_alloc |
|
679 * |
|
680 * @param aName - name of the data that needs to be added |
|
681 * @param aData- variant data to be added into the container. Ownership is transferred |
|
682 * if the method completes without exceptions. If there is an exception |
|
683 * (e.g. due to out of memory), the client code is responsible for cleaning up the object. |
|
684 * @return void. |
|
685 * @since S60 ?S60_version |
|
686 */ |
|
687 OSN_IMPORT void addItem(IAlfVariantType* aData, const UString& aName); |
|
688 |
|
689 /** |
|
690 * Adds a variantData item into the container .From IAlfContainer interface |
|
691 * @exception std::bad_alloc |
|
692 * |
|
693 * @aIndex index where the data is added |
|
694 * @param aName - name of the data that needs to be added |
|
695 * @param aData- variant data to be added into the container. Ownership is transferred |
|
696 * if the method completes without exceptions. If there is an exception |
|
697 * (e.g. due to out of memory), the client code is responsible for cleaning up the object. |
|
698 * @return void. |
|
699 * @since S60 ?S60_version |
|
700 */ |
|
701 OSN_IMPORT void addItem(uint aIndex, IAlfVariantType* aData, const UString& aName); |
|
702 |
|
703 /** |
|
704 * Gets the Name at a given index in the container |
|
705 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidArrayIndex if |
|
706 * aIndex is invalid. |
|
707 * |
|
708 * @param aIndex - index at which the name of the element in the map is required |
|
709 * @return item name as a TPtr |
|
710 * @since S60 ?S60_version |
|
711 */ |
|
712 const UString& name(uint aIndex) const; |
|
713 |
|
714 //class methods |
|
715 /** |
|
716 * Destructor |
|
717 * @since S60 ?S60_version |
|
718 */ |
|
719 OSN_IMPORT ~AlfMap(); |
|
720 |
|
721 |
|
722 //from IAlfVariantType Interface |
|
723 /** |
|
724 * Set the Data the variantData. From IAlfVariantType Interface. |
|
725 * Always throws an exception always. |
|
726 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidMapOperation always. |
|
727 * Use the addItem API. |
|
728 * @param aValue The new value. |
|
729 * @return void |
|
730 * @since S60 ?S60_version |
|
731 */ |
|
732 OSN_IMPORT void set(IAlfVariantType& aValue); |
|
733 |
|
734 /** |
|
735 * Get the data type.From IAlfVariantType Interface |
|
736 * |
|
737 * @return The data type. |
|
738 * @since S60 ?S60_version |
|
739 */ |
|
740 OSN_IMPORT IAlfVariantType::Type type() const; |
|
741 |
|
742 /** |
|
743 * Get the data value as an bool .From IAlfVariantType Interface |
|
744 * Always throws an exception. |
|
745 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
746 * since AlfMap is not boolean. |
|
747 * |
|
748 * @return bool data value. |
|
749 * @since S60 ?S60_version |
|
750 */ |
|
751 OSN_IMPORT bool boolean() const; |
|
752 |
|
753 /** |
|
754 * Get the data value as an Integer .From IAlfVariantType Interface |
|
755 * Always throws an exception. |
|
756 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
757 * since AlfMap is not an integer. |
|
758 * |
|
759 * @return Integer data value. |
|
760 * @since S60 ?S60_version |
|
761 */ |
|
762 OSN_IMPORT int integer() const; |
|
763 |
|
764 /** |
|
765 * Get the data value as unsigned int.From IAlfVariantType Interface |
|
766 * Always throws an exception. |
|
767 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
768 * since AlfMap is not an unsigned integer. |
|
769 * |
|
770 * @return unsigned integer data value. |
|
771 * @since S60 ?S60_version |
|
772 */ |
|
773 OSN_IMPORT uint uinteger() const; |
|
774 |
|
775 /** |
|
776 * Get the data value as an bool .From IAlfVariantType Interface |
|
777 * Always throws an exception. |
|
778 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
779 * since AlfMap is not a real value. |
|
780 * |
|
781 * @return double data value. |
|
782 * @since S60 ?S60_version |
|
783 */ |
|
784 OSN_IMPORT double real() const; |
|
785 |
|
786 /** |
|
787 * Get the data value as an Descriptor .From IAlfVariantType Interface |
|
788 * Always throws an exception. |
|
789 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
790 * since AlfMap is not a string value. |
|
791 * |
|
792 * @return string data value. |
|
793 * @since S60 ?S60_version |
|
794 */ |
|
795 OSN_IMPORT const UString& string() const; |
|
796 |
|
797 /** |
|
798 * Get the data value as an Conatiner .From IAlfVariantType Interface |
|
799 * Always throws an exception. |
|
800 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
801 * since AlfMap is not a container. |
|
802 * |
|
803 * @return AlfContiner . |
|
804 * @since S60 ?S60_version |
|
805 */ |
|
806 OSN_IMPORT IAlfContainer* container(); |
|
807 |
|
808 /** |
|
809 * Get the data value as Map .From IAlfVariantType Interface |
|
810 * |
|
811 * @return Map |
|
812 * @since S60 ?S60_version |
|
813 */ |
|
814 OSN_IMPORT IAlfMap* map(); |
|
815 |
|
816 /** |
|
817 * Get the data value as Branch .From IAlfVariantType Interface |
|
818 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
819 * since AlfMap is not a branch. |
|
820 * |
|
821 * @return Branch |
|
822 * @since S60 ?S60_version |
|
823 */ |
|
824 OSN_IMPORT IAlfBranch* branch(); |
|
825 |
|
826 /** |
|
827 * Get the data value as a User Defined Data Pointer. |
|
828 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
829 * since AlfMap is not a custom data type. |
|
830 * |
|
831 * @return IAlfModelBase interface. |
|
832 * @since S60 ?S60_version |
|
833 */ |
|
834 OSN_IMPORT IAlfModelBase* customData(); |
|
835 |
|
836 /** |
|
837 * Equality comparison operator. |
|
838 * |
|
839 * @since S60 ?S60_version |
|
840 */ |
|
841 OSN_IMPORT bool operator==(const IAlfVariantType& aOther) const; |
|
842 |
|
843 private: |
|
844 void construct(); |
|
845 //data |
|
846 auto_ptr<AlfMapDataImpl> mMapDataImpl; |
|
847 }; |
|
848 |
|
849 /** |
|
850 * @class AlfBranch alfvarianttype.h "alf/alfvarianttype.h" |
|
851 * Concrete implementation of the variant data type interface. |
|
852 * @see IAlfBranch |
|
853 * |
|
854 * @lib alfwidgetmodel.lib |
|
855 * @since S60 ?S60_version |
|
856 * @status Draft |
|
857 */ |
|
858 class AlfBranch: public IAlfBranch |
|
859 { |
|
860 public: |
|
861 |
|
862 |
|
863 /** |
|
864 * Parameterized Constructor |
|
865 * @exception std::bad_alloc |
|
866 * |
|
867 * @since S60 ?S60_version |
|
868 */ |
|
869 OSN_IMPORT AlfBranch( IAlfMap* aData, IAlfMap* aChildData); |
|
870 |
|
871 /** |
|
872 * Default Constructor |
|
873 * @exception std::bad_alloc |
|
874 * |
|
875 * @since S60 ?S60_version |
|
876 */ |
|
877 OSN_IMPORT AlfBranch(); |
|
878 |
|
879 /** |
|
880 * |
|
881 * @return |
|
882 * @since S60 ?S60_version |
|
883 */ |
|
884 OSN_IMPORT IAlfMap* data(); |
|
885 |
|
886 /** |
|
887 * |
|
888 * @param aData - |
|
889 * @return void. |
|
890 * @since S60 ?S60_version |
|
891 */ |
|
892 OSN_IMPORT void setData( IAlfMap* aData ); |
|
893 |
|
894 /** |
|
895 * |
|
896 * @param aIndex - |
|
897 * @return . |
|
898 * @since S60 ?S60_version |
|
899 */ |
|
900 OSN_IMPORT IAlfVariantType* childData(int aIndex); |
|
901 |
|
902 /** |
|
903 * |
|
904 * @param aIndex - |
|
905 * @return . |
|
906 * @since S60 ?S60_version |
|
907 */ |
|
908 OSN_IMPORT const UString& childName(int aIndex); |
|
909 |
|
910 /** |
|
911 * |
|
912 * @return . |
|
913 * @since S60 ?S60_version |
|
914 */ |
|
915 OSN_IMPORT IAlfMap* childData(); |
|
916 |
|
917 /** |
|
918 * |
|
919 * @param aChildData - |
|
920 * @return void |
|
921 * @since S60 ?S60_version |
|
922 */ |
|
923 OSN_IMPORT void setChildData( IAlfMap* aChildData ); |
|
924 |
|
925 /** |
|
926 * |
|
927 * @return |
|
928 * @since S60 ?S60_version |
|
929 */ |
|
930 OSN_IMPORT uint childrenCount(); |
|
931 |
|
932 /** |
|
933 * Destructor |
|
934 * @since S60 ?S60_version |
|
935 */ |
|
936 OSN_IMPORT ~AlfBranch(); |
|
937 |
|
938 /** |
|
939 * sorts the branch using user defined sort function. |
|
940 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidBranchOperation if |
|
941 * sorting fails. |
|
942 * |
|
943 * @param aSortFunction - sort function. |
|
944 * return void |
|
945 * @since S60 ?S60_version |
|
946 */ |
|
947 OSN_IMPORT void sort( const IAlfSortFunction& aSortFunction ); |
|
948 |
|
949 /** |
|
950 * Function to Clone the Branch |
|
951 * @exception std::bad_alloc |
|
952 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidBranchOperation if |
|
953 * cloning fails. |
|
954 * |
|
955 * @return |
|
956 * @since S60 ?S60_version |
|
957 */ |
|
958 OSN_IMPORT IAlfBranch* clone(); |
|
959 |
|
960 |
|
961 //from IAlfVariantType Interface |
|
962 /** |
|
963 * Set the Data the variantData. From IAlfVariantType Interface |
|
964 * Always throws an exception always. |
|
965 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidBranchOperation always. |
|
966 * Use the setData API. |
|
967 * |
|
968 * @param aValue The new value. |
|
969 * @return void |
|
970 * @since S60 ?S60_version |
|
971 */ |
|
972 OSN_IMPORT void set(IAlfVariantType& aValue); |
|
973 |
|
974 /** |
|
975 * Get the data type.From IAlfVariantType Interface |
|
976 * |
|
977 * @return The data type. |
|
978 * @since S60 ?S60_version |
|
979 */ |
|
980 OSN_IMPORT IAlfVariantType::Type type() const; |
|
981 |
|
982 /** |
|
983 * Get the data value as an bool .From IAlfVariantType Interface |
|
984 * Always throws an exception. |
|
985 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
986 * since AlfBranch is not boolean. |
|
987 * @return bool data value. |
|
988 * @since S60 ?S60_version |
|
989 */ |
|
990 OSN_IMPORT bool boolean() const; |
|
991 |
|
992 /** |
|
993 * Get the data value as an Integer .From IAlfVariantType Interface |
|
994 * Always throws an exception. |
|
995 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
996 * since AlfBranch is not an integer. |
|
997 * |
|
998 * @return Integer data value. |
|
999 * @since S60 ?S60_version |
|
1000 */ |
|
1001 OSN_IMPORT int integer() const; |
|
1002 |
|
1003 /** |
|
1004 * Get the data value as unsigned int.From IAlfVariantType Interface |
|
1005 * Always throws an exception. |
|
1006 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
1007 * since AlfBranch is not an unsigned integer. |
|
1008 * |
|
1009 * @return unsigned integer data value. |
|
1010 * @since S60 ?S60_version |
|
1011 */ |
|
1012 OSN_IMPORT uint uinteger() const; |
|
1013 |
|
1014 /** |
|
1015 * Get the data value as an bool .From IAlfVariantType Interface |
|
1016 * Always throws an exception. |
|
1017 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
1018 * since AlfBranch is not a real value. |
|
1019 * |
|
1020 * @return real data value. |
|
1021 * @since S60 ?S60_version |
|
1022 */ |
|
1023 OSN_IMPORT double real() const; |
|
1024 |
|
1025 /** |
|
1026 * Get the data value as an Descriptor .From IAlfVariantType Interface |
|
1027 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
1028 * since AlfBranch is not a string value. |
|
1029 * |
|
1030 * @return string data value. |
|
1031 * @since S60 ?S60_version |
|
1032 */ |
|
1033 OSN_IMPORT const UString& string() const; |
|
1034 |
|
1035 /** |
|
1036 * Get the data value as an Conatiner. From IAlfVariantType Interface |
|
1037 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
1038 * since AlfBranch is not a container. |
|
1039 * |
|
1040 * @return AlfContiner . |
|
1041 * @since S60 ?S60_version |
|
1042 */ |
|
1043 OSN_IMPORT IAlfContainer* container(); |
|
1044 |
|
1045 /** |
|
1046 * Get the data value as Map. From IAlfVariantType Interface |
|
1047 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
1048 * since AlfBranch is not a map. |
|
1049 * |
|
1050 * @return Map |
|
1051 * @since S60 ?S60_version |
|
1052 */ |
|
1053 OSN_IMPORT IAlfMap* map(); |
|
1054 |
|
1055 /** |
|
1056 * Get the data value as Branch. From IAlfVariantType Interface |
|
1057 * |
|
1058 * @return Map |
|
1059 * @since S60 ?S60_version |
|
1060 */ |
|
1061 OSN_IMPORT IAlfBranch* branch(); |
|
1062 |
|
1063 /** |
|
1064 * Get the data value as a User Defined Data Pointer. |
|
1065 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidVariantDataType always |
|
1066 * since AlfBranch is not a custom value. |
|
1067 * |
|
1068 * @return IAlfModelBase interface. |
|
1069 * @since S60 ?S60_version |
|
1070 */ |
|
1071 OSN_IMPORT IAlfModelBase* customData(); |
|
1072 |
|
1073 /** |
|
1074 * Equality comparison operator. |
|
1075 * Always throws an exception. |
|
1076 * @exception osncore::AlfDataException Thrown with error code osncore::EInvalidBranchOperation always. |
|
1077 * |
|
1078 * @param aOther object to compare against. |
|
1079 * @since S60 ?S60_version |
|
1080 */ |
|
1081 OSN_IMPORT bool operator==(const IAlfVariantType& aOther) const; |
|
1082 private: |
|
1083 /** |
|
1084 * 2nd Phase Constructor |
|
1085 * @return |
|
1086 * @since S60 ?S60_version |
|
1087 */ |
|
1088 void construct( IAlfMap* aData, IAlfMap* aChildData); |
|
1089 |
|
1090 private: |
|
1091 |
|
1092 //Data - owned |
|
1093 auto_ptr<AlfBranchDataImpl> mBranchData; |
|
1094 |
|
1095 |
|
1096 }; |
|
1097 |
|
1098 } // namespace Alf |
|
1099 |
|
1100 #endif // ALFVARIANTTYPE_H |
|
1101 |
|
1102 // End of File |