VR-Link API Documentation for HLA 1.3
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 



#include <vl/hStateEncoder.h>

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"
#include <vlpi/NetStructs.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 May 14 08:06:18 EDT 2012 from SVN revision 114750
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)