VR-Link API Documentation for HLA 1.3
Shoot Interaction Decoder

shootDec decodes Shoot interactions.


/*********************************************************************
** Copyright (c) 1999 MaK Technologies, Inc.
** All rights reserved.
*********************************************************************/

#ifndef ShootDecoder_H_
#define ShootDecoder_H_

#if DtHLA

#include "myFomMap.h"

#include <vl/interDecoder.h>

class DT_DLL_VL DtFireInteraction;

#define DtDECLARE_SHOOT_PARAM_DECODER(paramName) \
   DtDECLARE_PARAM_DECODER(DtFireInteraction, paramName)

class DT_DLL_FOMMAP ShootDecoder : public DtInteractionDecoder
{
public:
   
   ShootDecoder(DtExerciseConn* exConn, DtInterClassDesc* classDesc);

   virtual ~ShootDecoder();

protected:

   DtDECLARE_SHOOT_PARAM_DECODER(Shooter);
   DtDECLARE_SHOOT_PARAM_DECODER(Shootee);
};

#endif
#endif

/*********************************************************************
** Copyright (c) 1997 MaK Technologies, Inc.
** All rights reserved.
*********************************************************************/
/*********************************************************************
** $RCSfile: shootDec.cxx,v $ $Revision: 1.3 $ $State: Exp $
*********************************************************************/

#if DtHLA 

#include "shootDec.h"
#include <vl/hFireInter.h>
#include <stdio.h>
#include <string.h>

// Constructor.
ShootDecoder::ShootDecoder(
   DtExerciseConn* exConn,
   DtInterClassDesc* classDesc) : 
   DtInteractionDecoder(exConn, classDesc)
{
   // Register the individual decoding functions for Shoot's parameters with
   // object.  The decoding functions have names like decodeShooter and
   // decodeShootee.  The macro expands to look like this:
   // addDecoder("Shooter", (DtParameterDecoder) decodeShooter);
   DtADD_PARAM_DECODER(Shooter);
   DtADD_PARAM_DECODER(Shootee);
}

ShootDecoder::~ShootDecoder()
{
}

// Decoding functions

// Macros can help with definitions of simple decoding functions, as in in
// examples/extend/testInter/testDec.cxx but here we do not rely on them.

void ShootDecoder::decodeShooter(DtFireInteraction* inter,
   const RTI::ParameterHandleValuePairSet& params,
   int index)
{
   RTI::ULong length = 0;
   // Get value in RTI representation into netVal.
   char* netVal = (char*) 
      params.getValuePointer(index, length);

   // Must copy to a buffer, because string returned by getValuePointer may
   // not be NULL terminated.
   static char buff[100];
   strncpy(buff, netVal, length);
   buff[length] = 0;

   // In this case, we can implicitly convert from FOM representation (char*)
   // to VR-Link representation (DtGlobalObjectDesignator).  No explicit
   // conversion is necessary.  Just pass the value to the mutator function.
   inter->setAttackerId(buff);
}

void ShootDecoder::decodeShootee(DtFireInteraction* inter,
   const RTI::ParameterHandleValuePairSet& params,
   int index)
{
   RTI::ULong length = 0;
   // Get value in RTI representation into netVal.
   char* netVal = (char*) 
      params.getValuePointer(index, length);
   
   // Must copy to a buffer, because string returned by getValuePointer may
   // not be NULL terminated.
   static char buff[100];
   strncpy(buff, netVal, length);
   buff[length] = 0;

   // In this case, we can implicitly convert from FOM representation (char*)
   // to VR-Link representation (DtGlobalObjectDesignator).  No explicit
   // conversion is necessary.  Just pass the value to the mutator function.
   inter->setTargetId(buff);
}

#endif

Document ID: Generated on Mon May 14 08:06:18 EDT 2012 from SVN revision 114750
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)