VR-Forces 4.0.4 Class Documentation
examples/addAttr/addAttrSim/myEsr.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002 ** Copyright (c) 2007 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 *******************************************************************************/
00005 /*******************************************************************************
00006 ** $RCSfile: myEsr.h,v $ $Revision: 1.8 $ $State: Exp $
00007 *******************************************************************************/
00008 
00009 #pragma once
00010 
00011 #if DtHLA
00012 
00013 #include <vrfExtObjects/extEntSR.h>
00014 
00015 #include <stdio.h>
00016 
00017 //Because this example adds a concept that did not already exist in VR-Link's
00018 //DtEntityStateRepository class, we create this subclass of
00019 //DtEntityStateRepository that adds the concept of mass.
00020 
00021 class MyEntityStateRep : public DtExtEntityStateRepository
00022 {
00023 public:
00024    MyEntityStateRep()
00025    : DtExtEntityStateRepository()
00026    , myMass(0.)
00027    {
00028    }
00029 
00030    MyEntityStateRep(const MyEntityStateRep& o)
00031    : DtExtEntityStateRepository(o)
00032    , myMass(o.myMass)
00033    {
00034    }
00035 
00036    //Set/Get the value of mass
00037    virtual void setMass(float mass);
00038    virtual float mass() const;
00039    
00040    //Virtual function override: print the state rep's data.
00041    virtual void printData() const;
00042 
00043 public:
00044    
00045    //Create a MyEntityStateRep.  Caller is reponsible for deletion.
00046    static DtExtEntityStateRepository* create();
00047    
00048    //Copy shallow (false) or deep (true).
00049    virtual DtStateRepository* clone(bool copy = false) const;
00050    
00051 protected:
00052 
00053    float myMass;
00054 };
00055 
00056 //Inline functions
00057 
00058 inline void MyEntityStateRep::setMass(float temp)
00059 {
00060    myMass = temp;
00061 }
00062 
00063 inline float MyEntityStateRep::mass() const
00064 {
00065    return myMass;
00066 }
00067 
00068 inline void MyEntityStateRep::printData() const
00069 {
00070    DtEntityStateRepository::printData();
00071    printf("Mass: %lf\n", mass());
00072 }
00073 
00074 inline DtExtEntityStateRepository* MyEntityStateRep::create()
00075 {
00076    return new MyEntityStateRep();
00077 }
00078 
00079 inline DtStateRepository* MyEntityStateRep::clone(bool copy) const
00080 {
00081    if (copy)
00082    {
00083       return new MyEntityStateRep(*this);
00084    }
00085    else
00086    {
00087       return new MyEntityStateRep();
00088    }
00089 }
00090 
00091 #endif

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)