![]() |
VR-Forces 4.3 Class Documentation
|
This section provides additional details about plan statements.
Statements are implemented by objects derived from DtSimStatement. VR-Forces has the following kinds of statements: task statements, set data request statements, If statements, While statements, and When (trigger) statements.
Note:
Each DtSimStatement object represents a single statement in a plan (but not necessarily a single line in a Plan window.) Some kinds of statements have subblocks which contain other statements (for example, If), and these compound statements have one extra line per subblock in the Plan window (for example, else and endif).
DtSimStatements are created by either the statement factory or by cloning another statement. Normally, the parent DtSimBlock creates its statements when it reads a plan file, or they are created in the front-end and passed to the back-end as part of a complete DtPlan object.
Each DtSimStatement object is assigned a unique, non-zero statement ID number when it is created. This number is preserved in all copies of the original statement and is used to match up statements when comparing two (potentially modified) clones of the same original DtPlan. DtPlans, DtSimStatements, and DtSimBlocks all provide ways to help search for a statement with a particular statement ID.
DtStmtIndex objects use statement ID values to hide the difference between a direct DtSimStatement pointer and a combination of a statement ID and a DtPlan pointer. Statement objects are normally accessed via DtStmtIndex objects for portability across clones of the surrounding DtPlan.
Statement objects do not have direct pointers to their DtPlans. The execute() and step() member functions are passed a DtPlan reference as a "context of execution". Statements can use this context to look up information in the DtPlan, send out messages to the DtPlan’s associated entity, or modify the DtPlan’s state (such as the current statement index).
The DtSimStatement class has a static pointer to an instance of a DtStatementFactory. This is a factory for creating new instances of DtSimStatement, given a string statement type. The DtSimCreator class, which is responsible for creating all of the various object factories in VR-Forces, creates the DtStatementFactory instance and then sets a pointer to it in the DtSimStatement class.
Each block of statements is represented by an object of a class derived from DtSimBlock. DtSimBlock is a DtRwIntrusiveList (rwIntList.h) of DtSimStatement objects.
Derived block objects are used in VR-Forces as each plan's Main Block, When Statement trigger blocks, and as Then or Else blocks in If statements.
Since the various derived block types are closely tied to, and created only by their associated DtPlan or DtSimStatement types, there is no separate factory mechanism for them.
The base DtSimBlock type does not contain any data members, but derived classes usually contain a pointer to their parent object (DtSimStatement or DtPlan).
VR-Forces provides three classes derived from DtSimBlock. Each class has a pointer back to its parent DtSimStatement or DtPlan, and the only other significant difference is what they do when their exitFromBlock() member function is called.
[<< Executing a Plan] [Home] [Top of Page] [Conditional Expressions >>]