![]() |
VR-Forces 4.0.4 Class Documentation
|
The MyEntityStateRep class contains the new mass variable
/******************************************************************************* ** Copyright (c) 2007 MAK Technologies, Inc. ** All rights reserved. *******************************************************************************/ /******************************************************************************* ** $RCSfile: myEsr.h,v $ $Revision: 1.8 $ $State: Exp $ *******************************************************************************/ #pragma once #if DtHLA #include <vrfExtObjects/extEntSR.h> #include <stdio.h> //Because this example adds a concept that did not already exist in VR-Link's //DtEntityStateRepository class, we create this subclass of //DtEntityStateRepository that adds the concept of mass. class MyEntityStateRep : public DtExtEntityStateRepository { public: MyEntityStateRep() : DtExtEntityStateRepository() , myMass(0.) { } MyEntityStateRep(const MyEntityStateRep& o) : DtExtEntityStateRepository(o) , myMass(o.myMass) { } //Set/Get the value of mass virtual void setMass(float mass); virtual float mass() const; //Virtual function override: print the state rep's data. virtual void printData() const; public: //Create a MyEntityStateRep. Caller is reponsible for deletion. static DtExtEntityStateRepository* create(); //Copy shallow (false) or deep (true). virtual DtStateRepository* clone(bool copy = false) const; protected: float myMass; }; //Inline functions 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 DtExtEntityStateRepository* MyEntityStateRep::create() { return new MyEntityStateRep(); } inline DtStateRepository* MyEntityStateRep::clone(bool copy) const { if (copy) { return new MyEntityStateRep(*this); } else { return new MyEntityStateRep(); } } #endif