VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
rwProperty.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2025 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 #pragma once
10 
13 #include <readerWriter/rwBoolean.h>
14 #include <readerWriter/rwString.h>
15 #include <readerWriter/rwInt.h>
16 #include <readerWriter/rwReal.h>
17 #include <readerWriter/rwVector.h>
19 #include <vlutil/vlTime.h>
20 
21 #include <string>
22 
25 template <typename _RwType>
26 class DtRwProperty : public _RwType, public DtPropertyInterface
27 {
28 private:
30  DtRwProperty();
31 
32 public:
33 
34  DtRwProperty(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
35  DtRwProperty(const DtString& name, const DtRwProperty& orig,
36  DtReaderWriterRegistry* parentRegistry = 0);
37  DtRwProperty& operator=(const DtRwProperty& orig);
38  virtual ~DtRwProperty() override;
39 
41  virtual void copy(const DtPropertyInterface &rhs) override;
42 
45 
48  virtual char *encode(char *) const override;
49 
52  virtual const char *decode(const char *) override;
53 
56  virtual void getSize(int &size) const override;
57 
59  virtual int hlaAlignment() const override;
61 
62  virtual DtString stringRep(const DtString &root = "") const override;
63 
65  virtual const char *propertyType() const override;
66 
68  virtual DtSymbolString propertyName() const override { return _RwType::name(); };
69 
71  virtual void setPropertyName(const DtString &propertyName) override { _RwType::setName(propertyName); };
72 
73  virtual void getSelf(DtlObjPtr args,
76 
77  virtual DtlObjPtr getData(DtlObjPtr args, const DtReaderWriter::SearchPaths &searchPaths,
78  const DtVariableBindingsList &variableBindings) override;
79 
81  virtual bool merge(const DtPropertyInterface &target, MergeFlags,
82  const DtMergePath &path = DtMergePath(),
83  const std::set<DtString> &ignore = std::set<DtString>()) override;
84 
87  virtual DtReaderWriter *readerWriter() override;
88  virtual const DtReaderWriter *readerWriter() const override;
90 
93  virtual DtPropertyInterface* property();
94  virtual const DtPropertyInterface* property() const;
96 
98  virtual void recordUpdateTime() const;
99 
102  virtual bool isUpdateNeeded(DtTime t) const override;
103 
105  virtual bool hasReceivedUpdateSince(DtTime t) const override;
106 
110  virtual DtTime updateClockTime() const override;
111 
114  virtual bool isPublished() const override;
115  virtual void setIsPublished(bool isPub) override;
117 
121  virtual unsigned disRecordType() const override;
122  virtual void setDisRecordType(unsigned recType) override;
124 
127  virtual bool isDebugEnabled() const override;
128  virtual void setDebugEnabled(bool en) override;
130 
131  virtual void reset() override;
132 
135  virtual void setKeepPublishingSettings(bool keep) override;
136  virtual bool keepPublishingSettings() const override;
137 
138 protected:
139 
142  unsigned myDisRecordType;
145 
147 };
148 
150 {
154 };
155 
160 template <typename _RwType>
162 {
163 private:
166 
167 public:
168 
169  DtRwPropertyWithThreshold(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
171  DtReaderWriterRegistry* parentRegistry = 0);
173  virtual ~DtRwPropertyWithThreshold() override;
174 
179  virtual char *encode(char *) const override;
180 
183  virtual bool isUpdateNeeded(DtTime t) const override;
184 
188 
192 
196  virtual void setThreshold(double value);
197  virtual double threshold() const;
198 
201  static void setDefaultThreshold(double value);
202 
207  virtual void setMaxUpdateInterval(DtTime interval);
208  virtual DtTime maxUpdateInterval() const;
209 
212  static void setDefaultMaxUpdateInterval(DtTime interval);
213 
222  virtual void setMaxUnchangedUpdateInterval(DtTime interval);
223  virtual DtTime maxUnchangedUpdateInterval() const;
224 
227  static void setDefaultMaxUnchangedUpdateInterval(DtTime interval);
228 
232  virtual void processPublicationArg(DtlObjPtr arg) override;
233 
235  virtual void copyPublishingSettings(const DtPropertyInterface &prop) override;
236 
238  virtual double percentChanged() const;
239 
241  virtual double amountChanged() const;
242 
244  virtual bool merge(const DtPropertyInterface &target, DtPropertyInterface::MergeFlags,
245  const DtMergePath &path = DtMergePath(),
246  const std::set<DtString> &ignore = std::set<DtString>()) override;
247 
249  virtual void writePublishInformation(std::string& fp, int indentLevel) override;
250 
251 protected:
252 
254  mutable _RwType myLastEncodedValue;
255 
258 
261 
262  static double myDefaultThreshold;
263  double myThreshold;
264 
267 
270 };
271 
273 {
274 public:
275  DtRwPropertyString(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
276  DtRwPropertyString(const DtString& name, const DtString& value,
277  DtReaderWriterRegistry* parentRegistry = 0);
278  DtRwPropertyString(const DtString& name, const DtRwPropertyString& orig,
279  DtReaderWriterRegistry* parentRegistry = 0);
281  DtReaderWriterRegistry* parentRegistry = 0);
282 
284 
285  virtual ~DtRwPropertyString() override;
286 };
287 
289 {
290 public:
291  DtRwPropertySizedString(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
292  DtRwPropertySizedString(const DtString& name, const DtString& value,
293  DtReaderWriterRegistry* parentRegistry = 0);
295  DtReaderWriterRegistry* parentRegistry = 0);
297  DtReaderWriterRegistry* parentRegistry = 0);
298 
299  virtual ~DtRwPropertySizedString() override;
300 
303  virtual char *encode(char *) const override;
304 
307  virtual const char *decode(const char *) override;
308 
311  virtual void getSize(int &size) const override;
312 
314  virtual int hlaAlignment() const override;
315 
316  virtual const char *readerWriterType() const override;
317 
318  static const char* theXmlType();
319 
320  virtual const char *xmlType() const override {
321  return theXmlType();
322  }
323 };
324 
325 #define rwProperties_INL_
326 #include <readerWriter/rwProperty.inl>
327 #undef rwProperties_INL_
328 
330 {
331 public:
332  DtRwPropertyBoolean(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
333  DtRwPropertyBoolean(const DtString& name, bool value,
334  DtReaderWriterRegistry* parentRegistry = 0);
335  DtRwPropertyBoolean(const DtString& name, const DtRwPropertyBoolean& orig,
336  DtReaderWriterRegistry* parentRegistry = 0);
338  DtReaderWriterRegistry* parentRegistry = 0);
340  virtual ~DtRwPropertyBoolean() override;
341 };
342 
344 {
345 public:
346  DtRwPropertyInt(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
347  DtRwPropertyInt(const DtString& name, int value,
348  DtReaderWriterRegistry* parentRegistry = 0);
349  DtRwPropertyInt(const DtString& name, const DtRwPropertyInt& orig,
350  DtReaderWriterRegistry* parentRegistry = 0);
351  DtRwPropertyInt(const DtRwPropertyInt& orig,
352  DtReaderWriterRegistry* parentRegistry = 0);
354  virtual ~DtRwPropertyInt() override;
355  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
356 };
357 
359 {
360 public:
361  DtRwPropertyInt8(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
362  DtRwPropertyInt8(const DtString& name, DtInt8 value,
363  DtReaderWriterRegistry* parentRegistry = 0);
364  DtRwPropertyInt8(const DtString& name, const DtRwPropertyInt8& orig,
365  DtReaderWriterRegistry* parentRegistry = 0);
367  DtReaderWriterRegistry* parentRegistry = 0);
369  virtual ~DtRwPropertyInt8() override;
370  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
371 };
372 
374 {
375 public:
376  DtRwPropertyInt16(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
377  DtRwPropertyInt16(const DtString& name, DtInt16 value,
378  DtReaderWriterRegistry* parentRegistry = 0);
379  DtRwPropertyInt16(const DtString& name, const DtRwPropertyInt16& orig,
380  DtReaderWriterRegistry* parentRegistry = 0);
382  DtReaderWriterRegistry* parentRegistry = 0);
384  virtual ~DtRwPropertyInt16() override;
385  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
386 };
387 
389 {
390 public:
391  DtRwPropertyInt32(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
392  DtRwPropertyInt32(const DtString& name, DtInt32 value,
393  DtReaderWriterRegistry* parentRegistry = 0);
394  DtRwPropertyInt32(const DtString& name, const DtRwPropertyInt32& orig,
395  DtReaderWriterRegistry* parentRegistry = 0);
397  DtReaderWriterRegistry* parentRegistry = 0);
399  virtual ~DtRwPropertyInt32() override;
400  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
401 };
402 
404 {
405 public:
406  DtRwPropertyReal(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
407  DtRwPropertyReal(const DtString& name, DtReal value,
408  DtReaderWriterRegistry* parentRegistry = 0);
409  DtRwPropertyReal(const DtString& name, const DtRwPropertyReal& orig,
410  DtReaderWriterRegistry* parentRegistry = 0);
412  DtReaderWriterRegistry* parentRegistry = 0);
414  virtual ~DtRwPropertyReal() override;
415  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
416 };
417 
419 {
420 public:
421  DtRwPropertyReal32(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
422  DtRwPropertyReal32(const DtString& name, DtFloat32 value,
423  DtReaderWriterRegistry* parentRegistry = 0);
424  DtRwPropertyReal32(const DtString& name, const DtRwPropertyReal32& orig,
425  DtReaderWriterRegistry* parentRegistry = 0);
427  DtReaderWriterRegistry* parentRegistry = 0);
429  virtual ~DtRwPropertyReal32() override;
430  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
431 };
432 
434 {
435 public:
436  DtRwPropertyReal64(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
437  DtRwPropertyReal64(const DtString& name, DtFloat64 value,
438  DtReaderWriterRegistry* parentRegistry = 0);
439  DtRwPropertyReal64(const DtString& name, const DtRwPropertyReal64& orig,
440  DtReaderWriterRegistry* parentRegistry = 0);
442  DtReaderWriterRegistry* parentRegistry = 0);
444  virtual ~DtRwPropertyReal64() override;
445  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
446 };
447 
449 {
450 public:
451  DtRwPropertyVector(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
452  DtRwPropertyVector(const DtString& name, const DtVector& value,
453  DtReaderWriterRegistry* parentRegistry = 0);
454  DtRwPropertyVector(const DtString& name, const DtRwPropertyVector& orig,
455  DtReaderWriterRegistry* parentRegistry = 0);
457  DtReaderWriterRegistry* parentRegistry = 0);
459  virtual ~DtRwPropertyVector() override;
460 };
461 
462 
464 {
465 public:
466  DtRwPropertyOffsetVector(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
467  DtRwPropertyOffsetVector(const DtString& name, const DtVector& value,
468  DtReaderWriterRegistry* parentRegistry = 0);
470  DtReaderWriterRegistry* parentRegistry = 0);
472  DtReaderWriterRegistry* parentRegistry = 0);
474  virtual ~DtRwPropertyOffsetVector() override;
475 };
virtual bool hasReceivedUpdateSince(DtTime t) const override
Returns true if an update was received remotely since the specified time.
virtual const char * xmlType() const override
Routines to archive/dearchive from an XML Environment.
Definition: rwProperty.h:320
virtual void writePublishInformation(std::string &fp, int indentLevel) override
Writes threshold specific information.
double myThreshold
Definition: rwProperty.h:263
DtClock myClock
Definition: rwProperty.h:140
#define DT_DLL_readerWriter
This file is used to determine how to build Disable inconsistent dll linkage warning Visual Studio 6...
Definition: readerWriterDefines.h:34
virtual const char * readerWriterType() const override
Used to supply a string type that this reader writer type is. This can be used in place of dynamic-ca...
virtual void setPropertyName(const DtString &propertyName) override
Sets name of this property. Should generally only be called when initially created.
Definition: rwProperty.h:71
virtual const char * propertyType() const override
Typically returns reader/writer type.
static const char * theXmlType()
The type that is used when archiving to an XML stream.
This class allows one to collect and compare strings using an index number instead of having to do st...
Definition: symbolString.h:27
virtual bool merge(const DtPropertyInterface &target, MergeFlags, const DtMergePath &path=DtMergePath(), const std::set< DtString > &ignore=std::set< DtString >()) override
In this case replace does not matter – will replace value regardless.
virtual DtPropertyInterface * property()
Returns a PropertyInterface pointer of the ReaderWriter.
virtual const char * decode(const char *) override
Decodes the property from the specified buffer. Assumes buffer is the start of the property and prece...
unsigned myDisRecordType
Definition: rwProperty.h:142
virtual DtString stringRep(const DtString &root="") const override
This class is similar to DtRwProperty, but allows you to specify a threshold at which the value shoul...
Definition: rwProperty.h:161
virtual void setDisRecordType(unsigned recType) override
If this property is published, which DIS record type should it use. Default is 0, which indicates tha...
virtual DtThresholdAlgorithm thresholdAlgorithm() const
virtual DtTime maxUnchangedUpdateInterval() const
Definition: rwProperty.h:329
static DtThresholdAlgorithm myDefaultThresholdAlgorithm
Definition: rwProperty.h:259
virtual bool keepPublishingSettings() const override
Definition: rwProperty.h:433
DtThresholdAlgorithm
Definition: rwProperty.h:149
virtual DtlObjPtr getData(DtlObjPtr args, const DtReaderWriter::SearchPaths &searchPaths, const DtVariableBindingsList &variableBindings) override
Override to allow a variable to be assigned to a property of derived type.
virtual double amountChanged() const
Returns the amount the value has changed since the last update.
Definition: rwProperty.h:151
voidpf void uLong size
Definition: ioapi.h:39
Definition: readerWriter.h:85
virtual void setMaxUpdateInterval(DtTime interval)
Changes the maximum time between updates if data has changed but has not crossed the threshold for an...
static void setDefaultMaxUnchangedUpdateInterval(DtTime interval)
Changes the default max unchanged update interval for cases when setMaxUnchangedUpdateInterval() has ...
virtual void copy(const DtPropertyInterface &rhs) override
Copies the given property into the current one as long as the types are the same. ...
virtual void setDebugEnabled(bool en) override
Enables debug output. Generally this should be left off.
virtual bool isPublished() const override
Whether this property should be published.
Definition: readerWriterRegistry.h:39
virtual void setIsPublished(bool isPub) override
Whether this property should be published.
Definition: rwProperty.h:403
Definition: rwProperty.h:272
Interface class used to define minimal interface for a property. The DtPropertyInterface class provid...
Definition: propertyInterface.h:53
virtual void copyPublishingSettings(const DtPropertyInterface &prop) override
Copies the publishing settings from another property to use for this one.
virtual ~DtRwPropertyWithThreshold() override
virtual bool isUpdateNeeded(DtTime t) const override
Returns true if the value has been updated since the specified time and needs to be sent on the netwo...
Definition: rwProperty.h:373
DtTime myUpdateTime
Definition: rwProperty.h:141
virtual void reset() override
Override to clear out variable value.
DtRwPropertyWithThreshold()
Not implemented.
virtual void setDefaultThresholdAlgorithm(DtThresholdAlgorithm alg)
Sets the default threshold algorithm to use for cases when setThresholdAlgorithm() has not been set...
float DtFloat32
Definition: vrvControlStructTypes.h:35
static double myDefaultThreshold
Definition: rwProperty.h:262
DtTime myMaxUnchangedUpdateInterval
Definition: rwProperty.h:269
Definition: rwProperty.h:418
std::list< const DtRwVariableBindings * > DtVariableBindingsList
Definition: readerWriterRegistry.h:29
int DtInt32
Definition: vrvControlStructTypes.h:31
virtual void setThreshold(double value)
Sets the threshold for when an update should be sent. If, based on the chosen threshold algorithm...
virtual char * encode(char *) const override
Encodes the property into the supplied buffer. Does not align the property. Buffer must already be al...
std::vector< DtFilename > SearchPaths
Definition: readerWriter.h:92
static DtTime myDefaultMaxUnchangedUpdateInterval
Definition: rwProperty.h:268
int getSize() const
Returns the network size of this item in bytes. This does not include any upfront padding for alignme...
virtual void setThresholdAlgorithm(DtThresholdAlgorithm alg)
Sets the threshold algorithm to use.
Definition: rwProperty.h:153
std::vector< DtMergePathStruct > DtMergePath
Definition: readerWriterFactory.h:181
virtual void setMaxUnchangedUpdateInterval(DtTime interval)
Changes the maximum time between updates if data has changed but has not crossed the threshold for an...
bool myKeepPublishingSettingsOnCopy
Definition: rwProperty.h:144
double DtFloat64
Definition: vrvControlStructTypes.h:36
DtRwPropertyWithThreshold & operator=(const DtRwPropertyWithThreshold &orig)
Definition: rwProperty.h:388
Definition: rwProperty.h:358
short DtInt16
Definition: vrvControlStructTypes.h:29
Definition: rwProperty.h:288
DtRwProperty()
Not implemented.
_RwType myLastEncodedValue
The value at the last time the value was encoded.
Definition: rwProperty.h:254
Definition: rwProperty.h:463
bool myDebugEnabled
Definition: rwProperty.h:146
static const DtVariableBindingsList & nullVariableReference()
virtual DtReaderWriter * readerWriter() override
Returns a ReaderWriter pointer of the property.
virtual double threshold() const
DtTime myLastEncodeTime
The time the value was last encoded.
Definition: rwProperty.h:257
DtRwProperty & operator=(const DtRwProperty &orig)
virtual int hlaAlignment() const override
Returns alignment necessary to encode this item in HLA.
Defines the DtPropertyInterface class, the interface for all property classes.
virtual double percentChanged() const
Returns the percentage the value has changed since the last update.
virtual char * encode(char *) const override
These methods are for network encoding/decoding for Hla encoding decoding reasons. Implemented at templated rw level. Encodes the variable bindings into the supplied buffer. In addition, stores the value in myLastEncodedValue for threshold testing.
DtThresholdAlgorithm myThresholdAlgorithm
Definition: rwProperty.h:260
Definition: rwProperty.h:343
bool myIsPublished
Definition: rwProperty.h:143
Templated class that allows for the definition of a property. Only templates of this type can be adde...
Definition: rwProperty.h:26
char DtInt8
Definition: vrvControlStructTypes.h:27
virtual bool isDebugEnabled() const override
Enables debug output. Generally this should be left off.
virtual void processPublicationArg(DtlObjPtr arg) override
Processes publication a publication argument specified in the SMS for this property. Overloaded to handle &quot;thresholdPercent&quot;, &quot;maxUnchangedInterval&quot;, and &quot;maxInterval&quot; arguments.
virtual bool merge(const DtPropertyInterface &target, DtPropertyInterface::MergeFlags, const DtMergePath &path=DtMergePath(), const std::set< DtString > &ignore=std::set< DtString >()) override
In this case replace does not matter – will replace value regardless.
static void setDefaultThreshold(double value)
Changes the default threshold for cases when setThreshold() has not been called.
virtual ~DtRwProperty() override
virtual unsigned disRecordType() const override
If this property is published, which DIS record type should it use. Default is 0, which indicates tha...
Definition: rwProperty.h:152
virtual DtTime maxUpdateInterval() const
virtual DtTime updateClockTime() const override
Returns the current time on the update clock. Can be used to pass into a future call to hasReceivedUp...
virtual bool isSimilarProperty(const DtPropertyInterface *rhs, bool strict=true) const
Returns true if the readerWriterType is the same. Subclasses can do extra checking. If strict is true, some property types will do extra checking and fail if the types do not exactly match. If false, these types will do a basic check, which can be useful when the the types are similar enough to perform a merge.
static DtTime myDefaultMaxUpdateInterval
Definition: rwProperty.h:265
virtual DtSymbolString propertyName() const override
The name of this property.
Definition: rwProperty.h:68
virtual bool isUpdateNeeded(DtTime t) const override
Returns true if the value has been updated since the specified time and needs to be sent on the netwo...
File: rwVector.h.
DtTime myMaxUpdateInterval
Definition: rwProperty.h:266
virtual void setKeepPublishingSettings(bool keep) override
Specifies whether the publishing settings for this property should be retained when it is updated fro...
static void setDefaultMaxUpdateInterval(DtTime interval)
Changes the default max update interval for cases when setMaxUpdateInterval() has not been called...
virtual void getSelf(DtlObjPtr args, const DtReaderWriter::SearchPaths &searchPaths=DtReaderWriter::SearchPaths(), const DtVariableBindingsList &variableBindings=DtReaderWriter::nullVariableReference())
virtual void recordUpdateTime() const
Stamps the time when updated.
Definition: rwProperty.h:448
MergeFlags
Determines how two lists of properties will be merged by the merge function.
Definition: propertyInterface.h:58

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)