os/graphics/graphicsdeviceinterface/directgdiinterface/inc/directgdipanics.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicsdeviceinterface/directgdiinterface/inc/directgdipanics.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,99 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Panic and logging functions common to both the DirectGDI adaptation layer and
    1.18 +// associated modules/interfaces.
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +#ifndef DIRECTGDIPANICS_H
    1.23 +#define DIRECTGDIPANICS_H
    1.24 +
    1.25 +#include <graphics/directgdipanics.inl>
    1.26 +#include <e32cmn.h>
    1.27 +
    1.28 +
    1.29 +/**
    1.30 +@publishedPartner
    1.31 +@prototype
    1.32 +*/
    1.33 +
    1.34 +#ifndef SYMBIAN_PANIC_CATEGORY
    1.35 +#error SYMBIAN_PANIC_CATEGORY not defined.
    1.36 +#endif
    1.37 +
    1.38 +/** Helper macros for the assert and panic macros.
    1.39 + */
    1.40 +#define GRAPHICS_SOURCE_FILENAME(sourceFileName)	_LIT(KSourceFileName, sourceFileName);
    1.41 +#define GRAPHICS_ASSERT_CONDITION(condition)		_LIT(KPanicCondition, condition);
    1.42 +#define GRAPHICS_LOG_MESSAGE(literalMessage)		_LIT(KLogMessage, # literalMessage);
    1.43 +
    1.44 +#define GRAPHICS_ASSERT_ALWAYS(condition, panicCode) \
    1.45 +			if (!(condition)) \
    1.46 +				{ \
    1.47 +				GRAPHICS_SOURCE_FILENAME(__FILE__); \
    1.48 +				GRAPHICS_ASSERT_CONDITION(#condition); \
    1.49 +				DirectGdi::PanicWithDebugLog(SYMBIAN_PANIC_CATEGORY, panicCode, KSourceFileName, __LINE__, &KPanicCondition); \
    1.50 +				}
    1.51 +
    1.52 +#define GRAPHICS_PANIC_ALWAYS(panicCode) \
    1.53 +		{ \
    1.54 +		GRAPHICS_SOURCE_FILENAME(__FILE__); \
    1.55 +		DirectGdi::PanicWithDebugLog(SYMBIAN_PANIC_CATEGORY, panicCode, KSourceFileName, __LINE__, NULL); \
    1.56 +		}
    1.57 +
    1.58 +#define GRAPHICS_LOG_ALWAYS(message) \
    1.59 +		{ \
    1.60 +		GRAPHICS_SOURCE_FILENAME(__FILE__);\
    1.61 +		GRAPHICS_LOG_MESSAGE(message); \
    1.62 +		DirectGdi::Log(KSourceFileName, __LINE__, KLogMessage); \
    1.63 +		}
    1.64 +
    1.65 +#define GRAPHICS_LOGD_ALWAYS(message) \
    1.66 +	{ \
    1.67 +	GRAPHICS_SOURCE_FILENAME(__FILE__);\
    1.68 +	DirectGdi::Log(KSourceFileName, __LINE__, message); \
    1.69 +	} 
    1.70 +
    1.71 +/**
    1.72 +Define "debug only" macros ONLY when this is a debug build.
    1.73 +*/
    1.74 +#ifdef _DEBUG
    1.75 +	#define GRAPHICS_LOG_DEBUG(literalMessage)			GRAPHICS_LOG_ALWAYS(literalMessage)	 // Paste parameter literally to log
    1.76 +	#define GRAPHICS_LOGD_DEBUG(TDesCRefMessage)			GRAPHICS_LOGD_ALWAYS(TDesCRefMessage) // Treat message as const TDesC&
    1.77 +	#define GRAPHICS_ASSERT_DEBUG(condition, panicCode) 	GRAPHICS_ASSERT_ALWAYS(condition, panicCode)
    1.78 +	#define GRAPHICS_PANIC_DEBUG(panicCode)				GRAPHICS_PANIC_ALWAYS(panicCode)
    1.79 +#else
    1.80 +	#define GRAPHICS_LOG_DEBUG(literalMessage)
    1.81 +	#define GRAPHICS_LOGD_DEBUG(TDesCRefMessage)
    1.82 +	#define GRAPHICS_ASSERT_DEBUG(condition, panicCode)
    1.83 +    #define GRAPHICS_PANIC_DEBUG(panicCode)
    1.84 +#endif // _DEBUG
    1.85 +
    1.86 +
    1.87 +// Cannot enable DirectGDI calltrace unless in debug mode.
    1.88 +#ifndef _DEBUG
    1.89 +#undef ENABLE_DIRECTGDI_CALLTRACE
    1.90 +#endif
    1.91 +
    1.92 +#ifdef ENABLE_DIRECTGDI_CALLTRACE
    1.93 +	#define GRAPHICS_TRACE(functionName)				RDebug::Print(_L(functionName));
    1.94 +	#define GRAPHICS_TRACE1(functionName, p)		    RDebug::Printf(functionName, p);
    1.95 +	#define GRAPHICS_TRACE2(functionName, p1, p2)		RDebug::Printf(functionName, p1, p2);
    1.96 +#else
    1.97 +	#define GRAPHICS_TRACE(functionName)
    1.98 +	#define GRAPHICS_TRACE1(functionName, p)
    1.99 +	#define GRAPHICS_TRACE2(functionName, p1, p2)
   1.100 +#endif 
   1.101 +
   1.102 +#endif // DIRECTGDIPANICS_H