|
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 __MDERELATION_H__ |
|
20 #define __MDERELATION_H__ |
|
21 |
|
22 |
|
23 #include <mdeinstanceitem.h> |
|
24 |
|
25 |
|
26 class CMdERelationDef; |
|
27 class CMdCSerializationBuffer; |
|
28 class CMdENamespaceDef; |
|
29 |
|
30 |
|
31 NONSHARABLE_CLASS(TMdERelation) |
|
32 { |
|
33 public: |
|
34 |
|
35 TMdERelation(); |
|
36 |
|
37 IMPORT_C TItemId Id() const; |
|
38 |
|
39 /** |
|
40 * Returns the definition of the relation. |
|
41 * |
|
42 * @return relation definition |
|
43 */ |
|
44 IMPORT_C CMdERelationDef& DefL() const; |
|
45 |
|
46 /** |
|
47 * Returns the identifier of the left object of the relation. |
|
48 * |
|
49 * @return object identifier |
|
50 */ |
|
51 IMPORT_C TItemId LeftObjectId() const; |
|
52 |
|
53 /** |
|
54 * Returns the identifier of the right object of the relation. |
|
55 * |
|
56 * @return object identifier |
|
57 */ |
|
58 IMPORT_C TItemId RightObjectId() const; |
|
59 |
|
60 public: |
|
61 /** |
|
62 * Calculates required size for buffer to serialize relation |
|
63 * |
|
64 * @return necessary buffer size |
|
65 */ |
|
66 TUint32 RequiredBufferSize() const; |
|
67 |
|
68 /** |
|
69 * DeSerialize relation |
|
70 * |
|
71 * @param aBuffer buffer where is serialized relation |
|
72 */ |
|
73 void DeSerializeL(CMdCSerializationBuffer& aBuffer, CMdENamespaceDef& aNamespaceDef); |
|
74 |
|
75 private: |
|
76 |
|
77 TItemId iId; |
|
78 |
|
79 TItemId iLeftObjectId; |
|
80 TItemId iRightObjectId; |
|
81 |
|
82 /** Relation definition. */ |
|
83 CMdERelationDef* iDef; |
|
84 }; |
|
85 |
|
86 /** |
|
87 * Relation between two objects. |
|
88 */ |
|
89 NONSHARABLE_CLASS(CMdERelation) : public CMdEInstanceItem |
|
90 { |
|
91 public: |
|
92 |
|
93 /* Constructors and destructor. */ |
|
94 |
|
95 /** |
|
96 * Create new realation from serialized buffer |
|
97 * |
|
98 * @param aBuffer serialized relation |
|
99 * @return new relation |
|
100 */ |
|
101 static CMdERelation* NewL(CMdESession* aSession, CMdCSerializationBuffer& aBuffer, CMdENamespaceDef& aNamespaceDef); |
|
102 |
|
103 /** |
|
104 * Create new realation from serialized buffer and leaves it on stack |
|
105 * |
|
106 * @param aBuffer serialized relation |
|
107 * @return new relation |
|
108 */ |
|
109 static CMdERelation* NewLC(CMdESession* aSession, CMdCSerializationBuffer& aBuffer, CMdENamespaceDef& aNamespaceDef); |
|
110 |
|
111 |
|
112 static CMdERelation* NewL(CMdERelationDef& aDef, TItemId aLeftObjectId, |
|
113 TItemId aRightObjectId, TInt32 aParameter); |
|
114 |
|
115 static CMdERelation* NewLC(CMdERelationDef& aDef, TItemId aLeftObjectId, |
|
116 TItemId aRightObjectId, TInt32 aParameter); |
|
117 |
|
118 /** |
|
119 * Destructor. |
|
120 */ |
|
121 virtual ~CMdERelation(); |
|
122 |
|
123 |
|
124 /* Methods. */ |
|
125 |
|
126 /** |
|
127 * Returns the definition of the relation. |
|
128 * |
|
129 * @return relation definition |
|
130 */ |
|
131 IMPORT_C CMdERelationDef& Def() const; |
|
132 |
|
133 /** |
|
134 * Returns the identifier of the left object of the relation. |
|
135 * |
|
136 * @return object identifier |
|
137 */ |
|
138 IMPORT_C TItemId LeftObjectId() const; |
|
139 |
|
140 /** |
|
141 * Returns the identifier of the right object of the relation. |
|
142 * |
|
143 * @return object identifier |
|
144 */ |
|
145 IMPORT_C TItemId RightObjectId() const; |
|
146 |
|
147 /** |
|
148 * Returns the parameter value associated with this relation |
|
149 * |
|
150 * @return The parameter value |
|
151 */ |
|
152 IMPORT_C TInt32 Parameter() const; |
|
153 |
|
154 /** |
|
155 * Set the parameter. |
|
156 * @param aParameter new value for parameter |
|
157 */ |
|
158 IMPORT_C void SetParameter(TInt32 aParameter); |
|
159 |
|
160 /** |
|
161 * Sets left object ID. |
|
162 * @param aLeftObjectId left object ID |
|
163 */ |
|
164 IMPORT_C void SetLeftObjectIdL( TItemId aLeftObjectId ); |
|
165 |
|
166 /** |
|
167 * Sets right object ID. |
|
168 * @param aRightObjectId right object ID |
|
169 */ |
|
170 IMPORT_C void SetRightObjectIdL( TItemId aRightObjectId ); |
|
171 |
|
172 /** |
|
173 * Returns the GUID of the relation. |
|
174 * |
|
175 * @param aGuidHigh reference where GuidHigh will be stored |
|
176 * @param aGuidLow reference where GuidLow will be stored |
|
177 */ |
|
178 IMPORT_C void Guid(TInt64& aGuidHigh, TInt64& aGuidLow) const; |
|
179 |
|
180 /** |
|
181 * Sets the GUID of the relation. |
|
182 * |
|
183 * @param aGuidHigh new GuidHigh value |
|
184 * @param aGuidLow new GuidLow value |
|
185 */ |
|
186 IMPORT_C void SetGuid(const TInt64& aGuidHigh, const TInt64& aGuidLow); |
|
187 |
|
188 /** |
|
189 * Returns last modified date of the relation. |
|
190 * |
|
191 * @return last modified date |
|
192 */ |
|
193 IMPORT_C TTime LastModifiedDate() const; |
|
194 |
|
195 /** |
|
196 * Sets last modified date of the relation. |
|
197 * |
|
198 * @param aLastModifiedDate last modified date |
|
199 */ |
|
200 IMPORT_C void SetLastModifiedDate(TTime aLastModifiedDate); |
|
201 |
|
202 /** |
|
203 * Calculates required size for buffer to serialize relation |
|
204 * |
|
205 * @return necessary buffer size |
|
206 */ |
|
207 TUint32 RequiredBufferSize() const; |
|
208 |
|
209 /** |
|
210 * Serialize relation |
|
211 * |
|
212 * @param aBuffer buffer where serialized relation should go |
|
213 */ |
|
214 TMdCOffset SerializeL(CMdCSerializationBuffer& aBuffer, TMdCOffset aFreespaceOffset) const; |
|
215 |
|
216 protected: |
|
217 |
|
218 /** |
|
219 * Constructs a new relation. |
|
220 * |
|
221 * @param aDef definition of the new relation |
|
222 * @param aLeftObjectId identifier of the left object of the new relation |
|
223 * @param aRightObjectId identifier of the right object of the new relation |
|
224 * @param aParameter value for parameter |
|
225 * |
|
226 */ |
|
227 CMdERelation(CMdESession* aSession, TItemId aId, |
|
228 CMdERelationDef& aDef, TItemId aLeftObjectId, |
|
229 TItemId aRightObjectId, TInt32 aParameter); |
|
230 |
|
231 /** |
|
232 * Second-phase constructor. |
|
233 */ |
|
234 void ConstructL(); |
|
235 |
|
236 TMdEInstanceType InstanceType() const; |
|
237 |
|
238 |
|
239 private: |
|
240 |
|
241 /** Relation definition. */ |
|
242 CMdERelationDef& iDef; |
|
243 |
|
244 /** Left object ID. */ |
|
245 TItemId iLeftObjectId; |
|
246 |
|
247 /** Right object ID. */ |
|
248 TItemId iRightObjectId; |
|
249 |
|
250 /** Parameter value */ |
|
251 TInt32 iParameter; |
|
252 |
|
253 /** Guid High and Low */ |
|
254 TInt64 iGuidHigh; |
|
255 TInt64 iGuidLow; |
|
256 |
|
257 /** Relations last modified date */ |
|
258 TTime iLastModifiedDate; |
|
259 }; |
|
260 |
|
261 #endif // __MDERELATION_H__ |