VR-Link API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Vehicle Object Dec

vehicleDec decodes vehicle objects.


/*********************************************************************
** Copyright (c) 1998 MaK Technologies, Inc.
** All rights reserved.
*********************************************************************/
#if DtHLA
#ifndef VehicleDecoder_H_
#define VehicleDecoder_H_
#include "myFomMap.h"
// Forward declaration of DtEntityStateRepository class.
// We define several macros that can be helpful in defining the class, and the
// individual decoding functions.
#define DtDECLARE_VEHICLE_ATTR_DECODER(attrName) \
DtDECLARE_ATTR_DECODER(DtEntityStateRepository, attrName)
{
public:
// default constructor
// destructor
virtual ~VehicleDecoder();
protected:
// Individual attribute decoding functions - one for each attribute.
// These macros expand to look like this:
// static void decodeVehicleType(DtEntityStateRepository* stateRep,
// const RTI::AttributeHandleValuePairSet& attrs, int pairSetIndex)
};
#endif
#endif

/*********************************************************************
** Copyright (c) 1998 MAK Technologies, Inc.
** All rights reserved.
*********************************************************************/
/*********************************************************************
** $RCSfile: vehicleDec.cxx,v $ $Revision: 1.4 $ $State: Exp $
*********************************************************************/
#if DtHLA
#include "vehicleDec.h"
// Default constructor
DtExerciseConn* exConn,
DtObjClassDesc* classDesc) :
DtHlaStateDecoder(exConn, classDesc)
{
// Register the individual decoding functions for Vehicle's attributes with
// the object. The decoding functions have names like decodeVehicleType
// and decodeGeocLoc. The macro expands to look like this:
// addDecoder("VehicleType", (DtAttributeDecoder) decodeVehicleType);
DtADD_ATTR_DECODER(VehicleType);
}
{
}
// Decoding functions
// Macros can help with definitions of simple decoding functions, as in in
// examples/extend/testObj/testDec.cxx but here we do not rely on them.
void VehicleDecoder::decodeVehicleType(DtEntityStateRepository* stateRep,
const RTI::AttributeHandleValuePairSet& attrs,
int index)
{
RTI::ULong length = 0;
// Get value from RTI representation into netVal.
DtNetInt32* netVal = (DtNetInt32*) attrs.getValuePointer(index, length);
// Convert from FOM representation to VR-Link representation.
// Byte swapping occurs if necessary, when converting from "Net" types to
// native types.
int nativeVal = (DtInt32) *netVal;
DtEntityType entityType;
if (nativeVal == 0)
{
// It's an M1.
entityType = DtEntityType(1, 1, 225, 1, 1, 0, 0);
}
else if (nativeVal == 1)
{
// It's a T72.
entityType = DtEntityType(1, 1, 222, 1, 2, 0, 0);
}
// pass the value to the mutator function
stateRep->setEntityType(entityType);
}
void VehicleDecoder::decodeGeocLoc(DtEntityStateRepository* stateRep,
const RTI::AttributeHandleValuePairSet& attrs,
int index)
{
RTI::ULong length = 0;
// Get value from RTI representation into netVal.
DtNet64Vector* netVal =
(DtNet64Vector*) attrs.getValuePointer(index, length);
// In this case, the FOM representation (DtNet64Vector) can be implicitly
// converted to VR-Link representation (DtVector)
stateRep->setLocation(*netVal);
}
#endif

Document ID: Generated on Tue Mar 1 02:56:17 EST 2016 from SVN revision 162687
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)