![]() |
VR-Link API Documentation for HLA 1.3
|
The files testInter.h and testInter.cxx contain definitions for a new class called TestInteraction, and its member functions.
Like all interaction classes in VR-Link, it is derived from DtInteractionWithEncDec, rather than directly from DtInteraction. DtInteraction is rather general, and allows for a wide variety of subclass implementations, including those that do not involve our concept of encoders and decoders. DtInteractionWithEncDec is set up to deal with encoders and decoders, and we will be taking advantage of this.
TestInteraction includes inspector and mutator functions to access the values of the Number and Parameter attributes. We represent them in the same way as in the FOM, but this is not strictly necessary. We could perform a non-trivial conversion in FOM mapping code instead.
The TestInteraction class hard-codes its own FOM mapping information, rather than relying on the default behavior, which is to obtain it from the FOM Mapper. We do this here, because it make things simpler, by saving us the step of configuring the FOM Mapper with mappings for our new class. But this choice means that it would be more difficult to change the way this kind of interaction is represented in the FOM.
This choice manifests itself in the fact that we override the virtual functions interactionClassToUse(), createEncoder() and createDecoder(). The base class implementation of interactionClassToUse() asks the FOM Mapper for the name of a FOM class to use. But TestInteraction's implementation just returns the class name Test. The base versions of createEncoder() and createDecoder() ask the FOM Mapper for instances of the kind of encoder and decoder that have been registered with it for use with the Test interaction class. But TestInteraction's implementations of these functions just return a new'ed TestEncoder and TestDecoder instance respectively.
In addition, within TestInteraction::addCallback(), we inform the DtExerciseConn's interaction factory that it should create an instance of the TestInteraction class to represent incoming interactions of FOM class Test. This is achieved using DtInteractionFactory's addCreator() member function.
Notice that the TestInteraction has decided that it will use instances of the classes TestEncoder and TestDecoder to map between its representation of its parameters, and the FOM representation.