graphicsdeviceinterface/directgdiinterface/inc/directgdipanics.inl
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // General inline utility and logging functions for use with DirectGDI.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @publishedPartner
       
    21  @prototype
       
    22 */
       
    23 
       
    24 #ifndef DIRECTGDIPANICS_INL
       
    25 #define DIRECTGDIPANICS_INL
       
    26 
       
    27 #include <e32std.h>
       
    28 #include <e32debug.h>
       
    29 
       
    30 _LIT(KDGDILogFormat, "File %S +%i: %S");
       
    31 _LIT(KDGDINonConditionalPanicFormat, "Panic: %S %i.");
       
    32 _LIT(KDGDIConditionalPanicFormat, "Panic: %S %i, assert \"%S\" failed.");
       
    33 
       
    34 namespace DirectGdi
       
    35 	{
       
    36 
       
    37 /**
       
    38 Helper function used by the GRAPHICS_LOG_ALWAYS and GRAPHICS_LOGD_ALWAYS macros.
       
    39  */
       
    40 inline void Log(const TDesC& aFileName, TInt aLine, const TDesC& aLogMessage)
       
    41 	{
       
    42 	TBuf<256> buf;
       
    43 	buf.Format(KDGDILogFormat, &aFileName, aLine, &aLogMessage);
       
    44 	RDebug::Print(buf);
       
    45 	}
       
    46 
       
    47 /**
       
    48 Helper function used by GRAPHICS_ASSERT_ALWAYS and GRAPHICS_PANIC_ALWAYS macros
       
    49 which allows a panic category and code to be logged.
       
    50  */
       
    51 inline void PanicWithDebugLog (
       
    52 		const TDesC& aPanicCategory, 
       
    53 		TInt aPanicCode,
       
    54 		const TDesC& aFileName,
       
    55 		TInt aLine,
       
    56 		const TDesC* aCondition)
       
    57 	{
       
    58 	TBuf<256> message;
       
    59 
       
    60 	if (aCondition)
       
    61 		{
       
    62 		message.Format(KDGDIConditionalPanicFormat, &aPanicCategory, aPanicCode, aCondition);
       
    63 		}
       
    64 	else
       
    65 		{
       
    66 		message.Format(KDGDINonConditionalPanicFormat, &aPanicCategory, aPanicCode);
       
    67 		}
       
    68 	
       
    69 	Log(aFileName, aLine, message);
       
    70 
       
    71 	User::Panic(aPanicCategory, aPanicCode);
       
    72 	}
       
    73 	}
       
    74 
       
    75 #endif // DIRECTGDIPANICS_INL
       
    76 
       
    77