os/graphics/graphicsdeviceinterface/directgdiinterface/inc/directgdipanics.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Panic and logging functions common to both the DirectGDI adaptation layer and
sl@0
    15
// associated modules/interfaces.
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
#ifndef DIRECTGDIPANICS_H
sl@0
    20
#define DIRECTGDIPANICS_H
sl@0
    21
sl@0
    22
#include <graphics/directgdipanics.inl>
sl@0
    23
#include <e32cmn.h>
sl@0
    24
sl@0
    25
sl@0
    26
/**
sl@0
    27
@publishedPartner
sl@0
    28
@prototype
sl@0
    29
*/
sl@0
    30
sl@0
    31
#ifndef SYMBIAN_PANIC_CATEGORY
sl@0
    32
#error SYMBIAN_PANIC_CATEGORY not defined.
sl@0
    33
#endif
sl@0
    34
sl@0
    35
/** Helper macros for the assert and panic macros.
sl@0
    36
 */
sl@0
    37
#define GRAPHICS_SOURCE_FILENAME(sourceFileName)	_LIT(KSourceFileName, sourceFileName);
sl@0
    38
#define GRAPHICS_ASSERT_CONDITION(condition)		_LIT(KPanicCondition, condition);
sl@0
    39
#define GRAPHICS_LOG_MESSAGE(literalMessage)		_LIT(KLogMessage, # literalMessage);
sl@0
    40
sl@0
    41
#define GRAPHICS_ASSERT_ALWAYS(condition, panicCode) \
sl@0
    42
			if (!(condition)) \
sl@0
    43
				{ \
sl@0
    44
				GRAPHICS_SOURCE_FILENAME(__FILE__); \
sl@0
    45
				GRAPHICS_ASSERT_CONDITION(#condition); \
sl@0
    46
				DirectGdi::PanicWithDebugLog(SYMBIAN_PANIC_CATEGORY, panicCode, KSourceFileName, __LINE__, &KPanicCondition); \
sl@0
    47
				}
sl@0
    48
sl@0
    49
#define GRAPHICS_PANIC_ALWAYS(panicCode) \
sl@0
    50
		{ \
sl@0
    51
		GRAPHICS_SOURCE_FILENAME(__FILE__); \
sl@0
    52
		DirectGdi::PanicWithDebugLog(SYMBIAN_PANIC_CATEGORY, panicCode, KSourceFileName, __LINE__, NULL); \
sl@0
    53
		}
sl@0
    54
sl@0
    55
#define GRAPHICS_LOG_ALWAYS(message) \
sl@0
    56
		{ \
sl@0
    57
		GRAPHICS_SOURCE_FILENAME(__FILE__);\
sl@0
    58
		GRAPHICS_LOG_MESSAGE(message); \
sl@0
    59
		DirectGdi::Log(KSourceFileName, __LINE__, KLogMessage); \
sl@0
    60
		}
sl@0
    61
sl@0
    62
#define GRAPHICS_LOGD_ALWAYS(message) \
sl@0
    63
	{ \
sl@0
    64
	GRAPHICS_SOURCE_FILENAME(__FILE__);\
sl@0
    65
	DirectGdi::Log(KSourceFileName, __LINE__, message); \
sl@0
    66
	} 
sl@0
    67
sl@0
    68
/**
sl@0
    69
Define "debug only" macros ONLY when this is a debug build.
sl@0
    70
*/
sl@0
    71
#ifdef _DEBUG
sl@0
    72
	#define GRAPHICS_LOG_DEBUG(literalMessage)			GRAPHICS_LOG_ALWAYS(literalMessage)	 // Paste parameter literally to log
sl@0
    73
	#define GRAPHICS_LOGD_DEBUG(TDesCRefMessage)			GRAPHICS_LOGD_ALWAYS(TDesCRefMessage) // Treat message as const TDesC&
sl@0
    74
	#define GRAPHICS_ASSERT_DEBUG(condition, panicCode) 	GRAPHICS_ASSERT_ALWAYS(condition, panicCode)
sl@0
    75
	#define GRAPHICS_PANIC_DEBUG(panicCode)				GRAPHICS_PANIC_ALWAYS(panicCode)
sl@0
    76
#else
sl@0
    77
	#define GRAPHICS_LOG_DEBUG(literalMessage)
sl@0
    78
	#define GRAPHICS_LOGD_DEBUG(TDesCRefMessage)
sl@0
    79
	#define GRAPHICS_ASSERT_DEBUG(condition, panicCode)
sl@0
    80
    #define GRAPHICS_PANIC_DEBUG(panicCode)
sl@0
    81
#endif // _DEBUG
sl@0
    82
sl@0
    83
sl@0
    84
// Cannot enable DirectGDI calltrace unless in debug mode.
sl@0
    85
#ifndef _DEBUG
sl@0
    86
#undef ENABLE_DIRECTGDI_CALLTRACE
sl@0
    87
#endif
sl@0
    88
sl@0
    89
#ifdef ENABLE_DIRECTGDI_CALLTRACE
sl@0
    90
	#define GRAPHICS_TRACE(functionName)				RDebug::Print(_L(functionName));
sl@0
    91
	#define GRAPHICS_TRACE1(functionName, p)		    RDebug::Printf(functionName, p);
sl@0
    92
	#define GRAPHICS_TRACE2(functionName, p1, p2)		RDebug::Printf(functionName, p1, p2);
sl@0
    93
#else
sl@0
    94
	#define GRAPHICS_TRACE(functionName)
sl@0
    95
	#define GRAPHICS_TRACE1(functionName, p)
sl@0
    96
	#define GRAPHICS_TRACE2(functionName, p1, p2)
sl@0
    97
#endif 
sl@0
    98
sl@0
    99
#endif // DIRECTGDIPANICS_H