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

The TestEncoder class (in testEnc.h and testEnc.cxx) is implemented similarly to the decoder class, but it also contains checking functions in addition to encoding functions.


/*********************************************************************
** Copyright (c) 1992-2010 VT MAK
** All rights reserved.
*********************************************************************/
#pragma once
#if DtHLA
class DT_DLL_VL TestStateRepository;
#define DtDECLARE_TEST_ATTR_CHECKER(attrName) \
DtDECLARE_ATTR_CHECKER(TestStateRepository, attrName)
#define DtDECLARE_TEST_ATTR_ENCODER(attrName) \
DtDECLARE_ATTR_ENCODER(TestStateRepository, attrName)
#define DtDEFINE_SIMPLE_TEST_ATTR_ENCODER( \
attrName, netType, inspector) \
DtDEFINE_SIMPLE_ATTR_ENCODER(TestEncoder, \
TestStateRepository, attrName, netType, inspector)
#define DtDEFINE_SIMPLE_TEST_ATTR_CHECKER( \
attrName, inspector) \
DtDEFINE_SIMPLE_ATTR_CHECKER(TestEncoder, \
TestStateRepository, \
attrName, inspector)
class TestEncoder : public DtHlaStateEncoder
{
public:
TestEncoder(
DtExerciseConn* exConn,
DtObjClassDesc* classDesc);
virtual ~TestEncoder();
protected:
DtDECLARE_TEST_ATTR_ENCODER(Number);
DtDECLARE_TEST_ATTR_ENCODER(Vector);
DtDECLARE_TEST_ATTR_CHECKER(Number);
DtDECLARE_TEST_ATTR_CHECKER(Vector);
};
#endif

/*********************************************************************
** Copyright (c) 1992-2010 VT MAK
** All rights reserved.
*********************************************************************/
#if DtHLA
#include "testEnc.h"
#include "testSR.h"
TestEncoder::TestEncoder(
DtExerciseConn* exConn,
DtObjClassDesc* classDesc) :
DtHlaStateEncoder(exConn, classDesc)
{
// Register the individual encoding and checking functions for Test's
// attributes with the object. The encoding functions have names like
// encodeNumber, while checking functions have names like needNumber. The
// macros expands to look like this:
// addEncoder("Number", (DtAttributeEncoder) encodeNumber);
// addChecker("Number", (DtAttributeChecker) needNumber);
DtADD_ATTR_ENCODER(Number);
DtADD_ATTR_ENCODER(Vector);
DtADD_ATTR_CHECKER(Number);
DtADD_ATTR_CHECKER(Vector);
}
TestEncoder::~TestEncoder()
{
}
// Encoding functions
DtDEFINE_SIMPLE_TEST_ATTR_ENCODER(
Number, DtNetU32, number);
DtDEFINE_SIMPLE_TEST_ATTR_ENCODER(
Vector, DtNet64Vector, vector);
// Checking functions
DtDEFINE_SIMPLE_TEST_ATTR_CHECKER(
Number, number);
DtDEFINE_SIMPLE_TEST_ATTR_CHECKER(
Vector, vector);
#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)