locationlandmarksrefappfors60/Inc/LandmarksDbEventHandler.h
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2004-2005 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:  
       
    15 *     See class description below
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __LANDMARKS_DB_EVENT_HANDLER_H__
       
    21 #define __LANDMARKS_DB_EVENT_HANDLER_H__
       
    22 
       
    23 
       
    24 #include "LandmarksDbObserver.h"
       
    25 #include <e32base.h>
       
    26 #include <EPos_Landmarks.h>
       
    27 
       
    28 
       
    29 class CPosLandmarkDatabase;
       
    30 class MLandmarksDbEventObserver;
       
    31 
       
    32 
       
    33 
       
    34 /**
       
    35 *  In the Landmark reference application there is only one instance of 
       
    36 *  CLandmarksDbEventHandler. It is the only object observing the 
       
    37 *  default landmark database directly. Other objects that want to observe the 
       
    38 *  database must register to this object. When an event occurs this object 
       
    39 *  broadcasts it to all registered observers.
       
    40 */
       
    41 class CLandmarksDbEventHandler : public CActive
       
    42     {
       
    43     public: // Constructors and destructor
       
    44 
       
    45         /**
       
    46         * C++ constructor.
       
    47         *
       
    48         * @param aDb the database to observer
       
    49         */
       
    50         CLandmarksDbEventHandler(
       
    51             CPosLandmarkDatabase& aDb);
       
    52 
       
    53         /**
       
    54         * Destructor.
       
    55         */
       
    56         ~CLandmarksDbEventHandler();
       
    57 
       
    58     public: // New functions
       
    59 
       
    60         /**
       
    61         * AddObserverL registers a db observer.
       
    62         *
       
    63         * @param aObserver the observer to register
       
    64         */
       
    65         void AddObserverL(MLandmarksDbObserver* aObserver);
       
    66 
       
    67     protected: // from CActive
       
    68 
       
    69         /**
       
    70         * Handles an active object’s request completion event.
       
    71         */
       
    72         void RunL();
       
    73 
       
    74         /**
       
    75         * Implements cancellation of an outstanding request.
       
    76         */
       
    77         void DoCancel();
       
    78 
       
    79         /**
       
    80         * Handles a leave occurring in the request completion event 
       
    81         * handler RunL().
       
    82         *
       
    83         * @return KErrNone
       
    84         */
       
    85         TInt RunError(TInt aError);
       
    86 
       
    87     private:
       
    88 
       
    89         /**
       
    90         * Starts observing of db enevs
       
    91         */
       
    92         void ObserveEvents();
       
    93 
       
    94     private:
       
    95 
       
    96         //! The database to observe
       
    97         CPosLandmarkDatabase& iDb;
       
    98 
       
    99         //! A db event to be reported
       
   100         TPosLmEvent iEvent;
       
   101 
       
   102         //! An array of registered observers
       
   103         RPointerArray<MLandmarksDbObserver> iDbObservers;
       
   104 
       
   105     };
       
   106 
       
   107 
       
   108 #endif // __LANDMARKS_DB_EVENT_HANDLER_H__
       
   109