S60 3rd Edition SDK for Symbian OS
Example Applications Guide

LandmarksCategoriesEngine.h

00001 /*
00002 * ==============================================================================
00003 *  Name        : LandmarksCategoriesEngine.h
00004 *  Part of     : Landmark Reference Application
00005 *  Interface   : -
00006 *  Description : See class description below
00007 *  Version     : 1.0
00008 *
00009 *  Copyright (c) 2004-2006 Nokia Corporation.
00010 *  This material, including documentation and any related 
00011 *  computer programs, is protected by copyright controlled by 
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 #ifndef __LANDMARKS_CATEGORIES_ENGINE_H__
00017 #define __LANDMARKS_CATEGORIES_ENGINE_H__
00018 
00019 // INCLUDES
00020 #include "LandmarksEngineBase.h"
00021 #include "LandmarksOperationObserver.h"
00022 
00023 // FORWARD DECLARATIONS
00024 class CPosLmCategoryManager;
00025 class CPosLandmarkCategory;
00026 class CPosLandmarkDatabase;
00027 class CPosLmItemIterator;
00028 
00029 // CLASS DECLARATION
00030 
00031 /**
00032 *  Implements all functions of the engine related to categories. This engine 
00033 *  servs the categories view.
00034 */
00035 class CLandmarksCategoriesEngine : public CLandmarksEngineBase
00036     {
00037     public: // Constructors and destructor
00038 
00039         /**
00040         * Two-phased constructor.
00041         *
00042         * @param aDb an instance of the default landmark database
00043         */
00044         static CLandmarksCategoriesEngine* NewL(CPosLandmarkDatabase& aDb);
00045 
00046         /**
00047         * Destructor.
00048         */
00049         ~CLandmarksCategoriesEngine();
00050 
00051     public: // New functions
00052 
00053         /**
00054         * AddCategoryL adds a category to the database.
00055         *
00056         * @param aCategory the landmark to add
00057         */
00058         void AddCategoryL(CPosLandmarkCategory& aCategory);
00059 
00060         /**
00061         * UpdateCategoryL updates a category in the database.
00062         *
00063         * @param aCategory the landmark to update
00064         */
00065         void UpdateCategoryL(const CPosLandmarkCategory& aCategory);
00066 
00067         /**
00068         * DeleteCategoryL deletes a category.
00069         *
00070         * @param aItemId the itemId identifying the category to be deleted
00071         */
00072         void DeleteCategoryL(TPosLmItemId aItemId);
00073 
00074         /**
00075         * CategoryLC reads a category in the default landmark database.
00076         * Ownership of the returned category is transferred to the caller. 
00077         * 
00078         * @param aItemId the ItemId identifying the category
00079         * @return a category
00080         */
00081         CPosLandmarkCategory* CategoryLC(TPosLmItemId aItemId);
00082 
00083         /**
00084         * StartSearchingCategoriesL starts an asynchronous search operation for
00085         * categories. When the search completes the supplied observer is 
00086         * notified and it is supposed to fetch the matches by calling 
00087         * @ref FetchCategorySearchResult. All categoiries in the database are 
00088         * returned.
00089         * 
00090         * @param aObserver the observer that is notified when the search 
00091         * operation completes
00092         */
00093         void StartSearchingCategoriesL(
00094             MLandmarksOperationObserver* aObserver);
00095 
00096         /**
00097         * StartSearchingCategoriesL starts an asynchronous search operation for
00098         * categories. The names of the categories are used as criterion for a
00099         * match. When the search completes the supplied observer is notified 
00100         * and it is supposed to fetch the matches by calling 
00101         * @ref FetchLandmarkSearchResult.
00102         * 
00103         * @param aSearchPattern search pattern to compare landmarks against
00104         * @param aSearchOnlyInPreviousMatches boolean indicating that only
00105         * previous matches should be searched
00106         * @param aObserver the observer that is notified when the search 
00107         * operation completes
00108         */
00109         void StartSearchingCategoriesL(
00110             const TDesC& aSearchPattern,
00111             TBool aSearchOnlyInPreviousMatches,
00112             MLandmarksOperationObserver* aObserver);
00113 
00114         /**
00115         * FetchSearchResultL should be called after a successful 
00116         * category search operation. It returns the matches from the 
00117         * previous category search operation. Ownership of the returned array 
00118         * is kept by this class.
00119         * 
00120         * @return an array containing matches from a previous categories search
00121         * operation
00122         */
00123         RArray<TPosLmItemId>* FetchSearchResult();
00124 
00125         /**
00126         * StartReadingCategoriesL should be called after a successful 
00127         * category search operation. It continously reads a number of 
00128         * categories until all landmarks found in a previous search operation 
00129         * are read. The method is asynchronous and every time a number of 
00130         * categories are read the supplied observer is notified. 
00131         * @ref FetchLandmarksLC should be called to fetch the read categories.
00132         *
00133         * @param aNrOfItemsToReadPerBundle the number of categories to read 
00134         * before notifying the supplied observer
00135         * @param aObserver the observer that is notified every time a bundle of 
00136         * categories are read
00137         */
00138         void StartReadingCategoriesL(
00139             TInt aNrOfItemsToReadPerBundle,
00140             MLandmarksOperationObserver* aObserver);
00141 
00142         /**
00143         * FetchCategoriesLC should be called after a successful category read
00144         * operation. It returns the categories that were read during a
00145         * preceding landmark read operation. Ownership of the returned array 
00146         * is transferred to the caller.
00147         *
00148         * @return an array containing partially read landmarks from a previous 
00149         * read operation
00150         */
00151         CArrayPtr<CPosLandmarkCategory>* FetchCategoriesLC();
00152 
00153         /**
00154         * CategoriesL reads all categories in the default database 
00155         * synchronously.Ownership of the returned array is transferred 
00156         * to the caller.
00157         *
00158         * @return an array containing all categories in the database.
00159         */
00160         CArrayPtr<CPosLandmarkCategory>* CategoriesL();
00161 
00162     protected: // From CActive
00163 
00164         /**
00165         * Handles an active object’s request completion event.
00166         */
00167         void RunL();
00168 
00169         /**
00170         * Implements cancellation of an outstanding request.
00171         */
00172         void DoCancel();
00173 
00174         /**
00175         * Handles a leave occurring in the request completion event 
00176         * handler RunL().
00177         *
00178         * @return KErrNone
00179         */
00180         TInt RunError(TInt aError);
00181 
00182     private: // New functions
00183 
00184         /**
00185         * C++ constructor.
00186         *
00187         * @param aDb an instance of the default landmark database
00188         */
00189         CLandmarksCategoriesEngine(CPosLandmarkDatabase& aDb);
00190 
00191         /**
00192         * By default Symbian 2nd phase constructor is private.
00193         */
00194         void ConstructL();
00195 
00196         /**
00197         * ReadSomeLandmarksL reads a number of categories. The number of 
00198         * categories is specified when initiating an asynchronous categories 
00199         * read operation.
00200         */
00201         void ReadSomeCategoriesL();
00202 
00203         /**
00204         * NotifyOperationReadyL notifies the observer of an asynchronous 
00205         * operation that the operation has completed.
00206         *
00207         * @param aOperation the kind of operation that is finished
00208         * @param aErrorCode the complete code the operation returned
00209         */
00210         void NotifyOperationReadyL(TOperation aOperation, TInt aErrorCode);
00211 
00212         /**
00213         * Fetches the matches after a search operation and populates the data 
00214         * member @ref iItemIds
00215         */
00216         void PopulateItemIdArrayL();
00217 
00218     private: // Data
00219 
00220         //! provides access to categories in the default database
00221         CPosLmCategoryManager* iCatManager;
00222 
00223         //! an array containing the item Ids of the last search
00224         RArray<TPosLmItemId> iItemIds;
00225 
00226         /** represents a subset of a search result. Used when 
00227             reading categories */
00228         RArray<TPosLmItemId> iSubSetOfIds;
00229 
00230         /** the observer to notify the progress of asynchronous 
00231             operations */
00232         MLandmarksOperationObserver* iObserver;
00233 
00234         //! keeps track of which type of operation is executed
00235         TOperation iActiveOperation;
00236 
00237         //! keeps track of which item to read
00238         TInt iCurrentItemId;
00239 
00240         //! keeps track of how many items to read per bundle
00241         TInt iNrOfItemsToRead;
00242 
00243         /** indicates if there is any previous result to 
00244             search */
00245         TBool iSearchResultExists;
00246 
00247         /** indicates if the current search operation has 
00248             carried out with or without search pattern */
00249         TBool iFilterSearch;
00250 
00251     };
00252 
00253 
00254 #endif // __LANDMARKS_CATEGORIES_ENGINE_H__
00255 
00256 // End of File
00257 

© Nokia 2006

Back to top