VR-Link API Documentation for HLA 1516
FOM Mapper Source

This file contains the main class MyFomMapper which is created by the plugin manager.

There are several ways to configure a FOM Mapper to work with this new FOM. For example, you could allow the DtExerciseConn constructor to create an empty FOM Mapper, and then add mappings to that FOM Mapper later.

However, this example creates a subclass of DtFomMapper called MyFomMapper, whose implementation of the virtual init() function self registers all of the mappings we want. Then it can either create an instance of this class and pass it to the DtExerciseConn constructor, or create a shared library containing a function called DtCreateFomMapper() that returns a new'ed instance of MyFomMapper, and pass the name of the shared library to the DtExerciseConn constructor. This example uses the shared library option.

Regardless of how an instance of a DtFomMapper is passed to a DtExerciseConn constructor, DtExerciseConn calls init() on that FOM Mapper after reading the FED file and initializing the RTI.

The MyFomMapper class is defined in myFomMap.h and myFomMap.cxx. The code is included below. Notice that MyFomMapper is derived from DtEmptyFomMapper. Within MyFomMapper::init(), call down to the DtEmptyFomMapper::init(), which initializes the FOM Mapper with empty factories and tables. Then add your own mappings to the tables, including adding instances of our encoders and decoders to the FOM Mapper's encoder and decoder factories.


/*********************************************************************
** Copyright (c) 1998 MaK Technologies, Inc.
** All rights reserved.
*********************************************************************/
#pragma once
// Export Symbols on Windows (and do nothing on Linux)
#if DT_NEED_DLL_DECLARATIONS
#ifdef DT_DLL_FOMMAP
#undef DT_DLL_FOMMAP
#define DT_DLL_FOMMAP __declspec( dllexport )
#else
#define DT_DLL_FOMMAP __declspec( dllimport )
#endif
#else
#ifdef DT_DLL_FOMMAP
#undef DT_DLL_FOMMAP
#endif
#define DT_DLL_FOMMAP
#endif
#if DtHLA
#include <vl/rprFomMap.h>
{
public:
// Default constructor - most initialization is delayed until init() is
// called.
// Destructor
virtual ~MyFomMapper();
// Virtual function override. init actually initializes most data. It is
// called from DtExerciseConn constructor. Required.
virtual void init(DtExerciseConn* conn);
protected:
// Copy Ctor Not implemented
MyFomMapper(const MyFomMapper&orig);
};
#endif

/*********************************************************************
** Copyright (c) 1998 MaK Technologies, Inc.
** All rights reserved.
*********************************************************************/
/*********************************************************************
** $RCSfile: myFomMap.cxx,v $ $Revision: 1.2 $ $State: Exp $
*********************************************************************/
#if DtHLA
#include <vl/fom.h>
#include "myFomMap.h"
#include <vl/intDecFact.h>
#include <vl/intEncFact.h>
{
// Real initialization takes place in virtual init() function,
// when a DtExerciseConn is available.
}
class ReplaceAudioDataDecoder : public DtEncodedAudioRadioSignalDecoder
{
public:
ReplaceAudioDataDecoder( DtExerciseConn* exConn, DtInterClassDesc* classDesc )
: DtEncodedAudioRadioSignalDecoder( exConn, classDesc )
{
}
ReplaceAudioDataDecoder( const ReplaceAudioDataDecoder& orig )
{
}
static void decodeAudioDataRpr2( DtSignalInteraction* inter,
const RTI::ParameterHandleValuePairSet& params, int pairSetIndex )
{
DtEncodedAudioRadioSignalDecoder::decodeAudioData( inter,
params, pairSetIndex );
}
};
class ReplaceAudioDataEncoder : public DtEncodedAudioRadioSignalEncoder
{
public:
ReplaceAudioDataEncoder( DtExerciseConn* exConn, DtInterClassDesc* classDesc )
: DtEncodedAudioRadioSignalEncoder( exConn, classDesc )
{
}
ReplaceAudioDataEncoder( const ReplaceAudioDataEncoder& orig )
{
}
static void encodeAudioDataRpr2( const DtSignalInteraction& inter,
RTI::ParameterHandle paramHandle )
{
DtEncodedAudioRadioSignalEncoder::encodeAudioData( inter,
params, paramHandle );
}
};
{
// Call base class init. This sets myExConn, and initializes all factories
// to default or empty factories (no encoders or decoders registered, no
// mappings between FOM interaction classes and VR-Link interaction
// classes.
"EncodedAudioRadioSignal", "AudioData",
(DtInteractionEncoder::DtParameterEncoder) ReplaceAudioDataEncoder::encodeAudioDataRpr2, true);
"EncodedAudioRadioSignal", "AudioData",
(DtInteractionDecoder::DtParameterDecoder) ReplaceAudioDataDecoder::decodeAudioDataRpr2, true);
}
{
}
#endif

Document ID: Generated on Wed Aug 14 15:35:11 EDT 2013 from SVN revision 130445
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)