FBX SDK Reference Guide: kdebug.h Source File
Go to the documentation of this file.
00001 
00005 /**************************************************************************************
00006 
00007  Copyright © 1998 - 2007 Autodesk, Inc. and/or its licensors.
00008  All Rights Reserved.
00009 
00010  The coded instructions, statements, computer programs, and/or related material
00011  (collectively the "Data") in these files contain unpublished information
00012  proprietary to Autodesk, Inc. and/or its licensors, which is protected by
00013  Canada and United States of America federal copyright law and by international
00014  treaties.
00015 
00016  The Data may not be disclosed or distributed to third parties, in whole or in
00017  part, without the prior written consent of Autodesk, Inc. ("Autodesk").
00018 
00019  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00020  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
00021  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR ARISING
00022  BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES OF TITLE,
00023  NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR USE.
00024  WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT WARRANT THAT THE OPERATION
00025  OF THE DATA WILL BE UNINTERRUPTED OR ERROR FREE.
00026 
00027  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
00028  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR EXPENSES
00029  OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE DAMAGES OR OTHER
00030  SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS OF PROFITS, REVENUE
00031  OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR DAMAGES OF ANY KIND),
00032  HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF LIABILITY, WHETHER DERIVED
00033  FROM CONTRACT, TORT (INCLUDING, BUT NOT LIMITED TO, NEGLIGENCE), OR OTHERWISE,
00034  ARISING OUT OF OR RELATING TO THE DATA OR ITS USE OR ANY OTHER PERFORMANCE,
00035  WHETHER OR NOT AUTODESK HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS
00036  OR DAMAGE.
00037 
00038 **************************************************************************************/
00039 #ifndef FBXFILESDK_COMPONENTS_KBASELIB_KLIB_KDEBUG_H
00040 #define FBXFILESDK_COMPONENTS_KBASELIB_KLIB_KDEBUG_H
00041 
00042 #include <fbxfilesdk/components/kbaselib/kbaselib_h.h>
00043 
00044 #include <fbxfilesdk/components/kbaselib/klib/ktime.h>
00045 
00046 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00047 
00048 
00049     // Constants
00050     #define  K_NO_TRACE          0            // Tracing disabled, this level must not 
00051                                             // be used with the KTrace function
00052     #define  K_ASSERT_ONLY_TRACE 1            // Show only assert traces
00053     #define  K_NORMAL_TRACE      3            // Descriptive trace
00054     #define  K_ALL_TRACE         4            // Highly detailled level of trace
00055     #define  K_DEFAULT_TRACE     20           // Default value, K_TRACE_LEVEL 
00056                                             // environment variable is used when
00057                                             // level TraceLevel is set to that value
00058                                             // Never use this value as an argument 
00059                                             // to KTrace
00060 
00061     // Functions prototypes
00062     KFBX_DLL   void KRegisterAssertStubFct(int (*pFct)(const char *pFileName, const char *pFunctionName, kULong pLineNumber, 
00063                                                         const char *pMessage,  bool pAbortEnabled));
00064     KFBX_DLL   void* KGetAssertStubFct();
00065     KFBX_DLL   void KAssertFailed( const char *pFileName, const char *pFunctionName, kULong pLineNumber, const char *pMessage=NULL,bool *pHideForEver=NULL );
00066     KFBX_DLL   void KAssertFailedWithLevel( const char *pFileName, const char *pFunctionName, kULong pLineNumber, 
00067                                             kULong pLevel, const char *pMessage=NULL,bool *pHideForEver=NULL );
00068 
00069     KFBX_DLL   void ShowLastError( char* pOperation );
00070 
00071     KFBX_DLL   void KTraceFnc(char* pStr, ... );
00072     inline void KNoTraceFnc( char* /*pStr*/, ... ) {}
00073 
00074     KFBX_DLL    bool KIsAssertDisplayed();
00075 
00076     // To debug in both Debug and Release, all calls to this function must be removed before shipping.
00077     #define KAlwaysTrace    KTraceFnc
00078 
00079     // Add another indirection level, so that in can work in conjunction with the __FILE__ usage.
00080     #define KSTRINGITIZE(a) (a)
00081 
00082     // Macros
00083     #ifdef _DEBUG
00084 
00085         #ifndef __MWERKS__
00086             #define __func__    KSTRINGITIZE("")
00087         #endif
00088 
00089         #undef KFBX_ASSERT_NAMESPACE
00090 
00091         #if !defined(FBXFILESDK_NAMESPACE_USE)
00092         #   define KFBX_ASSERT_NAMESPACE(a)     a
00093         #else
00094         #   define KFBX_ASSERT_NAMESPACE(a)     FBXFILESDK_NAMESPACE::a
00095         #endif
00096 
00097         #define K_ASSERT( pCondition )   \
00098                             if( !(pCondition) )\
00099                             {\
00100                                 static bool HideForEver=false; \
00101                                 if (!HideForEver) KFBX_ASSERT_NAMESPACE(KAssertFailed)( KSTRINGITIZE(__FILE__), __func__, __LINE__, KSTRINGITIZE(#pCondition),&HideForEver ); \
00102                             }((void)0)
00103 
00104         #define K_ASSERT_MSG_NOW( pMessage )   \
00105                             { \
00106                                 static bool HideForEver=false; \
00107                                 if (!HideForEver) KFBX_ASSERT_NAMESPACE(KAssertFailed)( KSTRINGITIZE(__FILE__), __func__, __LINE__,  pMessage,&HideForEver ); \
00108                             }((void)0)
00109 
00110         #define K_ASSERT_MSG( pCondition, pMessage )   \
00111                             if( !(pCondition) )\
00112                             {\
00113                                 static bool HideForEver=false; \
00114                                 if (!HideForEver) KFBX_ASSERT_NAMESPACE(KAssertFailed)( KSTRINGITIZE(__FILE__), __func__, __LINE__,  pMessage,&HideForEver ); \
00115                             }((void)0)
00116 
00117         #define K_ASSERT_MSG_NOT_IMPLEMENTED \
00118                             { \
00119                                 static bool HideForEver=false; \
00120                                 if (!HideForEver) KFBX_ASSERT_NAMESPACE(KAssertFailed)( KSTRINGITIZE(__FILE__), __func__, __LINE__,  "Not implemented",&HideForEver ); \
00121                             }((void)0)
00122 
00123         // To debug in both Debug only
00124         #define KTrace          KTraceFnc
00125 
00126 
00127     #else
00128         #define K_ASSERT( pCondition )                              ((void)0)
00129         #define K_ASSERT_MSG_NOW( pMessage )                        ((void)0)
00130         #define K_ASSERT_MSG(pCondition,  pMessage )                ((void)0)
00131         #define K_ASSERT_MSG_NOT_IMPLEMENTED                        ((void)0)
00132         // To debug in both Debug only
00133         #define KTrace          KNoTraceFnc
00134 
00135 
00136     #endif    
00137 
00138     struct KDebugTimeEvent {
00139         KTime   EventTime;
00140         KTime   EventWantedtime;
00141         int    Id;
00142         int    ToId;
00143         float  Color[3];
00144         char  InternalComment[52];
00145         int    UserId;
00146         char* Comment;
00147     };
00148 
00149     enum { KTRACE_SYNC=-1,KTRACE_START=-1,KTRACE_END=-2 };
00150 
00151     KFBX_DLL   void KTimerTrace_Init();
00152     KFBX_DLL   void KTimerTrace_Start();
00153     KFBX_DLL   int  KTimerTrace_GetId(char* pName, bool pProfile=false);
00154     KFBX_DLL   int  KTimerTrace (int pId,KTime pTime,KTime pScheduledTime,int LastId,float R,float G,float B,char* pStr,bool pCopy=false);
00155     KFBX_DLL   int  KTimerPrintf(int pId,KTime pTime,KTime pScheduledTime,int LastId,float R,float G,float B,char* pStr, ...);
00156     KFBX_DLL   void KTimerTrace_Stop();
00157     KFBX_DLL   void KTimerTrace_Release();
00158     KFBX_DLL   int   KTimerTrace_GetEventCount();
00159     KFBX_DLL   KDebugTimeEvent *KTimerTrace_GetEvent(int pIndex);
00160 
00161     KFBX_DLL   int      KTimerTrace_GetIdCount();
00162     KFBX_DLL   char* KTimerTrace_GetIdName(int pId);
00163 
00167 #define K_CHECKRTNV( condition, value )     \
00168     if( !(condition) ){                     \
00169         K_ASSERT_MSG_NOW( #condition );     \
00170         return value;                       \
00171     } 
00172 
00176 #define K_CHECKRTN( condition )             \
00177     if( !(condition) ){                     \
00178         K_ASSERT_MSG_NOW( #condition );     \
00179         return;                             \
00180     } 
00181 
00182 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00183 
00184 #endif // FBXFILESDK_COMPONENTS_KBASELIB_KLIB_KDEBUG_H
00185