windowing/windowserver/graphicsresourcewrapper/graphicsresourcewrapper.h
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2008-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 // graphicsresourcewrapper.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __GRAPHICSRESOURCEWRAPPER_H__
       
    19 #define __GRAPHICSRESOURCEWRAPPER_H__
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <graphics/sgresource.h>
       
    23 
       
    24 class CGraphicsResourceWrapper;
       
    25 
       
    26 _LIT(KGraphicsResourceWrapperDll, "graphicsresourcewrapper.dll");
       
    27 
       
    28 
       
    29 /**
       
    30 @internalComponent
       
    31 */
       
    32 class CGraphicsResourceWrapperFactory : public CBase
       
    33 	{
       
    34 public:
       
    35 	inline ~CGraphicsResourceWrapperFactory();
       
    36 	inline CGraphicsResourceWrapper* NewGraphicsResourceWrapper();
       
    37 
       
    38 private:
       
    39 	enum { EFactoryMethod = 1 };
       
    40 	RLibrary iLibrary;
       
    41 	TBool iLoaded;
       
    42 	};
       
    43 
       
    44 inline CGraphicsResourceWrapperFactory::~CGraphicsResourceWrapperFactory()
       
    45 	{
       
    46 	if (iLoaded)
       
    47 		iLibrary.Close();
       
    48 	}
       
    49 
       
    50 inline CGraphicsResourceWrapper* CGraphicsResourceWrapperFactory::NewGraphicsResourceWrapper()
       
    51 	{
       
    52 	if (!iLoaded)
       
    53 		{
       
    54 		if (KErrNone == iLibrary.Load(KGraphicsResourceWrapperDll))
       
    55 			iLoaded = ETrue;
       
    56 		else
       
    57 			return NULL;
       
    58 		}
       
    59 
       
    60 	typedef CGraphicsResourceWrapper*(* TFactoryMethod)();
       
    61 	TFactoryMethod f = reinterpret_cast<TFactoryMethod>(iLibrary.Lookup(EFactoryMethod));
       
    62 	if (f)
       
    63 		return f();
       
    64 
       
    65 	return NULL;
       
    66 	}
       
    67 
       
    68 /**
       
    69 A wrapper class around Graphics Resource so that Wserv doesn't need to link
       
    70 against graphics resource.
       
    71 
       
    72 @internalComponent
       
    73 */
       
    74 class CGraphicsResourceWrapper : public CBase
       
    75 	{
       
    76 public:
       
    77 	virtual RSgDrawable* NewDrawableL() = 0;
       
    78 	virtual TInt Open(RSgDrawable& aDrawable, const TSgDrawableId& aDrawableId) = 0;
       
    79 	virtual void Close(RSgDrawable& aDrawable) = 0;
       
    80 	virtual TBool IsNull(const RSgDrawable& aDrawable) = 0;
       
    81 	virtual TSgDrawableId Id(const RSgDrawable& aDrawable) = 0;
       
    82 	};
       
    83 
       
    84 #endif //__GRAPHICSRESOURCEWRAPPER_H__