VR-Link JAVA API Documentation
 All Classes Namespaces Files Functions Variables Enumerator Pages
6.5 - Setting Up a FOM Mapper's Class Mappings

Table of Contents

6.3 - FOM Mapping Information Required By VR-Link's API, explains that a FOM Mapper contains class mapping information as well as attribute and parameter encoding and decoding information.

This section describes how to set up a FOM Mapper's class mappings.

6.5.1 Choosing an Object Class to Publish

A DtObjectPublisher asks the FOM Mapper for the name of the FOM object class to use to represent its locally simulated object by calling chooseObjectClass(). The publisher passes the name of its own VR-Link C++ publisher class, for example, DtEntityPublisher or DtAggregatePublisher.

When you configure a FOM Mapper, you can dictate what FOM class chooseObjectClass() will return in one of two ways:

6.5.2 Mapping a Single FOM Class to a Publisher

If one FOM class should always be chosen for a particular kind of publisher, create this association using DtFomMapper::setObjectClassToChoose(). For example, in the RPR FOM, DtAggregatePublishers should always use the FOM class BaseEntity.AggregateEntity:

fomMapper->setObjectClassToChoose("DtAggregatePublisher", "BaseEntity.AggregateEntity");

6.5.2.1 Mapping Multiple FOM Classes to A Publisher

It might be possible to map several FOM classes to a publisher. In these cases, some instance-specific data might be necessary in order to make a choice. In this case, you can associate a class choosing function with the name of a VR-Link class, rather than just a single object class, using setObjectClassChooser().

A class choosing function looks like this:

char* myClassChooser(const char* vrlinkClassName, DtExerciseConn* conn, void* usr);

You can associate a class choosing function with a VR-Link publisher class name as follows:

fomMapper->setObjectClassChooser("DtEntityPublisher", myClassChooser);

The VR-Link class may pass instance-specific data as the usr argument to chooseObjectClass(), and this data will be passed to your chooser function as usr. For example, DtEntityPublisher passes a pointer to the entity's DtEntityType, and in the RPR FOM Mapper, our class chooser function picks a FOM class based on the entity type.

6.5.3 Subscribing to Object Classes

A DtReflectedObjectList asks the FOM Mapper for the names of the FOM classes to subscribe to and manage, by calling objectClassNames(). Besides subscribing to the returned classes, the reflected object list registers discoverObjectInstance() callbacks with lower layers of VR-Link for these classes, so that it can be made aware of new instances, and can create DtReflectedObject instances to represent them. The reflected object list passes the name of its own VR-Link C++ class, for example, DtReflectedEntityList.

When configuring a FOM Mapper, you can specify which FOM classes objectClassNames() returns in one of the following ways:

6.5.3.1 Choosing An Interaction Class to Publish

Choosing an interaction class works very similarly to choosing an object class. When you call setExConn() on an interaction (DtExerciseConn::send() and sendStamped() call this function), the DtInteraction instance uses chooseInteractionClass() to ask the FOM Mapper for the name of a FOM class to use to represent the interaction. The interaction instance passes a reference to itself. Based on the name of the VR-Link C++ interaction class (which can be obtained from an interaction instance using its name() function) the FOM Mapper must choose an appropriate FOM class to use.

As with objects, you can specify which FOM class chooseInteractionClass() returns in one of two ways:

The actual interaction for which a choice is being requested is passed to your chooser, in case any instance-specific data is needed to make the choice.

6.5.4 Subscribing to Interaction Classes

When you call the static addCallback() function on a particular DtInteraction subclass, you are saying that you are interested in interactions of that type. The DtInteraction subclass maps that request to subscriptions to FOM classes. It obtains the set of FOM classes to subscribe to from the FOM Mapper using its interactionClasses() member function.

You can determine what this function will return using setInteractionClass() or setInteractionClasses(). Use setInteractionClass() to map to a single FOM class, for example:

fomMapper->setInteractionClass("DtFireInteraction", "WeaponFire");

and setInteractionClasses() for multiple FOM classes, for example:

DtList classNames;
classNames.add(RadioSignal.ApplicationSpecific");
classNames.add(RadioSignal.EncodedAudio");
...
fomMapper->setInteractionClasses(classNames);

[<< FOM Mapping Details] [Home] [Top of Page] [Creating Instances of DtInteraction >>]


Document ID: Generated on Tue Mar 1 02:56:17 EST 2016 from SVN revision 162687
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)