landmarks/locationlandmarks/server/inc/EPos_CPosLmEventHandler.h
changeset 0 667063e416a2
equal deleted inserted replaced
-1:000000000000 0:667063e416a2
       
     1 /*
       
     2 * Copyright (c) 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: class to handle event notification to subscribers.
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CPOSLMEVENTHANDLER_H
       
    21 #define CPOSLMEVENTHANDLER_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <EPos_Landmarks.h>
       
    26 
       
    27 // CLASS DECLARATION
       
    28 
       
    29 /**
       
    30 * This class handles event notification to subscribers.
       
    31 */
       
    32 class CPosLmEventHandler : public CBase
       
    33     {
       
    34 
       
    35     /**
       
    36     * Specifies which events that should be removed from the event queue in
       
    37     * @p RemoveEvents.
       
    38     */
       
    39     enum TRemoveEventType
       
    40         {
       
    41         ESpecificLandmarks = 0,
       
    42         ESpecificCategories,
       
    43         ENewDefaultDbs
       
    44         };
       
    45 
       
    46     public:  // Constructor & Destructor
       
    47 
       
    48         /**
       
    49         * Two-phased constructor.
       
    50         */
       
    51         static CPosLmEventHandler* NewL();
       
    52 
       
    53         /**
       
    54         * Destructor.
       
    55         */
       
    56         ~CPosLmEventHandler();
       
    57 
       
    58     public:     // New functions
       
    59 
       
    60         /**
       
    61         * If there is at least one event waiting in the event queue, this
       
    62         * message will be completed directly. Otherwise the message will be
       
    63         * put on hold until an event arrives.
       
    64         *
       
    65         * @param aMessagePtr A message.
       
    66         */
       
    67         void HandleRequestForEventL(
       
    68         /* IN */        const RMessagePtr2& aMessage
       
    69         );
       
    70 
       
    71         /**
       
    72         * Called when a landmark operation has generated an event.
       
    73         * If there is a message waiting for an event it will be completed
       
    74         * directly. Otherwise this event will be put in the event queue.
       
    75         *
       
    76         * @param aEvent An event.
       
    77         */
       
    78         void HandleIncomingEventL(
       
    79         /* IN */        TPosLmEvent aEvent
       
    80         );
       
    81 
       
    82         /**
       
    83         * Completes an outstanding event if it exists.
       
    84         *
       
    85         * @param aError The error code to complete with.
       
    86         */
       
    87         void CompleteAnyOutStandingRequest(
       
    88         /* IN */        TInt aError
       
    89         );
       
    90 
       
    91     private:
       
    92 
       
    93         /**
       
    94         * C++ default constructor.
       
    95         */
       
    96         CPosLmEventHandler();
       
    97 
       
    98         void WriteEventAndComplete(
       
    99         /* IN */        const RMessagePtr2& aMessage,
       
   100         /* IN */        TPosLmEvent aEvent
       
   101         );
       
   102 
       
   103         void AddToEventQueueL(
       
   104         /* IN */        TPosLmEvent aEvent
       
   105         );
       
   106 
       
   107         TBool MergeEventsIfPossibleL(
       
   108         /* IN */        TPosLmEvent aEvent
       
   109         );
       
   110 
       
   111         void HandleUnknownEvent(
       
   112         /* IN */        TPosLmEventType aEventInQueue,
       
   113         /* IN */        TBool aExpression,
       
   114         /* IN/OUT */    TBool& aAddEvent,
       
   115         /* IN/OUT */    TInt& aIndex
       
   116         );
       
   117 
       
   118         void HandleSpecificEvent(
       
   119         /* IN */        TPosLmEventType aEventInQueue,
       
   120         /* IN */        TPosLmEventType aCompareEventType,
       
   121         /* IN/OUT */    TBool& aAddEvent,
       
   122         /* IN/OUT */    TInt& aNoOfSpecificCats,
       
   123         /* IN/OUT */    TInt& aNoOfSpecificLms
       
   124         );
       
   125 
       
   126         TBool IsSpecificLandmark(
       
   127         /* IN */        TPosLmEventType aEventType
       
   128         );
       
   129 
       
   130         TBool IsSpecificCategory(
       
   131         /* IN */        TPosLmEventType aEventType
       
   132         );
       
   133 
       
   134         /**
       
   135         * Removes events of a specified type from the queue.
       
   136         *
       
   137         * @param aRemoveType A type of events to remove from the queue.
       
   138         * @param aQueuePosition Holds the queue position where the first
       
   139         *   occurrence of the event type was found. Set to KErrNotFound if
       
   140         *   no events was found. Note: the event at that position was removed,
       
   141         *   but another event may have been moved to that position.
       
   142         */
       
   143         void RemoveEvents(
       
   144         /* IN */        TRemoveEventType aRemoveType,
       
   145         /* OUT */       TInt& aQueuePosition
       
   146         );
       
   147 
       
   148         // By default, prohibit copy constructor
       
   149         CPosLmEventHandler( const CPosLmEventHandler& );
       
   150         // Prohibit assigment operator
       
   151         CPosLmEventHandler& operator= ( const CPosLmEventHandler& );
       
   152 
       
   153     private:    // Data
       
   154 
       
   155         RArray<TPosLmEvent> iEventQueue;
       
   156         RMessagePtr2 iHoldingMessage;
       
   157 
       
   158     };
       
   159 
       
   160 #endif  // CPOSLMEVENTHANDLER_H
       
   161 
       
   162 // End of File