analyzetool/kerneleventhandler/inc/analyzetooleventhandler.h
branchRCL_3
changeset 13 da2cedce4920
equal deleted inserted replaced
12:d27dfa8884ad 13:da2cedce4920
       
     1 /*
       
     2 * Copyright (c) 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 "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:  Declaration of the class DAnalyzeToolEventHandler.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __ANALYZETOOLEVENTHANDLER_H__
       
    20 #define __ANALYZETOOLEVENTHANDLER_H__
       
    21 
       
    22 // INCLUDES
       
    23 #include <analyzetool/analyzetool.h>
       
    24 #include "atlog.h"
       
    25 #include <kernel/kernel.h>
       
    26 
       
    27 // CLASS DECLARATION
       
    28 
       
    29 /**
       
    30 * Callback class for kernel events
       
    31 */
       
    32 
       
    33 class DAnalyzeToolEventHandler : public DKernelEventHandler
       
    34 	{
       
    35 	public:
       
    36 	
       
    37         /**
       
    38         * C++ default constructor.
       
    39         */
       
    40 		inline DAnalyzeToolEventHandler( TDfcQue* aDfcQ );
       
    41 		
       
    42         /**
       
    43         * Destructor.
       
    44         */ 
       
    45 		~DAnalyzeToolEventHandler();
       
    46 		
       
    47         /**
       
    48         * Second stage constructor.
       
    49         * @param aDevice A pointer to device where the event handler belongs.
       
    50         * @param aProcessId Owner process id.
       
    51         * @return TInt Returns KErrNone, if successful
       
    52         			   otherwise one of the other system-wide error codes
       
    53         */
       
    54 		TInt Create( DLogicalDevice* aDevice, const TUint aProcessId );
       
    55 		
       
    56         /**
       
    57         * Subscribes library event.
       
    58         * @param aStatus The request status object for this request. 
       
    59         * @param aLibraryInfo The library information which 
       
    60         					  is filled by the device driver
       
    61         * @param aMessage Reference to received thread message.
       
    62         * @return TInt Returns KErrNone, if successful
       
    63         			   otherwise one of the other system-wide error codes
       
    64         */
       
    65 		void InformLibraryEvent( TRequestStatus* aStatus, 
       
    66 								 TAny* aLibraryInfo,
       
    67 								 TThreadMessage& aMessage );
       
    68         
       
    69         /**
       
    70         * Cancels subscribetion of the library event.
       
    71         */
       
    72 		void CancelInformLibraryEvent();
       
    73 
       
    74         /**
       
    75         * Static function for DFC events.
       
    76         * @param aPtr Pointer to DAnalyzeToolEventHandler object. 
       
    77         */
       
    78 	    static void EventDfc( TAny* aPtr );
       
    79 		
       
    80 	private:
       
    81 	
       
    82         /**
       
    83         * Pointer to  callback function called when an event occurs.
       
    84         * @param aEvent Designates what event is dispatched.
       
    85         * @param a1 Event-specific paramenter.
       
    86         * @param a2 Event-specific paramenter.
       
    87         * @param aThis A pointer to the event handler
       
    88         * @return TUint Bitmask returned by callback function.
       
    89         */
       
    90 		static TUint EventHandler( TKernelEvent aEvent, 
       
    91 								   TAny* a1, 
       
    92 								   TAny* a2, 
       
    93 								   TAny* aThis );
       
    94 	
       
    95 	private:
       
    96 	
       
    97         /**
       
    98         * Handles the EEventAddLibrary and EEventRemoveLibrary events
       
    99         * @param aLib* A pointer to added/removed library.
       
   100         * @param aThread* A pointer to thread where the libary is.
       
   101         * @param aInfo* A reference class to be written to the client
       
   102         */	
       
   103 		void HandleLibraryEvent( DLibrary* aLib, 
       
   104 								 DThread* aThread, 
       
   105 								 TLibraryEventInfo& aInfo );
       
   106 		
       
   107 		/**
       
   108 		* Handles the EEventKillThread events
       
   109 		* @param aThread* A pointer to the thread being terminated. 
       
   110 		* @param aInfo* A reference class
       
   111 		*/	
       
   112 		void HandleKillThreadEvent( DThread* aThread, 
       
   113 									TLibraryEventInfo& aInfo );
       
   114 		
       
   115 		/**
       
   116 		* Informs client about the occured event
       
   117 		*/	
       
   118 	    void DoEventComplete();
       
   119 					
       
   120 	private:
       
   121 	
       
   122 		/* Mutex for serializing access to event handler */
       
   123 		DMutex* iHandlerMutex;
       
   124 		
       
   125 		/* Mutex fof serializing access to event handler variables */
       
   126 		DMutex* iDataMutex;		
       
   127 		
       
   128 		/* If the client is a RAM-loaded LDD (or PDD), it is possible for the DLL to
       
   129 		be unloaded while the handler is still in use.  This would result in an
       
   130 		exception.  To avoid this, the handler must open a reference to the
       
   131 		DLogicalDevice (or DPhysicalDevice) and close it in its d'tor. */
       
   132 		DLogicalDevice* iDevice;    
       
   133 				
       
   134 		/* Owner process ID */
       
   135 		TUint iProcessId;
       
   136 		
       
   137 		/* Event array */
       
   138 		RArray<TLibraryEventInfo> iEventArray;
       
   139 				
       
   140 		/* Pointer to client's TRequestStatus */ 
       
   141 		TRequestStatus* iClientRequestStatus;
       
   142 		
       
   143 		/* Pointer to client's thread */ 
       
   144 		DThread* iClientThread;
       
   145 
       
   146 		/* Pointer to client's TLibraryEventInfo */ 
       
   147 		TAny* iClientInfo;
       
   148 		
       
   149 		/* DFC for informing events to the client */ 
       
   150 		TDfc iEventDfc;
       
   151 	};
       
   152 	
       
   153 // ----------------------------------------------------------------------------
       
   154 // DAnalyzeToolEventHandler::DAnalyzeToolEventHandler()
       
   155 // C++ default constructor.
       
   156 // ----------------------------------------------------------------------------
       
   157 //
       
   158 inline DAnalyzeToolEventHandler::DAnalyzeToolEventHandler( TDfcQue* aDfcQ ) :	
       
   159 	DKernelEventHandler( EventHandler, this ),
       
   160 	iEventDfc( EventDfc, this, 1 )
       
   161 	{
       
   162 	LOGSTR1( "ATDD DAnalyzeToolEventHandler::DAnalyzeToolEventHandler()" );
       
   163 	iEventDfc.SetDfcQ( aDfcQ );
       
   164 	}
       
   165 
       
   166 #endif // __ANALYZETOOLEVENTHANDLER_H__
       
   167 
       
   168 // End of File