VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
myEsr.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2007 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: myEsr.h,v $ $Revision: 1.8 $ $State: Exp $
7 *******************************************************************************/
8 
9 #pragma once
10 
11 #if DtHLA
12 
13 //#include <vrfExtendedProperties/extendedPropertiesEntityStateRepository.h>
15 #include <stdio.h>
17 #include <vl/entityPublisher.h>
18 #include <vl/reflectedEntityList.h>
19 
20 //Because this example adds a concept that did not already exist in VR-Link's
21 //DtEntityStateRepository class, we create this subclass of
22 //DtEntityStateRepository that adds the concept of mass.
23 
24 class MyEntityStateRep : public DtExtEntityStateRepository // DtExtendedPropertiesEntityStateRepository
25 {
26 public:
28  : //DtExtendedPropertiesEntityStateRepository()
30  , myMass(0.)
31  {
32  }
33 
35  : //DtExtendedPropertiesEntityStateRepository(o)
37  , myMass(o.myMass)
38  {
39  }
40 
41  //Set/Get the value of mass
42  virtual void setMass(float mass);
43  virtual float mass() const;
44 
45  //Virtual function override: print the state rep's data.
46  virtual void printData() const;
47 
48 public:
49 
50  //Create a MyEntityStateRep. Caller is reponsible for deletion.
52 
53  //Copy shallow (false) or deep (true).
54  virtual DtStateRepository* clone(bool copy = false) const;
55 
56 protected:
57 
58  float myMass;
59 };
60 
61 //Inline functions
62 
63 inline void MyEntityStateRep::setMass(float temp)
64 {
65  myMass = temp;
66 }
67 
68 inline float MyEntityStateRep::mass() const
69 {
70  return myMass;
71 }
72 
73 inline void MyEntityStateRep::printData() const
74 {
75  DtEntityStateRepository::printData();
76  printf("Mass: %lf\n", mass());
77 }
78 
80 {
81  return new MyEntityStateRep();
82 }
83 
85 {
86  if (copy)
87  {
88  return new MyEntityStateRep(*this);
89  }
90  else
91  {
92  return new MyEntityStateRep();
93  }
94 }
95 
97 {
98 public:
99 
103  {
104  DtWarn << "Constructing" << std::endl;
105  }
106 
109  {
110  DtWarn << "Destructing" << std::endl;
111  }
112 
113 protected:
114 
116  {
117  DtEntityPublisher::setStateRepCreator((DtEntityPublisher::DtStateRepCreator)
119  }
120 
122  {
123  DtReflectedEntity::setStateRepCreator((DtReflectedEntity::DtStateRepCreator)
125  }
126 };
127 
128 #endif
The extended attributes initializer for entity objects.
Definition: extendedAttributesInitializer.h:141
Because this example adds a concept that did not already exist in VR-Link&#39;s DtEntityStateRepository c...
Definition: myEsr.h:24
virtual void printData() const
Print data to the DtInfo stream.
Definition: myEsr.h:73
virtual DtStateRepository * clone(bool copy=false) const
Return a copy/empty object of the same type as this.
Definition: myEsr.h:84
static DtExtEntityStateRepository * create()
Definition: myEsr.h:79
DtExtEntityStateRepository class extends the DtExtEntityBaseStateRepository to be able to handle exte...
Definition: extEntityStateRepository.h:25
float myMass
Definition: myEsr.h:58
virtual ~MyEntityExtendedAttributesInitializer()
Destructor.
Definition: myEsr.h:108
Contains the DtExtEntityStateRepository class.
virtual void setMass(float mass)
Definition: myEsr.h:63
MyEntityExtendedAttributesInitializer()
Constructor.
Definition: myEsr.h:101
MyEntityStateRep()
Definition: myEsr.h:27
void setReflectedObjectStateRepCreator()
Sets the state rep creator for the associated reflected object.
Definition: myEsr.h:121
virtual float mass() const
Definition: myEsr.h:68
MyEntityStateRep(const MyEntityStateRep &o)
Definition: myEsr.h:34
void setPublisherStateRepCreator()
Sets the state rep creator for the associated publisher.
Definition: myEsr.h:115

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)