S60 3rd Edition SDK for Symbian OS
Example Applications Guide

LandmarksApplicationEngine.h

00001 /*
00002 * ==============================================================================
00003 *  Name        : LandmarksApplicationEngine.h
00004 *  Part of     : Landmark Reference Application
00005 *  Interface   : Application Engine API
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_APPLICATION_ENGINE_H__
00017 #define __LANDMARKS_APPLICATION_ENGINE_H__
00018 
00019 // INCLUDES
00020 #include <e32base.h>
00021 #include <EPos_TPosLmSortPref.h>
00022 
00023 // FORWARD DECLARATIONS
00024 class CPosLandmark;
00025 class CPosLmOperation;
00026 class CPosLandmarkDatabase;
00027 class CPosLandmarkSearch;
00028 class CLandmarksEngine;
00029 class CLandmarksCategoriesEngine;
00030 class CLandmarksDbEventHandler;
00031 class MLandmarksDbObserver;
00032 class MLandmarksOperationObserver;
00033 class CPosLandmarkCategory;
00034 
00035 // CLASS DECLARATION
00036 
00037 /**
00038 *  CLandmarksApplicationEngine provides the main interface to the application 
00039 *  engine component.
00040 *  
00041 *  CLandmarksApplicationEngine is the only engine class UI-components need to 
00042 *  interact with. It uses the default landmark database for reading/writing
00043 *  landmarks and categories.
00044 *
00045 */
00046 class CLandmarksApplicationEngine : public CBase
00047     {
00048     public: // Constructors and destructor
00049 
00050         /**
00051         * Two-phased constructor.
00052         *
00053         * @returns A new instance of this class.
00054         */
00055         static CLandmarksApplicationEngine* NewL();
00056 
00057         /**
00058         * Destructor.
00059         */
00060         ~CLandmarksApplicationEngine();
00061 
00062     public: // New functions
00063 
00064         /**
00065         * NotifyViewActivated notifies the engine which view is in focus. Should
00066         * be called by views when they are activated/deactivated. This makes it
00067         * possible for the engine to prioritize its asynchronous operations.
00068         *
00069         * @param aViewId the TUid identifying the view
00070         * @param aIsActive ETrue if view is active, EFalse otherwise
00071         */
00072         void NotifyViewActivated(TUid aViewId, TBool aIsActive);
00073 
00074         /**
00075         * StartInitializeDbIfNecessaryL indicates if the default database needs
00076         * to be initialised before it can be used. If it needs to be 
00077         * initialized the initialization is started immediately and the 
00078         * supplied observer is notified when initialization is ready.
00079         *
00080         * @param aObserver the observer to be notified when initialization is 
00081         * ready
00082         * @return ETrue if initializing is necessary, EFalse otherwise
00083         */
00084         TBool StartInitializeDbIfNecessaryL(
00085             MLandmarksOperationObserver* aObserver);
00086 
00087         /**
00088         * AddDbObserverL registers the supplied observer as observer of 
00089         * database events.
00090         *
00091         * @param aObserver the observer to be notified when a database event 
00092         * occurs
00093         */
00094         void AddDbObserverL(MLandmarksDbObserver* aObserver);
00095 
00096         // Landmark related functions
00097 
00098         /**
00099         * LandmarkLC reads all fields of a landmark in the default 
00100         * landmark database. Ownership of the returned landmark is transferred
00101         * to the caller.
00102         * 
00103         * @param aItemId the ItemId identifying the landmark
00104         * @return a landmark
00105         */
00106         CPosLandmark* LandmarkLC(TPosLmItemId aItemId);
00107 
00108         /**
00109         * CommitLandmarkL commits a modified landmark.
00110         *
00111         * @param aLandmark the landmark to commit
00112         */
00113         void CommitLandmarkL(const CPosLandmark& aLandmark);
00114 
00115         /**
00116         * DeleteLandmarkL deletes a landmark.
00117         *
00118         * @param aItemId the itemId identifying the landmark to be deleted
00119         */
00120         void DeleteLandmarkL(TPosLmItemId aItemId);
00121 
00122         /**
00123         * AddLandmarkL adds a landmark to the database.
00124         *
00125         * @param aLandmark the landmark to add
00126         */
00127         void AddLandmarkL(CPosLandmark& aLandmark);
00128 
00129         /**
00130         * StartSearchingLandmarksL starts an asynchronous search operation for
00131         * landmarks. When the search completes the supplied observer is 
00132         * notified and it is supposed to fetch the matches by calling 
00133         * @ref FetchLandmarkSearchResult(). All landmarks in the database are 
00134         * returned.
00135         * 
00136         * @param aObserver the observer that is notified when the search 
00137         * operation completes
00138         */
00139         void StartSearchingLandmarksL(
00140             MLandmarksOperationObserver* aObserver);
00141 
00142         /**
00143         * StartSearchingLandmarksL starts an asynchronous search operation for
00144         * landmarks. The names of the landmarks are used as criterion for a 
00145         * match. When the search completes the supplied observer is notified 
00146         * and it is supposed to fetch the matches by calling 
00147         * @ref FetchLandmarkSearchResult().
00148         * 
00149         * @param aSearchPattern search pattern to compare landmarks against
00150         * @param aSearchOnlyInPreviousMatches boolean indicating that only
00151         * previous matches should be searched
00152         * @param aObserver the observer that is notified when the search 
00153         * operation completes
00154         */
00155         void StartSearchingLandmarksL(
00156             const TDesC& aSearchPattern, 
00157             TBool aSearchOnlyInPreviousMatches,
00158             MLandmarksOperationObserver* aObserver);
00159 
00160         /**
00161         * FetchLandmarkSearchResult should be called after a successful 
00162         * landmark search operation. It returns the matches from the 
00163         * previous landmark search operation. Ownership of the returened array
00164         * is kept by this class.
00165         * 
00166         * @return an array containing matches from a previous landmark search
00167         * operation
00168         */
00169         RArray<TPosLmItemId>* FetchLandmarkSearchResult();
00170 
00171         /**
00172         * StartReadingLandmarksL should be called after a successful 
00173         * landmark search operation. It continously reads a number of landmarks 
00174         * partially, i.e. only the name and the icon of the landmarks are read,
00175         * until all landmarks found in a previous search operation are read.  
00176         * The method is asynchronous and every time a number of landmarks are  
00177         * read the supplied observer is notified, @ref FetchLandmarksLC should 
00178         * be called to fetch the read landmarks.
00179         *
00180         * @param aNrOfItemsToReadPerBundle the number of items to read before 
00181         * notifying the supplied observer
00182         * @param aObserver the observer that is notified every time a bundle of 
00183         * landmarks are read
00184         */
00185         void StartReadingLandmarksL(
00186             TInt aNrOfItemsToReadPerBundle,
00187             MLandmarksOperationObserver* aObserver);
00188 
00189         /**
00190         * FetchLandmarksLC should be called after a successful landmark read
00191         * operation. It returns the landmarks that were partially read during a
00192         * preceding landmark read operation. Ownership of the returned array is
00193         * transferred to the caller.
00194         *
00195         * @return an array containing partially read landmarks from a previous 
00196         * read operation
00197         */
00198         CArrayPtr<CPosLandmark>* FetchLandmarksLC();
00199 
00200         // Category related functions
00201 
00202         /**
00203         * CategoryLC reads all fields of a category in the default 
00204         * landmark database. Ownership of the returned category is transferred
00205         * to the caller.
00206         * 
00207         * @param aItemId the ItemId identifying the category
00208         * @return a category
00209         */
00210         CPosLandmarkCategory* CategoryLC(TPosLmItemId aItemId);
00211 
00212         /**
00213         * DeleteCategoryL deletes a category.
00214         *
00215         * @param aItemId the itemId identifying the category to be deleted
00216         */
00217         void DeleteCategoryL(TPosLmItemId aItemId);
00218 
00219         /**
00220         * UpdateCategoryL updates a modified category.
00221         *
00222         * @param aCategory the category to update
00223         */
00224         void UpdateCategoryL(const CPosLandmarkCategory& aCategory);
00225 
00226         /**
00227         * AddCategoryL adds a category to the default database.
00228         *
00229         * @param aCategory the category to add
00230         */
00231         void AddCategoryL(CPosLandmarkCategory& aCategory);
00232 
00233         /**
00234         * StartSearchingCategoriesL starts an asynchronous search operation for
00235         * categories. When the search completes the supplied observer is 
00236         * notified and it is supposed to fetch the matches by calling 
00237         * @ref FetchCategorySearchResult. All categoiries in the database are 
00238         * returned.
00239         * 
00240         * @param aObserver the observer that is notified when the search 
00241         * operation completes
00242         */
00243         void StartSearchingCategoriesL(
00244             MLandmarksOperationObserver* aObserver);
00245 
00246         /**
00247         * StartSearchingCategoriesL starts an asynchronous search operation for
00248         * categories. The names of the categories are used as criterion for a
00249         * match. When the search completes the supplied observer is notified 
00250         * and it is supposed to fetch the matches by calling 
00251         * @ref FetchLandmarkSearchResult().
00252         * 
00253         * @param aSearchPattern search pattern to compare landmarks against
00254         * @param aSearchOnlyInPreviousMatches boolean indicating that only
00255         * previous matches should be searched
00256         * @param aObserver the observer that is notified when the search 
00257         * operation completes
00258         */
00259         void StartSearchingCategoriesL(
00260             const TDesC& aSearchPattern, 
00261             TBool aSearchOnlyInPreviousMatches,
00262             MLandmarksOperationObserver* aObserver);
00263 
00264         /**
00265         * FetchCategorySearchResult should be called after a successful 
00266         * category search operation. It returns the matches from the 
00267         * previous category search operation. Ownership of the returned array
00268         * is kept by this class.
00269         * 
00270         * @return an array containing matches from a previous categories search
00271         * operation
00272         */
00273         RArray<TPosLmItemId>* FetchCategorySearchResult();
00274 
00275         /**
00276         * StartReadingCategoriesL should be called after a successful 
00277         * category search operation. It continously reads a number of 
00278         * categories until all landmarks found in a previous search operation 
00279         * are read. The method is asynchronous and every time a number of 
00280         * categories are read the supplied observer is notified. 
00281         * @ref FetchLandmarksLC should be called to fetch the read categories.
00282         *
00283         * @param aNrOfItemsToReadPerBundle the number of categories to read 
00284         * before notifying the supplied observer
00285         * @param aObserver the observer that is notified every time a bundle of 
00286         * categories are read
00287         */
00288         void StartReadingCategoriesL(
00289             TInt aNrOfItemsToReadPerBundle,
00290             MLandmarksOperationObserver* aObserver);
00291 
00292         /**
00293         * FetchCategoriesLC should be called after a successful category read
00294         * operation. It returns the categories that were read during a
00295         * preceding landmark read operation. Ownership of teh returned array is
00296         * transferred to the caller.
00297         *
00298         * @return an array containing partially read landmarks from a previous 
00299         * read operation
00300         */
00301         CArrayPtr<CPosLandmarkCategory>* FetchCategoriesLC();
00302 
00303         /**
00304         * CategoriesL reads all categories in the default database 
00305         * synchronously. Ownership of the returned array is transferred to the
00306         * caller.
00307         *
00308         * @return an array containing all categories in the database.
00309         */
00310         CArrayPtr<CPosLandmarkCategory>* CategoriesL();
00311 
00312     private:
00313 
00314         /**
00315         * C++ default constructor.
00316         */
00317         CLandmarksApplicationEngine();
00318 
00319         /**
00320         * By default Symbian 2nd phase constructor is private.
00321         */
00322         void ConstructL();
00323 
00324         /**
00325         * CompactIfNeededL compacts the database synchronously if necessary.
00326         */
00327         void CompactIfNeededL();
00328 
00329     private: // Data
00330 
00331         //! Default landmark database
00332         CPosLandmarkDatabase* iDb;
00333 
00334         //! Landmarks engine part
00335         CLandmarksEngine* iLandmarksEngine;
00336 
00337         //! Categories engine part
00338         CLandmarksCategoriesEngine* iCategoriesEngine;
00339 
00340         //! Database event handler
00341         CLandmarksDbEventHandler* iDbEventHandler;
00342 
00343     };
00344 
00345 
00346 #endif // __LANDMARKS_APPLICATION_ENGINE_H__
00347 
00348 // End of File
00349 

© Nokia 2006

Back to top