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.
#pragma once
#if DtHLA
{
public:
TestStateRepository();
virtual ~TestStateRepository();
TestStateRepository(const TestStateRepository& orig);
TestStateRepository&
operator=(
const TestStateRepository& orig);
virtual void setNumber(int num);
virtual int number() const;
virtual void setVector(
const DtVector& vec);
public:
protected:
int myNum;
};
#endif
#if DtHLA
#include <iostream>
TestStateRepository::TestStateRepository() :
myNum(0),
myVec()
{
}
TestStateRepository::~TestStateRepository()
{
}
TestStateRepository::TestStateRepository(const TestStateRepository& orig) :
myNum(orig.myNum),
myVec(orig.myVec)
{
}
const TestStateRepository& orig)
{
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::setNumber(int num)
{
myNum = num;
}
int TestStateRepository::number() const
{
return myNum;
}
void TestStateRepository::setVector(
const DtVector& vec)
{
myVec = vec;
}
const DtVector& TestStateRepository::vector()
const
{
return myVec;
}
{
return new TestStateRepository();
}
#endif