1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * This class is a data container of unit categories. |
|
16 * It is able to construct itself from a resource file. |
|
17 * This class implements the Model Instantiation API. |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 #ifndef __CCNVCONVERTER_H__ |
|
24 #define __CCNVCONVERTER_H__ |
|
25 |
|
26 // INCLUDES |
|
27 #include <e32base.h> |
|
28 #include <bamdesca.h> |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CCnvCategory; |
|
32 class TCnvCategory; |
|
33 class RWriteStream; |
|
34 class TResourceReader; |
|
35 |
|
36 // CLASS DEFINITION |
|
37 /** |
|
38 * This class is a data container of unit categories. |
|
39 * It is able to construct itself from a resource file. |
|
40 * This class implements the Model Instantiation API. |
|
41 */ |
|
42 enum TCurrencyType |
|
43 { |
|
44 ENotApplicable, |
|
45 ENameChanged, |
|
46 EHome, |
|
47 EForeign |
|
48 }; |
|
49 |
|
50 class CCnvConverter : public CBase, public MDesCArray |
|
51 { |
|
52 public: // Constructors and destructor. |
|
53 |
|
54 /** |
|
55 * Destructor. |
|
56 */ |
|
57 IMPORT_C ~CCnvConverter(); |
|
58 |
|
59 /** |
|
60 * Two-phased constructor |
|
61 * @param aReader A resource reader object initialised to a resource. |
|
62 */ |
|
63 IMPORT_C static CCnvConverter* NewL( TResourceReader& aReader ); |
|
64 |
|
65 private: // Constructors |
|
66 |
|
67 /** |
|
68 * Default constructor. |
|
69 * 1 = minimum array granularity |
|
70 */ |
|
71 inline CCnvConverter() : iCategoryArray( 1 ) {}; |
|
72 |
|
73 /** |
|
74 * Constructs the model a CNV_MODEL resource. |
|
75 * @param aReader A resource reader object initialised to a resource. |
|
76 */ |
|
77 void ConstructFromResourceL( TResourceReader& aReader ); |
|
78 |
|
79 public: // from MDesCArray (need not to be imported, vftable takes care..) |
|
80 |
|
81 /** |
|
82 * Returns the number of unit categories. |
|
83 * @return number of items. |
|
84 */ |
|
85 TInt MdcaCount() const; |
|
86 |
|
87 /** |
|
88 * Returns a pointer to a unit category name specified by aIndex. |
|
89 * @param aIndex Defines the point in the array that is |
|
90 * queried for the name. |
|
91 * @return Pointer to category name. |
|
92 */ |
|
93 TPtrC MdcaPoint( TInt aIndex ) const; |
|
94 |
|
95 public: // new methods |
|
96 |
|
97 /** |
|
98 * Returns a category accessor for the requested category. |
|
99 * @param aCategory Category accessor placeholder. |
|
100 * @param aCategoryIndex Category identifier. |
|
101 */ |
|
102 IMPORT_C void GetCategoryAccessor( TCnvCategory& aCategory, |
|
103 TUint aCategoryIndex ); |
|
104 /** |
|
105 * Return a category accessor for the category list. |
|
106 * @param aCategory Category accessor placeholder. |
|
107 */ |
|
108 IMPORT_C void GetCategorylistAccessor( TCnvCategory& aCategory ); |
|
109 |
|
110 /** |
|
111 * Returns the index of the currency category. |
|
112 * @return category index. |
|
113 */ |
|
114 IMPORT_C TUint CurrencyCategoryId() const; |
|
115 |
|
116 /** |
|
117 * Stores the category array to the given stream. |
|
118 * @param aStream Stream for writing. |
|
119 */ |
|
120 IMPORT_C void ExternalizeL( RWriteStream& aStream ) const; |
|
121 |
|
122 /** |
|
123 * Loads the category array from the given stream. |
|
124 * @param aStream Stream for reading. |
|
125 */ |
|
126 IMPORT_C void InternalizeL( RReadStream& aStream ); |
|
127 |
|
128 private: // new methods |
|
129 |
|
130 /** |
|
131 * Skips zero or more category structures. |
|
132 * @param aCount Skips this many categories |
|
133 * @param aReader A resource reader object initialised to a resource. |
|
134 */ |
|
135 void SkipCategoriesL( TInt aCount, TResourceReader& aReader ); |
|
136 |
|
137 private: // data |
|
138 |
|
139 /** |
|
140 * The running version number of the model data (structure and content) |
|
141 */ |
|
142 TUint iModelVersion; |
|
143 |
|
144 /** |
|
145 * The index of the category containing currencies (in the array). |
|
146 */ |
|
147 TUint iCurrencyCategory; |
|
148 |
|
149 /** |
|
150 * The array for categories in this model. Owned. |
|
151 */ |
|
152 CArrayPtrSeg< CCnvCategory > iCategoryArray; |
|
153 |
|
154 }; |
|
155 |
|
156 #endif // __CCNVCONVERTER_H__ |
|
157 |
|