VR-Link API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Example FOM Mapper

The myFomMap example shows how to create a FOM Mapper for a new FOM, but assumes that the new FOM contains concepts already covered by VR-Link's API (so no extensions are necessary).

It also demonstrates how to put the new FOM Mapper into a shared library that can be loaded by DtExerciseConn, and by MAK applications like MAK Stealth, MAK Data Logger, and VR-Forces. The shared library works with the FED file called MyFomMap.fed that is in the VR-Link root directory.

For this example, we created a new FED file called MyFomMap.fed, representing a new, simple FOM. The MyFomMap FOM contains one object class called Vehicle, and one interaction class called Shoot.

Vehicle has two attributes:

These attributes are mapped to DtEntityStateRepository's concepts of entity type and location.

Shoot has two parameters: Shooter and Shootee. Both are character strings representing the HLA object names of the attacker and target respectively. These parameters will be mapped to DtFireInteraction's concepts of attacker ID and target ID respectively.

This FOM uses different class, attribute, and parameter names than the RPR FOM, but uses similar data representations to keep our type conversion examples simple. (Though in one case - the VehicleType attribute, our data representation is very different to demonstrate that this can be done.)

For each of these FOM classes, the example:

  1. Creates an encoder class and a decoder class whose constructors self-register the necessary encoding and decoding functions for each attribute and parameter (and checking functions for each attribute as well.)
  2. Registers these encoders and decoders with a FOM Mapper along with other class mapping information.
  3. Implements the two global functions required for FOM Mapper shared libraries.
Using the FOM Mapper

When you execute make in the example directory, you build a shared library called myFomMap.so or myFomMap.dll. You can test this library with any VR-Link example that accepts a path to a FOM mapping shared library (through the -f option.) You can omit the .so or .dll, so that the same command can be used in Windows or in UNIX. Remember to also specify a federation execution name of MyFomMap, using the -x option, so that the MyFomMap.fed file is used.

For example, from the ./binHLA13 directory, you can run:

f18 -f ../examples/extend/myFomMap/myFomMap -x MyFomMap

Alternatively, you can write your own application that passes the name of the shared library to the DtExerciseConn. Again, make sure that you use the right FED file:

DtExerciseConn conn("MyFomMap", "MyApp", "myFomMap");

The following links provide additional detail about the design of the example FOM Mapper and include the commented source code:


Document ID: Generated on Mon Jun 22 21:18:40 EDT 2020 from SVN revision 213785
Copyright © 2005-2018 MAK Technologies. All Rights Reserved (www.mak.com)