VR-Link API Documentation for HLA 1516
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Creating the Decoder Class

TestDecoder is defined in testDec.h and testDec.cxx.

Macros help out in the declaration and definition of decoding functions, which are implemented as static member functions of TestDecoder. The TestDecoder constructor self-registers its decoding functions.


/*********************************************************************
** Copyright (c) 1992-2010 VT MAK
** All rights reserved.
*********************************************************************/
#if DtHLA
#pragma once
#define DtDECLARE_TEST_ATTR_DECODER(attrName) \
DtDECLARE_ATTR_DECODER(TestStateRepository, attrName)
#define DtDEFINE_SIMPLE_TEST_ATTR_DECODER( \
attrName, netType, inspector) \
DtDEFINE_SIMPLE_TEST_ATTR_DECODER_WITH_CAST( \
attrName, netType, inspector, (netType))
#define DtDEFINE_SIMPLE_TEST_ATTR_DECODER_WITH_CAST( \
attrName, netType, mutator, castExpr) \
DtDEFINE_SIMPLE_ATTR_DECODER_WITH_CAST( \
TestDecoder, TestStateRepository, \
attrName, netType, mutator, castExpr)
{
public:
DtExerciseConn* exConn,
DtObjClassDesc* classDesc);
virtual ~TestDecoder();
protected:
};
#endif

/*********************************************************************
** Copyright (c) 1992-2010 VT MAK
** All rights reserved.
*********************************************************************/
#if DtHLA
#include "testDec.h"
#include "testSR.h"
#include <vlutil/vlPrint.h>
// Default constructor
DtExerciseConn* exConn,
DtObjClassDesc* classDesc) :
DtHlaStateDecoder(exConn, classDesc)
{
// Register the individual decoding functions for Test's attributes with
// the object. The decoding functions have names like decodeNumber and
// decodeVector. The macro expands to look like this:
// addDecoder("Number", (DtAttributeDecoder) decodeNumber);
}
{
}
// Decoding functions
// The DtDEFINE_SIMPLE_ATTR_DECODER macro can be used to define a "simple"
// decoding function. Expanded, a decoding function looks like this:
//
// void TestDecoder::decodeNumber(TestStateRepository* 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);
// // Check for size mismatch
// if (length > sizeof(DtNetInt32))
// {
// DtWarn("Size of value decoded for attribute %s (%d)\n",
// "Number", length);
// DtWarn(" is larger than size of %s (%d)\n",
// "DtNetInt32", sizeof(DtNetInt32));
// }
// // Pass the value to the mutator function, assuming the "net" type can
// // be implicitly cast to the native type expected by the mutator.
// stateRep->setNumber(*netVal);
// }
#endif

Document ID: Generated on Mon Feb 6 18:36:34 EST 2017 from SVN revision 173107
Copyright © 2005-2016 VT MÄK. All Rights Reserved (www.mak.com)