![]() |
VR-Link API Documentation for HLA Evolved
|
This file contains the class declaration and definition of an entity state repository that adds the attribute "Mass" to the existing DtEntityStateRepository.
Applications typically get state information about entities from a DtEntityStateRepository. This class has mutators and inspectors that provide access to many components of an entity's state, but the concept of mass is not one of these components. So in the file myEsr.h, we extend the DtEntityStateRepository API by deriving a class called MyEntityStateRep.
We added an inspector and mutator function for the concept of mass, and overrode the virtual printData() function, so that mass will be printed along with the other state data. Finally, we provided a static create() function that you can register with other VR-Link classes, so that they can create an instance of our new state repository. These functions have straightforward implementations.
/********************************************************************* ** Copyright (c) 1992-2010 VT MAK ** All rights reserved. *********************************************************************/ #pragma once #if DtHLA #include <stdio.h> #include <vl/entitySR.h> class MyEntityStateRep : public DtEntityStateRepository { public: virtual void setMass(float mass); virtual float mass() const; virtual void printData() const; public: static DtEntityStateRepository* create(); virtual DtStateRepository* clone(bool copy = false) const; protected: float myMass; }; inline void MyEntityStateRep::setMass(float temp) { myMass = temp; } inline float MyEntityStateRep::mass() const { return myMass; } inline void MyEntityStateRep::printData() const { DtEntityStateRepository::printData(); printf("Mass: %lf\n", mass()); } inline DtEntityStateRepository* MyEntityStateRep::create() { return new MyEntityStateRep(); } inline DtStateRepository* MyEntityStateRep::clone(bool copy) const { if (copy) { return new MyEntityStateRep(*this); } else { return new MyEntityStateRep(); } } #endif