VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
articulatedPartStateComponent.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
6 #pragma once
7 
11 #include <vlpi/articulatedPartCollection.h>
12 
14 
15 namespace makVrf
16 {
17  class DtArticulatedPartStateRepository;
18 
20  {
22  : myArtPartListModified(false)
23  {
24  }
25 
26  void create()
27  {
28  myarticulatedPartManager = std::shared_ptr<DtArticulatedPartManager>(new DtArticulatedPartManager);
29  myartPartList = std::shared_ptr<DtArticulatedPartCollection>(new DtArticulatedPartCollection);
30  }
31 
33  : myarticulatedPartManager(orig.myarticulatedPartManager)
34  , myartPartList(orig.myartPartList)
35  , myArtPartListModified(orig.myArtPartListModified)
36  {
37  }
38 
40  {
41  myarticulatedPartManager = rhs.myarticulatedPartManager;
42  myartPartList = rhs.myartPartList;
43  myArtPartListModified = rhs.myArtPartListModified;
44 
45  return *this;
46  }
47 
48  bool initialized() const { return (myarticulatedPartManager.get() != 0); };
49  const DtArticulatedPartManager& articulatedPartManager() const { return *(myarticulatedPartManager.get()); };
50  DtArticulatedPartManager& articulatedPartManager(){ return *(myarticulatedPartManager.get()); };
51 
52  const DtArticulatedPartCollection& artPartList() const { return *(myartPartList.get()); };
53  DtArticulatedPartCollection& artPartList() { return *(myartPartList.get()); };
54 
55  void setArtPartListModified(bool b) { myArtPartListModified = b; };
56  bool artPartListModified() const { return myArtPartListModified; };
57  void clearArtPartListModified() { myArtPartListModified = false; };
58 
59  protected:
60  std::shared_ptr<DtArticulatedPartManager> myarticulatedPartManager;
61  std::shared_ptr<DtArticulatedPartCollection> myartPartList;
63  };
64 
66 
70  {
71  public:
73 
75  : DtFrameStateInterface(storage)
76  {
77  }
78 
82  virtual DtArticulatedPart& attachPartToListIfMissing(DtArtPartType partType) { throw DtUnimplementedMethod("DtArticulatedPart& attachPartToListIfMissing(DtArtPartType partType) is not implemented for this class."); };
83  virtual DtArticulatedPartStateRepository* attachPart(DtArtPartType partType) { throw DtUnimplementedMethod("DtArticulatedPartStateRepository* attachPart(DtArtPartType partType) is not implemented for this class."); };
84  virtual bool artPartListModified() const { throw DtUnimplementedMethod("bool artPartsModified() is not implemented for this class."); };
85  virtual void addParameterType(int partType, int parameterType) { throw DtUnimplementedMethod("void addParameterType(int partType, int parameterType) is not implemented for this class."); };
86  virtual void detachPartIfAttached(DtArtPartType partType) { throw DtUnimplementedMethod("void detachPartIfAttached(DtArtPartType partType) is not implemented for this class."); };
87  virtual void detachPart(DtArtPartType partType) { throw DtUnimplementedMethod("void detachPart(DtArtPartType partType) is not implemented for this class."); };
88  };
89 
92  {
93  public:
95 
97  const DtArticulatedPartStateComponentData& frameState() const { return myData; };
99 
100  virtual const DtArticulatedPartManager& articulatedPartManager() const override;
101  virtual DtArticulatedPartManager& articulatedPartManager() override;
102 
103  virtual const DtArticulatedPartManager& articulatedParts() const override;
104  virtual DtArticulatedPartManager& articulatedParts() override;
105 
106  virtual const DtArticulatedPartCollection& artPartList() const override;
107  virtual DtArticulatedPartCollection& artPartList() override;
108 
109  void setCoordinateSystem(const Coordinate_System*);
110 
112  virtual void makeWritable() override {};
113 
115  virtual void makeReadOnly() override {};
116 
117  virtual DtArticulatedPart& attachPartToListIfMissing(DtArtPartType partType) override;
118  virtual DtArticulatedPartStateRepository* attachPart(DtArtPartType partType) override;
119  virtual void detachPartIfAttached(DtArtPartType partType) override;
120  virtual void detachPart(DtArtPartType partType) override;
121 
122  void setPublishOnLegionNetwork(bool b);
123 
124  virtual void clearModified() override;
125  virtual bool artPartListModified() const override;
126 
127  virtual void addParameterType(int partType, int parameterType) override;
128 
129  protected:
132  };
133 
136  {
137  public:
139 
141  const DtArticulatedPartStateComponentData& frameState() const { return myData; };
142 
143  virtual const DtArticulatedPartManager& articulatedPartManager() const override;
144  virtual const DtArticulatedPartManager& articulatedParts() const override;
145  virtual const DtArticulatedPartCollection& artPartList() const override;
146 
149  void setUpdateFromLegionNetwork(bool);
150  virtual void clearModified() override;
151  virtual bool artPartListModified() const override;
152 
153  protected:
156  {
157  myData = data;
158  }
159 
160  protected:
163  };
164 
168  {
169  public:
171 
172  bool isDoubleBuffered() { return true; };
173  virtual const DtFrameStateInterface* currentFrameState() const override { return &myCurrentFrameState; }
174  virtual DtFrameStateInterface* nextFrameState() override { return &myNextFrameState; };
175  virtual const DtFrameStateInterface* nextFrameState() const override { return &myNextFrameState; };
176 
177  virtual void setCoordinateSystem(const Coordinate_System*) override;
178 
179  virtual void updateDataStorage() override;
180 
181  virtual void updateStateData(DtStateData* sd) override
182  {
183  myCurrentFrameState.updateStateData(sd);
184  myNextFrameState.updateStateData(sd);
185  }
186 
187  virtual void setPublishingOnLegionNetwork(bool b) override;
188 
189  virtual void initializeFromParameters(const DtVrfObjectParameters* params) override;
190 
191  virtual void aboutToBeDeleted() override
192  {
194  myCurrentFrameState.aboutToBeDeleted();
195  myNextFrameState.aboutToBeDeleted();
196  }
197 
200  static void SetAddMissingParameterToAllParts(bool);
201  static bool AddMissingParameterToAllParts();
202 
203  protected:
205  virtual void createPartsFromDescriptors(const std::list<DtSimArtPartDescriptor*>& descriptors,
206  const std::list<DtSimArtPartDescriptor*>& partDefaultsFromActuators);
207 
208  protected:
211  };
212 
216 }
Instances of DtVrfObjectParameters are the readable/writeable objects that contain the information ne...
Definition: vrfObjectParameters.h:64
The articulated part manager maintains a tree of articulated and attached parts for the state reposit...
Definition: articulatedPartManager.h:33
Definition: stateDataTypes.h:23
std::shared_ptr< DtArticulatedPartCollection > myartPartList
Definition: articulatedPartStateComponent.h:61
DtArticulatedPartCollection & artPartList()
Definition: articulatedPartStateComponent.h:53
2) Define the next frame class. This will be used for write access.
Definition: articulatedPartStateComponent.h:91
A readable, writable type that holds an articulated part type, attached-to part type, attachment point, and a list of art-part params (DtSimArtPartParamList). The read/write name is not used for anything in particular, and therefore may be used for file readability.
Definition: simArtPartDescriptor.h:28
Definition: stateComponent.h:269
In order to be a well defined state component, you must:
Definition: articulatedPartStateComponent.h:69
virtual bool artPartListModified() const
Definition: articulatedPartStateComponent.h:84
DtArticulatedPartManager & articulatedPartManager()
Definition: articulatedPartStateComponent.h:50
#define UNDEFINED_RETURNREF_ACCESSORS(ReturnType, Member)
Definition: doubleBufferedDataStorage.h:40
virtual DtFrameStateInterface * nextFrameState() override
Definition: articulatedPartStateComponent.h:174
const DtArticulatedPartStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: articulatedPartStateComponent.h:141
DtArticulatedPartStateComponentNextFrame myNextFrameState
Definition: articulatedPartStateComponent.h:210
DtArticulatedPartStateComponentData()
Definition: articulatedPartStateComponent.h:21
bool isDoubleBuffered()
Definition: articulatedPartStateComponent.h:172
virtual void aboutToBeDeleted() override
Definition: articulatedPartStateComponent.h:191
const DtArticulatedPartStateComponentData & frameState() const
Next frame access write access. Ensure this is only used in a single thread (i.e.a controller thread)...
Definition: articulatedPartStateComponent.h:97
bool myArtPartListModified
Definition: articulatedPartStateComponent.h:62
virtual void detachPartIfAttached(DtArtPartType partType)
Definition: articulatedPartStateComponent.h:86
virtual void updateStateData(DtStateData *sd) override
Implement to update data storage to the new state data.
Definition: articulatedPartStateComponent.h:181
Definition: coordSystem.h:54
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:398
DtArticulatedPartStateComponentData myData
Definition: articulatedPartStateComponent.h:130
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:231
virtual void makeWritable() override
Override to make component writable.
Definition: articulatedPartStateComponent.h:112
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:384
DtArticulatedPartStateComponentData(const DtArticulatedPartStateComponentData &orig)
Definition: articulatedPartStateComponent.h:32
DtStateComponentCreator< DtArticulatedPartStateComponentImplementation > DtArticulatedPartStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: articulatedPartStateComponent.h:215
virtual void aboutToBeDeleted()
virtual void detachPart(DtArtPartType partType)
Definition: articulatedPartStateComponent.h:87
virtual const DtFrameStateInterface * currentFrameState() const override
Definition: articulatedPartStateComponent.h:173
virtual const DtFrameStateInterface * nextFrameState() const override
Definition: articulatedPartStateComponent.h:175
bool initialized() const
Definition: articulatedPartStateComponent.h:48
DtArticulatedPartStateComponentData & frameState()
Definition: articulatedPartStateComponent.h:98
std::shared_ptr< DtArticulatedPartManager > myarticulatedPartManager
Definition: articulatedPartStateComponent.h:57
DtArticulatedPartStateComponentData & operator=(const DtArticulatedPartStateComponentData &rhs)
Definition: articulatedPartStateComponent.h:39
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: articulatedPartStateComponent.h:167
bool artPartListModified() const
Definition: articulatedPartStateComponent.h:56
void create()
Definition: articulatedPartStateComponent.h:26
The DtArticulatedPartStateRepository class is used to represent articulated parts for an entity...
Definition: articulatedPartStateRepository.h:40
void advanceFrame(const DtArticulatedPartStateComponentData &data)
Definition: articulatedPartStateComponent.h:155
DtArticulatedPartStateComponentCurrentFrame myCurrentFrameState
Definition: articulatedPartStateComponent.h:209
#define DT_DLL_vrfStateData
This file is used to determine how to build Disable inconsistent dll linkage warning Visual Studio 6...
Definition: vrfStateDataDefines.h:26
const DtArticulatedPartManager & articulatedPartManager() const
Definition: articulatedPartStateComponent.h:49
void setArtPartListModified(bool b)
Definition: articulatedPartStateComponent.h:55
const DtArticulatedPartCollection & artPartList() const
Definition: articulatedPartStateComponent.h:52
bool myPublishOnLegionNetwork
Definition: articulatedPartStateComponent.h:131
virtual DtArticulatedPartStateRepository * attachPart(DtArtPartType partType)
Definition: articulatedPartStateComponent.h:83
Definition: articulatedPartStateComponent.h:19
3) Define the current frame class. This will be used for read access.
Definition: articulatedPartStateComponent.h:135
virtual void addParameterType(int partType, int parameterType)
Definition: articulatedPartStateComponent.h:85
Contains the DtStateComponent class declaration.
DtArticulatedPartStateComponentData myData
Definition: articulatedPartStateComponent.h:161
virtual void makeReadOnly() override
Override to make component read-only.
Definition: articulatedPartStateComponent.h:115
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:294
bool myUpdateFromLegionNetwork
Definition: articulatedPartStateComponent.h:162

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)