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