00001
00004 #ifndef FBXFILESDK_COMPONENTS_KBASELIB_KLIB_KDEBUG_H
00005 #define FBXFILESDK_COMPONENTS_KBASELIB_KLIB_KDEBUG_H
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
00040
00041 #include <fbxfilesdk/fbxfilesdk_def.h>
00042
00043 #include <fbxfilesdk/components/kbaselib/klib/ktime.h>
00044
00045 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00046
00047
00052
00055 #define K_NO_TRACE 0
00056
00059 #define K_ASSERT_ONLY_TRACE 1
00060
00063 #define K_NORMAL_TRACE 3
00064
00067 #define K_ALL_TRACE 4
00068
00073 #define K_DEFAULT_TRACE 20
00074
00076
00077
00078 KFBX_DLL void KRegisterAssertStubFct(int (*pFct)(const char *pFileName, const char *pFunctionName, kULong pLineNumber,
00079 const char *pMessage, bool pAbortEnabled));
00080 KFBX_DLL void* KGetAssertStubFct();
00081 KFBX_DLL void KAssertFailed( const char *pFileName, const char *pFunctionName, kULong pLineNumber, const char *pMessage=NULL,bool *pHideForEver=NULL );
00082 KFBX_DLL void KAssertFailedWithLevel( const char *pFileName, const char *pFunctionName, kULong pLineNumber,
00083 kULong pLevel, const char *pMessage=NULL,bool *pHideForEver=NULL );
00084
00085 KFBX_DLL void ShowLastError( char* pOperation );
00086
00087 KFBX_DLL void KTraceFnc(char* pStr, ... );
00088 inline void KNoTraceFnc( char* , ... ) {}
00089
00090 KFBX_DLL bool KIsAssertDisplayed();
00091
00094 #define KAlwaysTrace KTraceFnc
00095
00098 #define KSTRINGITIZE(a) (a)
00099
00100
00101 #ifdef _DEBUG
00102
00103 #ifndef __MWERKS__
00104 #define __func__ KSTRINGITIZE("")
00105 #endif
00106
00107 #undef KFBX_ASSERT_NAMESPACE
00108
00109 #if !defined(FBXFILESDK_NAMESPACE_USE)
00110 # define KFBX_ASSERT_NAMESPACE(a) a
00111 #else
00112 # define KFBX_ASSERT_NAMESPACE(a) FBXFILESDK_NAMESPACE::a
00113 #endif
00114
00115 #define K_ASSERT( pCondition ) \
00116 if( !(pCondition) )\
00117 {\
00118 static bool sHideForEver=false; \
00119 if (!sHideForEver) KFBX_ASSERT_NAMESPACE(KAssertFailed)( KSTRINGITIZE(__FILE__), __func__, __LINE__, KSTRINGITIZE(#pCondition),&sHideForEver ); \
00120 }((void)0)
00121
00122 #define K_ASSERT_MSG_NOW( pMessage ) \
00123 { \
00124 static bool sHideForEver=false; \
00125 if (!sHideForEver) KFBX_ASSERT_NAMESPACE(KAssertFailed)( KSTRINGITIZE(__FILE__), __func__, __LINE__, pMessage,&sHideForEver ); \
00126 }((void)0)
00127
00128 #define K_ASSERT_MSG( pCondition, pMessage ) \
00129 if( !(pCondition) )\
00130 {\
00131 static bool sHideForEver=false; \
00132 if (!sHideForEver) KFBX_ASSERT_NAMESPACE(KAssertFailed)( KSTRINGITIZE(__FILE__), __func__, __LINE__, pMessage,&sHideForEver ); \
00133 }((void)0)
00134
00135 #define K_ASSERT_MSG_NOT_IMPLEMENTED \
00136 { \
00137 static bool sHideForEver=false; \
00138 if (!sHideForEver) KFBX_ASSERT_NAMESPACE(KAssertFailed)( KSTRINGITIZE(__FILE__), __func__, __LINE__, "Not implemented",&sHideForEver ); \
00139 }((void)0)
00140
00141 template <bool x> struct k_static_assert_type;
00142 template<> struct k_static_assert_type<true> { enum { value = 1 }; };
00143
00144 template<> struct k_static_assert_type<false> { enum { value = -1 }; };
00145
00146 #define K_STATIC_ASSERT( pCondition ) \
00147 typedef char build_break_if_false[ k_static_assert_type<(bool)(pCondition)>::value ];
00148
00149
00150 #define KTrace KTraceFnc
00151
00152
00153 #else
00154 #define K_ASSERT( pCondition ) ((void)0)
00155 #define K_ASSERT_MSG_NOW( pMessage ) ((void)0)
00156 #define K_ASSERT_MSG(pCondition, pMessage ) ((void)0)
00157 #define K_ASSERT_MSG_NOT_IMPLEMENTED ((void)0)
00158 #define K_STATIC_ASSERT( pCondition )
00159
00160 #define KTrace KNoTraceFnc
00161
00162
00163 #endif
00164
00165 struct KDebugTimeEvent {
00166 KTime EventTime;
00167 KTime EventWantedtime;
00168 int Id;
00169 int ToId;
00170 float Color[3];
00171 char InternalComment[52];
00172 int UserId;
00173 char* Comment;
00174 };
00175
00176 enum { KTRACE_SYNC=-1,KTRACE_START=-1,KTRACE_END=-2 };
00177
00178 KFBX_DLL void KTimerTrace_Start();
00179 KFBX_DLL int KTimerTrace_GetId(char* pName, bool pProfile=false);
00180 KFBX_DLL int KTimerTrace (int pId,KTime pTime,KTime pScheduledTime,int LastId,float R,float G,float B,char* pStr,bool pCopy=false);
00181 KFBX_DLL int KTimerPrintf(int pId,KTime pTime,KTime pScheduledTime,int LastId,float R,float G,float B,char* pStr, ...);
00182 KFBX_DLL void KTimerTrace_Stop();
00183 KFBX_DLL void KTimerTrace_Release();
00184 KFBX_DLL int KTimerTrace_GetEventCount();
00185 KFBX_DLL KDebugTimeEvent *KTimerTrace_GetEvent(int pIndex);
00186
00187 KFBX_DLL int KTimerTrace_GetIdCount();
00188 KFBX_DLL char* KTimerTrace_GetIdName(int pId);
00189
00193 #define K_CHECKRTNV( condition, value ) \
00194 if( !(condition) ){ \
00195 K_ASSERT_MSG_NOW( #condition ); \
00196 return value; \
00197 }
00198
00202 #define K_CHECKRTN( condition ) \
00203 if( !(condition) ){ \
00204 K_ASSERT_MSG_NOW( #condition ); \
00205 return; \
00206 }
00207
00208
00209 template<typename T> struct KFbxIncompatibleWithKArrayTemplate {
00210 enum {value = 0};
00211 };
00212
00213
00214 #define KFBX_INCOMPATIBLE_WITH_KARRAYTEMPLATE_TEMPLATE(T) \
00215 struct KFbxIncompatibleWithKArrayTemplate< T > { \
00216 union { \
00217 T t(); \
00218 } catcherr; \
00219 enum {value = 1}; \
00220 }
00221
00222 #define KFBX_INCOMPATIBLE_WITH_KARRAYTEMPLATE(T) \
00223 template<> KFBX_INCOMPATIBLE_WITH_KARRAYTEMPLATE_TEMPLATE(T)
00224
00225
00226 #define KFBX_IS_INCOMPATIBLE_WITH_KARRAYTEMPLATE(T) ((bool) KFbxIncompatibleWithKArrayTemplate<T>::value)
00227
00228
00229 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00230
00231 #endif // FBXFILESDK_COMPONENTS_KBASELIB_KLIB_KDEBUG_H
00232