PECengine/PresenceManager2/SrcCommon/RGenericObserverArray.inl
branchRCL_3
changeset 13 a941bc465d9f
parent 0 094583676ce7
equal deleted inserted replaced
12:6ca72c0fe49a 13:a941bc465d9f
       
     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:  Inline methods for thin templated RGenericObserverArray
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // ================= HELPER CLASS =======================
       
    21 /**
       
    22  * Helper inline class to forward requests
       
    23  * from base mediator (typeless) to type specific
       
    24  * mediator.
       
    25  *
       
    26  * @since 3.0
       
    27  */
       
    28 template< class T >
       
    29 class TGenObserverNotifyMediatorBase : public MGenObserverNotifyMediatorBase
       
    30     {
       
    31     public:
       
    32         inline TGenObserverNotifyMediatorBase( MGenObserverNotifyMediator< T >& aSpecificMediator )
       
    33             : iSpecificMediator( aSpecificMediator ){}
       
    34 
       
    35     private:
       
    36         inline void MediateNotifyL( TAny* aObserverToNotify )
       
    37             { iSpecificMediator.MediateNotifyL( *( static_cast<T*>( aObserverToNotify ) ) ); }
       
    38 
       
    39         inline void MediateNotifyError( TAny* aObserverToNotify, TInt aLeaveError )
       
    40             { iSpecificMediator.MediateNotifyError( *( static_cast<T*>( aObserverToNotify ) ), aLeaveError ); }
       
    41 
       
    42     private:
       
    43         ///< Observer type specific notify mediator, not owned
       
    44         MGenObserverNotifyMediator< T >& iSpecificMediator;
       
    45         };
       
    46 
       
    47 
       
    48 // ================= MEMBER FUNCTIONS =======================
       
    49 // C++ default constructor can NOT contain any code, that
       
    50 // might leave.
       
    51 //
       
    52 template < class T >
       
    53 inline RGenericObserverArray<T >::RGenericObserverArray()
       
    54     {
       
    55     }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // RGenericObserverArray::Close()
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 template < class T >
       
    62 inline void RGenericObserverArray< T >::Close()
       
    63     {
       
    64     RGenericObserverArrayBase::Close();
       
    65     }
       
    66 
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // RGenericObserverArray::AddObserver()
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 template < class T >
       
    73 inline TInt RGenericObserverArray< T >::AddObserver( const T* aObserver )
       
    74     {
       
    75     return RGenericObserverArrayBase::AddObserver( static_cast<const TAny*>( aObserver ) );
       
    76     }
       
    77 
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // RGenericObserverArray::AddObserverL()
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 template < class T >
       
    84 inline void RGenericObserverArray< T >::AddObserverL( const T* aObserver )
       
    85     {
       
    86     User::LeaveIfError( AddObserver( aObserver ) );
       
    87     }
       
    88 
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // RGenericObserverArray::RemoveObserver()
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 template < class T >
       
    95 inline TInt RGenericObserverArray< T >::RemoveObserver( T* aObserver )
       
    96     {
       
    97     return RGenericObserverArrayBase::RemoveObserver( static_cast<TAny*>( aObserver ) );
       
    98     }
       
    99 
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // RGenericObserverArray::Count()
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 template < class T >
       
   106 inline TInt RGenericObserverArray< T >::Count()
       
   107     {
       
   108     return RGenericObserverArrayBase::Count();
       
   109     }
       
   110 
       
   111 
       
   112 // -----------------------------------------------------------------------------
       
   113 // RGenericObserverArray::NotifyObservers()
       
   114 // -----------------------------------------------------------------------------
       
   115 //
       
   116 template < class T >
       
   117 inline void RGenericObserverArray< T >::NotifyObservers( MGenObserverNotifyMediator< T >& aNotifyMediator )
       
   118     {
       
   119     TGenObserverNotifyMediatorBase< T > baseMediator( aNotifyMediator );
       
   120     RGenericObserverArrayBase::NotifyObservers( baseMediator );
       
   121     }
       
   122 
       
   123 
       
   124 
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 // RGenericObserverArray::NotifyErrorObservers()
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 template < class T >
       
   131 inline void RGenericObserverArray< T >::NotifyErrorObservers( MGenObserverNotifyMediator< T >& aNotifyMediator,
       
   132                                                               TInt aError )
       
   133     {
       
   134     TGenObserverNotifyMediatorBase< T > baseMediator( aNotifyMediator );
       
   135     RGenericObserverArrayBase::NotifyErrorObservers( baseMediator, aError );
       
   136     }
       
   137 
       
   138 
       
   139 // -----------------------------------------------------------------------------
       
   140 // RGenericObserverArray::NotifyLoopRunning()
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 template < class T >
       
   144 inline TBool RGenericObserverArray< T >::NotifyLoopRunning() const
       
   145     {
       
   146     return RGenericObserverArrayBase::IsNotifyLoopRunning();
       
   147     }
       
   148 
       
   149 
       
   150 //  End of File
       
   151