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