VR-Link API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Creating a New State Repository

We first create a new subclass of DtStateRepository called TestStateRepository, in testSR.h and testSR.cxx.

This class is used to store the state of both local and reflected objects of our Test class.

The class definition is listed below. We provide inspector and mutator functions to access the state data, an override of the virtual printData() function that prints the current state data, and an override of the virtual clone() function that returned a new'ed instance of this class. We represent state data in the same way as in the FOM, but this is not strictly necessary. We could perform a non-trivial conversion in FOM mapping code instead.


/*********************************************************************
** Copyright (c) 1992-2010 VT MAK
** All rights reserved.
*********************************************************************/
#pragma once
#if DtHLA
{
public:
virtual DtStateRepository* clone(bool copy) const;
virtual void printData() const;
virtual void printDataToStream(std::ostream& stream) const;
virtual void setNumber(int num);
virtual int number() const;
virtual void setVector(const DtVector& vec);
virtual const DtVector& vector() const;
public:
protected:
int myNum;
};
#endif

/*********************************************************************
** Copyright (c) 1992-2010 VT MAK
** All rights reserved.
*********************************************************************/
#if DtHLA
#include "testSR.h"
#include <vlutil/vlPrint.h>
#include <iostream>
myNum(0),
myVec()
{
}
{
}
myNum(orig.myNum),
myVec(orig.myVec)
{
}
const TestStateRepository& orig)
{
// Guard against assignment to yourself.
if (this == &orig)
{
return *this;
}
myNum = orig.myNum;
myVec = orig.myVec;
return *this;
}
{
if (copy)
{
return new TestStateRepository(*this);
}
else
{
return new TestStateRepository();
}
}
{
}
void TestStateRepository::printDataToStream(std::ostream& stream) const
{
DtPrintAttribute(stream,"Number: ", number());
DtPrintAttribute(stream,"Vector: ", vector().string());
}
// Accessor functions are typically pretty straightforward.
{
myNum = num;
}
{
return myNum;
}
{
myVec = vec;
}
{
return myVec;
}
{
return new TestStateRepository();
}
#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)