PECengine/PresenceManager2/SrcCommon/GenObserverNotifyMediators.h
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:  Templated notify mediator implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef GENOBSERVERNOTIFYMEDIATORS_H__
       
    19 #define GENOBSERVERNOTIFYMEDIATORS_H__
       
    20 
       
    21 //  INCLUDES
       
    22 #include <E32Std.h>
       
    23 #include "RGenericObserverArray.h"
       
    24 
       
    25 
       
    26 // CLASS DECLARATION
       
    27 /**
       
    28  * Templated notify mediator implementation.
       
    29  *
       
    30  * Suitable for observers which have event and error
       
    31  * functions type:
       
    32  *   - void ObserverClass::EventFuncL( Type1 aArg1,
       
    33  *                                     Type2 aArg2 )
       
    34  *   - void ObserverClass::ErrorFunc( TInt aLeaveError,
       
    35  *                                    Type1 aArg1 )
       
    36  *
       
    37  * Inline functions left to header for clarity.
       
    38  *
       
    39  * @since 3.0
       
    40  */
       
    41 template < class _ObsClass,
       
    42 class _Arg1,
       
    43 class _Arg2 >
       
    44 class TGenNotifyMediator2
       
    45             : public MGenObserverNotifyMediator< _ObsClass >
       
    46     {
       
    47     public: //Constructor
       
    48 
       
    49         explicit TGenNotifyMediator2(
       
    50             void ( _ObsClass::* aEventFuncL )( _Arg1, _Arg2 ),
       
    51             void ( _ObsClass::* aErrorFunc )( TInt, _Arg1 ),
       
    52             _Arg1 aArg1,
       
    53             _Arg2 aArg2 )
       
    54                 : iEventFuncL( aEventFuncL ),
       
    55                 iErrorFunc( aErrorFunc ),
       
    56                 iArg1( aArg1 ),
       
    57                 iArg2( aArg2 )
       
    58             {
       
    59             }
       
    60 
       
    61 
       
    62     private: //From MGenObserverNotifyMediator
       
    63 
       
    64         void MediateNotifyL( _ObsClass& aObserverToNotify )
       
    65             {
       
    66             ( aObserverToNotify.*iEventFuncL )( iArg1, iArg2 );
       
    67             }
       
    68 
       
    69         void MediateNotifyError( _ObsClass& aObserverToNotify,
       
    70                                  TInt aLeaveError )
       
    71             {
       
    72             ( aObserverToNotify.*iErrorFunc )( aLeaveError, iArg1 );
       
    73             }
       
    74 
       
    75 
       
    76     private: //Data
       
    77         //OWN: Event handler function
       
    78         void ( _ObsClass::* iEventFuncL )( _Arg1, _Arg2 );
       
    79 
       
    80         //OWN: Error handler function
       
    81         void ( _ObsClass::* iErrorFunc )( TInt, _Arg1 );
       
    82 
       
    83         //OWN: Templated argument
       
    84         _Arg1 iArg1;
       
    85 
       
    86         //OWN: Templated argument
       
    87         _Arg2 iArg2;
       
    88     };
       
    89 
       
    90 
       
    91 
       
    92 #endif      //GENOBSERVERNOTIFYMEDIATORS_H__
       
    93 
       
    94 
       
    95 //  End of File
       
    96