VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
statePropertiesStateComponent.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2021 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
6 #pragma once
7 
13 #include <vrfutil/rwUUID.h>
14 #include "vrfutil/echelonId.h"
15 #include <vlutil/vlTime.h>
16 #include "legionDataStore/writeStateInstance.h"
17 #include "legionDataStore/readStateInstance.h"
18 #include "legionDataStore/view.h"
19 #include "vrfOM/sets/readStatePropertiesRepository.hpp"
20 #include "vrfOM/sets/writeStatePropertiesRepository.hpp"
21 
22 namespace makVrf
23 {
24  class DtStatePropertiesStateComponentDataStore;
25 
27  {
29  : myStateProperties("state-properties")
30  , myStatePropertiesUpdated(false)
31  , myParameterProperties(new DtRwProperties("parameter-properties"))
32  {
33  }
34 
36  : myStateProperties(orig.myStateProperties)
37  , myStatePropertiesUpdated(orig.myStatePropertiesUpdated)
38  , myParameterProperties(orig.myParameterProperties)
39  {
40  }
41 
43  {
44  myParameterProperties = rhs.myParameterProperties;
45  myStateProperties = rhs.myStateProperties;
46  myStatePropertiesUpdated = true;
47 
48  return *this;
49  }
50 
52  {
53  myStatePropertiesUpdated = false;
54  }
55 
57  {
58  myStatePropertiesUpdated = true;
59  }
60 
62  {
63  myStateProperties.clearVariables();
64  std::vector<DtReaderWriterRegistryData*>::const_iterator itr = other.registry().registryData().begin();
65  std::vector<DtReaderWriterRegistryData*>::const_iterator end = other.registry().registryData().end();
66  for(; itr != end; ++itr)
67  {
68  const DtPropertyInterface* iface = dynamic_cast<const DtPropertyInterface*>((*itr)->readerWriter());
69 
70  if (!iface || iface->isPublished())
71  {
72  const DtReaderWriter* otherRw = (*itr)->readerWriter();
74  otherRw, &myStateProperties.registry());
75  }
76  }
77  }
78 
79  const DtRwProperties& parameterProperties() const { return *(myParameterProperties.get()); };
80  DtRwProperties& parameterProperties() { return *(myParameterProperties.get()); };
81 
82  DEFINE_REF_ACCESSORS(DtRwProperties, stateProperties, StateProperties)
83  DEFINE_ACCESSOR_MUTATOR(bool, statePropertiesUpdated, StatePropertiesUpdated)
84 
85  protected:
86  DtRwProperties myStateProperties;
87  bool myStatePropertiesUpdated;
88  std::shared_ptr<DtRwProperties> myParameterProperties;
89  };
90 
94  {
95  public:
96  typedef std::map<DtString, DtString> ExtendedData;
98 
100  : DtFrameStateInterface(storage)
101  {
102  }
103 
105  UNDEFINED_RETURNREF_ACCESSOR(bool, statePropertiesUpdated)
106  UNDEFINED_RETURNREF_ACCESSORS(DtRwProperties, parameterProperties)
107  UNDEFINED_METHOD(void, setParameterProperties, const DtRwProperties&)
108 
109  virtual void setStateProperties(const DtRwProperties&) { throw DtUnimplementedMethod("setStateProperties(const DtRwProperties& key) is not implemented for this class"); };
110  };
111 
114  {
115  public:
117  virtual ~DtStatePropertiesStateComponentNextFrame() override;
118 
120  const DtStatePropertiesStateComponentData& frameState() const { return myData; };
122 
123  virtual const DtRwProperties& stateProperties() const override;
124  virtual DtRwProperties& stateProperties() override;
125  virtual void setStateProperties(const DtRwProperties&) override;
126 
127  virtual const bool& statePropertiesUpdated() const override;
128 
129  virtual const DtRwProperties& parameterProperties() const override;
130  virtual DtRwProperties& parameterProperties() override;
131  virtual void setParameterProperties(const DtRwProperties&) override;
132  virtual bool isModified() const override;
133 
135  virtual void makeWritable() override;
136 
138  virtual void makeReadOnly() override;
139 
141  {
142  return myStatePropertiesModified;
143  }
144 
146  {
147  myStatePropertiesModified = false;
148  }
149 
151  void setPublishingOnLegionNetwork(bool);
152 
153  void updateLegionNetwork(double newTime);
154 
156  {
157  return myLastTimeStatePropertiesUpdated;
158  }
159 
160  void markUpdated();
161 
162  protected:
163  VRF::WriteStatePropertiesRepository myWriteStatePropertiesRepository;
166  std::map<std::string, Legion::InstanceHandle> myLegionStateProperties;
168  double myLastTimeStatePropertiesUpdated = 0.;
169  };
170 
173  {
174  public:
177 
179  const DtStatePropertiesStateComponentData& frameState() const { return myData; };
180 
181  virtual const DtRwProperties& stateProperties() const override;
182  virtual const bool& statePropertiesUpdated() const override;
183  virtual const DtRwProperties& parameterProperties() const override;
184 
185  virtual bool findReadComponent();
186  virtual bool readComponentValid() const;
187 
188  void setPublishingOnLegionNetwork(bool);
189 
191  {
192  return myStatePropertiesModifiedByLegion;
193  }
194 
196  {
197  myStatePropertiesModifiedByLegion = false;
198  }
199 
200  protected:
202  void handleStatePropertiesUpdated();
203 
204  protected:
206  bool updateOnlyModifiedStatePropertiesSince(const DtRwProperties& source, double since);
208  {
209  myData.parameterProperties() = data.parameterProperties();
210  }
211 
212  protected:
213  VRF::ReadStatePropertiesRepository myReadStatePropertiesRepository;
214  unsigned int myCallbackHandle;
216  std::map<std::string, double> myLastTimeUpdated;
219  };
220 
224  {
225  public:
228 
229  bool isDoubleBuffered() { return true; };
230  virtual const DtFrameStateInterface* currentFrameState() const override { return &myCurrentFrameState; }
231  virtual DtFrameStateInterface* nextFrameState() override { return &myNextFrameState; };
232  virtual const DtFrameStateInterface* nextFrameState() const override { return &myNextFrameState; };
233 
234  virtual void updateDataStorage() override;
235 
236  virtual void updateStateData(DtStateData* sd) override
237  {
238  myCurrentFrameState.updateStateData(sd);
239  myNextFrameState.updateStateData(sd);
240  }
241 
243  virtual bool forceAdvance() override;
244 
245  virtual void initializeFromParameters(const DtVrfObjectParameters* params) override;
246 
247  virtual void aboutToBeDeleted() override
248  {
250  myCurrentFrameState.aboutToBeDeleted();
251  myNextFrameState.aboutToBeDeleted();
252  }
253 
255  virtual void setPublishingOnLegionNetwork(bool) override;
256 
257  protected:
261  };
262 
266 }
void copyOnlPublishedStateProperties(const DtRwProperties &other)
Definition: statePropertiesStateComponent.h:61
Instances of DtVrfObjectParameters are the readable/writeable objects that contain the information ne...
Definition: vrfObjectParameters.h:64
DtStatePropertiesStateComponentData()
Definition: statePropertiesStateComponent.h:28
1) Define the interface class that will be used to represent the next and curent frames. The UNDEFINED_ macros are convenience macros that will define methods that throw exceptions (until they are implemented)
Definition: statePropertiesStateComponent.h:93
std::map< std::string, double > myLastTimeUpdated
Definition: statePropertiesStateComponent.h:216
std::map< DtString, DtString > ExtendedData
Definition: statePropertiesStateComponent.h:96
DtStatePropertiesStateComponentNextFrame myNextFrameState
Definition: statePropertiesStateComponent.h:259
Definition: stateDataTypes.h:23
bool statePropertiesModified() const
Definition: statePropertiesStateComponent.h:140
Definition: statePropertiesStateComponent.h:26
#define UNDEFINED_METHOD(Type, Method,...)
Definition: doubleBufferedDataStorage.h:68
bool myStatePropertiesModified
Definition: statePropertiesStateComponent.h:164
2) Define the next frame class. This will be used for write access.
Definition: statePropertiesStateComponent.h:113
VRF::WriteStatePropertiesRepository myWriteStatePropertiesRepository
Definition: statePropertiesStateComponent.h:163
double lastTimeStatePropertiesUpdated() const
Definition: statePropertiesStateComponent.h:155
VRF::ReadStatePropertiesRepository myReadStatePropertiesRepository
Definition: statePropertiesStateComponent.h:213
Definition: stateComponent.h:269
const DtStatePropertiesStateComponentData & frameState() const
Next frame access write access. Ensure this is only used in a single thread (i.e.a controller thread)...
Definition: statePropertiesStateComponent.h:120
void clearStatePropertiesModifiedByLegion()
Definition: statePropertiesStateComponent.h:195
const std::vector< DtReaderWriterRegistryData * > & registryData() const
Definition: readerWriterRegistry.h:161
unsigned int myCallbackHandle
Definition: statePropertiesStateComponent.h:214
Definition: readerWriter.h:85
DtStatePropertiesStateComponentCurrentFrame myCurrentFrameState
Definition: statePropertiesStateComponent.h:258
#define UNDEFINED_RETURNREF_ACCESSORS(ReturnType, Member)
Definition: doubleBufferedDataStorage.h:40
Contains the DtUUID class declaration.
#define UNDEFINED_RETURNREF_ACCESSOR(ReturnType, Member)
Definition: doubleBufferedDataStorage.h:34
virtual void updateStateData(DtStateData *sd) override
Implement to update data storage to the new state data.
Definition: statePropertiesStateComponent.h:236
void clearStatePropertiesUpdated()
Definition: statePropertiesStateComponent.h:51
Interface class used to define minimal interface for a property. The DtPropertyInterface class provid...
Definition: propertyInterface.h:53
virtual DtReaderWriter * cloneReaderWriter(const DtString &name, const DtReaderWriter *sourceRw, DtReaderWriterRegistry *parentRegistry) const
Creates a clone of the RW object to create a clone of the specified object. The object will first be ...
static DtReaderWriterFactory * factory()
virtual const DtFrameStateInterface * nextFrameState() const override
Definition: statePropertiesStateComponent.h:232
DtStatePropertiesStateComponentData & frameState()
Definition: statePropertiesStateComponent.h:121
3) Define the current frame class. This will be used for read access.
Definition: statePropertiesStateComponent.h:172
virtual DtFrameStateInterface * nextFrameState() override
Definition: statePropertiesStateComponent.h:231
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:398
void clearStatePropertiesModified()
Definition: statePropertiesStateComponent.h:145
const DtReaderWriterRegistry & registry() const
Collection of child DtReaderWriter nodes owned by this object.
Definition: readerWriter.h:492
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:231
virtual const DtFrameStateInterface * currentFrameState() const override
Definition: statePropertiesStateComponent.h:230
DtStatePropertiesStateComponentData myData
Definition: statePropertiesStateComponent.h:167
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:384
const DtStatePropertiesStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: statePropertiesStateComponent.h:179
std::map< std::string, Legion::InstanceHandle > myLegionStateProperties
Definition: statePropertiesStateComponent.h:166
virtual void aboutToBeDeleted()
virtual void aboutToBeDeleted() override
Definition: statePropertiesStateComponent.h:247
const char * source
Definition: lz4.h:442
void advanceFrame(const DtStatePropertiesStateComponentData &data)
Definition: statePropertiesStateComponent.h:207
virtual bool isPublished() const =0
Whether this property should be published.
#define DEFINE_REF_ACCESSORS(ReturnType, Method, Member)
Definition: doubleBufferedDataStorage.h:13
#define DEFINE_ACCESSOR_MUTATOR(ReturnType, Accessor, Mutator)
Definition: doubleBufferedDataStorage.h:23
bool myStatePropertiesModifiedByLegion
Definition: statePropertiesStateComponent.h:217
const DtRwProperties & parameterProperties() const
Definition: statePropertiesStateComponent.h:79
bool statePropertiesModifiedByLegion() const
Definition: statePropertiesStateComponent.h:190
DtStatePropertiesStateComponentData & operator=(const DtStatePropertiesStateComponentData &rhs)
Definition: statePropertiesStateComponent.h:42
bool myFoundComponent
Definition: statePropertiesStateComponent.h:260
DtStatePropertiesStateComponentData myData
Definition: statePropertiesStateComponent.h:218
bool isDoubleBuffered()
Definition: statePropertiesStateComponent.h:229
#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
bool myPublishOnLegionNetwork
Definition: statePropertiesStateComponent.h:215
A list of properties. A DtPropertyInterface object that is a specialized version of DtRwVariableBindi...
Definition: rwProperties.h:122
void statePropertiesWereUpdated()
Definition: statePropertiesStateComponent.h:56
DtRwProperties & parameterProperties()
Definition: statePropertiesStateComponent.h:80
Contains the DtStateComponent class declaration.
bool myPublishOnLegionNetwork
Definition: statePropertiesStateComponent.h:165
DtRwProperties myStateProperties
Definition: statePropertiesStateComponent.h:80
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: statePropertiesStateComponent.h:223
virtual DtSymbolString name() const
Accessor for name of this readable/writable object.
DtStateComponentCreator< DtStatePropertiesStateComponentImplementation > DtStatePropertiesStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: statePropertiesStateComponent.h:265
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:294
DtStatePropertiesStateComponentData(const DtStatePropertiesStateComponentData &orig)
Definition: statePropertiesStateComponent.h:35
std::shared_ptr< DtRwProperties > myParameterProperties
Definition: statePropertiesStateComponent.h:88

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)