1 #ifndef SimTK_SimTKCOMMON_STAGE_H_
2 #define SimTK_SimTKCOMMON_STAGE_H_
89 operator int()
const {
return level;}
130 case Empty:
return "Empty";
break;
131 case Topology:
return "Topology";
break;
132 case Model:
return "Model";
break;
133 case Instance:
return "Instance";
break;
134 case Time:
return "Time";
break;
135 case Position:
return "Position";
break;
136 case Velocity:
return "Velocity";
break;
137 case Dynamics:
return "Dynamics";
break;
139 case Report:
return "Report";
break;
140 case Infinity:
return "Infinity";
break;
141 default: assert(!
"Stage::getName(): illegal level");
148 if (level >= tooHigh.level)
149 *
this = tooHigh.
prev();
166 namespace Exception {
171 const char* objectType,
172 const char* objectName,
const char* methodName) :
Base(fn,ln)
175 +
" topology has not been realized since the last topological change"
176 " -- you must call realizeTopology() first.");
184 const char* objectType,
185 const char* objectName,
const char* methodName,
187 int stateTopoVersion) :
Base(fn,ln)
190 +
": The given State's Topology stage version number ("
191 +
String(stateTopoVersion)
192 +
") doesn't match the current topology cache version number ("
194 +
") of " +
String(objectType) +
" " +
String(objectName) +
"."
195 +
" That means there has been a topology change to this System since this"
196 " State was created so they are no longer compatible. You should create"
197 " a new State from the System's default State."
198 " (Loopholes exist for advanced users.)");
208 Stage currentStage,
Stage targetStage,
const char* where) :
Base(fn,ln)
211 +
" but current stage was " + currentStage.
getName());
219 Stage currentStage,
Stage targetStage,
const char* where) :
Base(fn,ln)
222 +
" but current stage was " + currentStage.
getName());
230 Stage currentStage,
Stage targetStage,
const char* where) :
Base(fn,ln)
233 +
" but current stage was " + currentStage.
getName());
244 +
" but stage was " + currentStage.
getName());
252 Stage currentStage,
Stage dependsOn,
int dependsOnVersion,
int lastCalculatedVersion)
255 setMessage(
"State Cache entry was out of date at Stage " + currentStage.
getName()
256 +
". This entry depends on version " +
String(dependsOnVersion)
257 +
" of Stage " + dependsOn.
getName()
258 +
" but was last updated at version " +
String(lastCalculatedVersion) +
".");
267 int subsystemId,
const char* subsystemName,
268 const char* fmt ...) :
Base(fn,ln)
273 vsprintf(buf, fmt, args);
275 +
"(" +
String(subsystemName) +
") to Stage "
286 { o << g.
getName();
return o; }
294 #define SimTK_REALIZECHECK_ALWAYS(cond,stage,subsysIx,subsysName,msg) \
295 do{if(!(cond))SimTK_THROW4(SimTK::Exception::RealizeCheckFailed, \
296 (stage),(subsysIx),(subsysName),(msg)); \
298 #define SimTK_REALIZECHECK1_ALWAYS(cond,stage,subsysIx,subsysName,msg,a1) \
299 do{if(!(cond))SimTK_THROW5(SimTK::Exception::RealizeCheckFailed, \
300 (stage),(subsysIx),(subsysName),(msg),(a1)); \
302 #define SimTK_REALIZECHECK2_ALWAYS(cond,stage,subsysIx,subsysName,msg,a1,a2)\
303 do{if(!(cond))SimTK_THROW6(SimTK::Exception::RealizeCheckFailed, \
304 (stage),(subsysIx),(subsysName),(msg),(a1),(a2)); \
306 #define SimTK_REALIZECHECK3_ALWAYS(cond,stage,subsysIx,subsysName,msg,a1,a2,a3) \
307 do{if(!(cond))SimTK_THROW7(SimTK::Exception::RealizeCheckFailed, \
308 (stage),(subsysIx),(subsysName),(msg),(a1),(a2),(a3)); \
310 #define SimTK_REALIZECHECK4_ALWAYS(cond,stage,subsysIx,subsysName,msg,a1,a2,a3,a4) \
311 do{if(!(cond))SimTK_THROW8(SimTK::Exception::RealizeCheckFailed, \
312 (stage),(subsysIx),(subsysName),(msg),(a1),(a2),(a3),(a4)); \
314 #define SimTK_REALIZECHECK5_ALWAYS(cond,stage,subsysIx,subsysName,msg,a1,a2,a3,a4,a5) \
315 do{if(!(cond))SimTK_THROW9(SimTK::Exception::RealizeCheckFailed, \
316 (stage),(subsysIx),(subsysName),(msg),(a1),(a2),(a3),(a4),(a5)); \
320 #endif // SimTK_SimTKCOMMON_STAGE_H_
virtual ~RealizeCheckFailed()
Definition: Stage.h:279
Physical parameters set.
Definition: Stage.h:56
bool operator==(Level other) const
Definition: Stage.h:91
Modeling choices made.
Definition: Stage.h:55
Stage(Level l)
This is an implicit conversion from Stage::Level to Stage.
Definition: Stage.h:79
Level
Definition: Stage.h:52
RealizeTopologyMustBeCalledFirst(const char *fn, int ln, const char *objectType, const char *objectName, const char *methodName)
Definition: Stage.h:170
virtual ~CacheEntryOutOfDate()
Definition: Stage.h:260
bool operator==(Stage other) const
Definition: Stage.h:97
void setMessage(const std::string &msgin)
Definition: Exception.h:56
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
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:123
Spatial velocities available.
Definition: Stage.h:59
Lower than any legitimate Stage.
Definition: Stage.h:53
Stage operator--(int)
Definition: Stage.h:112
virtual ~RealizeTopologyMustBeCalledFirst()
Definition: Stage.h:178
This class is basically a glorified enumerated type, type-safe and range checked but permitting conve...
Definition: Stage.h:50
String getName() const
Return a printable name corresponding to the stage level currently stored in this Stage...
Definition: Stage.h:128
Stage next() const
Return the Stage following this one, with Stage::Infinity returned if this Stage is already at its hi...
Definition: Stage.h:118
bool operator!=(Level other) const
Definition: Stage.h:92
bool operator<=(Stage other) const
Definition: Stage.h:100
bool operator>=(Level other) const
Definition: Stage.h:96
CacheEntryOutOfDate(const char *fn, int ln, Stage currentStage, Stage dependsOn, int dependsOnVersion, int lastCalculatedVersion)
Definition: Stage.h:251
StageIsWrong(const char *fn, int ln, Stage currentStage, Stage targetStage, const char *where)
Definition: Stage.h:218
RealizeCheckFailed(const char *fn, int ln, Stage g, int subsystemId, const char *subsystemName, const char *fmt...)
Definition: Stage.h:266
void invalidate(Stage tooHigh)
Set this Stage=min(stageNow, tooHigh-1).
Definition: Stage.h:147
virtual ~StageTooHigh()
Definition: Stage.h:235
virtual ~StageIsWrong()
Definition: Stage.h:224
Report-only quantities evaluated.
Definition: Stage.h:62
System topology realized.
Definition: Stage.h:54
Stage operator++(int)
Definition: Stage.h:110
Forces calculated.
Definition: Stage.h:60
bool operator>=(Stage other) const
Definition: Stage.h:102
bool operator!=(Stage other) const
Definition: Stage.h:98
Definition: Exception.h:45
bool operator>(Stage other) const
Definition: Stage.h:101
bool operator<(Level other) const
Definition: Stage.h:93
Spatial configuration available.
Definition: Stage.h:58
bool isInRuntimeRange() const
Return true if this Stage has one of the meaningful values between Stage::Topology and Stage::Report...
Definition: Stage.h:155
Higher than any legitimate Stage.
Definition: Stage.h:63
For iterating over all stage values.
Definition: Stage.h:65
std::ostream & operator<<(std::ostream &o, const ContactForce &f)
Definition: CompliantContactSubsystem.h:387
Stage()
Default construction gives Stage::Empty.
Definition: Stage.h:77
const Stage & operator++()
Definition: Stage.h:105
SimTK::String is a plug-compatible std::string replacement (plus some additional functionality) inten...
Definition: String.h:62
StageOutOfRange(const char *fn, int ln, Stage lower, Stage currentStage, Stage upper, const char *where)
Definition: Stage.h:240
Mandatory first inclusion for any Simbody source or header file.
bool operator<(Stage other) const
Definition: Stage.h:99
Stage(int l)
You can explicitly create a Stage from an int if it is in range.
Definition: Stage.h:84
const Stage & operator--()
Definition: Stage.h:107
bool operator<=(Level other) const
Definition: Stage.h:94
StateAndSystemTopologyVersionsMustMatch(const char *fn, int ln, const char *objectType, const char *objectName, const char *methodName, int sysTopoVersion, int stateTopoVersion)
Definition: Stage.h:183
virtual ~StageOutOfRange()
Definition: Stage.h:246
For iterating over meaningful stage values.
Definition: Stage.h:67
StageTooHigh(const char *fn, int ln, Stage currentStage, Stage targetStage, const char *where)
Definition: Stage.h:229
bool operator>(Level other) const
Definition: Stage.h:95
A new time has been realized.
Definition: Stage.h:57
Accelerations and multipliers calculated.
Definition: Stage.h:61
virtual ~StateAndSystemTopologyVersionsMustMatch()
Definition: Stage.h:200