os/graphics/graphicsutils/commongraphicsheaders/inc/extensioncontainer.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef EXTENSIONCONTAINER_H_
    17 #define EXTENSIONCONTAINER_H_
    18 
    19 class CExtensionContainer:public CBase
    20     {
    21 public:
    22     /** Get Extension Interface.
    23      *  Implemented using the CBase::Extension_() mechanism 
    24      *  Note that the pointer returned is only good for the lifetime of the called CBase derived object.
    25      *  @param  aExtensionId    The GUID/ Well-known ID of the interface
    26      *  @return pointer to the interface or NULL if not available
    27      **/
    28         inline TAny* GetInterface(TUint aExtensionId);
    29     /** Get Extension Interface - templated helper.
    30      *  Resolves the ID and returned pointer based on the class name.
    31      *  Note that the pointer returned is only good for the lifetime of the called CBase derived object.
    32      *  Class name should support ETypeId intergral value, else use non-template version. 
    33      *  @param  MClass  The class of the interface with embedded GUID / Well known ID 
    34      *  @return pointer to the interface or NULL if not available
    35      **/
    36         template <class MClass> MClass* GetInterface()
    37         {
    38             return static_cast<MClass*>(GetInterface(MClass::ETypeId));
    39         }
    40     };
    41 
    42 inline TAny* CExtensionContainer::GetInterface(TUint aExtensionId)
    43     {
    44     TAny*   retVal=NULL;
    45     //Note that extension is intentionally not overloaded in CExtensionContainer
    46     if (this->Extension_(aExtensionId,retVal,NULL)<KErrNone)
    47         {
    48         return NULL;
    49         }
    50     else
    51         {
    52         return retVal;
    53         }
    54     }
    55 
    56 #endif /* EXTENSIONCONTAINER_H_ */