sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: //
sl@0: 
sl@0: #ifndef WSGCEDEBUGSESSION_H_
sl@0: #define WSGCEDEBUGSESSION_H_
sl@0: 
sl@0: #include <w32std.h>
sl@0: #include <w32debug.h>
sl@0: struct TWsDebugWindowId;
sl@0: 
sl@0: class RWsDebugSession:public RWsSession
sl@0: 	{
sl@0: public:
sl@0: 	RWsDebugSession(TInt aScreenNo = -1);
sl@0: 	~ RWsDebugSession();
sl@0: 	using RWsSession::DebugInfo;		//exposes the following two functions:
sl@0: //	TInt	DebugInfo(TInt aFunction, TInt aParam=0) const;
sl@0: //	TInt	DebugInfo(TInt aFunction, TDes8& aReturnBuf, TInt aParam=0) const;
sl@0: 	
sl@0: 	/**	Returns an array of debug data about the specified object. 
sl@0: 	 *  The data is placed in the aHostBuffer 
sl@0: 	 * 	If data is returned, aReturnedObject points to the start of the returned data, and the return value is the number of DataType objects.
sl@0: 	 * 	If no data is returned, aReturnedObject is NULL.
sl@0: 	 *  If so the return code indicates an error code, or the required number of objects.
sl@0: 	 * 	The object index is specified using the masks and shifts in TWsDebugClassArgMask
sl@0: 	 *  Various error codes may be returned from the server, some of which may simply explain why no data is available.
sl@0: 	 * 	The client may return 
sl@0: 	 * 		KErrCancel to indicate that there is zero length of data
sl@0: 	 * 		KErrCorrupt if the size of the returned data is not an exact multiple of DataType.
sl@0: 	 * 	No other type checking is performed.  
sl@0: 	 **/
sl@0: 	template <class DataType>	// DataType may be TSurfaceId, TInt,TRect, TSurfaceConfiguration (not TRegion)
sl@0: 	TInt	DebugInfo(TWsDebugInfoFunc aFunction, TInt aObjectIndex, TDes8& aHostBuffer,const DataType*&aReturnedObject)const
sl@0: 	{
sl@0: 	return DebugInfo(aFunction,aObjectIndex,aHostBuffer,(const void*&)aReturnedObject,sizeof(DataType));
sl@0: 	}
sl@0: 	/**	Fills the region object with the specified debug information.
sl@0: 	 * 	If required the region is resized to fit the data, which may fail with KErrNoMemory
sl@0: 	 * 	The region will be forced to error state if an error code is returned.
sl@0: 	 * 	Other details: see overloads
sl@0: 	 **/
sl@0: 	TInt	DebugInfo(TWsDebugInfoFunc aFunction, TInt aObjectIndex, TRegion& aPreAllocatedReturnedRegion)const;
sl@0: 	
sl@0: 	/** Indicates the start of a "consistancy-critical-read" section and fetches the window list.
sl@0: 	 * 	Any number of debug commands can be fetched in the section, then client can check if the were interrupted by a server recalculation.
sl@0: 	 **/
sl@0: 	TInt	ResetUpdatedAndGetSurfaceWindowList (const TWsDebugWindowId*&);
sl@0: 	/** Indicates the start or end of a "consistancy-critical-read" section
sl@0: 	 * 	Any number of debug commands can be fetched in the section, then client can check if the were interrupted by a server recalculation.
sl@0: 	 * 	If this method returns ETrue then the data fetched since the start may be inconsistant, and should be refetched.
sl@0: 	 * 	This method may also be used as a dirty way of waiting for a deferred update to occur.
sl@0: 	 **/
sl@0: 	TBool	ResetUpdated();
sl@0: 	/**	Returns the screen number assigned when the stub was created. 
sl@0: 	 **/
sl@0: 	TInt DebugScreenNo()	{	return iScreenNo;	}
sl@0: 	/** Helper method to correctly format the aObjectIndex parameter.
sl@0: 	 **/
sl@0: 	inline TInt ObjInd(TInt aWin=0,TInt aLayer=0,TInt aExtra=0)
sl@0: 		{	return ObjIndScr(iScreenNo,aWin,aLayer,aExtra);	}
sl@0: 	/** Helper method to correctly format the aObjectIndex parameter.
sl@0: 	 **/
sl@0: 	inline TInt ObjIndScr(TInt aScreen,TInt aWin=0,TInt aLayer=0,TInt aExtra=0);
sl@0: 	
sl@0: 	inline	TInt Finish(TBool aAndFlush=ETrue)
sl@0: 		{
sl@0: 		if (aAndFlush)
sl@0: 			Flush();
sl@0: 		return RWsSession::Finish();
sl@0: 		}
sl@0: protected:
sl@0: 	// Resolves the template parameter to a size. See overload docs for more info.
sl@0: 	TInt	DebugInfo(TWsDebugInfoFunc aFunction, TInt aObjectIndex, TDes8& aHostBuffer,const void*&aReturnedObject,TInt aSize)const;
sl@0: 	TInt	iScreenNo;
sl@0: 	TInt	iSurfaceUpdateSerial;
sl@0: 	RBuf8	iSurfaceListBuffer;
sl@0: 	};
sl@0: inline TInt RWsDebugSession::ObjIndScr(TInt aScreen,TInt aWin,TInt aLayer,TInt aExtra)
sl@0: 	{
sl@0: 	return 	(aScreen<<EWsDebugArgScreenShift)
sl@0: 		|	(aWin<<EWsDebugArgWindowShift)
sl@0: 		|	(aLayer<<EWsDebugArgLayerShift)
sl@0: 		|	(aExtra<<EWsDebugArgExtraShift);
sl@0: 	}
sl@0: 
sl@0: #endif /*WSGCEDEBUGSESSION_H_*/