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)
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)
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)
232 +
" but current stage was " + currentStage.
getName());
240 Stage currentStage,
Stage targetStage,
const char* where) :
Base(fn,ln)
243 +
" but current stage was " + currentStage.
getName());
251 Stage currentStage,
Stage targetStage,
const char* where) :
Base(fn,ln)
254 +
" but current stage was " + currentStage.
getName());
265 +
" but stage was " + currentStage.
getName());
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)
296 vsnprintf(buf, n, fmt, args);
298 +
"(" +
String(subsystemName) +
") to Stage "
312 { o << g.
getName();
return o; }
320 #define SimTK_REALIZECHECK_ALWAYS(cond,stage,subsysIx,subsysName,msg) \
321 do{if(!(cond))SimTK_THROW4(SimTK::Exception::RealizeCheckFailed, \
322 (stage),(subsysIx),(subsysName),(msg)); \
324 #define SimTK_REALIZECHECK1_ALWAYS(cond,stage,subsysIx,subsysName,msg,a1) \
325 do{if(!(cond))SimTK_THROW5(SimTK::Exception::RealizeCheckFailed, \
326 (stage),(subsysIx),(subsysName),(msg),(a1)); \
328 #define SimTK_REALIZECHECK2_ALWAYS(cond,stage,subsysIx,subsysName,msg,a1,a2)\
329 do{if(!(cond))SimTK_THROW6(SimTK::Exception::RealizeCheckFailed, \
330 (stage),(subsysIx),(subsysName),(msg),(a1),(a2)); \
332 #define SimTK_REALIZECHECK3_ALWAYS(cond,stage,subsysIx,subsysName,msg,a1,a2,a3) \
333 do{if(!(cond))SimTK_THROW7(SimTK::Exception::RealizeCheckFailed, \
334 (stage),(subsysIx),(subsysName),(msg),(a1),(a2),(a3)); \
336 #define SimTK_REALIZECHECK4_ALWAYS(cond,stage,subsysIx,subsysName,msg,a1,a2,a3,a4) \
337 do{if(!(cond))SimTK_THROW8(SimTK::Exception::RealizeCheckFailed, \
338 (stage),(subsysIx),(subsysName),(msg),(a1),(a2),(a3),(a4)); \
340 #define SimTK_REALIZECHECK5_ALWAYS(cond,stage,subsysIx,subsysName,msg,a1,a2,a3,a4,a5) \
341 do{if(!(cond))SimTK_THROW9(SimTK::Exception::RealizeCheckFailed, \
342 (stage),(subsysIx),(subsysName),(msg),(a1),(a2),(a3),(a4),(a5)); \
Mandatory first inclusion for any Simbody source or header file.
Definition: Exception.h:46
void setMessage(const std::string &msgin)
Definition: Exception.h:57
CacheEntryOutOfDate(const char *fn, int ln, Stage currentStage, Stage dependsOn, StageVersion dependsOnVersion, StageVersion lastCalculatedVersion)
Definition: Stage.h:272
virtual ~CacheEntryOutOfDate()
Definition: Stage.h:282
RealizeCheckFailed(const char *fn, int ln, Stage g, int subsystemId, const char *subsystemName, const char *fmt,...)
Definition: Stage.h:288
virtual ~RealizeCheckFailed()
Definition: Stage.h:302
RealizeTopologyMustBeCalledFirst(const char *fn, int ln, const char *objectType, const char *objectName, const char *methodName)
Definition: Stage.h:191
virtual ~RealizeTopologyMustBeCalledFirst()
Definition: Stage.h:199
StageIsWrong(const char *fn, int ln, Stage currentStage, Stage targetStage, const char *where)
Definition: Stage.h:239
virtual ~StageIsWrong()
Definition: Stage.h:245
StageOutOfRange(const char *fn, int ln, Stage lower, Stage currentStage, Stage upper, const char *where)
Definition: Stage.h:261
virtual ~StageOutOfRange()
Definition: Stage.h:267
StageTooHigh(const char *fn, int ln, Stage currentStage, Stage targetStage, const char *where)
Definition: Stage.h:250
virtual ~StageTooHigh()
Definition: Stage.h:256
StateAndSystemTopologyVersionsMustMatch(const char *fn, int ln, const char *objectType, const char *objectName, const char *methodName, int sysTopoVersion, int stateTopoVersion)
Definition: Stage.h:204
virtual ~StateAndSystemTopologyVersionsMustMatch()
Definition: Stage.h:221
This class is basically a glorified enumerated type, type-safe and range checked but permitting conve...
Definition: Stage.h:66
String getName() const
Return a printable name corresponding to the stage level currently stored in this Stage.
Definition: Stage.h:144
const Stage & operator--()
Definition: Stage.h:123
void invalidate(Stage tooHigh)
Set this Stage=min(stageNow, tooHigh-1).
Definition: Stage.h:163
Stage(int l)
You can explicitly create a Stage from an int if it is in range.
Definition: Stage.h:100
bool operator<=(Level other) const
Definition: Stage.h:110
Stage operator++(int)
Definition: Stage.h:126
bool isInRuntimeRange() const
Return true if this Stage has one of the meaningful values between Stage::Topology and Stage::Report,...
Definition: Stage.h:171
Stage(Level l)
This is an implicit conversion from Stage::Level to Stage.
Definition: Stage.h:95
@ NValid
Definition: Stage.h:88
@ NRuntime
Definition: Stage.h:89
const Stage & operator++()
Definition: Stage.h:121
bool operator<(Stage other) const
Definition: Stage.h:115
bool operator!=(Stage other) const
Definition: Stage.h:114
bool operator==(Level other) const
Definition: Stage.h:107
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
bool operator!=(Level other) const
Definition: Stage.h:108
Stage()
Default construction gives Stage::Empty.
Definition: Stage.h:93
bool operator>=(Level other) const
Definition: Stage.h:112
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
bool operator<=(Stage other) const
Definition: Stage.h:116
bool operator>=(Stage other) const
Definition: Stage.h:118
bool operator<(Level other) const
Definition: Stage.h:109
bool operator==(Stage other) const
Definition: Stage.h:113
Level
Definition: Stage.h:68
@ Time
A new time has been realized.
Definition: Stage.h:73
@ LowestRuntime
For iterating over meaningful stage values.
Definition: Stage.h:83
@ Topology
System topology realized.
Definition: Stage.h:70
@ Empty
Lower than any legitimate Stage.
Definition: Stage.h:69
@ HighestRuntime
Definition: Stage.h:84
@ Acceleration
Accelerations and multipliers calculated.
Definition: Stage.h:77
@ Position
Spatial configuration available.
Definition: Stage.h:74
@ Dynamics
Forces calculated.
Definition: Stage.h:76
@ Velocity
Spatial velocities available.
Definition: Stage.h:75
@ Model
Modeling choices made.
Definition: Stage.h:71
@ Infinity
Higher than any legitimate Stage.
Definition: Stage.h:79
@ Instance
Physical parameters set.
Definition: Stage.h:72
@ Report
Report-only quantities evaluated.
Definition: Stage.h:78
@ HighestValid
Definition: Stage.h:82
@ LowestValid
For iterating over all stage values.
Definition: Stage.h:81
bool operator>(Stage other) const
Definition: Stage.h:117
bool operator>(Level other) const
Definition: Stage.h:111
Stage operator--(int)
Definition: Stage.h:128
SimTK::String is a plug-compatible std::string replacement (plus some additional functionality) inten...
Definition: String.h:65
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
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
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
std::ostream & operator<<(std::ostream &o, const ContactForce &f)
Definition: CompliantContactSubsystem.h:387