WSF
The 'Object Type' System

The 'object type' system is most useful when used the the simulation loader described later, but it is also useful even if you aren't going to use it. The object type system allows you to create an object (platform, sensor, etc.) and register it as a 'object type'. The created object can be an instance of any of the classes provided by WSF that has been populated with the characteristics you desire or an instance of a derived class that you have created.

All of the object types that have been pre-defined by WSF (for example, WsfAirMover, WsfRadarSensor, etc.) have been pre-registered in the object type system and are available to be used in simulation input files. You can create derived classes and also register them so they can be used in simulation input files. Assume you have a new sensor (the same pattern would apply to a platform, mover, etc.):

class MySensor : public WsfSensor
{
...
};
Definition WsfSensor.hpp:92

The sensor can be registered as a new sensor type in either an application or scenario extension using the following:

#include "MySensor.hpp"
...
// 'scenario' is a reference to the scenario.
scenario.GetSensorTypes().AddCoreType("MY_SENSOR", new MySensor(scenario));

The sensor can then be attached to a platform type in an input file:

platform_type MY_AC WSF_PLATFORM
  sensor sensor-1 MY_SENSOR
     ... commands specific to MY_SENSOR ...
  end_sensor
end_platform_type

Use of object types is not just limited to the simulation loader. Let's say a new platform type has been created and registered as 'MY_AC'. How it got there isn't important. It could have been created by the simulation loader or by code you have written. At any rate, you can create a copy of the aircraft and add it to the simulation:

platformPtr->SetName("ac-1");
// Set other parameters as desired such as the route, etc.
sim.AddPlatform(platformPtr);
WsfPlatform * platformPtr
Definition WsfScriptTrackClass.cpp:507
virtual WsfObject * Clone(WsfStringId aId) const =0
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115

What do you want to do next?

Copyrights Multiple, All Rights Reserved