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 __MDERELATIONCONDITION_H__ |
|
20 #define __MDERELATIONCONDITION_H__ |
|
21 |
|
22 |
|
23 #include <mdccommon.h> |
|
24 #include <mdecondition.h> |
|
25 #include <mderange.h> |
|
26 |
|
27 |
|
28 /* Forward declarations. */ |
|
29 class CMdELogicCondition; |
|
30 class CMdERelationDef; |
|
31 |
|
32 /** |
|
33 * Search condition for relations. |
|
34 */ |
|
35 NONSHARABLE_CLASS(CMdERelationCondition) : public CMdECondition |
|
36 { |
|
37 public: |
|
38 |
|
39 /* Constructors and destructor. */ |
|
40 |
|
41 static CMdERelationCondition* NewL( TItemId aRelationId = KNoId, |
|
42 const RArray<TItemId>* aRelationIds = NULL, |
|
43 TRelationConditionSide aSide = ERelationConditionSideEither, |
|
44 const CMdERelationDef* aRelationDef = NULL, |
|
45 const TMdEIntRange* aParameterRange = NULL ); |
|
46 |
|
47 static CMdERelationCondition* NewLC( TItemId aRelationId = KNoId, |
|
48 const RArray<TItemId>* aRelationIds = NULL, |
|
49 TRelationConditionSide aSide = ERelationConditionSideEither, |
|
50 const CMdERelationDef* aRelationDef = NULL, |
|
51 const TMdEIntRange* aParameterRange = NULL ); |
|
52 |
|
53 /** |
|
54 * Destructor. |
|
55 */ |
|
56 virtual ~CMdERelationCondition(); |
|
57 |
|
58 /* Methods. */ |
|
59 |
|
60 /** |
|
61 * Returns the relation ID. |
|
62 * |
|
63 * @return Relation ID. |
|
64 */ |
|
65 IMPORT_C TItemId RelationId() const; |
|
66 |
|
67 /** |
|
68 * Returns the relation IDs. |
|
69 * |
|
70 * @return Relation IDs. |
|
71 */ |
|
72 IMPORT_C const RArray<TItemId>* RelationIds() const; |
|
73 |
|
74 /** |
|
75 * Returns a pointer to the relation definition. |
|
76 * |
|
77 * @return Relation definition; or <code>NULL</code>, |
|
78 * if no relation definition has been associated with this |
|
79 * condition. |
|
80 */ |
|
81 IMPORT_C const CMdERelationDef* RelationDef() const; |
|
82 |
|
83 /** |
|
84 * Returns the conditions for the object on the left side of the relation. |
|
85 * |
|
86 * @return Logic condition node. |
|
87 */ |
|
88 IMPORT_C CMdELogicCondition& LeftL(); |
|
89 |
|
90 /** |
|
91 * Returns the conditions for the object on the right side of the |
|
92 * relation. |
|
93 * |
|
94 * @return Logic condition node. |
|
95 */ |
|
96 IMPORT_C CMdELogicCondition& RightL(); |
|
97 |
|
98 /** |
|
99 * Returns the side on which a matched object must be. |
|
100 * @return The side on which an object must be. |
|
101 */ |
|
102 TRelationConditionSide Side() const; |
|
103 |
|
104 /** |
|
105 * Sets the side on which a matched object must be. |
|
106 * @return The side on which an object must be. |
|
107 */ |
|
108 IMPORT_C void SetSide(TRelationConditionSide aSide); |
|
109 |
|
110 /** |
|
111 * Returns the relation parameter range. |
|
112 * @return Parameter's range conditions |
|
113 */ |
|
114 IMPORT_C const TMdEIntRange* ParameterRange() const; |
|
115 |
|
116 /** |
|
117 * Sets the GUID which a relation must match. |
|
118 * |
|
119 * @param aGuidHigh new GuidHigh value |
|
120 * @param aGuidLow new GuidLow value |
|
121 */ |
|
122 IMPORT_C void SetGuid(const TInt64& aGuidHigh, const TInt64& aGuidLow); |
|
123 |
|
124 /** |
|
125 * Gets the GUID which a relation must match. |
|
126 * |
|
127 * @param aGuidHigh reference where GuidHigh will be stored |
|
128 * @param aGuidLow reference where GuidLow will be stored |
|
129 * @return returns ETrue if relation condition contains GUID condition, |
|
130 * otherwise doesn't change parameters' values and returns EFalse |
|
131 */ |
|
132 IMPORT_C TBool Guid(TInt64& aGuidHigh, TInt64& aGuidLow) const; |
|
133 |
|
134 /** |
|
135 * Sets the last modified date range which a relation must match. |
|
136 * |
|
137 * @param aLastModifiedTimeRange last modified date range |
|
138 */ |
|
139 IMPORT_C void SetLastModifiedDateRangeL(const TMdETimeRange& aLastModifiedDateRange); |
|
140 |
|
141 /** |
|
142 * Gets the last modified date range which a relation must match. |
|
143 * |
|
144 * @param aLastModifiedDateRange reference where last modified date range will be stored |
|
145 * @return returns ETrue if relation condition contains last modified date range condition, |
|
146 * otherwise doesn't change parameter's value and returns EFalse |
|
147 */ |
|
148 IMPORT_C TBool LastModifiedDateRange(TMdETimeRange& aLastModifiedDateRange) const; |
|
149 |
|
150 /** |
|
151 * Get possible query's internal optimization flags from condition. |
|
152 * |
|
153 * @param aFlaga query's internal optimization flags |
|
154 * @return last level internal optimization flags |
|
155 */ |
|
156 TUint32 InternalQueryOptimizationFlags(TUint32& aFlags); |
|
157 |
|
158 /** |
|
159 * Get required size of serialized buffer when it is serialized. |
|
160 * |
|
161 * @return required serialized buffer size |
|
162 */ |
|
163 TUint32 RequiredBufferSize() const; |
|
164 |
|
165 /** |
|
166 * Serialize own data to serialized buffer (correct position must be set |
|
167 * before calling). |
|
168 * |
|
169 * @param aBuffer serialized buffer. |
|
170 */ |
|
171 void SerializeL(CMdCSerializationBuffer& aBuffer, |
|
172 TMdCOffset& aFreespaceOffset) const; |
|
173 |
|
174 protected: |
|
175 |
|
176 /* Constructor. */ |
|
177 |
|
178 |
|
179 /* Utility methods. */ |
|
180 |
|
181 |
|
182 private: |
|
183 |
|
184 /* Private methods. */ |
|
185 |
|
186 /** |
|
187 * Constructor. |
|
188 * |
|
189 * @param aRelationId The relation ID which an relation must match. |
|
190 * @param aSide The side on which an object must be. |
|
191 * @param aRelationDef relation definition |
|
192 */ |
|
193 CMdERelationCondition(TItemId aRelationId, TRelationConditionSide aSide, |
|
194 const CMdERelationDef* aRelationDef); |
|
195 |
|
196 /** |
|
197 * Second-phase constructor. Creates two LogicConditions as children of |
|
198 * this relation condition and creates range condition for parameter. |
|
199 * Ownership of the parameter stays with caller. |
|
200 * |
|
201 * @param aRelationIds The relation IDs which an relation must match. |
|
202 * @param aParameterRange parameter range conditions |
|
203 */ |
|
204 void ConstructL(const RArray<TItemId>* aRelationIds, |
|
205 const TMdEIntRange* aParameterRange); |
|
206 |
|
207 |
|
208 private: |
|
209 |
|
210 const TItemId iRelationId; |
|
211 |
|
212 RArray<TItemId>* iRelationIds; |
|
213 |
|
214 /** Relation definition. */ |
|
215 const CMdERelationDef* iRelationDef; |
|
216 |
|
217 /** Conditions for the left object. */ |
|
218 CMdELogicCondition* iLeftCondition; |
|
219 |
|
220 /** Conditions for the right object. */ |
|
221 CMdELogicCondition* iRightCondition; |
|
222 |
|
223 /** The side on which an object must be. */ |
|
224 TRelationConditionSide iSide; |
|
225 |
|
226 /** Conditions for the relation parameter. */ |
|
227 TMdEIntRange* iParameterRange; |
|
228 |
|
229 /** Conditions for the relation GUID. */ |
|
230 TInt64 iGuidHigh; |
|
231 TInt64 iGuidLow; |
|
232 |
|
233 /** Conditions for the relation last modified date. */ |
|
234 TMdETimeRange* iLastModifiedDateRange; |
|
235 }; |
|
236 |
|
237 #endif // __MDERELATIONCONDITION_H__ |
|