WSF
Programming Notes

This section provides general programming notes when using WSF.

The Platform List

WsfSimulation maintains a list of all active platforms in the simulation. It includes methods for determining if a platform exists, iterating over all active platforms, etc.

Platforms and Platform indices.

Platforms may be destroyed during a simulation. Therefore, an object (simulation observer, another platform, etc.) must not retain a pointer to another platform as there is no way to guarantee that the platform will always exist. What should be retained is a 'platform index'.

When a platform is added to the simulation it is assigned a unique platform index that will never be reassigned during the simulation (Note: the platform index is not assigned until WsfSimulation::Initialize is called). The platform index for an active platform can be retrieved by:

unsigned int platformIndex = platformPtr->GetIndex();
WsfPlatform * platformPtr
Definition WsfScriptTrackClass.cpp:507

Given a platform index, the address of the associated platform can be retrieved by:

Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
WsfPlatform * GetPlatformByIndex(size_t aIndex) const
Definition WsfSimulation.cpp:717

The return value will be the pointer to the platform if it still exists or 0 if the platform has been removed from the simulation.

What do you want to do next?

Copyrights Multiple, All Rights Reserved