phonebookengines/VirtualPhonebook/inc/CVPbkEComImplementationsList.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2007-2007 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:  Virtual Phonebook utility for listing ECOM implementations
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CVPBKECOMIMPLEMENTATIONSLIST_H
       
    20 #define CVPBKECOMIMPLEMENTATIONSLIST_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <ecom/ecom.h>
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 
       
    28 /**
       
    29  * Virtual Phonebook utility for listing ECOM implementations
       
    30  *
       
    31  * Lists all ecom implementations according to interface UID.
       
    32  */
       
    33 class CVPbkEComImplementationsListBase : public CBase
       
    34     {
       
    35     public: // Construction and destruction
       
    36         IMPORT_C ~CVPbkEComImplementationsListBase();
       
    37 
       
    38     public: // Interface
       
    39 
       
    40         /**
       
    41          * Create ECOM implementations for aInterfaceUid and give aParam
       
    42          * for them.
       
    43          *
       
    44          * @param aInterfaceUid An ECOM interface UID
       
    45          * @param aParam The parameter for the implementations.
       
    46          */
       
    47         IMPORT_C void LoadImplementationsL( TUid aInterfaceUid, TAny* aParam );
       
    48 
       
    49         /**
       
    50          * Create ECOM implementations for aInterfaceUid and give aParam
       
    51          * for them.
       
    52          *
       
    53          * @param aInterfaceUid An ECOM interface UID
       
    54          * @param aResolverParams parameters for ECOM resolver
       
    55          * @param aParam The parameter for the implementations.
       
    56          */
       
    57         IMPORT_C void LoadImplementationsL( TUid aInterfaceUid,
       
    58                 const TEComResolverParams& aResolverParams, TAny* aParam );
       
    59 
       
    60         /**
       
    61          * Returns the number of implementations in this list.
       
    62          *
       
    63          * @return the number of implementations in this list.
       
    64          */
       
    65         IMPORT_C TInt Count() const;
       
    66 
       
    67         /**
       
    68          * Returns the implementation at position aIndex
       
    69          *
       
    70          * @param aIndex the position of the implemetation.
       
    71          * @return The implementation at position aIndex
       
    72          */
       
    73         IMPORT_C CBase& At( TInt aIndex ) const;
       
    74 
       
    75         /**
       
    76          * Returns the ECOM implementation information for implementation
       
    77          * aImpl or NULL.
       
    78          *
       
    79          * @param aImpl The implementation retrieved using At() in this
       
    80          *              list.
       
    81          * @return The ECOM implementation information for implementation
       
    82          *         aImpl or NULL.
       
    83          */
       
    84         IMPORT_C const CImplementationInformation* FindInfo(
       
    85                 CBase& aImpl ) const;
       
    86 
       
    87     protected: // Interface
       
    88         IMPORT_C CVPbkEComImplementationsListBase();
       
    89 
       
    90     private: // Implementation
       
    91         virtual CBase* CreateImplementationL( TUid aImplementationUid,
       
    92                 TAny* aParam ) = 0;
       
    93         void DoLoadImplementationsL( RImplInfoPtrArray& aImplInfoPtrArray,
       
    94                 TAny* aParam );
       
    95 
       
    96     private: // Data
       
    97         class CEComImpl : public CBase
       
    98             {
       
    99             public:
       
   100                 CEComImpl( CImplementationInformation* aInfo,
       
   101                     CBase* aImpl );
       
   102                 ~CEComImpl();
       
   103                 CImplementationInformation* iInfo;
       
   104                 CBase* iImpl;
       
   105             };
       
   106         RPointerArray<CEComImpl> iImplementations;
       
   107     };
       
   108 
       
   109 /**
       
   110  * A template for a list of type T ECOM implementations.
       
   111  *
       
   112  * An implementation class must be CBase derived class that has a
       
   113  * NewL( TUid aImplementationUid, <ParamT>& aParam )
       
   114  */
       
   115 template<typename T, typename ParamT>
       
   116 NONSHARABLE_CLASS( CVPbkEComImplementationsList )
       
   117         :   public CVPbkEComImplementationsListBase
       
   118     {
       
   119     public: // See documentation from CVPbkEComImplementationsListBase
       
   120         inline void LoadImplementationsL( TUid aInterfaceUid,
       
   121                 ParamT& aParam );
       
   122         inline void LoadImplementationsL( TUid aInterfaceUid,
       
   123                 const TEComResolverParams& aResolverParams, ParamT& aParam );
       
   124         inline TInt Count() const;
       
   125         inline T& At( TInt aIndex ) const;
       
   126         inline const CImplementationInformation* FindInfo( T& aImpl ) const;
       
   127 
       
   128         // From CVPbkEComImplementationsListBase
       
   129         inline CBase* CreateImplementationL( TUid aImplementationUid,
       
   130                 TAny* aParam );
       
   131     };
       
   132 
       
   133 // --------------------------------------------------------------------------
       
   134 // CVPbkEComImplementationsList<T,ParamT>::LoadImplementationsL
       
   135 // --------------------------------------------------------------------------
       
   136 //
       
   137 template<typename T, typename ParamT>
       
   138 inline void CVPbkEComImplementationsList<T,ParamT>::LoadImplementationsL(
       
   139         TUid aInterfaceUid, ParamT& aParam )
       
   140     {
       
   141     CVPbkEComImplementationsListBase::LoadImplementationsL( aInterfaceUid,
       
   142             &aParam );
       
   143     }
       
   144 
       
   145 // --------------------------------------------------------------------------
       
   146 // CVPbkEComImplementationsList<T,ParamT>::LoadImplementationsL
       
   147 // --------------------------------------------------------------------------
       
   148 //
       
   149 template<typename T, typename ParamT>
       
   150 inline void CVPbkEComImplementationsList<T,ParamT>::LoadImplementationsL(
       
   151         TUid aInterfaceUid, const TEComResolverParams& aResolverParams,
       
   152         ParamT& aParam )
       
   153     {
       
   154     CVPbkEComImplementationsListBase::LoadImplementationsL( aInterfaceUid,
       
   155             aResolverParams, &aParam );
       
   156     }
       
   157 
       
   158 // --------------------------------------------------------------------------
       
   159 // CVPbkEComImplementationsList<T,ParamT>::Count
       
   160 // --------------------------------------------------------------------------
       
   161 //
       
   162 template<typename T, typename ParamT>
       
   163 inline TInt CVPbkEComImplementationsList<T,ParamT>::Count() const
       
   164     {
       
   165     return CVPbkEComImplementationsListBase::Count();
       
   166     }
       
   167 
       
   168 // --------------------------------------------------------------------------
       
   169 // CVPbkEComImplementationsList<T,ParamT>::At
       
   170 // --------------------------------------------------------------------------
       
   171 //
       
   172 template<typename T, typename ParamT>
       
   173 inline T& CVPbkEComImplementationsList<T,ParamT>::At( TInt aIndex ) const
       
   174     {
       
   175     return static_cast<T&>( CVPbkEComImplementationsListBase::At( aIndex ));
       
   176     }
       
   177 
       
   178 // --------------------------------------------------------------------------
       
   179 // CVPbkEComImplementationsList<T,ParamT>::FindInfo
       
   180 // --------------------------------------------------------------------------
       
   181 //
       
   182 template<typename T, typename ParamT>
       
   183 const CImplementationInformation*
       
   184         CVPbkEComImplementationsList<T,ParamT>::FindInfo(
       
   185             T& aImpl ) const
       
   186     {
       
   187     return CVPbkEComImplementationsListBase::FindInfo( aImpl );
       
   188     }
       
   189 
       
   190 // --------------------------------------------------------------------------
       
   191 // CVPbkEComImplementationsList<T,ParamT>::CreateImplementationL
       
   192 // --------------------------------------------------------------------------
       
   193 //
       
   194 template<typename T, typename ParamT>
       
   195 inline CBase* CVPbkEComImplementationsList<T,ParamT>::CreateImplementationL(
       
   196         TUid aImplementationUid, TAny* aParam )
       
   197     {
       
   198     return T::NewL( aImplementationUid,
       
   199             *reinterpret_cast<ParamT*>( aParam ) );
       
   200     }
       
   201 
       
   202 #endif // CVPBKECOMIMPLEMENTATIONSLIST_H
       
   203 //End of file
       
   204