imagehandlinglib/Src/IHLDebugPrint.h
changeset 0 2014ca87e772
child 26 ea43e3e86079
equal deleted inserted replaced
-1:000000000000 0:2014ca87e772
       
     1 /*
       
     2 * Copyright (c) 2006 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:  IHL debug macros
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef IHLDEBUGPRINT_H
       
    20 #define IHLDEBUGPRINT_H
       
    21 
       
    22 // Debug logging is enabled, you may enable debug printing in release builds also
       
    23 #ifdef IHL_ENABLE_DEBUG_PRINT
       
    24 
       
    25     // warn if this is a release build!!
       
    26     #ifndef __WINSCW__
       
    27     #ifndef _DEBUG
       
    28         #if defined(__VC32__)
       
    29             #pragma message( "Warning: IHL debug printing is on in release build!" ) // CSI: 68 #
       
    30         #else // __GCC32__
       
    31             #warning "IHL debug printing is on in release build!"
       
    32         #endif // __VC32__
       
    33     #endif
       
    34     #endif // __WINSCW__
       
    35 
       
    36 // no include files if no debug printing --> faster compile time
       
    37 // INCLUDES
       
    38 #include <e32std.h>
       
    39 #include <e32svr.h>
       
    40 
       
    41     /**
       
    42      * Helper macro for defining debug strings with just the debug text.
       
    43      */
       
    44     #define IHL_DEBUG_STRING(name,s) _LIT(name,s)
       
    45 
       
    46     /**
       
    47      * Output to debugger output
       
    48      */
       
    49     #define IHL_DEBUG_PRINT RDebug::Print
       
    50 
       
    51 #else   // IHL_ENABLE_DEBUG_PRINT
       
    52 
       
    53     /**
       
    54      * Dummy struct for checking that all IHL_DEBUG_PRINT's define string
       
    55      * literals using space-saving IHL_DEBUG_STRING.
       
    56      */
       
    57     struct TIHLEmptyDebugString { }; // CSI: 80 #
       
    58 
       
    59     /**
       
    60      * Macro for defining debug-only literal strings (empty release version)
       
    61      */
       
    62     #define IHL_DEBUG_STRING(name, s) const TIHLEmptyDebugString name
       
    63 
       
    64     /**
       
    65      * Output to debugger output (empty)
       
    66      */
       
    67     #define IHL_DEBUG_PRINT IHL_EmptyPrint
       
    68 
       
    69     namespace {
       
    70 
       
    71     /// Empty debug print function for release builds.
       
    72     inline void IHL_EmptyPrint(TIHLEmptyDebugString)
       
    73         {
       
    74         }
       
    75 
       
    76     /// Empty debug print function for release builds.
       
    77     template<class T1>
       
    78     inline void IHL_EmptyPrint(TIHLEmptyDebugString,T1)
       
    79         {
       
    80         }
       
    81 
       
    82     /// Empty debug print function for release builds.
       
    83     template<class T1,class T2>
       
    84     inline void IHL_EmptyPrint(TIHLEmptyDebugString,T1,T2)
       
    85         {
       
    86         }
       
    87 
       
    88     /// Empty debug print function for release builds.
       
    89     template<class T1,class T2,class T3>
       
    90     inline void IHL_EmptyPrint(TIHLEmptyDebugString,T1,T2,T3)
       
    91         {
       
    92         }
       
    93 
       
    94     /// Empty debug print function for release builds.
       
    95     template<class T1,class T2,class T3,class T4>
       
    96     inline void IHL_EmptyPrint(TIHLEmptyDebugString,T1,T2,T3,T4)
       
    97         {
       
    98         }
       
    99 
       
   100     /// Empty debug print function for release builds.
       
   101     template<class T1,class T2,class T3,class T4,class T5>
       
   102     inline void IHL_EmptyPrint(TIHLEmptyDebugString,T1,T2,T3,T4,T5)
       
   103         {
       
   104         }
       
   105 
       
   106     /// Empty debug print function for release builds.
       
   107     template<class T1,class T2,class T3,class T4,class T5,class T6>
       
   108     inline void IHL_EmptyPrint(TIHLEmptyDebugString,T1,T2,T3,T4,T5,T6)
       
   109         {
       
   110         }
       
   111 
       
   112     /// Empty debug print function for release builds.
       
   113     template<class T1,class T2,class T3,class T4,class T5,class T6,class T7>
       
   114     inline void IHL_EmptyPrint(TIHLEmptyDebugString,T1,T2,T3,T4,T5,T6,T7)
       
   115         {
       
   116         }
       
   117 
       
   118     /// Empty debug print function for release builds.
       
   119     template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8>
       
   120     inline void IHL_EmptyPrint(TIHLEmptyDebugString,T1,T2,T3,T4,T5,T6,T7,T8)
       
   121         {
       
   122         }
       
   123 
       
   124     } // unnamed namespace
       
   125 
       
   126 
       
   127 #endif  // IHL_ENABLE_DEBUG_PRINT
       
   128 
       
   129 /**
       
   130  * Short variant for easier basic usage.
       
   131  */
       
   132 #define IHL_DEBUG1( name, s ) IHL_DEBUG_STRING( name, s ); IHL_DEBUG_PRINT( name );
       
   133 
       
   134 #ifdef IHL_ENABLE_DEBUG_PRINT
       
   135 #define IHL_DEBUG( s ) RDebug::Print( _L( s ) )
       
   136 #define IHL_DEBUG2( name, s, i ) IHL_DEBUG_STRING( name, s ); IHL_DEBUG_PRINT( name, i );
       
   137 #define IHL_DEBUG3( name, s, i, j ) IHL_DEBUG_STRING( name, s ); IHL_DEBUG_PRINT( name, i, j );
       
   138 #define IHL_DEBUG4( name, s, i, j, k ) IHL_DEBUG_STRING( name, s ); IHL_DEBUG_PRINT( name, i, j, k );
       
   139 #define IHL_DEBUG5( name, s, i, j, k, l ) IHL_DEBUG_STRING( name, s ); IHL_DEBUG_PRINT( name, i, j, k, l );
       
   140 #else
       
   141 // If debug printing is not enabled, strip other parameters than the string
       
   142 // away to prevent unwanted function calls in release build.
       
   143 #define IHL_DEBUG( s )
       
   144 #define IHL_DEBUG2( name, s, i ) IHL_DEBUG1( name, s )
       
   145 #define IHL_DEBUG3( name, s, i, j ) IHL_DEBUG1( name, s )
       
   146 #define IHL_DEBUG4( name, s, i, j, k ) IHL_DEBUG1( name, s )
       
   147 #define IHL_DEBUG5( name, s, i, j, k, l ) IHL_DEBUG1( name, s )
       
   148 #endif
       
   149 
       
   150 #endif //  __IHLDEBUGPRINT_H__