os/ossrv/lowlevellibsandfws/pluginfw/Framework/frame/LoadManager.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/Framework/frame/LoadManager.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,192 @@
     1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +
    1.20 +#ifndef __LOADMANAGER_H__
    1.21 +#define __LOADMANAGER_H__
    1.22 +
    1.23 +#include <e32base.h>
    1.24 +#include <ecom/extendedinterfaceimplementationproxy.h>
    1.25 +//Forward declarations
    1.26 +class CUnloadPolicy;
    1.27 +
    1.28 +/**
    1.29 +@internalComponent
    1.30 +Represents an instance of an implementation
    1.31 +*/
    1.32 +NONSHARABLE_CLASS(CInstanceInfo): public CBase
    1.33 +	{
    1.34 +public:
    1.35 +	virtual ~CInstanceInfo();
    1.36 +	CUnloadPolicy* UnloadPolicy() {return iUnloadPolicy;};
    1.37 +public:
    1.38 +	virtual TUid ImplementationUid() = 0;
    1.39 +    virtual TProxyExtendedInterfaceGetPtrL ProxyExtendedIntGetPtr() = 0;
    1.40 +    virtual TProxyExtendedInterfaceReleasePtr ProxyExtendedIntReleasePtr() = 0;
    1.41 +    virtual TAny* CreateExtObjectL(const TUid& aExtendedInterfaceUID) = 0;
    1.42 +    virtual void DestroyExtObject(const TUid& aExtendedInterfaceUID) = 0;
    1.43 +    virtual TAny* ImplementationObject() = 0;
    1.44 +protected:
    1.45 +    CInstanceInfo(CUnloadPolicy* aUnloadPolicy);
    1.46 +private:
    1.47 +   	// The Unload Policy for the dll which contains this implementation
    1.48 +	CUnloadPolicy*	iUnloadPolicy;
    1.49 +	};
    1.50 +
    1.51 +/**
    1.52 +@internalComponent
    1.53 +Represents an instance of a PLUGIN3 type implementation
    1.54 +*/
    1.55 +NONSHARABLE_CLASS(CInstanceInfoExtended): public CInstanceInfo
    1.56 +{
    1.57 +public:
    1.58 +	static CInstanceInfoExtended* NewL(CUnloadPolicy* aUnloadPolicy,const TImplementationProxy3* aRow);
    1.59 +	void SetObject(TAny* aImplementationObject);
    1.60 +	~CInstanceInfoExtended(); // Release all extended objects (if not already released)
    1.61 +public:
    1.62 +    TUid ImplementationUid() {return iImplementationProxyRow->iImplementationUid;};
    1.63 +    TProxyExtendedInterfaceGetPtrL ProxyExtendedIntGetPtr() {return iImplementationProxyRow->iFuncPtrInterfaceGetL;};
    1.64 +    TProxyExtendedInterfaceReleasePtr ProxyExtendedIntReleasePtr() {return iImplementationProxyRow->iFuncPtrInterfaceRelease;};
    1.65 +    TAny* CreateExtObjectL(const TUid& aExtendedInterfaceUID);
    1.66 +    void DestroyExtObject(const TUid& aExtendedInterfaceUID);
    1.67 +    TAny* ImplementationObject() {return iImplementationObject;};
    1.68 +private:
    1.69 +	CInstanceInfoExtended(CUnloadPolicy* aUnloadPolicy,const TImplementationProxy3* aImplementationProxyRow);
    1.70 +private:
    1.71 +   // Pointer to proxy implementation table row entry that this instance corresponds to.
    1.72 +   // This is where the implementation UID, get and release extended interface function
    1.73 +   // pointers reside.
    1.74 +   const TImplementationProxy3* iImplementationProxyRow;
    1.75 +   // The instantiation interface object for the dll which contains this implementation
    1.76 +   TAny*	iImplementationObject;
    1.77 +   // The created extended object information structure.
    1.78 +   struct TExtendedObjectInfo
    1.79 +	   {
    1.80 +	   // The extended interface UID
    1.81 +       TUid    iExtendedInterfaceUID;
    1.82 +	   // The extended interface object for the this implementation
    1.83 +	   TAny*   iExtendedInterfaceObject;
    1.84 +	   };
    1.85 +
    1.86 +    // List of all of the created extended objects for this implementation
    1.87 +	RArray<TExtendedObjectInfo> iExtendedObjectInfo;
    1.88 +
    1.89 +	// Friend classes
    1.90 +	friend class TLoadManager_StateAccessor;
    1.91 +};
    1.92 +
    1.93 +/**
    1.94 +@internalComponent
    1.95 +Represents an instance of a PLUGIN1 type implementation
    1.96 +*/
    1.97 +NONSHARABLE_CLASS(CInstanceInfoSimple): public CInstanceInfo
    1.98 +{
    1.99 +public:
   1.100 +	static CInstanceInfoSimple* NewL(CUnloadPolicy* aUnloadPolicy,const TImplementationProxy* aImplementationProxyRow);
   1.101 +public:
   1.102 +    TUid ImplementationUid() {return iImplementationProxyRow->iImplementationUid;};
   1.103 +	// The following functions are not required for CInstanceInfoSimple.
   1.104 +	// PLUGIN1 type is not meant to extend interfaces.  	
   1.105 +  	TProxyExtendedInterfaceGetPtrL ProxyExtendedIntGetPtr(){return NULL;};
   1.106 + 	TProxyExtendedInterfaceReleasePtr ProxyExtendedIntReleasePtr(){return NULL;};
   1.107 + 	TAny* CreateExtObjectL(const TUid& /*aExtendedInterfaceUID*/) {return NULL;};
   1.108 + 	void DestroyExtObject(const TUid& /* aExtendedInterfaceUID*/) {};
   1.109 +	TAny* ImplementationObject() {return NULL;}; 
   1.110 +
   1.111 +private:
   1.112 +	CInstanceInfoSimple(CUnloadPolicy* aUnloadPolicy,const TImplementationProxy* aImplementationProxyRow);
   1.113 +
   1.114 +private:
   1.115 +   // Pointer to proxy implementation table row entry that this instance corresponds to.
   1.116 +   // This is where the implementation UID resides.
   1.117 +   const TImplementationProxy* iImplementationProxyRow;
   1.118 +
   1.119 +};
   1.120 +
   1.121 +/**
   1.122 +@internalComponent
   1.123 +Manages the loading and unloading of interface implementation groupings.
   1.124 +*/
   1.125 +NONSHARABLE_CLASS(CLoadManager) : public CBase
   1.126 +{
   1.127 +public:
   1.128 +	static CLoadManager* NewL();
   1.129 +	~CLoadManager();
   1.130 +	TBool DestroyedThis(TUid aInstanceKey);
   1.131 +
   1.132 +	TBool PolicyArraysEmpty() const ;
   1.133 +	
   1.134 +	TAny* ImplementationObjectL(const TUid& aUniqueImplementationUid,
   1.135 +							   const TEntry& aEntry,
   1.136 +							   TAny* aCreationParameters,
   1.137 +							   TBool aCreationParamsFlag,
   1.138 +							   TUid& aInstanceKey);
   1.139 +
   1.140 +	TAny* GetExtendedInterfaceL(const TUid& aInstanceKey, const TUid& aExtendedInterfaceUid);
   1.141 +	void ManuallyReleaseExtendedInterfaceL(const TUid& aInstanceKey, const TUid& aExtendedInterfaceUid);
   1.142 +	void ClearGarbage();
   1.143 +
   1.144 +	TUid GetImplementationUidL(TUid aInstanceKey);
   1.145 +
   1.146 +private:
   1.147 +	CLoadManager();
   1.148 +
   1.149 +	void GetUnloadPolicy(TUid aUniqueImplementationUid,
   1.150 +						 const TEntry& aEntry,
   1.151 +						 CUnloadPolicy*& aPolicy);
   1.152 +
   1.153 +	template<typename TImpProxy,typename T> TAny* GetNewLPointerAndProxyTableRowL(TUid aUniqueImplementationUid,
   1.154 +										 TImpProxy*& aImplementationTableEntry,
   1.155 +										 const T aProxy);
   1.156 +
   1.157 +	TAny* ImplementationObject1L(const TUid& aUniqueImplementationUid,
   1.158 +						   	     TAny* aCreationParameters,
   1.159 +								 TBool aCreationParamsFlag,
   1.160 +								 TUid& aInstanceKey,
   1.161 +								 CUnloadPolicy* aPolicy,
   1.162 +								 TLibraryFunction& aLibFunctionProxy);
   1.163 +
   1.164 +	TAny* ImplementationObject3L(const TUid& aUniqueImplementationUid,
   1.165 +						   	     TAny* aCreationParameters,
   1.166 +								 TBool aCreationParamsFlag,
   1.167 +								 TUid& aInstanceKey,
   1.168 +								 CUnloadPolicy* aPolicy,
   1.169 +								 TLibraryFunction& aLibFunctionProxy);
   1.170 +
   1.171 +	TAny* ImplementationObjectL(TAny* aCreationParameters,
   1.172 +								TBool aCreationParamsFlag,
   1.173 +								const TAny* aNewLpointer);
   1.174 +
   1.175 +	void CleanupAfterFailure(CUnloadPolicy* aPolicy);
   1.176 +	void Cleanup(CUnloadPolicy* aPolicy);
   1.177 +private:
   1.178 +#ifdef ECOM_TRACE
   1.179 +	/** Instantiation counter for debug trace */
   1.180 +	TInt iDebugInstantiationCounter;
   1.181 +#endif
   1.182 +	/** List of all the UnloadPolicies for objects which have been created */
   1.183 +	RPointerArray<CUnloadPolicy> iAllUnloadPolicies;
   1.184 +	/** Garbage UnloadPolicy which is not in use anymore */
   1.185 +	CUnloadPolicy* iGarbagePolicy;
   1.186 +	// Array of instance information
   1.187 +	RPointerArray<CInstanceInfo> iInstanceInfoList;
   1.188 +
   1.189 +	// Make the test State Accessor a friend
   1.190 +	friend class TLoadManager_StateAccessor;
   1.191 +};
   1.192 +
   1.193 +#include "loadmanager.inl"
   1.194 +
   1.195 +#endif //__LOADMANAGER_H__