VR-Link API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MyEsr

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>
class MyEntityStateRep : public DtEntityStateRepository
{
public:
virtual void setMass(float mass);
virtual float mass() const;
virtual void printData() const;
public:
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
{
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

Document ID: Generated on Tue Aug 10 00:12:31 EDT 2021 from SVN revision 232765
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)