|
1 /* |
|
2 * Copyright (c) 2009 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __MDEPROPERTY_H__ |
|
20 #define __MDEPROPERTY_H__ |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 #include <mdeinstanceitem.h> |
|
25 |
|
26 |
|
27 /* Forward declarations. */ |
|
28 class CMdEObject; |
|
29 class CMdEPropertyDef; |
|
30 class CMdCSerializationBuffer; |
|
31 |
|
32 /** |
|
33 * Abstract base class for properties. |
|
34 */ |
|
35 NONSHARABLE_CLASS(CMdEProperty) : public CMdEInstanceItem |
|
36 { |
|
37 friend class CMdEObject; |
|
38 public: |
|
39 /** |
|
40 * Destructor. |
|
41 */ |
|
42 virtual ~CMdEProperty(); |
|
43 |
|
44 |
|
45 /* Methods. */ |
|
46 |
|
47 /** |
|
48 * Constructs a new property. |
|
49 * |
|
50 * @param aObject owner object of property |
|
51 * @param aBuffer buffer where property was serialized |
|
52 * @return new numeric property |
|
53 */ |
|
54 static CMdEProperty* NewL( const CMdEObject& aObject, CMdCSerializationBuffer& aBuffer ); |
|
55 |
|
56 /** |
|
57 * Constructs a new property and leave it on the cleanup stack. |
|
58 * |
|
59 * @param aObject owner object of property |
|
60 * @param aBuffer buffer where property was serialized |
|
61 * @return new numeric property |
|
62 */ |
|
63 static CMdEProperty* NewLC( const CMdEObject& aObject, CMdCSerializationBuffer& aBuffer ); |
|
64 |
|
65 /** |
|
66 * Constructs a new property. |
|
67 * |
|
68 * @param aDef property definition |
|
69 * @param aObject owner object of property |
|
70 * @return new numeric property |
|
71 */ |
|
72 static CMdEProperty* NewL(const CMdEPropertyDef& aDef, const CMdEObject& aObject); |
|
73 |
|
74 CMdEProperty(); |
|
75 |
|
76 /** |
|
77 * Constructs a new property. |
|
78 * |
|
79 * @param aDef property definition |
|
80 * @param aObject owner object of property |
|
81 * @return new numeric property |
|
82 */ |
|
83 static CMdEProperty* NewLC(const CMdEPropertyDef& aDef, const CMdEObject& aObject); |
|
84 |
|
85 |
|
86 /** |
|
87 * Returns the definition of the integer property. |
|
88 * |
|
89 * @return property definition |
|
90 */ |
|
91 IMPORT_C const CMdEPropertyDef& Def() const; |
|
92 |
|
93 /** |
|
94 * Returns the object which the property belongs to. |
|
95 * |
|
96 * @return Object. |
|
97 */ |
|
98 IMPORT_C const CMdEObject& Object() const; |
|
99 |
|
100 /** |
|
101 * @return ETrue if property was modified, |
|
102 * EFalse otherwise |
|
103 */ |
|
104 IMPORT_C TBool Modified() const; |
|
105 |
|
106 |
|
107 /** value getters */ |
|
108 |
|
109 /** |
|
110 * Returns the TBool value of the property. |
|
111 * @return value |
|
112 */ |
|
113 IMPORT_C TBool BoolValueL() const; |
|
114 |
|
115 /** |
|
116 * Returns the TInt8 value of the property. |
|
117 * @return value |
|
118 */ |
|
119 IMPORT_C TInt8 Int8ValueL() const; |
|
120 |
|
121 /** |
|
122 * Returns the TUint8 value of the property. |
|
123 * @return value |
|
124 */ |
|
125 |
|
126 IMPORT_C TUint8 Uint8ValueL() const; |
|
127 |
|
128 /** |
|
129 * Returns the TInt16 value of the property. |
|
130 * @return value |
|
131 */ |
|
132 IMPORT_C TInt16 Int16ValueL() const; |
|
133 |
|
134 /** |
|
135 * Returns the TUint16 value of the property. |
|
136 * @return value |
|
137 */ |
|
138 IMPORT_C TUint16 Uint16ValueL() const; |
|
139 |
|
140 /** |
|
141 * Returns the TInt32 value of the property. |
|
142 * @return value |
|
143 */ |
|
144 IMPORT_C TInt32 Int32ValueL() const; |
|
145 |
|
146 /** |
|
147 * Returns the TUint32 value of the property. |
|
148 * @return value |
|
149 */ |
|
150 IMPORT_C TUint32 Uint32ValueL() const; |
|
151 |
|
152 /** |
|
153 * Returns the TInt64 value of the property. |
|
154 * @return value |
|
155 */ |
|
156 IMPORT_C TInt64 Int64ValueL() const; |
|
157 |
|
158 /** |
|
159 * Returns the TReal32 value of the property. |
|
160 * @return value |
|
161 */ |
|
162 IMPORT_C TReal32 Real32ValueL() const; |
|
163 |
|
164 /** |
|
165 * Returns the TReal64 value of the property. |
|
166 * @return value |
|
167 */ |
|
168 IMPORT_C TReal64 Real64ValueL() const; |
|
169 |
|
170 /** |
|
171 * Returns the TTime value of the property. |
|
172 * @return value |
|
173 */ |
|
174 IMPORT_C TTime TimeValueL() const; |
|
175 |
|
176 /** |
|
177 * Returns the text value of the property. |
|
178 * |
|
179 * @return value |
|
180 */ |
|
181 IMPORT_C const TDesC& TextValueL() const; |
|
182 |
|
183 |
|
184 /** setter methods */ |
|
185 /** |
|
186 * Sets the TBool value of the property. |
|
187 * @param aValue New value. |
|
188 */ |
|
189 IMPORT_C void SetBoolValueL(TBool aValue); |
|
190 |
|
191 /** |
|
192 * Sets the TInt8 value of the property. |
|
193 * @param aValue New value. |
|
194 */ |
|
195 IMPORT_C void SetInt8ValueL(TInt8 aValue); |
|
196 |
|
197 /** |
|
198 * Sets the TUint8 value of the property. |
|
199 * @param aValue New value. |
|
200 */ |
|
201 IMPORT_C void SetUint8ValueL(TUint8 aValue); |
|
202 |
|
203 /** |
|
204 * Sets the TInt16 value of the property. |
|
205 * @param aValue New value. |
|
206 */ |
|
207 IMPORT_C void SetInt16ValueL(TInt16 aValue); |
|
208 |
|
209 /** |
|
210 * Sets the TUint16 value of the property. |
|
211 * @param aValue New value. |
|
212 */ |
|
213 IMPORT_C void SetUint16ValueL(TUint16 aValue); |
|
214 |
|
215 /** |
|
216 * Sets the TInt32 value of the property. |
|
217 * @param aValue New value. |
|
218 */ |
|
219 IMPORT_C void SetInt32ValueL(TInt32 aValue); |
|
220 |
|
221 /** |
|
222 * Sets the TUint32 value of the property. |
|
223 * @param aValue New value. |
|
224 */ |
|
225 IMPORT_C void SetUint32ValueL(TUint32 aValue); |
|
226 |
|
227 /** |
|
228 * Sets the TInt64 value of the property. |
|
229 * @param aValue New value. |
|
230 */ |
|
231 IMPORT_C void SetInt64ValueL(TInt64 aValue); |
|
232 |
|
233 /** |
|
234 * Sets the TReal32 value of the property. |
|
235 * @param aValue New value. |
|
236 */ |
|
237 IMPORT_C void SetReal32ValueL(TReal32 aValue); |
|
238 |
|
239 /** |
|
240 * Sets the TReal64 value of the property. |
|
241 * @param aValue New value. |
|
242 */ |
|
243 IMPORT_C void SetReal64ValueL(TReal64 aValue); |
|
244 |
|
245 /** |
|
246 * Sets the TTime value of the property. |
|
247 * @param aValue New value. |
|
248 */ |
|
249 IMPORT_C void SetTimeValueL(const TTime& aValue); |
|
250 |
|
251 /** |
|
252 * Sets the text value of the property. |
|
253 * |
|
254 * @param aValue New value. |
|
255 */ |
|
256 IMPORT_C void SetTextValueL(const TDesC& aValue); |
|
257 |
|
258 |
|
259 /** |
|
260 * Return required size for property serialization |
|
261 * |
|
262 * @return size of serialized property |
|
263 */ |
|
264 TUint32 RequiredBufferSize() const; |
|
265 |
|
266 /** |
|
267 * Serialize object |
|
268 * |
|
269 * @param aBuffer buffer where serialized object should go |
|
270 */ |
|
271 TMdCOffset SerializeL(CMdCSerializationBuffer& aBuffer, TMdCOffset aFreespaceOffset) const; |
|
272 |
|
273 private: |
|
274 |
|
275 TUint8 ModFlags() const; |
|
276 |
|
277 void SetRemoved(); |
|
278 TBool Removed(); |
|
279 |
|
280 void ClearFlags(); |
|
281 |
|
282 void SetModified(); |
|
283 |
|
284 |
|
285 /* Constructors. */ |
|
286 |
|
287 /** |
|
288 * Constructor. |
|
289 * |
|
290 * @param aDef Definition of the new property. |
|
291 * @param aObject object where this property belongs to. |
|
292 */ |
|
293 CMdEProperty(const CMdEPropertyDef& aDef, const CMdEObject& aObject); |
|
294 |
|
295 /** |
|
296 * Second-phase constructor. |
|
297 * |
|
298 * @param aSource Source of the new property. |
|
299 */ |
|
300 void BaseConstructL(); |
|
301 |
|
302 |
|
303 /* Methods. */ |
|
304 |
|
305 /** |
|
306 * Check if property has value is between min and max |
|
307 * and leave if not! |
|
308 */ |
|
309 #ifdef _DEBUG |
|
310 void CheckValueMinMaxL( const TMdCValueUnion& aValue ) const; |
|
311 #endif |
|
312 |
|
313 void DoSetTextValueL(const TDesC& aValue); |
|
314 |
|
315 TMdEInstanceType InstanceType() const; |
|
316 |
|
317 protected: |
|
318 /** property modifications flags */ |
|
319 TUint8 iModFlags; |
|
320 |
|
321 private: |
|
322 /** Property definition. */ |
|
323 const CMdEPropertyDef& iDef; |
|
324 |
|
325 /** Object this property belongs to. */ |
|
326 const CMdEObject& iObject; |
|
327 |
|
328 /** Value. */ |
|
329 TMdCValueUnion iValue; |
|
330 }; |
|
331 |
|
332 #endif // __MDEPROPERTY_H__ |