|
1 /* |
|
2 * Copyright (c) 2002-2007 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: CCFContextObjectImpl class declaration. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CFCONTEXTOBJECTIMPL_H |
|
20 #define C_CFCONTEXTOBJECTIMPL_H |
|
21 |
|
22 #include "cfcontextobject.h" |
|
23 |
|
24 /** |
|
25 * Context object implementation. |
|
26 * |
|
27 * @lib CFServices.lib |
|
28 * @since S60 5.0 |
|
29 */ |
|
30 NONSHARABLE_CLASS( CCFContextObjectImpl ): public CCFContextObject |
|
31 { |
|
32 public: |
|
33 |
|
34 /** |
|
35 * Two phased construction. |
|
36 * |
|
37 * @since S60 5.0 |
|
38 * @param None. |
|
39 * @return None. |
|
40 */ |
|
41 IMPORT_C static CCFContextObjectImpl* NewL(); |
|
42 IMPORT_C static CCFContextObjectImpl* NewLC(); |
|
43 |
|
44 /** |
|
45 * Two phased construction. |
|
46 * |
|
47 * @since S60 5.0 |
|
48 * @param aSource Initial source of the context. |
|
49 * @param aType Initial type of the context. |
|
50 * @param aValue Initial value of the context. |
|
51 * @return None. |
|
52 */ |
|
53 IMPORT_C static CCFContextObjectImpl* NewL( const TDesC& aSource, |
|
54 const TDesC& aType, |
|
55 const TDesC& aValue ); |
|
56 IMPORT_C static CCFContextObjectImpl* NewLC( const TDesC& aSource, |
|
57 const TDesC& aType, |
|
58 const TDesC& aValue ); |
|
59 |
|
60 // Destructior |
|
61 ~CCFContextObjectImpl(); |
|
62 |
|
63 public: // From base classes |
|
64 |
|
65 // @see CCFContextObject |
|
66 void SetTypeL( const TDesC& aType ); |
|
67 |
|
68 // @see CCFContextObject |
|
69 const TDesC& Type() const; |
|
70 |
|
71 // @see CCFContextObject |
|
72 void SetValueL( const TDesC& aValue ); |
|
73 |
|
74 // @see CCFContextObject |
|
75 const TDesC& Value() const; |
|
76 |
|
77 // @see CCFContextObject |
|
78 void SetSourceL( const TDesC& aSource ); |
|
79 |
|
80 // @see CCFContextObject |
|
81 const TDesC& Source() const; |
|
82 |
|
83 // @see CCFContextObject |
|
84 void SetConfidence( const TUint8& aConfidence ); |
|
85 |
|
86 // @see CCFContextObject |
|
87 TUint8 Confidence() const; |
|
88 |
|
89 // @see CCFContextObject |
|
90 void SetTimestampToHomeTime(); |
|
91 |
|
92 // @see CCFContextObject |
|
93 void SetTimestamp( const TTime& aTimestamp ); |
|
94 |
|
95 // @see CCFContextObject |
|
96 void SetTimestamp( const TInt64& aTimestamp ); |
|
97 |
|
98 // @see CCFContextObject |
|
99 const TTime& Timestamp() const; |
|
100 |
|
101 // @see CCFContextObject |
|
102 void CopyL( const CCFContextObject& aContext ); |
|
103 |
|
104 public: // New methods |
|
105 |
|
106 /** |
|
107 * Internalizes object. |
|
108 * |
|
109 * @since S60 5.0 |
|
110 * @param aStream Read stream. |
|
111 * @return None. |
|
112 */ |
|
113 IMPORT_C void InternalizeL( RReadStream& aStream ); |
|
114 |
|
115 /** |
|
116 * Externalizes object. |
|
117 * |
|
118 * @since S60 5.0 |
|
119 * @param aStream Write stream. |
|
120 * @return None. |
|
121 */ |
|
122 IMPORT_C void ExternalizeL( RWriteStream& aStream ); |
|
123 |
|
124 /** |
|
125 * Returns size of the object in bytes. |
|
126 * |
|
127 * @since S60 5.0 |
|
128 * @param None. |
|
129 * @return TInt. |
|
130 */ |
|
131 IMPORT_C TInt Size() const; |
|
132 |
|
133 /** |
|
134 * Compares value member variables of context objects. |
|
135 * Compares this context objects value member to the arguments value |
|
136 * member. |
|
137 * |
|
138 * @since S60 5.0 |
|
139 * @param aContext The context object to be compared with this one. |
|
140 * @return Positive if the value member of this is greater than |
|
141 * aContext's. Negative if the value member of this is less than |
|
142 * aContext's. Zero if both value members have the same length |
|
143 * and the their contents are the same. |
|
144 */ |
|
145 IMPORT_C TInt CompareValue( const CCFContextObject& aContext ) const; |
|
146 |
|
147 /** |
|
148 * Compares two context objects based on their type. |
|
149 * |
|
150 * @since S60 5.0 |
|
151 * @param aFirst A context object to be compared with aSecond. |
|
152 * @param aSecond A context object to be compared with aFirst. |
|
153 * @return Positive if aFirst is greater than aSecond. Negative if aFirst |
|
154 * is less than aSecond. Zero if both have the same length and |
|
155 * the their contents are the same. |
|
156 */ |
|
157 IMPORT_C static TInt CompareByType( const CCFContextObject& aFirst, |
|
158 const CCFContextObject& aSecond ); |
|
159 |
|
160 /** |
|
161 * Compares two context objects based on their type and source. |
|
162 * |
|
163 * @since S60 5.0 |
|
164 * @param aFirst A context object to be compared with aSecond. |
|
165 * @param aSecond A context object to be compared with aFirst. |
|
166 * @return Positive if aFirst is greater than aSecond. Negative if aFirst |
|
167 * is less than aSecond. Zero if both have the same length and |
|
168 * the their contents are the same. |
|
169 */ |
|
170 IMPORT_C static TInt CompareByTypeAndSource( |
|
171 const CCFContextObject& aFirst, |
|
172 const CCFContextObject& aSecond ); |
|
173 |
|
174 /** |
|
175 * Compares two context objects based on their time. |
|
176 * |
|
177 * @since S60 5.0 |
|
178 * @param aFirst A context object to be compared with aSecond. |
|
179 * @param aSecond A context object to be compared with aFirst. |
|
180 * @return Positive if aFirst is greater than aSecond. Negative if aFirst |
|
181 * is less than aSecond. Zero if both have the same length and |
|
182 * the their contents are the same. |
|
183 */ |
|
184 IMPORT_C static TInt CompareByTimeDescending( |
|
185 const CCFContextObject& aFirst, |
|
186 const CCFContextObject& aSecond ); |
|
187 |
|
188 /** |
|
189 * Checks whether the two context objects are the same. |
|
190 * Compares all member variables of the two context objects and if all |
|
191 * of them are equal, then the objects are the same. |
|
192 * |
|
193 * @param aFirst A context object to be compared with aSecond. |
|
194 * @param aSecond A context object to be compared with aFirst. |
|
195 * @return ETrue, if the objects are found to be equal. |
|
196 */ |
|
197 IMPORT_C static TBool IsSame( const CCFContextObject& aFirst, |
|
198 const CCFContextObject& aSecond ); |
|
199 |
|
200 private: |
|
201 |
|
202 CCFContextObjectImpl(); |
|
203 void ConstructL( const TDesC& aSource, |
|
204 const TDesC& aType, |
|
205 const TDesC& aValue ); |
|
206 |
|
207 private: // Data |
|
208 |
|
209 /** Source of the context */ |
|
210 HBufC* iSource; |
|
211 |
|
212 /** Type of the context */ |
|
213 HBufC* iType; |
|
214 |
|
215 /** iValue of the context */ |
|
216 HBufC* iValue; |
|
217 |
|
218 /** Time stamp */ |
|
219 TTime iTimestamp; |
|
220 |
|
221 /** Confidence of the context */ |
|
222 TUint iConfidence; |
|
223 }; |
|
224 |
|
225 #endif |