00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
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
00050 #define K_NO_TRACE 0 // Tracing disabled, this level must not
00051
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
00057
00058
00059
00060
00061
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* , ... ) {}
00073
00074 KFBX_DLL bool KIsAssertDisplayed();
00075
00076
00077 #define KAlwaysTrace KTraceFnc
00078
00079
00080 #define KSTRINGITIZE(a) (a)
00081
00082
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
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
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