memana/analyzetoolclient/kerneleventhandler/inc/analyzetooleventhandler.h
changeset 2 6a82cd05fb1e
parent 1 3ff3fecb12fe
equal deleted inserted replaced
1:3ff3fecb12fe 2:6a82cd05fb1e
     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         * @return TInt Returns KErrNone, if successful
       
    62         			   otherwise one of the other system-wide error codes
       
    63         */
       
    64 		void InformLibraryEvent( TRequestStatus* aStatus, 
       
    65 								 TAny* aLibraryInfo,
       
    66 								 TThreadMessage& aMessage );
       
    67         
       
    68         /**
       
    69         * Cancels subscribetion of the library event.
       
    70         */
       
    71 		void CancelInformLibraryEvent();
       
    72 
       
    73         /**
       
    74         * Static function for DFC events.
       
    75         * @param aPtr Pointer to DAnalyzeToolEventHandler object. 
       
    76         */
       
    77 	    static void EventDfc( TAny* aPtr );
       
    78 		
       
    79 	private:
       
    80 	
       
    81         /**
       
    82         * Pointer to  callback function called when an event occurs.
       
    83         * @param aEvent Designates what event is dispatched.
       
    84         * @param a1 Event-specific paramenter.
       
    85         * @param a2 Event-specific paramenter.
       
    86         * @param aThis A pointer to the event handler
       
    87         * @return TUint Bitmask returned by callback function.
       
    88         */
       
    89 		static TUint EventHandler( TKernelEvent aEvent, 
       
    90 								   TAny* a1, 
       
    91 								   TAny* a2, 
       
    92 								   TAny* aThis );
       
    93 	
       
    94 	private:
       
    95 	
       
    96         /**
       
    97         * Handles the EEventAddLibrary and EEventRemoveLibrary events
       
    98         * @param aLib* A pointer to added/removed library.
       
    99         * @param aThread* A pointer to thread where the libary is.
       
   100         * @param aInfo* A reference class to be written to the client
       
   101         */	
       
   102 		void HandleLibraryEvent( DLibrary* aLib, 
       
   103 								 DThread* aThread, 
       
   104 								 TLibraryEventInfo& aInfo );
       
   105 		
       
   106 		/**
       
   107 		* Handles the EEventKillThread events
       
   108 		* @param aThread* A pointer to the thread being terminated. 
       
   109 		* @param aInfo* A reference class
       
   110 		*/	
       
   111 		void HandleKillThreadEvent( DThread* aThread, 
       
   112 									TLibraryEventInfo& aInfo );
       
   113 		
       
   114 		/**
       
   115 		* Informs client about the occured event
       
   116 		*/	
       
   117 	    void DoEventComplete();
       
   118 					
       
   119 	private:
       
   120 	
       
   121 		/* Mutex for serializing access to event handler */
       
   122 		DMutex* iHandlerMutex;
       
   123 		
       
   124 		/* Mutex fof serializing access to event handler variables */
       
   125 		DMutex* iDataMutex;		
       
   126 		
       
   127 		/* If the client is a RAM-loaded LDD (or PDD), it is possible for the DLL to
       
   128 		be unloaded while the handler is still in use.  This would result in an
       
   129 		exception.  To avoid this, the handler must open a reference to the
       
   130 		DLogicalDevice (or DPhysicalDevice) and close it in its d'tor. */
       
   131 		DLogicalDevice* iDevice;    
       
   132 				
       
   133 		/* Owner process ID */
       
   134 		TUint iProcessId;
       
   135 		
       
   136 		/* Event array */
       
   137 		RArray<TLibraryEventInfo> iEventArray;
       
   138 				
       
   139 		/* Pointer to client's TRequestStatus */ 
       
   140 		TRequestStatus* iClientRequestStatus;
       
   141 		
       
   142 		/* Pointer to client's thread */ 
       
   143 		DThread* iClientThread;
       
   144 
       
   145 		/* Pointer to client's TLibraryEventInfo */ 
       
   146 		TAny* iClientInfo;
       
   147 		
       
   148 		/* DFC for informing events to the client */ 
       
   149 		TDfc iEventDfc;
       
   150 	};
       
   151 	
       
   152 // ----------------------------------------------------------------------------
       
   153 // DAnalyzeToolEventHandler::DAnalyzeToolEventHandler()
       
   154 // C++ default constructor.
       
   155 // ----------------------------------------------------------------------------
       
   156 //
       
   157 inline DAnalyzeToolEventHandler::DAnalyzeToolEventHandler( TDfcQue* aDfcQ ) :	
       
   158 	DKernelEventHandler( EventHandler, this ),
       
   159 	iEventDfc( EventDfc, this, 1 )
       
   160 	{
       
   161 	LOGSTR1( "ATDD DAnalyzeToolEventHandler::DAnalyzeToolEventHandler()" );
       
   162 	iEventDfc.SetDfcQ( aDfcQ );
       
   163 	}
       
   164 
       
   165 #endif // __ANALYZETOOLEVENTHANDLER_H__
       
   166 
       
   167 // End of File