|
1 /* |
|
2 * Copyright (c) 2004 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: This interface defines a generic data type |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef ALFMODEL_H |
|
22 #define ALFMODEL_H |
|
23 |
|
24 |
|
25 //INCLUDES |
|
26 #include <osn/osncommon.h> |
|
27 #include <osn/osndefines.h> |
|
28 #include <alf/ialfmodel.h> |
|
29 #include <memory> |
|
30 namespace osncore |
|
31 { |
|
32 template <class T> class AlfPtrVector; |
|
33 } |
|
34 namespace std |
|
35 { |
|
36 template <class T> class auto_ptr; |
|
37 } |
|
38 |
|
39 using namespace osncore; |
|
40 using namespace std; |
|
41 |
|
42 namespace Alf |
|
43 { |
|
44 |
|
45 /* Forward declarations*/ |
|
46 class IAlfVariantType; |
|
47 class IAlfModelChangeObserver; |
|
48 class AlfModelOperation; |
|
49 class AlfWidgetImpl; |
|
50 class AlfModelImpl; |
|
51 class IfId; |
|
52 |
|
53 |
|
54 /** @class AlfModel alfmodel.h "alf/alfmodel.h" |
|
55 * Concerete implementation of the IAlfModel |
|
56 * |
|
57 * @interfaces IAlfModel |
|
58 * @lib alfwidgetmodel.lib |
|
59 * @since S60 ?S60_version |
|
60 * @status Draft |
|
61 */ |
|
62 class AlfModel : public IAlfModel |
|
63 { |
|
64 public: |
|
65 |
|
66 /** |
|
67 * Constructor. |
|
68 * @exception std::bad_alloc |
|
69 * |
|
70 * @param aDataSource - datasource from where the model is initialized, |
|
71 * ownership is transferred to the model |
|
72 * @since S60 ?S60_version |
|
73 * @return New object. |
|
74 */ |
|
75 OSN_IMPORT AlfModel( IAlfVariantType* aDataSource); |
|
76 |
|
77 |
|
78 /** |
|
79 * The Default constructor. |
|
80 * |
|
81 * @since S60 ?S60_version |
|
82 */ |
|
83 OSN_IMPORT AlfModel(); |
|
84 |
|
85 /** |
|
86 * Class Destructor. |
|
87 * |
|
88 * @since S60 ?S60_version |
|
89 */ |
|
90 OSN_IMPORT virtual ~AlfModel(); |
|
91 |
|
92 |
|
93 //IAlfModel virtual Methods |
|
94 |
|
95 /** |
|
96 * From IAlfModel. |
|
97 * Add a new observer to be notified of any changes in the model. |
|
98 * |
|
99 * @exception std::bad_alloc |
|
100 * |
|
101 * @since S60 ?S60_version |
|
102 * @param aObserver The model change observer to be added. |
|
103 * |
|
104 * @return void |
|
105 */ |
|
106 OSN_IMPORT virtual void addModelChangeObserver( |
|
107 IAlfModelChangeObserver &aObserver); |
|
108 |
|
109 /** |
|
110 * From IAlfModel. |
|
111 * Remove an observer which is added to get notified of any changes |
|
112 * in the model. |
|
113 * |
|
114 * @since S60 ?S60_version |
|
115 * @param aObserver The model change observer to be removed. |
|
116 * |
|
117 * @return void |
|
118 */ |
|
119 OSN_IMPORT virtual void removeModelChangeObserver( |
|
120 IAlfModelChangeObserver &aObserver); |
|
121 |
|
122 |
|
123 /** |
|
124 * From IAlfModel. |
|
125 * Get the root data object of this model. |
|
126 * |
|
127 * @since S60 ?S60_version |
|
128 * @return The root data object. |
|
129 */ |
|
130 OSN_IMPORT virtual IAlfVariantType* data() const; |
|
131 |
|
132 /** |
|
133 * From IAlfModel. |
|
134 * Clears the Model. |
|
135 * |
|
136 * @since S60 ?S60_version |
|
137 * @return void |
|
138 */ |
|
139 OSN_IMPORT virtual void clearModel(); |
|
140 |
|
141 |
|
142 /** |
|
143 * Api to change the model completely at one short. From IAlfModel |
|
144 * |
|
145 * @since S60 ?S60_version |
|
146 * @param aData The new data. |
|
147 */ |
|
148 OSN_IMPORT void setData(IAlfVariantType* aData); |
|
149 |
|
150 /** |
|
151 * Change a given of data fields in the model . All model change |
|
152 * observers are notified about the change. |
|
153 * @exception osncore::AlfDataException Thrown with the error code |
|
154 * osncore::EInvalidModelOperation when the operation fails. |
|
155 * |
|
156 * @since S60 ?S60_version |
|
157 * @param aNumContainerIndices The number of indices in aContainerIndices. |
|
158 * @param aContainerIndices The container indices to find the correct |
|
159 * location in the data hierarchy. The ownership is transferred. |
|
160 * @param aData - The new data to be set |
|
161 */ |
|
162 OSN_IMPORT void updateData( |
|
163 int aNumContainerIndices, |
|
164 int* aContainerIndices, |
|
165 IAlfVariantType* aData ) ; |
|
166 |
|
167 /** |
|
168 * Add a number of data fields in the model data. All model change |
|
169 * observers are notified about the change. |
|
170 * |
|
171 * @exception osncore::AlfDataException Thrown with the error code |
|
172 * osncore::EInvalidModelOperation when the operation fails. |
|
173 * |
|
174 * @since S60 ?S60_version |
|
175 * @param aNumContainerIndices The number of indices in aContainerIndices. |
|
176 * @param aContainerIndices The container indices to find the correct |
|
177 * location in the data hierarchy. The ownership is transferred. |
|
178 * |
|
179 * @param aData The new data. |
|
180 */ |
|
181 OSN_IMPORT void addData( |
|
182 int aNumContainerIndices, |
|
183 int* aContainerIndices, |
|
184 IAlfVariantType* aData ); |
|
185 |
|
186 /** |
|
187 * Remove a number of data fields in the model data. All model change |
|
188 * observers are notified about the change. |
|
189 * @exception osncore::AlfDataException Thrown with the error code |
|
190 * osncore::EInvalidModelOperation when the operation fails. |
|
191 * |
|
192 * @since S60 ?S60_version |
|
193 * @param aNumContainerIndices The number of indices in aContainerIndices. |
|
194 * @param aContainerIndices The container indices to find the correct |
|
195 * location in the data hierarchy. The ownership is transferred. |
|
196 */ |
|
197 OSN_IMPORT void removeData( |
|
198 int aNumContainerIndices, |
|
199 int* aContainerIndices) ; |
|
200 |
|
201 /** |
|
202 * Api for executing batch operations |
|
203 * |
|
204 * @exception osncore::AlfDataException Thrown with the error code |
|
205 * osncore::EInvalidModelOperation when the operation fails. |
|
206 * |
|
207 * @since S60 ?S60_version |
|
208 * @param aOperationsArray - An RPOinterArray containing the list of |
|
209 * operations to be executed in batch. |
|
210 */ |
|
211 OSN_IMPORT void executeOperations( |
|
212 AlfPtrVector<AlfModelOperation>& aOperationsArray); |
|
213 |
|
214 /** |
|
215 * Api for executing one operation at a Time |
|
216 * |
|
217 * @since S60 ?S60_version |
|
218 * @param aOperation - An Operation to be executed on the model. |
|
219 */ |
|
220 OSN_IMPORT void executeOperation(AlfModelOperation* aOperation); |
|
221 |
|
222 /** |
|
223 * Notifies the observers, that the model has changed. |
|
224 */ |
|
225 OSN_IMPORT void notifyModelChanged(); |
|
226 |
|
227 |
|
228 // from base class IAlfInterfaceBase |
|
229 |
|
230 /** |
|
231 * From IAlfInterfaceBase. |
|
232 * Getter for interfaces provided by the widget classes. |
|
233 * Derived classes should always call the base class method |
|
234 * from the overridden makeInterface. |
|
235 * |
|
236 * @since S60 ?S60_version |
|
237 * @param aType A descriptor to identify the type of the queried interface. |
|
238 * |
|
239 * @return The queried interface, or NULL if the interface is not |
|
240 * supported or available. |
|
241 */ |
|
242 virtual IAlfInterfaceBase* makeInterface( const IfId& aType ); |
|
243 |
|
244 |
|
245 protected: |
|
246 |
|
247 private: |
|
248 /** |
|
249 * Internal addDataL method . |
|
250 * @param aAddOperation - An Addoperation |
|
251 * @since S60 ?S60_version |
|
252 */ |
|
253 void addData(AlfModelOperation* aAddOperation); |
|
254 |
|
255 /** |
|
256 * Internal removeDataL method . |
|
257 * @param aRemoveOperation - A remove operation |
|
258 * @since S60 ?S60_version |
|
259 */ |
|
260 void removeData(AlfModelOperation* aRemoveOperation); |
|
261 |
|
262 /** |
|
263 * Internal updateDataL method . |
|
264 * @param aUpdateOperation - An update operation |
|
265 * @since S60 ?S60_version |
|
266 */ |
|
267 void updateData(AlfModelOperation* aUpdateOperation); |
|
268 |
|
269 private: |
|
270 |
|
271 auto_ptr<AlfModelImpl> mData; |
|
272 |
|
273 }; |
|
274 |
|
275 } // namespace Alf |
|
276 |
|
277 #endif // ALFMODEL_H |