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: Base class for all search condition tree nodes. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __MDECONDITION_H__ |
|
20 #define __MDECONDITION_H__ |
|
21 |
|
22 |
|
23 #include <e32base.h> |
|
24 |
|
25 #include <mdccommon.h> |
|
26 |
|
27 // Forward declaration |
|
28 class CMdCSerializationBuffer; |
|
29 |
|
30 /** |
|
31 * Base class for all search condition tree nodes. |
|
32 */ |
|
33 NONSHARABLE_CLASS(CMdECondition) : public CBase |
|
34 { |
|
35 public: |
|
36 |
|
37 /* Destructor. */ |
|
38 |
|
39 /** |
|
40 * Destructor. |
|
41 */ |
|
42 virtual ~CMdECondition(); |
|
43 |
|
44 |
|
45 /* Methods. */ |
|
46 |
|
47 /** |
|
48 * Returns the type of the condition. |
|
49 * |
|
50 * @return Condition type. |
|
51 */ |
|
52 IMPORT_C TConditionType Type() const; |
|
53 |
|
54 /** |
|
55 * Determines whether the condition is negated. |
|
56 * |
|
57 * @return <code>ETrue</code>, if the condition is negated. |
|
58 * Otherwise <code>EFalse</code>. |
|
59 */ |
|
60 IMPORT_C TBool Negate() const; |
|
61 |
|
62 /** |
|
63 * Sets the negate flag. The negate flag negates the meaning of the |
|
64 * condition like a boolean NOT operator. |
|
65 * |
|
66 * @param aNegate <code>ETrue</code> to negate. |
|
67 */ |
|
68 IMPORT_C void SetNegate(TBool aNegate); |
|
69 |
|
70 /** |
|
71 * Determines whether the condition node has been locked. Attempting to |
|
72 * modify locked conditions causes a panic. |
|
73 * |
|
74 * @return <code>ETrue</code>, if the condition is locked. Otherwise |
|
75 * <code>EFalse</code>. |
|
76 */ |
|
77 IMPORT_C TBool Locked() const; |
|
78 |
|
79 /** |
|
80 * Locks the condition to prevent changes. Attempting to change a locked |
|
81 * condition causes a panic. |
|
82 * |
|
83 * @param aLocked <code>ETrue</code> to lock; <code>EFalse</code> to |
|
84 * unlock. |
|
85 */ |
|
86 IMPORT_C virtual void SetLocked(TBool aLocked = ETrue); |
|
87 |
|
88 /** |
|
89 * Get possible query's internal optimization flags from condition. |
|
90 * |
|
91 * @param aFlaga query's internal optimization flags |
|
92 * @return last level internal optimization flags |
|
93 */ |
|
94 virtual TUint32 InternalQueryOptimizationFlags(TUint32& aFlags) = 0; |
|
95 |
|
96 /** |
|
97 * Get required size of serialized buffer when this is serialized. |
|
98 * |
|
99 * @return required size of serialized buffer |
|
100 */ |
|
101 virtual TUint32 RequiredBufferSize() const = 0; |
|
102 |
|
103 /** |
|
104 * Serialize own data to serialized buffer (correct position must be set |
|
105 * before calling). |
|
106 * |
|
107 * @param aBuffer serialized buffer. |
|
108 */ |
|
109 virtual void SerializeL(CMdCSerializationBuffer& aBuffer, |
|
110 TMdCOffset& aFreespaceOffset) const = 0; |
|
111 |
|
112 /* Constructors. */ |
|
113 |
|
114 /** |
|
115 * Constructor. |
|
116 * |
|
117 * @param aType Type of the condition node. |
|
118 */ |
|
119 CMdECondition(TConditionType aType); |
|
120 |
|
121 protected: |
|
122 /** |
|
123 * Second-phase constructor. |
|
124 */ |
|
125 void ConditionConstruct(); |
|
126 |
|
127 |
|
128 /* Utility methods. */ |
|
129 |
|
130 /** |
|
131 * Panics if the condition is not locked. |
|
132 * |
|
133 * @panic TMdEPanic::EConditionLocked Condition is locked against |
|
134 * changes. |
|
135 */ |
|
136 void AssertNotLocked() const; |
|
137 |
|
138 protected: |
|
139 |
|
140 /** Type of the condition. */ |
|
141 TConditionType iType; |
|
142 |
|
143 /** The negate flag negates the result of the condition: if the |
|
144 condition evaluates to True, the result will really be False. */ |
|
145 TBool iNegated; |
|
146 |
|
147 /** Locked conditions can't be modified. */ |
|
148 TBool iLocked; |
|
149 }; |
|
150 |
|
151 #endif // __MDECONDITION_H__ |
|