![]() |
VR-Link API Documentation for HLA 1516
|
vehicleDec decodes vehicle objects.
/********************************************************************* ** Copyright (c) 1998 MaK Technologies, Inc. ** All rights reserved. *********************************************************************/ #if DtHLA #ifndef VehicleDecoder_H_ #define VehicleDecoder_H_ #include "myFomMap.h" #include <vl/hStateDecoder.h> // Forward declaration of DtEntityStateRepository class. class DT_DLL_VL DtEntityStateRepository; // 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) class DT_DLL_FOMMAP VehicleDecoder : public DtHlaStateDecoder { public: // default constructor VehicleDecoder(DtExerciseConn* exConn, DtObjClassDesc* classDesc); // 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) DtDECLARE_VEHICLE_ATTR_DECODER(VehicleType); DtDECLARE_VEHICLE_ATTR_DECODER(GeocLoc); }; #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" #include <vl/entitySR.h> #include <vlpi/NetStructs.h> // Default constructor VehicleDecoder::VehicleDecoder( 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); DtADD_ATTR_DECODER(GeocLoc); } VehicleDecoder::~VehicleDecoder() { } // 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