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: Represents value range of property condition |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __MDERANGEPROPERTYCONDITION_H__ |
|
20 #define __MDERANGEPROPERTYCONDITION_H__ |
|
21 |
|
22 |
|
23 #include <mdepropertycondition.h> |
|
24 #include <mderange.h> |
|
25 |
|
26 /* Forward declarations. */ |
|
27 class CMdEPropertyDef; |
|
28 class CMdCSerializationBuffer; |
|
29 |
|
30 class TMdESerializeRangePropertyCondition |
|
31 { |
|
32 public: |
|
33 static void SerializeL( CMdCSerializationBuffer& aBuffer, |
|
34 const CMdEPropertyCondition& aPropertyCondition, |
|
35 TMdERangeType aType, const void* aMin, const void* aMax, |
|
36 TInt aValueSize, TMdCOffset& aFreespaceOffset ); |
|
37 static TUint32 RequiredBufferSize( TInt aValueSize ); |
|
38 }; |
|
39 |
|
40 /** |
|
41 * Instances of CMdERangePropertyCondition are associated with a specific |
|
42 * property definition. |
|
43 */ |
|
44 template <TConditionType KConditionType, class T> |
|
45 NONSHARABLE_CLASS(CMdERangePropertyCondition) : public CMdEPropertyCondition |
|
46 { |
|
47 public: |
|
48 /* Constructors and destructor. */ |
|
49 |
|
50 /** |
|
51 * Two-phased constructor. |
|
52 */ |
|
53 static CMdERangePropertyCondition* NewL( const CMdEPropertyDef& aPropertyDef, |
|
54 const TMdERange<T>& aValueRange) |
|
55 { |
|
56 CMdERangePropertyCondition* self = |
|
57 CMdERangePropertyCondition::NewLC( aPropertyDef, aValueRange ); |
|
58 CleanupStack::Pop( self ); |
|
59 return self; |
|
60 } |
|
61 |
|
62 /** |
|
63 * Two-phased constructor. |
|
64 */ |
|
65 static CMdERangePropertyCondition* NewLC( const CMdEPropertyDef& aPropertyDef, |
|
66 const TMdERange<T>& aValueRange) |
|
67 { |
|
68 CMdERangePropertyCondition* self = |
|
69 new ( ELeave ) CMdERangePropertyCondition( aPropertyDef, aValueRange ); |
|
70 CleanupStack::PushL( self ); |
|
71 self->ConstructL(); |
|
72 return self; |
|
73 } |
|
74 |
|
75 |
|
76 /** |
|
77 * Destructor. |
|
78 */ |
|
79 virtual ~CMdERangePropertyCondition() |
|
80 { |
|
81 } |
|
82 |
|
83 |
|
84 /* Methods. */ |
|
85 |
|
86 /** |
|
87 * Returns the range of the property condition. |
|
88 * |
|
89 * @return Range. |
|
90 */ |
|
91 inline const TMdERange<T>& Range() const |
|
92 { |
|
93 return iRange; |
|
94 } |
|
95 |
|
96 /** |
|
97 * Get possible query's internal optimization flags from condition. |
|
98 * |
|
99 * @param aFlaga query's internal optimization flags |
|
100 * @return last level internal optimization flags |
|
101 */ |
|
102 TUint32 InternalQueryOptimizationFlags(TUint32& aFlags) |
|
103 { |
|
104 return CMdEPropertyCondition::InternalQueryOptimizationFlags(aFlags); |
|
105 } |
|
106 |
|
107 /** |
|
108 * Get required size of serialized buffer when this is serialized. |
|
109 * |
|
110 * @return required size of serialized buffer |
|
111 */ |
|
112 TUint32 RequiredBufferSize() const |
|
113 { |
|
114 return TMdESerializeRangePropertyCondition::RequiredBufferSize( |
|
115 sizeof(T) ); |
|
116 } |
|
117 |
|
118 /** |
|
119 * Serialize own data to serialized buffer (correct position must be set |
|
120 * before calling) and return new position of serialized buffer. |
|
121 * |
|
122 * @param aBuffer serialized buffer. |
|
123 */ |
|
124 void SerializeL(CMdCSerializationBuffer& aBuffer, |
|
125 TMdCOffset& aFreespaceOffset) const |
|
126 { |
|
127 TMdESerializeRangePropertyCondition::SerializeL( aBuffer, *this, iRange.Type(), |
|
128 &iRange.Min(), &iRange.Max(), sizeof(T), aFreespaceOffset ); |
|
129 } |
|
130 |
|
131 protected: |
|
132 |
|
133 /* Utility methods. */ |
|
134 |
|
135 |
|
136 private: |
|
137 |
|
138 /* Private methods. */ |
|
139 /** |
|
140 * Constructor. |
|
141 * |
|
142 * @param aType type of the condition node |
|
143 */ |
|
144 CMdERangePropertyCondition(const CMdEPropertyDef& aPropertyDef, |
|
145 const TMdERange<T>& aValueRange) |
|
146 : CMdEPropertyCondition(KConditionType, aPropertyDef), |
|
147 iRange(aValueRange) |
|
148 { |
|
149 } |
|
150 |
|
151 private: |
|
152 |
|
153 /** The value range that is valid for the condition. */ |
|
154 TMdERange<T> iRange; |
|
155 }; |
|
156 |
|
157 |
|
158 /* The actual RangePropertyConditions. */ |
|
159 |
|
160 #define MDE_DEFINE_RANGE_CONDITION(RangeType) \ |
|
161 typedef CMdERangePropertyCondition<EConditionTypeProperty##RangeType##Range, T##RangeType> CMdE##RangeType##RangePropertyCondition; |
|
162 |
|
163 MDE_DEFINE_RANGE_CONDITION(Int) |
|
164 MDE_DEFINE_RANGE_CONDITION(Int64) |
|
165 MDE_DEFINE_RANGE_CONDITION(Uint) |
|
166 MDE_DEFINE_RANGE_CONDITION(Real) |
|
167 MDE_DEFINE_RANGE_CONDITION(Time) |
|
168 |
|
169 #undef MDE_DEFINE_RANGE_CONDITION |
|
170 |
|
171 #endif // __MDERANGEPROPERTYCONDITION_H__ |
|