os/security/authorisation/userpromptservice/inc_private/pluginmanager.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
/**
sl@0
    20
 @file
sl@0
    21
 @internalComponent
sl@0
    22
 @released 
sl@0
    23
*/
sl@0
    24
sl@0
    25
#ifndef PLUGINMANAGER_H
sl@0
    26
#define PLUGINMANAGER_H
sl@0
    27
sl@0
    28
namespace UserPromptService
sl@0
    29
	{	
sl@0
    30
	class CPolicyEvaluator;
sl@0
    31
	class CDialogCreator;
sl@0
    32
	class CPolicyEvaluatorPlugin;
sl@0
    33
	class CDialogCreatorPlugin;
sl@0
    34
	class CPluginManager;
sl@0
    35
	
sl@0
    36
	/**
sl@0
    37
	Container class for a plug-in that notifies a manager object when 
sl@0
    38
	it is destroyed.
sl@0
    39
	*/
sl@0
    40
	template <class T> 
sl@0
    41
		class CPlugin : public CBase
sl@0
    42
			{
sl@0
    43
		public:
sl@0
    44
			CPlugin(CPluginManager* aManager, T* aImp);
sl@0
    45
			T& Imp();
sl@0
    46
			~CPlugin();
sl@0
    47
		private:
sl@0
    48
			CPluginManager* iManager;	///< The plug-in manager that tracks active plug-ins.
sl@0
    49
			T* iImp;					///< The policy evaluator or dialog creator owned by this object.
sl@0
    50
			};
sl@0
    51
			
sl@0
    52
	/**
sl@0
    53
	Plug-in manager that tracks the number of plug-ins enabling REComSession::FinalClose()
sl@0
    54
	to be deferred (after calling Unload) once all the plug-ins have been unloaded.
sl@0
    55
	
sl@0
    56
	N.B. REComSession::FinalClose CANNOT be called from within an ECOM plug-in.	
sl@0
    57
	*/
sl@0
    58
	NONSHARABLE_CLASS(CPluginManager) : public CBase
sl@0
    59
		{
sl@0
    60
		template <class T> friend class CPlugin;
sl@0
    61
	public:
sl@0
    62
		IMPORT_C static CPluginManager* NewL();		
sl@0
    63
		IMPORT_C CPlugin<CPolicyEvaluator>* CreateEvaluatorL(const TUid& aEvaluatorId);
sl@0
    64
		IMPORT_C CPlugin<CDialogCreator>* CreateDialogCreatorL(const TUid& aDialogCreatorId);
sl@0
    65
		IMPORT_C void Unload();	
sl@0
    66
				
sl@0
    67
		~CPluginManager();
sl@0
    68
	public:
sl@0
    69
		// For testing. Do not modify directly
sl@0
    70
		TInt iPluginCount;		///< The number of active CPlugin objects. (do not modify)
sl@0
    71
	private:
sl@0
    72
		CPluginManager();			
sl@0
    73
		IMPORT_C void ReleasePlugin();
sl@0
    74
sl@0
    75
		TBool iUnload;			///< Indicates that a deferred call to REComSession::FinalClose is required		
sl@0
    76
		};	
sl@0
    77
				
sl@0
    78
	template <class T>
sl@0
    79
	inline CPlugin<T>::CPlugin(CPluginManager* aManager, T* aImp) : iManager(aManager), iImp(aImp)	
sl@0
    80
	/**
sl@0
    81
	Constructor
sl@0
    82
	@param aManager	The plug-in manager that tracks the number of plug-ins in existance.
sl@0
    83
	@param aImp		The ECOM implementation that this class managers.
sl@0
    84
	*/
sl@0
    85
		{
sl@0
    86
		}
sl@0
    87
sl@0
    88
	template <class T>
sl@0
    89
	inline T& CPlugin<T>::Imp() 
sl@0
    90
	/**
sl@0
    91
	Gets a reference to the plug-in implementation
sl@0
    92
	@return The plug-in implementation.
sl@0
    93
	*/
sl@0
    94
		{
sl@0
    95
		return *iImp;
sl@0
    96
		}
sl@0
    97
	
sl@0
    98
	template <class T>
sl@0
    99
	inline CPlugin<T>::~CPlugin() 
sl@0
   100
	/**
sl@0
   101
	Destructor
sl@0
   102
	*/
sl@0
   103
		{		
sl@0
   104
		delete iImp;
sl@0
   105
		iManager->ReleasePlugin();
sl@0
   106
		}		
sl@0
   107
	}
sl@0
   108
#endif // PLUGINMANAGER_H