1 #ifndef SimTK_SimTKCOMMON_STAGE_H_ 2 #define SimTK_SimTKCOMMON_STAGE_H_ 105 operator int()
const {
return level;}
146 case Empty:
return "Empty";
break;
147 case Topology:
return "Topology";
break;
148 case Model:
return "Model";
break;
149 case Instance:
return "Instance";
break;
150 case Time:
return "Time";
break;
151 case Position:
return "Position";
break;
152 case Velocity:
return "Velocity";
break;
153 case Dynamics:
return "Dynamics";
break;
155 case Report:
return "Report";
break;
156 case Infinity:
return "Infinity";
break;
157 default: assert(!
"Stage::getName(): illegal level");
164 if (level >= tooHigh.level)
165 *
this = tooHigh.
prev();
182 namespace Exception {
185 #pragma warning(push) 186 #pragma warning(disable:4996) // don't warn about sprintf, etc. 192 const char* objectType,
193 const char* objectName,
const char* methodName) :
Base(fn,ln)
196 +
" topology has not been realized since the last topological change" 197 " -- you must call realizeTopology() first.");
205 const char* objectType,
206 const char* objectName,
const char* methodName,
208 int stateTopoVersion) :
Base(fn,ln)
210 setMessage(
String(methodName)
211 +
": The given State's Topology stage version number (" 212 +
String(stateTopoVersion)
213 +
") doesn't match the current topology cache version number (" 215 +
") of " +
String(objectType) +
" " +
String(objectName) +
"." 216 +
" That means there has been a topology change to this System since this" 217 " State was created so they are no longer compatible. You should create" 218 " a new State from the System's default State." 219 " (Loopholes exist for advanced users.)");
229 Stage currentStage,
Stage targetStage,
const char* where) :
Base(fn,ln)
231 setMessage(
"Expected stage to be at least " + targetStage.
getName() +
" in " +
String(where)
232 +
" but current stage was " + currentStage.
getName());
240 Stage currentStage,
Stage targetStage,
const char* where) :
Base(fn,ln)
242 setMessage(
"Expected stage to be " + targetStage.
getName() +
" in " +
String(where)
243 +
" but current stage was " + currentStage.
getName());
251 Stage currentStage,
Stage targetStage,
const char* where) :
Base(fn,ln)
253 setMessage(
"Expected stage to be less than " + targetStage.
getName() +
" in " +
String(where)
254 +
" but current stage was " + currentStage.
getName());
264 setMessage(
"Expected (" + lower.
getName() +
" <= stage <= " + upper.
getName() +
") in " +
String(where)
265 +
" but stage was " + currentStage.
getName());
274 StageVersion dependsOnVersion, StageVersion lastCalculatedVersion)
277 setMessage(
"State Cache entry was out of date at Stage " + currentStage.
getName()
278 +
". This entry depends on version " +
String(dependsOnVersion)
279 +
" of Stage " + dependsOn.
getName()
280 +
" but was last updated at version " +
String(lastCalculatedVersion) +
".");
289 int subsystemId,
const char* subsystemName,
290 const char* fmt, ...) :
Base(fn,ln)
295 vsprintf(buf, fmt, args);
296 setMessage(
"Couldn't realize subsystem " +
String(subsystemId)
297 +
"(" +
String(subsystemName) +
") to Stage " 311 { o << g.
getName();
return o; }
319 #define SimTK_REALIZECHECK_ALWAYS(cond,stage,subsysIx,subsysName,msg) \ 320 do{if(!(cond))SimTK_THROW4(SimTK::Exception::RealizeCheckFailed, \ 321 (stage),(subsysIx),(subsysName),(msg)); \ 323 #define SimTK_REALIZECHECK1_ALWAYS(cond,stage,subsysIx,subsysName,msg,a1) \ 324 do{if(!(cond))SimTK_THROW5(SimTK::Exception::RealizeCheckFailed, \ 325 (stage),(subsysIx),(subsysName),(msg),(a1)); \ 327 #define SimTK_REALIZECHECK2_ALWAYS(cond,stage,subsysIx,subsysName,msg,a1,a2)\ 328 do{if(!(cond))SimTK_THROW6(SimTK::Exception::RealizeCheckFailed, \ 329 (stage),(subsysIx),(subsysName),(msg),(a1),(a2)); \ 331 #define SimTK_REALIZECHECK3_ALWAYS(cond,stage,subsysIx,subsysName,msg,a1,a2,a3) \ 332 do{if(!(cond))SimTK_THROW7(SimTK::Exception::RealizeCheckFailed, \ 333 (stage),(subsysIx),(subsysName),(msg),(a1),(a2),(a3)); \ 335 #define SimTK_REALIZECHECK4_ALWAYS(cond,stage,subsysIx,subsysName,msg,a1,a2,a3,a4) \ 336 do{if(!(cond))SimTK_THROW8(SimTK::Exception::RealizeCheckFailed, \ 337 (stage),(subsysIx),(subsysName),(msg),(a1),(a2),(a3),(a4)); \ 339 #define SimTK_REALIZECHECK5_ALWAYS(cond,stage,subsysIx,subsysName,msg,a1,a2,a3,a4,a5) \ 340 do{if(!(cond))SimTK_THROW9(SimTK::Exception::RealizeCheckFailed, \ 341 (stage),(subsysIx),(subsysName),(msg),(a1),(a2),(a3),(a4),(a5)); \ 345 #endif // SimTK_SimTKCOMMON_STAGE_H_ virtual ~RealizeCheckFailed()
Definition: Stage.h:301
Physical parameters set.
Definition: Stage.h:72
bool operator==(Stage other) const
Definition: Stage.h:113
bool operator>(Stage other) const
Definition: Stage.h:117
Modeling choices made.
Definition: Stage.h:71
Stage(Level l)
This is an implicit conversion from Stage::Level to Stage.
Definition: Stage.h:95
Level
Definition: Stage.h:68
RealizeTopologyMustBeCalledFirst(const char *fn, int ln, const char *objectType, const char *objectName, const char *methodName)
Definition: Stage.h:191
virtual ~CacheEntryOutOfDate()
Definition: Stage.h:282
String getName() const
Return a printable name corresponding to the stage level currently stored in this Stage...
Definition: Stage.h:144
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
bool operator!=(Stage other) const
Definition: Stage.h:114
bool operator<=(Stage other) const
Definition: Stage.h:116
Spatial velocities available.
Definition: Stage.h:75
Lower than any legitimate Stage.
Definition: Stage.h:69
Stage operator--(int)
Definition: Stage.h:128
virtual ~RealizeTopologyMustBeCalledFirst()
Definition: Stage.h:199
bool operator<(Level other) const
Definition: Stage.h:109
This class is basically a glorified enumerated type, type-safe and range checked but permitting conve...
Definition: Stage.h:66
bool operator>=(Level other) const
Definition: Stage.h:112
long long StageVersion
This is the type to use for Stage version numbers that get incremented whenever a state variable chan...
Definition: Stage.h:44
bool operator>=(Stage other) const
Definition: Stage.h:118
CacheEntryOutOfDate(const char *fn, int ln, Stage currentStage, Stage dependsOn, StageVersion dependsOnVersion, StageVersion lastCalculatedVersion)
Definition: Stage.h:272
bool operator>(Level other) const
Definition: Stage.h:111
StageIsWrong(const char *fn, int ln, Stage currentStage, Stage targetStage, const char *where)
Definition: Stage.h:239
long long ValueVersion
This is the type to use for state variable version numbers that get incremented whenever a state valu...
Definition: Stage.h:52
void invalidate(Stage tooHigh)
Set this Stage=min(stageNow, tooHigh-1).
Definition: Stage.h:163
bool operator==(Level other) const
Definition: Stage.h:107
virtual ~StageTooHigh()
Definition: Stage.h:256
virtual ~StageIsWrong()
Definition: Stage.h:245
bool operator!=(Level other) const
Definition: Stage.h:108
Report-only quantities evaluated.
Definition: Stage.h:78
System topology realized.
Definition: Stage.h:70
Stage operator++(int)
Definition: Stage.h:126
Forces calculated.
Definition: Stage.h:76
bool isInRuntimeRange() const
Return true if this Stage has one of the meaningful values between Stage::Topology and Stage::Report...
Definition: Stage.h:171
Definition: Exception.h:46
Spatial configuration available.
Definition: Stage.h:74
bool operator<(Stage other) const
Definition: Stage.h:115
Higher than any legitimate Stage.
Definition: Stage.h:79
Stage prev() const
Return the Stage before this one, with Stage::Empty returned if this Stage is already at its lowest v...
Definition: Stage.h:139
For iterating over all stage values.
Definition: Stage.h:81
std::ostream & operator<<(std::ostream &o, const ContactForce &f)
Definition: CompliantContactSubsystem.h:387
Stage()
Default construction gives Stage::Empty.
Definition: Stage.h:93
RealizeCheckFailed(const char *fn, int ln, Stage g, int subsystemId, const char *subsystemName, const char *fmt,...)
Definition: Stage.h:288
const Stage & operator++()
Definition: Stage.h:121
SimTK::String is a plug-compatible std::string replacement (plus some additional functionality) inten...
Definition: String.h:62
Stage next() const
Return the Stage following this one, with Stage::Infinity returned if this Stage is already at its hi...
Definition: Stage.h:134
StageOutOfRange(const char *fn, int ln, Stage lower, Stage currentStage, Stage upper, const char *where)
Definition: Stage.h:261
Mandatory first inclusion for any Simbody source or header file.
Stage(int l)
You can explicitly create a Stage from an int if it is in range.
Definition: Stage.h:100
const Stage & operator--()
Definition: Stage.h:123
StateAndSystemTopologyVersionsMustMatch(const char *fn, int ln, const char *objectType, const char *objectName, const char *methodName, int sysTopoVersion, int stateTopoVersion)
Definition: Stage.h:204
virtual ~StageOutOfRange()
Definition: Stage.h:267
For iterating over meaningful stage values.
Definition: Stage.h:83
StageTooHigh(const char *fn, int ln, Stage currentStage, Stage targetStage, const char *where)
Definition: Stage.h:250
A new time has been realized.
Definition: Stage.h:73
bool operator<=(Level other) const
Definition: Stage.h:110
Accelerations and multipliers calculated.
Definition: Stage.h:77
virtual ~StateAndSystemTopologyVersionsMustMatch()
Definition: Stage.h:221