VR-Link C# API Documentation
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros Pages
6.6 - Creating Instances of DtInteraction

For interactions, the final class mapping component is the mapping between FOM classes and functions that create instances of the appropriate DtInteraction subclasses.

DtFomMapper uses a DtInteractionFactory (defined in interactionFactory.h) to manage this kind of mapping.

When an interaction is received from the RTI, the DtExerciseConn asks the FOM Mapper's DtInteractionFactory to create an instance of the appropriate kind of DtInteraction subclass, using its createInteraction() member function. The FOM Mapper's interaction factory is obtained using DtFomMapper::interactionFactory().

You can add or change an interaction factory's mappings using its addCreator() member function, passing a FOM class name and an interaction creation function such as a DtInteraction subclass's static create() member function. For example, when we receive an interaction of FOM class WeaponFire, we want to create an instance of DtFireInteraction:

fomMapper()->interactionFactory()->addCreator("WeaponFire", DtFireInteraction::create);

You can replace a DtFomMapper's interaction factory with a new one using its setInteractionFactory() member. For example, you might want to create a subclass of DtInteractionFactory for your FOM that registers all of the desired creators from within its constructor. You would then create an instance of this DtInteractionFactory subclass, and instruct the FOM Mapper to use it as its interaction factory.

No analogous mapping step is required for objects, since instances of appropriate DtReflectedObject subclasses are created not by a central class like DtExerciseConn, as interactions are, but rather by DtReflectedObjectList subclasses. And each DtReflectedObjectList knows what kind of DtReflectedObject subclass to instantiate.

[<< Setting Up a FOM Mapper's Class Mappings] [Home] [Top of Page] [Attribute and Parameter Encoding and Decoding >>]


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)