![]() |
VR-Forces Developer's Guide
|
All DtLocalObject instances have an internal state repository data member that contains all the internal state information for the object–that is, information that is not available for other objects to see.
State repositories are essentially container classes for state information.
There are several derived state repository classes that contain state information specific to a particular category of objects. For example, the fixed-wing state repository class, DtFixedWingStateRepository, maintains information specific to fixed-wing entities, like maximum angle of attack and minimum altitude.
The state repository is a readable, writeable member of a DtLocalObject and, therefore, is saved and restored as part of an object’s data in the order of battle file.
Whenever you save or checkpoint a scenario, VR-Forces saves the state of all locally simulated simulation objects to the order of battle file. This state includes items such as kinematic state (position, velocity, orientation, and so on), damage status, and resource levels. VR-Forces also saves information about the processes the simulation object was carrying out at the time of the save, such as the name of a waypoint it was heading toward, or the identity of the current target in a weapon system.
As noted in Simulation Object Design, the differences between simulated objects are expressed in the state repository class hierarchy. The differences between a tank, a helicopter, or a route are partly a function of the kind of internal state repository each has. Control objects use a DtVrfObjectStateRepository. Moving simulation objects use DtMovingObjectStateRepository or one of its derived classes. The figure illustrates the hierarchy of derived state repositories for simulating different kinds of objects.
The DtVrfObjectStateRepository holds information that is common to all simulated simulation objects within VR-Forces. It is an intermediate state repository that has a role similar to an abstract base class for simulation object state repositories. It is not created for any simulation objects in VR-Forces. However, all other state repositories in VR-Forces inherit this class.
DtVrfObjectStateRepository maintains a readable and writeable list of current tasks a simulation object is working on. This data is manipulated by the DtTaskControllerComponents configured on a simulation object (users should not typically have to access it directly). This data is also saved as part of a simulation object's state in the order of battle file. This enables simulation objects to remember what task they were working on at the time the scenario was saved (whether assigned from a plan or from the GUI as an independent task).
The DtVrfObjectStateRepository also owns the internal state properties of the entity. For more on state properties, see State and Parameter Properties.
DtVrfMovingObjectStateRepository is derived from DtVrfObjectStateRepository. It holds information that is common to all VR-Forces objects that can move. It is the base class for all of the individual state repositories. It is also the state repository used for units. It provides storage, accessors, and mutators for the following data:
You can extend the base state repository class DtVrfObjectStateRepository, as an alternative to, or in addition to extending leaf-level classes in the DtVrfObjectStateRepository hierarchy. The base state repository class, DtVrfObjectStateRepository has-a DtVrfStateRepositoryUserExtension (vrfSRUserExt.h) that you can extend for all types of simulation objects and objects (vrfstaterephierarchyfigure State Repository Hierarchy).
For example, suppose you want to extend all types of simulation objects in VR-Forces (fixed-wing, rotary-wing, ground, and so on) with a new kind of identifier. Rather than extending each type of state repository to include the new identifier, you just need to create a single derived kind of DtVrfStateRepositoryUserExtension class. This allows you to write the extension once, and configure it as part of a variety of different kinds of simulation objects, control objects, or tactical graphics. The alternative to this approach would be to subclass each kind of state repository separately, extending each class in exactly the same way.
Like the DtVrfObjectStateRepository classes, classes derived from DtVrfStateRepositoryUserExtension are readable and writeable. Any DtReaderWriter data members you add to your derived DtVrfStateRepositoryUserExtension will be saved to an order of battle file along with the rest of an object’s DtVrfObjectStateRepository data.
The example project State Repository Extension (extendStateRepository) demonstrates how to extend state repositories at the base class level.