VR-Forces 5.0.2 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:
118 
120  const DtStatePropertiesStateComponentData& frameState() const { return myData; };
122 
123  const DtRwProperties& stateProperties() const;
124  DtRwProperties& stateProperties();
125  void setStateProperties(const DtRwProperties&);
126 
127  const bool& statePropertiesUpdated() const;
128 
129  const DtRwProperties& parameterProperties() const;
130  DtRwProperties& parameterProperties();
131  void setParameterProperties(const DtRwProperties&);
132 
134  virtual void makeWritable();
135 
137  virtual void makeReadOnly();
138 
140  {
141  return myStatePropertiesModified;
142  }
143 
145  {
146  myStatePropertiesModified = false;
147  }
148 
150  void setPublishingOnLegionNetwork(bool);
151 
152  void updateLegionNetwork(double newTime);
153 
154  protected:
155  VRF::WriteStatePropertiesRepository myWriteStatePropertiesRepository;
158  std::map<std::string, Legion::InstanceHandle> myLegionStateProperties;
161  };
162 
165  {
166  public:
169 
171  const DtStatePropertiesStateComponentData& frameState() const { return myData; };
172 
173  const DtRwProperties& stateProperties() const;
174  const bool& statePropertiesUpdated() const;
175  const DtRwProperties& parameterProperties() const;
176 
177  virtual bool findReadComponent();
178  virtual bool readComponentValid() const;
179 
180  void setPublishingOnLegionNetwork(bool);
181 
183  {
184  return myStatePropertiesModifiedByLegion;
185  }
186 
188  {
189  myStatePropertiesModifiedByLegion = false;
190  }
191 
192  protected:
194  void handleStatePropertiesUpdated();
195 
196  protected:
198  void updateOnlyModifiedStatePropertiesSince(const DtRwProperties& source, double since);
200  {
201  myData.parameterProperties() = data.parameterProperties();
202  }
203 
204  protected:
205  VRF::ReadStatePropertiesRepository myReadStatePropertiesRepository;
206  unsigned int myCallbackHandle;
208  std::map<std::string, double> myLastTimeUpdated;
212  };
213 
217  {
218  public:
221 
222  bool isDoubleBuffered() { return true; };
223  const DtFrameStateInterface* currentFrameState() const { return &myCurrentFrameState; }
224  virtual DtFrameStateInterface* nextFrameState() { return &myNextFrameState; };
225  virtual const DtFrameStateInterface* nextFrameState() const { return &myNextFrameState; };
226 
227  void updateDataStorage();
228 
230  {
231  myCurrentFrameState.updateStateData(sd);
232  myNextFrameState.updateStateData(sd);
233  }
234 
236  virtual bool forceAdvance();
237 
238  virtual void initializeFromParameters(const DtVrfObjectParameters* params);
239 
240  virtual void aboutToBeDeleted() override
241  {
243  myCurrentFrameState.aboutToBeDeleted();
244  myNextFrameState.aboutToBeDeleted();
245  }
246 
248  void setPublishingOnLegionNetwork(bool) override;
249 
250  protected:
255  };
256 
260 }
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:63
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:208
std::map< DtString, DtString > ExtendedData
Definition: statePropertiesStateComponent.h:96
DtStatePropertiesStateComponentNextFrame myNextFrameState
Definition: statePropertiesStateComponent.h:252
double myLastTimeStatePropertiesUpdated
Definition: statePropertiesStateComponent.h:254
Definition: stateDataTypes.h:23
bool statePropertiesModified() const
Definition: statePropertiesStateComponent.h:139
Definition: statePropertiesStateComponent.h:26
#define UNDEFINED_METHOD(Type, Method,...)
Definition: doubleBufferedDataStorage.h:68
bool myStatePropertiesModified
Definition: statePropertiesStateComponent.h:156
2) Define the next frame class. This will be used for write access.
Definition: statePropertiesStateComponent.h:113
VRF::WriteStatePropertiesRepository myWriteStatePropertiesRepository
Definition: statePropertiesStateComponent.h:155
VRF::ReadStatePropertiesRepository myReadStatePropertiesRepository
Definition: statePropertiesStateComponent.h:205
Definition: stateComponent.h:257
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
virtual DtFrameStateInterface * nextFrameState()
Definition: statePropertiesStateComponent.h:224
void clearStatePropertiesModifiedByLegion()
Definition: statePropertiesStateComponent.h:187
const std::vector< DtReaderWriterRegistryData * > & registryData() const
Definition: readerWriterRegistry.h:161
unsigned int myCallbackHandle
Definition: statePropertiesStateComponent.h:206
Definition: readerWriter.h:85
DtStatePropertiesStateComponentCurrentFrame myCurrentFrameState
Definition: statePropertiesStateComponent.h:251
#define UNDEFINED_RETURNREF_ACCESSORS(ReturnType, Member)
Definition: doubleBufferedDataStorage.h:40
DtStateData * myStateData
Definition: statePropertiesStateComponent.h:159
Contains the DtUUID class declaration.
#define UNDEFINED_RETURNREF_ACCESSOR(ReturnType, Member)
Definition: doubleBufferedDataStorage.h:34
void clearStatePropertiesUpdated()
Definition: statePropertiesStateComponent.h:51
Interface class used to define minimal interface for a property. The DtPropertyInterface class provid...
Definition: propertyInterface.h:48
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 ...
DtStateData * myStateData
Definition: statePropertiesStateComponent.h:210
static DtReaderWriterFactory * factory()
DtStatePropertiesStateComponentData & frameState()
Definition: statePropertiesStateComponent.h:121
3) Define the current frame class. This will be used for read access.
Definition: statePropertiesStateComponent.h:164
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:336
void clearStatePropertiesModified()
Definition: statePropertiesStateComponent.h:144
const DtReaderWriterRegistry & registry() const
Collection of child DtReaderWriter nodes owned by this object.
Definition: readerWriter.h:496
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:219
void updateStateData(DtStateData *sd)
Implement to update data storage to the new state data.
Definition: statePropertiesStateComponent.h:229
DtStatePropertiesStateComponentData myData
Definition: statePropertiesStateComponent.h:160
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:370
const DtStatePropertiesStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: statePropertiesStateComponent.h:171
std::map< std::string, Legion::InstanceHandle > myLegionStateProperties
Definition: statePropertiesStateComponent.h:158
virtual void aboutToBeDeleted()
virtual void aboutToBeDeleted() override
Definition: statePropertiesStateComponent.h:240
const char * source
Definition: lz4.h:442
void advanceFrame(const DtStatePropertiesStateComponentData &data)
Definition: statePropertiesStateComponent.h:199
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:209
const DtRwProperties & parameterProperties() const
Definition: statePropertiesStateComponent.h:79
bool statePropertiesModifiedByLegion() const
Definition: statePropertiesStateComponent.h:182
DtStatePropertiesStateComponentData & operator=(const DtStatePropertiesStateComponentData &rhs)
Definition: statePropertiesStateComponent.h:42
bool myFoundComponent
Definition: statePropertiesStateComponent.h:253
DtStatePropertiesStateComponentData myData
Definition: statePropertiesStateComponent.h:211
bool isDoubleBuffered()
Definition: statePropertiesStateComponent.h:222
const DtFrameStateInterface * currentFrameState() const
Definition: statePropertiesStateComponent.h:223
#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:207
A list of properties. A DtPropertyInterface object that is a specialized version of DtRwVariableBindi...
Definition: rwProperties.h:126
void statePropertiesWereUpdated()
Definition: statePropertiesStateComponent.h:56
DtRwProperties & parameterProperties()
Definition: statePropertiesStateComponent.h:80
Contains the DtStateComponent class declaration.
bool myPublishOnLegionNetwork
Definition: statePropertiesStateComponent.h:157
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:216
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:259
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:282
DtStatePropertiesStateComponentData(const DtStatePropertiesStateComponentData &orig)
Definition: statePropertiesStateComponent.h:35
std::shared_ptr< DtRwProperties > myParameterProperties
Definition: statePropertiesStateComponent.h:88
virtual const DtFrameStateInterface * nextFrameState() const
Definition: statePropertiesStateComponent.h:225

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)