![]() |
VR-Forces 4.1.1 Class Documentation
|
A DtPlan object represents the plan for an individual DtVrfObject.
In VR-Forces, there is one DtPlan created for each DtVrfObject that needs one. If an entity does not have a plan, no DtPlan gets created. The plan for an aggregate entity is associated with the DtVrfObject of the aggregate, and individual members of the aggregate might not have plans of their own.
The DtCgf class provides member functions for performing some of the more common operations for managing plans. These include functions for loading and saving scenarios (plans are implicitly loaded and saved as part of these functions), and a member function for assigning new plans to entities. If you require more control over plans, you can access the Plan Manager for an object by calling DtVrfObject::vrfObjectPlanManager().
To load a plan file into the Plan Manager, call DtVrfObjectPlanAdministrator::readPlanFile(). This instantiates a DtPlan object for each plan in the file and assigns it to the object’s DtVrfObjectPlanManager. This is call should generally only be made from DtCgf::loadScenario().
To save the plans to file, call DtVrfObjectPlanAdministrator::writePlanFile(). This call should generally only be made from DtCgf::saveScenario(). When you save a scenario, a plan file is one of the files that gets saved as part of the scenario. The name of the plan file is referenced in the scenario file.
The simplePlan example (in ./examples/simplePlan) demonstrates how to create and assign a plan to an entity. In main.cxx, a simple plan consisting of a Set Speed request, a Wait Duration task, and a Move To Waypoint task, is created and assigned to a tank.
To create a new DtPlan, you can call the DtPlan constructor with no arguments. You can use this form of constructor when assigning plans through the DtCgf class. The name of the object passed into DtCgf::assignPlanByName() gets assigned to the DtPlan. You must call DtPlan::init() before you can use any other member functions in the DtPlan class. The init() function completes construction of the DtPlan object.
Plan statements are the individual items that get executed in a DtPlan. Statements represent tasks for the entity to perform, set data requests, or control-flow statements such as if(conditional expression)-then-else and when(conditional expression). They are derived from the DtSimStatement class (simStmt.h). In the simplePlan example, we create task and set data request statements. To create these kinds of statements, we first created the content for the statement (a derived type of DtSimTask or DtSetDataRequest), and then assigned it to a newly created corresponding DtTaskStmt or DtSetDataRequestStmt class.
A DtPlan contains a DtPlanBlock, which is the list of DtSimStatements in a plan. To add our new statements to the plan, we first obtained a pointer to the DtPlan’s main block of statements, and then added the statements to it. Because the plan assumes responsibility for deleting the memory associated with the plan statements, we cloned in the statements before adding them.
Once you have created a DtPlan, you need to assign it to a particular DtVrfObject. The assignPlanByName() function associates the given DtPlan with the given DtVrfObject, referenced by name. The DtPlan will get executed as its DtVrfObjectPlanManager gets ticked.
To look up the plan for an object, use the DtVrfObjectPlanManager::plan() accessor. If the object has not been assigned a plan, a NULL pointer is returned. For example, given a pointer to a DtVrfObject "myObject", the following code prints a message if the plan is complete. For information about accessing a certain DtVrfObject, please see 3.5.5 Looking Up Individual Objects.
[<< The Plan Manager] [Home] [Top of Page] [The Plan Administrator >>]