PECengine/PresenceManager2/SrcCommon/RGenericObserverArrayBase.h
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     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:  Generic observer array.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __RGENERICOBSERVERARRAYBASE_H__
       
    19 #define __RGENERICOBSERVERARRAYBASE_H__
       
    20 
       
    21 //  INCLUDES
       
    22 #include <E32Base.h>
       
    23 
       
    24 
       
    25 
       
    26 // CLASS DECLARATION
       
    27 /**
       
    28  * Observer notify mediator base.
       
    29  *
       
    30  * Base interface to manage observer notifications
       
    31  * and notify errors. Typical implementation will
       
    32  * forward notifications to actual type specific
       
    33  * mediator.
       
    34  *
       
    35  * Main idea behind the notify mediator is encapsulate
       
    36  * the observer array management from actual observer
       
    37  * type specific details. (Type specific details will
       
    38  * be implemented by the concrete mediator.) Usage
       
    39  * of mediator base interface allows generic
       
    40  * observer array implementation.
       
    41  *
       
    42  * @since 3.0
       
    43  */
       
    44 class MGenObserverNotifyMediatorBase
       
    45     {
       
    46     public:
       
    47 
       
    48         /**
       
    49          * Observer notification.
       
    50          * This member is internal and not intended for use.
       
    51          */
       
    52         virtual void MediateNotifyL( TAny* aObserverToNotify ) = 0;
       
    53 
       
    54 
       
    55         /**
       
    56          * Observer notification from error.
       
    57          * This member is internal and not intended for use.
       
    58          */
       
    59         virtual void MediateNotifyError( TAny* aObserverToNotify, TInt aLeaveError ) = 0;
       
    60 
       
    61 
       
    62     protected:
       
    63 
       
    64         /**
       
    65          * Protected destructor.
       
    66          */
       
    67         virtual ~MGenObserverNotifyMediatorBase() {}
       
    68     };
       
    69 
       
    70 
       
    71 
       
    72 
       
    73 // CLASS DECLARATION
       
    74 /**
       
    75  * Generic observer array.
       
    76  *
       
    77  * Generic observer array to manage observers
       
    78  * and notify them. Observers are managed as
       
    79  * typeless TAny pointers. Notification is done
       
    80  * trough generic MGenObserverNotifyMediatorBase
       
    81  * notify mediator.
       
    82  *
       
    83  * @since 3.0
       
    84  */
       
    85 NONSHARABLE_CLASS( RGenericObserverArrayBase ) :
       
    86         private RPointerArrayBase   // CSI: 70 #
       
    87     {
       
    88 protected: //protected members for derived classes
       
    89 
       
    90     /**
       
    91      * C++ constructor.
       
    92      * This member is internal and not intended for use.
       
    93      */
       
    94     RGenericObserverArrayBase();
       
    95 
       
    96     /**
       
    97      * Closes the array and frees all memory allocated to it.
       
    98      * This member is internal and not intended for use.
       
    99      */
       
   100     void Close();
       
   101 
       
   102     /**
       
   103      * Adds observer.
       
   104      * This member is internal and not intended for use.
       
   105      */
       
   106     TInt AddObserver( const TAny* aObserver );
       
   107 
       
   108     /**
       
   109      * Removes observer.
       
   110      * This member is internal and not intended for use.
       
   111      */
       
   112     TInt RemoveObserver( const TAny* aObserver );
       
   113 
       
   114     /**
       
   115      * Gets observer count.
       
   116      * This member is internal and not intended for use.
       
   117      */
       
   118     TInt Count();
       
   119 
       
   120     /**
       
   121      * Observer notify implementation.
       
   122      * This member is internal and not intended for use.
       
   123      */
       
   124     void NotifyObservers( MGenObserverNotifyMediatorBase& aNotifyMediator );
       
   125 
       
   126 
       
   127     /**
       
   128      * Observer notify implementation.
       
   129      * This member is internal and not intended for use.
       
   130      */
       
   131     void NotifyErrorObservers( MGenObserverNotifyMediatorBase& aNotifyMediator,
       
   132                                TInt aError );
       
   133 
       
   134     /**
       
   135      * Observer notify implementation.
       
   136      * This member is internal and not intended for use.
       
   137      */
       
   138     TBool IsNotifyLoopRunning() const;
       
   139 
       
   140 
       
   141 private: //private helpers
       
   142 
       
   143     /**
       
   144      * Private helper.
       
   145      * This member is internal and not intended for use.
       
   146      */
       
   147     void FinalizeObsArrayAfterNotifyLoop();
       
   148 
       
   149 
       
   150 private: //Data
       
   151 
       
   152     //OWN: Flag describing the observer array state
       
   153     TBool iNotifyLoopRunning;
       
   154     };
       
   155 
       
   156 #endif      //__RGenericObserverArrayBase_H__
       
   157 //  End of File
       
   158 
       
   159