This file contains macros which are convenient to use for sprinkling error checking around liberally in SimTK programs, a practice which is highly encouraged.
More...
|
#define | SimTK_INDEXCHECK_ALWAYS(ix, ub, where) |
|
#define | SimTK_SIZECHECK_ALWAYS(sz, maxsz, where) |
|
#define | SimTK_SIZECHECK_NONNEG_ALWAYS(sz, where) |
|
#define | SimTK_VALUECHECK_ALWAYS(lb, val, ub, valName, where) |
|
#define | SimTK_VALUECHECK_NONNEG_ALWAYS(val, valName, where) |
|
#define | SimTK_INDEXCHECK(ix, ub, where) SimTK_INDEXCHECK_ALWAYS(ix,ub,where) |
|
#define | SimTK_SIZECHECK(sz, maxsz, where) SimTK_SIZECHECK_ALWAYS(sz,maxsz,where) |
|
#define | SimTK_SIZECHECK_NONNEG(sz, where) SimTK_SIZECHECK_NONNEG_ALWAYS(sz,where) |
|
#define | SimTK_VALUECHECK(lb, val, ub, valName, where) SimTK_VALUECHECK_ALWAYS(lb,val,ub,valName,where) |
|
#define | SimTK_VALUECHECK_NONNEG(val, valName, where) SimTK_VALUECHECK_NONNEG_ALWAYS(val,valName,where) |
|
#define | SimTK_STAGECHECK_TOPOLOGY_REALIZED_ALWAYS(cond, objType, objName, methodNm) |
|
#define | SimTK_STAGECHECK_TOPOLOGY_VERSION_ALWAYS(sysTopoVersion,stateTopoVersion, objType, objName, methodNm) |
|
#define | SimTK_STAGECHECK_EQ_ALWAYS(currentStage, targetStage, methodNm) |
|
#define | SimTK_STAGECHECK_GE_ALWAYS(currentStage, targetStage, methodNm) |
|
#define | SimTK_STAGECHECK_LT_ALWAYS(currentStage, targetStage, methodNm) |
|
#define | SimTK_STAGECHECK_RANGE_ALWAYS(lower, current, upper, methodNm) |
|
#define | SimTK_STAGECHECK_TOPOLOGY_REALIZED(cond, objType, objName, methodName) SimTK_STAGECHECK_TOPOLOGY_REALIZED_ALWAYS(cond,objType,objName,methodName) |
|
#define | SimTK_STAGECHECK_TOPOLOGY_VERSION(sysTopoVersion, stateTopoVersion, objType, objName, methodNm) |
|
#define | SimTK_STAGECHECK_EQ(currentStage, targetStage, methodNm) SimTK_STAGECHECK_EQ_ALWAYS(currentStage,targetStage,methodNm) |
|
#define | SimTK_STAGECHECK_GE(currentStage, targetStage, methodNm) SimTK_STAGECHECK_GE_ALWAYS(currentStage,targetStage,methodNm) |
|
#define | SimTK_STAGECHECK_LT(currentStage, targetStage, methodNm) SimTK_STAGECHECK_LE_ALWAYS(currentStage,targetStage,methodNm) |
|
#define | SimTK_STAGECHECK_RANGE(lower, current, upper, methodNm) SimTK_STAGECHECK_RANGE_ALWAYS(lower,current,upper,methodNm) |
|
#define | SimTK_APIARGCHECK_ALWAYS(cond, className, methodName, msg) |
|
#define | SimTK_APIARGCHECK1_ALWAYS(cond, className, methodName, fmt, a1) |
|
#define | SimTK_APIARGCHECK2_ALWAYS(cond, className, methodName, fmt, a1, a2) |
|
#define | SimTK_APIARGCHECK3_ALWAYS(cond, className, methodName, fmt, a1, a2, a3) |
|
#define | SimTK_APIARGCHECK4_ALWAYS(cond, className, methodName, fmt, a1, a2, a3, a4) |
|
#define | SimTK_APIARGCHECK5_ALWAYS(cond, className, methodName, fmt, a1, a2, a3, a4, a5) |
|
#define | SimTK_APIARGCHECK(cond, className, methodName, msg) SimTK_APIARGCHECK_ALWAYS(cond,className,methodName,msg) |
|
#define | SimTK_APIARGCHECK1(cond, className, methodName, fmt, a1) SimTK_APIARGCHECK1_ALWAYS(cond,className,methodName,fmt,a1) |
|
#define | SimTK_APIARGCHECK2(cond, className, methodName, fmt, a1, a2) SimTK_APIARGCHECK2_ALWAYS(cond,className,methodName,fmt,a1,a2) |
|
#define | SimTK_APIARGCHECK3(cond, className, methodName, fmt, a1, a2, a3) SimTK_APIARGCHECK3_ALWAYS(cond,className,methodName,fmt,a1,a2,a3) |
|
#define | SimTK_APIARGCHECK4(cond, className, methodName, fmt, a1, a2, a3, a4) SimTK_APIARGCHECK4_ALWAYS(cond,className,methodName,fmt,a1,a2,a3,a4) |
|
#define | SimTK_APIARGCHECK5(cond, className, methodName, fmt, a1, a2, a3, a4, a5) SimTK_APIARGCHECK5_ALWAYS(cond,className,methodName,fmt,a1,a2,a3,a4,a5) |
|
#define | SimTK_ERRCHK_ALWAYS(cond, whereChecked, msg) |
|
#define | SimTK_ERRCHK1_ALWAYS(cond, whereChecked, fmt, a1) |
|
#define | SimTK_ERRCHK2_ALWAYS(cond, whereChecked, fmt, a1, a2) |
|
#define | SimTK_ERRCHK3_ALWAYS(cond, whereChecked, fmt, a1, a2, a3) |
|
#define | SimTK_ERRCHK4_ALWAYS(cond, whereChecked, fmt, a1, a2, a3, a4) |
|
#define | SimTK_ERRCHK5_ALWAYS(cond, whereChecked, fmt, a1, a2, a3, a4, a5) |
|
#define | SimTK_ERRCHK6_ALWAYS(cond, whereChecked, fmt, a1, a2, a3, a4, a5, a6) |
|
#define | SimTK_ERRCHK7_ALWAYS(cond, whereChecked, fmt, a1, a2, a3, a4, a5, a6, a7) |
|
#define | SimTK_ERRCHK(cond, whereChecked, msg) SimTK_ERRCHK_ALWAYS(cond,whereChecked,msg) |
|
#define | SimTK_ERRCHK1(cond, whereChecked, fmt, a1) SimTK_ERRCHK1_ALWAYS(cond,whereChecked,fmt,a1) |
|
#define | SimTK_ERRCHK2(cond, whereChecked, fmt, a1, a2) SimTK_ERRCHK2_ALWAYS(cond,whereChecked,fmt,a1,a2) |
|
#define | SimTK_ERRCHK3(cond, whereChecked, fmt, a1, a2, a3) SimTK_ERRCHK3_ALWAYS(cond,whereChecked,fmt,a1,a2,a3) |
|
#define | SimTK_ERRCHK4(cond, whereChecked, fmt, a1, a2, a3, a4) SimTK_ERRCHK4_ALWAYS(cond,whereChecked,fmt,a1,a2,a3,a4) |
|
#define | SimTK_ERRCHK5(cond, whereChecked, fmt, a1, a2, a3, a4, a5) SimTK_ERRCHK5_ALWAYS(cond,whereChecked,fmt,a1,a2,a3,a4,a5) |
|
#define | SimTK_ERRCHK6(cond, whereChecked, fmt, a1, a2, a3, a4, a5, a6) SimTK_ERRCHK6_ALWAYS(cond,whereChecked,fmt,a1,a2,a3,a4,a5,a6) |
|
#define | SimTK_ERRCHK7(cond, whereChecked, fmt, a1, a2, a3, a4, a5, a6, a7) SimTK_ERRCHK7_ALWAYS(cond,whereChecked,fmt,a1,a2,a3,a4,a5,a6,a7) |
|
#define | SimTK_ASSERT_ALWAYS(cond, msg) do{if(!(cond))SimTK_THROW2(SimTK::Exception::Assert,#cond,(msg));}while(false) |
|
#define | SimTK_ASSERT1_ALWAYS(cond, msg, a1) do{if(!(cond))SimTK_THROW3(SimTK::Exception::Assert,#cond,(msg),(a1));}while(false) |
|
#define | SimTK_ASSERT2_ALWAYS(cond, msg, a1, a2) do{if(!(cond))SimTK_THROW4(SimTK::Exception::Assert,#cond,(msg),(a1),(a2));}while(false) |
|
#define | SimTK_ASSERT3_ALWAYS(cond, msg, a1, a2, a3) do{if(!(cond))SimTK_THROW5(SimTK::Exception::Assert,#cond,(msg),(a1),(a2),(a3));}while(false) |
|
#define | SimTK_ASSERT4_ALWAYS(cond, msg, a1, a2, a3, a4) do{if(!(cond))SimTK_THROW6(SimTK::Exception::Assert,#cond,(msg),(a1),(a2),(a3),(a4));}while(false) |
|
#define | SimTK_ASSERT5_ALWAYS(cond, msg, a1, a2, a3, a4, a5) do{if(!(cond))SimTK_THROW7(SimTK::Exception::Assert,#cond,(msg),(a1),(a2),(a3),(a4),(a5));}while(false) |
|
#define | SimTK_ASSERT(cond, msg) SimTK_ASSERT_ALWAYS(cond,msg) |
|
#define | SimTK_ASSERT1(cond, msg, a1) SimTK_ASSERT1_ALWAYS(cond,msg,a1) |
|
#define | SimTK_ASSERT2(cond, msg, a1, a2) SimTK_ASSERT2_ALWAYS(cond,msg,a1,a2) |
|
#define | SimTK_ASSERT3(cond, msg, a1, a2, a3) SimTK_ASSERT3_ALWAYS(cond,msg,a1,a2,a3) |
|
#define | SimTK_ASSERT4(cond, msg, a1, a2, a3, a4) SimTK_ASSERT4_ALWAYS(cond,msg,a1,a2,a3,a4) |
|
#define | SimTK_ASSERT5(cond, msg, a1, a2, a3, a4, a5) SimTK_ASSERT5_ALWAYS(cond,msg,a1,a2,a3,a4,a5) |
|
This file contains macros which are convenient to use for sprinkling error checking around liberally in SimTK programs, a practice which is highly encouraged.
You can think of this as a generalization of the standard assert() macro. By default, these macros evaporate completely in a release build, but are present in any debug build. Macros are also provided which are always present in cases where the error checking is not a performance problem, and those should be used in preference to the disappearing ones when appropriate. Also, you can force the disappearing macros to remain present on a file-by-file basis, primarily for use in debugging those annoying problems which only occur in release builds and won't reproduce in a debug build.
Most macros have a similar structure, something like this:
SimTK_MACRONAME[nargs][_ALWAYS](cond, printfString [, args...])
for example
SimTK_ASSERT3(lower<count && count<upper,
"expected %d < count < %d but count=%d",
lower, upper, count);
or
SimTK_ASSERT3_ALWAYS(lower<count && count<upper,
"expected %d < count < %d but count=%d",
lower, upper, count);
To override the disappearance of the non-ALWAYS macros, your compilation should define a preprocessor symbols like SimTK_KEEP_ASSERT, SimTK_KEEP_ERRCHK, etc.
These macros will also capture the current file name and line number for reporting to developers when appropriate, and those with a condition that failed will include the condition in the message.
Note that these are *global* symbols, so we use the reserved SimTK_ name prefix (since we can't use the SimTK:: namespace for macros) to attempt to avoid pollution of user programs.
We distinguish between macros which are used as internal "bugcatchers" and those which are used to report errors to API users. The C++ exception mechanism is used in both circumstances but the meaning and intended audience is quite different. Any macro with 'ASSERT' in the name represents an internal error which cannot be attributed to user misbehavior. Other macros are for communicating with users. Those need to be carefully documented so that users can selectively catch the exceptions when appropriate.