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.
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:
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:
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:
You can associate a class choosing function with a VR-Link publisher class name as follows:
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.
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:
If a particular DtReflectedObjectList subclass should manage only a single FOM class, create this association using setObjectClass(). For example:
If you want a particular kind of list to manage more than one FOM object class, use setObjectClassNames() to pass a DtList of names of FOM classes. For example:
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:
If one single FOM class should always be chosen for a particular kind of DtInteraction, create this association using DtFomMapper::setInteractionClassToChoose(). For example, in the RPR FOM, DtFireInteractions should always use the FOM class WeaponFire:
When more than one mapping is possible for a single kind of DtInteraction, associate an interaction class chooser function with the VR-Link class name using setInteractionClassChooser(). Choosers look like this:
and are registered like this:
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.
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:
and setInteractionClasses() for multiple FOM classes, for example:
[<< FOM Mapping Details] [Home] [Top of Page] [Creating Instances of DtInteraction >>]