|
1 /* |
|
2 * Copyright (c) 2006 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: ImumInSettingsDataAttribute.h |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_IMUMINSETTINGSDATAATTRIBUTE_H |
|
20 #define C_IMUMINSETTINGSDATAATTRIBUTE_H |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 /** |
|
25 * Object with unique key ID to store anydata possible. |
|
26 * |
|
27 * @lib ImumUtils.lib |
|
28 * @since S60 v3.2 |
|
29 */ |
|
30 NONSHARABLE_CLASS( CImumInSettingsDataAttribute ) : public CBase |
|
31 { |
|
32 public: // Constructors and destructor |
|
33 |
|
34 /** |
|
35 * Creates the attribute object. |
|
36 * |
|
37 * @since S60 v3.2 |
|
38 * @param aAttributeId Unique id of the attribute |
|
39 * @param aAttributeType Type of the attribute |
|
40 * @param aAttributeSize Size of the data |
|
41 * @param aAttributeValue The actual value of the attribute |
|
42 * @param aAttributeDefault The default value of the attribute |
|
43 * @return Constructed object |
|
44 * @see ImumInSettingsKeys.h |
|
45 * @see ImumDaSettingsKeys.h |
|
46 */ |
|
47 static CImumInSettingsDataAttribute* NewLC( |
|
48 const TUint aAttributeId, |
|
49 const TInt aAttributeType, |
|
50 const TUint aAttributeSize, |
|
51 const TAny* aAttributeValue, |
|
52 const TAny* aAttributeDefault ); |
|
53 |
|
54 /** |
|
55 * Creates the attribute object. |
|
56 * |
|
57 * @since S60 v3.2 |
|
58 * @param aAttributeId Unique id of the attribute |
|
59 * @param aAttributeType Type of the attribute |
|
60 * @param aAttributeSize Size of the data |
|
61 * @param aAttributeValue The actual value of the attribute |
|
62 * @param aAttributeDefault The default value of the attribute |
|
63 * @return Constructed object |
|
64 * @see ImumInSettingsKeys.h |
|
65 * @see ImumDaSettingsKeys.h |
|
66 */ |
|
67 static CImumInSettingsDataAttribute* NewL( |
|
68 const TUint aAttributeId, |
|
69 const TInt aAttributeType, |
|
70 const TUint aAttributeSize, |
|
71 const TAny* aAttributeValue, |
|
72 const TAny* aAttributeDefault ); |
|
73 |
|
74 /** |
|
75 * Destructor |
|
76 * |
|
77 * @since S60 v3.2 |
|
78 */ |
|
79 virtual ~CImumInSettingsDataAttribute(); |
|
80 |
|
81 public: // New functions |
|
82 |
|
83 /** |
|
84 * Retrieves the stored value of the attribute. |
|
85 * |
|
86 * @since S60 v3.2 |
|
87 * @param aAttribute Return parameter to store the value. |
|
88 * @type T The type of the attribute |
|
89 * @return |
|
90 */ |
|
91 template<class T> |
|
92 inline void Value( T& aAttribute ) const; |
|
93 |
|
94 /** |
|
95 * Creates identical copy of the object |
|
96 * |
|
97 * @since S60 v3.2 |
|
98 * @return Identical copy of the object |
|
99 */ |
|
100 CImumInSettingsDataAttribute* CloneL(); |
|
101 |
|
102 /** |
|
103 * Copies content of the attribute. |
|
104 * |
|
105 * @since S60 v3.2 |
|
106 * @param aAttribute Attribute to be copied |
|
107 */ |
|
108 void Copy( |
|
109 const CImumInSettingsDataAttribute& aAttribute ); |
|
110 |
|
111 /** |
|
112 * Resets the value to default. |
|
113 * |
|
114 * @since S60 v3.2 |
|
115 */ |
|
116 void Reset(); |
|
117 |
|
118 /** |
|
119 * Compares objects. |
|
120 * |
|
121 * @since S60 v3.2 |
|
122 * @param aAttribute The attribute to be compared |
|
123 * @return ETrue, when objects are matching |
|
124 */ |
|
125 TBool operator==( |
|
126 const CImumInSettingsDataAttribute& aAttribute ); |
|
127 |
|
128 /** |
|
129 * Compares objects. |
|
130 * |
|
131 * @since S60 v3.2 |
|
132 * @param aAttribute The attribute to be compared |
|
133 * @return ETrue, when objects are not matching |
|
134 */ |
|
135 TBool operator!=( |
|
136 const CImumInSettingsDataAttribute& aAttribute ); |
|
137 |
|
138 /** |
|
139 * Sets the id of the attribute. |
|
140 * |
|
141 * @since S60 v3.2 |
|
142 * @param aId New unique ID |
|
143 */ |
|
144 void SetId( const TUint aId ); |
|
145 |
|
146 /** |
|
147 * Returns the unique Id of the key. |
|
148 * |
|
149 * @since S60 v3.2 |
|
150 * @return The id of the key |
|
151 */ |
|
152 TUint Id() const; |
|
153 |
|
154 /** |
|
155 * Returns the type of the key. |
|
156 * |
|
157 * @since S60 v3.2 |
|
158 * @return The type of the key |
|
159 */ |
|
160 TInt Type() const; |
|
161 |
|
162 /** |
|
163 * Method to compare id's of the to attributes. For RArrayPointer class. |
|
164 * |
|
165 * @since S60 v3.2 |
|
166 * @param aLeft Item for comparing |
|
167 * @param aLeft Another item for comparing |
|
168 * @return ETrue/EFalse depending if the ID matches |
|
169 */ |
|
170 static TBool IdCompare( |
|
171 const CImumInSettingsDataAttribute& aLeft, |
|
172 const CImumInSettingsDataAttribute& aRight ); |
|
173 |
|
174 protected: // Constructors |
|
175 |
|
176 /** |
|
177 * Default constructor for classCImumInSettingsDataAttribute |
|
178 * @since S60 v3.2 |
|
179 * @return, Constructed object |
|
180 */ |
|
181 CImumInSettingsDataAttribute(); |
|
182 |
|
183 /** |
|
184 * Symbian 2-phase constructor |
|
185 * |
|
186 * @since S60 v3.2 |
|
187 * @param aAttributeId Unique id of the attribute |
|
188 * @param aAttributeType Type of the attribute |
|
189 * @param aAttributeSize Size of the data |
|
190 * @param aAttributeValue The actual value of the attribute |
|
191 * @param aAttributeDefault The default value of the attribute |
|
192 * @see ImumInSettingsKeys.h |
|
193 * @see ImumDaSettingsKeys.h |
|
194 */ |
|
195 void ConstructL( |
|
196 const TUint aAttributeId, |
|
197 const TInt aAttributeType, |
|
198 const TUint aAttributeSize, |
|
199 const TAny* aAttribute, |
|
200 const TAny* aAttributeDefault ); |
|
201 |
|
202 private: // New functions |
|
203 |
|
204 /** |
|
205 * Deletes the text objects allocated by the class |
|
206 * |
|
207 * @since S60 v3.2 |
|
208 */ |
|
209 void DeleteText(); |
|
210 |
|
211 /** |
|
212 * Deletes number objects allocated by the class |
|
213 * |
|
214 * @since S60 v3.2 |
|
215 * @param |
|
216 */ |
|
217 template<class T> |
|
218 inline void DeleteNumber(); |
|
219 |
|
220 /** |
|
221 * Deletes any objects allocated by the attribute. |
|
222 * |
|
223 * @since S60 v3.2 |
|
224 */ |
|
225 void Cleanup(); |
|
226 |
|
227 /** |
|
228 * Allocates memory from heap for the values |
|
229 * |
|
230 * @since S60 v3.2 |
|
231 * @template T type of the parameter |
|
232 * @param aValue The actual value of the attribute |
|
233 * @param aDefault The default value of the attibute |
|
234 */ |
|
235 template<class T> |
|
236 inline void DoAllocL( |
|
237 const TAny* aValue, |
|
238 const TAny* aDefault ); |
|
239 |
|
240 /** |
|
241 * Allocates memory from heap for the values |
|
242 * |
|
243 * @since S60 v3.2 |
|
244 * @param aValue The actual value of the attribute |
|
245 * @param aDefault The default value of the attibute |
|
246 */ |
|
247 void AllocL( |
|
248 const TAny* aValue, |
|
249 const TAny* aDefault ); |
|
250 |
|
251 /** |
|
252 * Sets all the values of the attribute |
|
253 * |
|
254 * @since S60 v3.2 |
|
255 * @param aAttributeId Unique id of the attribute |
|
256 * @param aAttributeType Type of the attribute |
|
257 * @param aAttributeSize Size of the data |
|
258 * @param aAttributeValue The actual value of the attribute |
|
259 * @param aAttributeDefault The default value of the attribute |
|
260 * @see ImumInSettingsKeys.h |
|
261 * @see ImumDaSettingsKeys.h |
|
262 */ |
|
263 void SetAttributeL( |
|
264 const TUint aAttributeId, |
|
265 const TInt aAttributeType, |
|
266 const TUint aAttributeSize, |
|
267 const TAny* aAttributeValue, |
|
268 const TAny* aAttributeDefault ); |
|
269 |
|
270 /** |
|
271 * Logs the data in the attribute. Debug only. |
|
272 * |
|
273 * @since S60 v3.2 |
|
274 */ |
|
275 void Log() const; |
|
276 |
|
277 private: // Data |
|
278 |
|
279 // Unique ID |
|
280 TUint iId; |
|
281 // Item type |
|
282 TInt iType; |
|
283 // Length of the item |
|
284 TUint iSize; |
|
285 // Owned: The value, of which type is defined by iType |
|
286 TAny* iValue; |
|
287 // Owned: Default value of the attribute |
|
288 TAny* iDefault; |
|
289 }; |
|
290 |
|
291 #include "ImumInSettingsDataAttribute.inl" |
|
292 |
|
293 #endif // C_IMUMINSETTINGSDATAATTRIBUTE_H |
|
294 |
|
295 // End of File |