|
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: Class to hold description about one property |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __MDSPROPERTYDEF_H__ |
|
19 #define __MDSPROPERTYDEF_H__ |
|
20 |
|
21 #include "mdsitemdef.h" |
|
22 #include "mdssqliteconnection.h" |
|
23 |
|
24 class CMdCSerializationBuffer; |
|
25 |
|
26 |
|
27 /** |
|
28 * Metadata namespace class |
|
29 * |
|
30 * This class is responsible for holding information about one property |
|
31 * |
|
32 */ |
|
33 class CMdsPropertyDef : public CMdsItemDef |
|
34 { |
|
35 friend class CMdsSchema; |
|
36 friend class CMdsObjectDef; |
|
37 public: |
|
38 |
|
39 /** |
|
40 * Create new property object |
|
41 * @param aId id of property |
|
42 * @param aName name of property |
|
43 * @param aType type of property |
|
44 * @param aMandatory mandatory flag |
|
45 * @param aReadOnly read-only flag |
|
46 * @param aIndexed should this property be indexed or not |
|
47 * @return pointer to new created property |
|
48 */ |
|
49 static CMdsPropertyDef* NewL( const TDesC& aName, TPropertyType aType, |
|
50 TBool aReadOnly, TBool aMandatory, TBool aIndexed ); |
|
51 |
|
52 /** |
|
53 * Create new property object |
|
54 * @param aId id of property |
|
55 * @param aName name of property |
|
56 * @param aType type of property |
|
57 * @param aMandatory mandatory flag |
|
58 * @param aReadOnly read-only flag |
|
59 * @param aIndexed should this property be indexed or not |
|
60 * @return pointer to new created property |
|
61 */ |
|
62 static CMdsPropertyDef* NewLC( const TDesC& aName, TPropertyType aType, |
|
63 TBool aReadOnly, TBool aMandatory, TBool aIndexed ); |
|
64 |
|
65 /** |
|
66 * Create new property object |
|
67 * @param aId id of property |
|
68 * @param aName name of property |
|
69 * @param aType type of property |
|
70 * @param aFlags property flag |
|
71 * @return pointer to new created property |
|
72 */ |
|
73 static CMdsPropertyDef* NewL( const TDesC& aName, TPropertyType aType, |
|
74 TUint32 aFlags ); |
|
75 |
|
76 /** |
|
77 * Create new property object |
|
78 * @param aId id of property |
|
79 * @param aName name of property |
|
80 * @param aType type of property |
|
81 * @param aFlags property flag |
|
82 * @return pointer to new created property |
|
83 */ |
|
84 static CMdsPropertyDef* NewLC( const TDesC& aName, TPropertyType aType, |
|
85 TUint32 aFlags ); |
|
86 |
|
87 |
|
88 virtual ~CMdsPropertyDef(); |
|
89 |
|
90 |
|
91 void StoreToDBL( TDefId aObjectDefId ); |
|
92 |
|
93 /** |
|
94 * Add minimun and maximum value to property |
|
95 * leave on type mismatch |
|
96 * @param aMinValue min value |
|
97 * @param aMaxValue max value |
|
98 */ |
|
99 void AddMinMaxValueL( const TInt32& aMinValue, const TInt32& aMaxValue ); |
|
100 |
|
101 /** |
|
102 * Add minimun and maximum value to property |
|
103 * leave on type mismatch |
|
104 * @param aMinValue min value |
|
105 * @param aMaxValue max value |
|
106 */ |
|
107 void AddMinMaxValueL( const TUint32& aMinValue, const TUint32& aMaxValue ); |
|
108 |
|
109 /** |
|
110 * Add minimun and maximum value to property |
|
111 * leave on type mismatch |
|
112 * @param aMinValue min value |
|
113 * @param aMaxValue max value |
|
114 */ |
|
115 void AddMinMaxValueL( const TInt64& aMinValue, const TInt64& aMaxValue ); |
|
116 |
|
117 /** |
|
118 * Add minimun and maximum value to property |
|
119 * leave on type mismatch |
|
120 * @param aMinValue min value |
|
121 * @param aMaxValue max value |
|
122 */ |
|
123 void AddMinMaxValueL( const TReal& aMinValue, const TReal& aMaxValue ); |
|
124 |
|
125 /** |
|
126 * Check if property's value is between allowed minimum and maximum value. |
|
127 * |
|
128 * @param aValue property's value |
|
129 * |
|
130 * @return is value between allowed minimum and maximum value |
|
131 */ |
|
132 inline TBool CheckMinMaxValue( TInt32 aValue ) const; |
|
133 |
|
134 /** |
|
135 * Check if property's value is between allowed minimum and maximum value. |
|
136 * |
|
137 * @param aValue property's value |
|
138 * |
|
139 * @return is value between allowed minimum and maximum value |
|
140 */ |
|
141 inline TBool CheckMinMaxValue( TUint32 aValue ) const; |
|
142 |
|
143 /** |
|
144 * Check if property's value is between allowed minimum and maximum value. |
|
145 * |
|
146 * @param aValue property's value |
|
147 * |
|
148 * @return is value between allowed minimum and maximum value |
|
149 */ |
|
150 inline TBool CheckMinMaxValue( const TInt64& aValue ) const; |
|
151 |
|
152 /** |
|
153 * Check if property's value is between allowed minimum and maximum value. |
|
154 * |
|
155 * @param aValue property's value |
|
156 * |
|
157 * @return is value between allowed minimum and maximum value |
|
158 */ |
|
159 inline TBool CheckMinMaxValue( const TReal& aValue ) const; |
|
160 |
|
161 /** |
|
162 * Get SQLite type name |
|
163 * @return type name |
|
164 */ |
|
165 const TDesC& GetSqlTypeName() const; |
|
166 |
|
167 /** |
|
168 * Get SQLite property type |
|
169 * @return property type |
|
170 */ |
|
171 TColumnDataType GetSqlType() const; |
|
172 |
|
173 /** |
|
174 * Get property type |
|
175 * @return property type |
|
176 */ |
|
177 inline TPropertyType GetType() const; |
|
178 |
|
179 /** |
|
180 * Get property read-only |
|
181 * @return property read-only |
|
182 */ |
|
183 inline TBool GetReadOnly() const; |
|
184 |
|
185 /** |
|
186 * Get property mandatory |
|
187 * @return is property mandatory |
|
188 */ |
|
189 inline TBool GetMandatory() const; |
|
190 |
|
191 /** |
|
192 * Get property indexed flag |
|
193 * @return is property indexed |
|
194 */ |
|
195 inline TBool GetIndexed() const; |
|
196 |
|
197 TBool operator==( const CMdsPropertyDef& aPropertyDef ) const; |
|
198 |
|
199 inline TBool operator!=( const CMdsPropertyDef& aPropertyDef ) const; |
|
200 |
|
201 /** |
|
202 * Get required size of serialized buffer when this is serialized. |
|
203 * |
|
204 * @return required size of serialized buffer |
|
205 */ |
|
206 TUint32 RequiredBufferSize(); |
|
207 |
|
208 /** |
|
209 * Serialize own data to serialized buffer (correct position must be set |
|
210 * before calling) and return new position of serialized buffer. |
|
211 * |
|
212 * @param aBuffer serialized buffer. |
|
213 */ |
|
214 TMdCOffset SerializeL(CMdCSerializationBuffer& aBuffer, TMdCOffset aFreeSpace); |
|
215 |
|
216 |
|
217 private: |
|
218 /** |
|
219 * default constructor |
|
220 */ |
|
221 inline CMdsPropertyDef( TPropertyType aType ); |
|
222 |
|
223 /** |
|
224 * 2nd phase constructor |
|
225 * @param aName name of property |
|
226 * @param aMinCount min count of property |
|
227 * @param aMaxCount max count of property |
|
228 * @param aMandatory mandatory property |
|
229 * @param aIndexed create an index of this property |
|
230 */ |
|
231 void ConstructL( const TDesC& aName, TBool aReadOnly, TBool aMandatory, TBool aIndexed ); |
|
232 |
|
233 |
|
234 private: |
|
235 |
|
236 /** |
|
237 * type of property |
|
238 */ |
|
239 const TPropertyType iType; |
|
240 |
|
241 /** |
|
242 * Minimum value for property |
|
243 */ |
|
244 TMdCValueUnion iMinValue; |
|
245 |
|
246 /** |
|
247 * Maximum value for property |
|
248 */ |
|
249 TMdCValueUnion iMaxValue; |
|
250 |
|
251 /** |
|
252 * property read-only flag |
|
253 */ |
|
254 TUint32 iPropertyFlags; |
|
255 |
|
256 /** |
|
257 * Should this property be indexed or not. |
|
258 */ |
|
259 TBool iIndexed; |
|
260 }; |
|
261 |
|
262 #include "mdspropertydef.inl" |
|
263 |
|
264 #endif // __MDSPROPERTYDEF_H__ |