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 
141  unsigned myDisRecordType;
144 
146 };
147 
149 {
153 };
154 
159 template <typename _RwType>
161 {
162 private:
165 
166 public:
167 
168  DtRwPropertyWithThreshold(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
170  DtReaderWriterRegistry* parentRegistry = 0);
172  virtual ~DtRwPropertyWithThreshold() override;
173 
178  virtual char *encode(char *) const override;
179 
182  virtual bool isUpdateNeeded(DtTime t) const override;
183 
187 
191 
195  virtual void setThreshold(double value);
196  virtual double threshold() const;
197 
200  static void setDefaultThreshold(double value);
201 
206  virtual void setMaxUpdateInterval(DtTime interval);
207  virtual DtTime maxUpdateInterval() const;
208 
211  static void setDefaultMaxUpdateInterval(DtTime interval);
212 
221  virtual void setMaxUnchangedUpdateInterval(DtTime interval);
222  virtual DtTime maxUnchangedUpdateInterval() const;
223 
226  static void setDefaultMaxUnchangedUpdateInterval(DtTime interval);
227 
231  virtual void processPublicationArg(DtlObjPtr arg) override;
232 
234  virtual void copyPublishingSettings(const DtPropertyInterface &prop) override;
235 
237  virtual double percentChanged() const;
238 
240  virtual double amountChanged() const;
241 
243  virtual bool merge(const DtPropertyInterface &target, DtPropertyInterface::MergeFlags,
244  const DtMergePath &path = DtMergePath(),
245  const std::set<DtString> &ignore = std::set<DtString>()) override;
246 
248  virtual void writePublishInformation(std::string& fp, int indentLevel) override;
249 
250 protected:
251 
253  mutable _RwType myLastEncodedValue;
254 
257 
260 
261  static double myDefaultThreshold;
262  double myThreshold;
263 
266 
269 };
270 
272 {
273 public:
274  DtRwPropertyString(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
275  DtRwPropertyString(const DtString& name, const DtString& value,
276  DtReaderWriterRegistry* parentRegistry = 0);
277  DtRwPropertyString(const DtString& name, const DtRwPropertyString& orig,
278  DtReaderWriterRegistry* parentRegistry = 0);
280  DtReaderWriterRegistry* parentRegistry = 0);
281 
283 
284  virtual ~DtRwPropertyString() override;
285 };
286 
288 {
289 public:
290  DtRwPropertySizedString(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
291  DtRwPropertySizedString(const DtString& name, const DtString& value,
292  DtReaderWriterRegistry* parentRegistry = 0);
294  DtReaderWriterRegistry* parentRegistry = 0);
296  DtReaderWriterRegistry* parentRegistry = 0);
297 
298  virtual ~DtRwPropertySizedString() override;
299 
302  virtual char *encode(char *) const override;
303 
306  virtual const char *decode(const char *) override;
307 
310  virtual void getSize(int &size) const override;
311 
313  virtual int hlaAlignment() const override;
314 
315  virtual const char *readerWriterType() const override;
316 
317  static const char* theXmlType();
318 
319  virtual const char *xmlType() const override {
320  return theXmlType();
321  }
322 };
323 
324 #define rwProperties_INL_
325 #include <readerWriter/rwProperty.inl>
326 #undef rwProperties_INL_
327 
329 {
330 public:
331  DtRwPropertyBoolean(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
332  DtRwPropertyBoolean(const DtString& name, bool value,
333  DtReaderWriterRegistry* parentRegistry = 0);
334  DtRwPropertyBoolean(const DtString& name, const DtRwPropertyBoolean& orig,
335  DtReaderWriterRegistry* parentRegistry = 0);
337  DtReaderWriterRegistry* parentRegistry = 0);
339  virtual ~DtRwPropertyBoolean() override;
340 };
341 
343 {
344 public:
345  DtRwPropertyInt(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
346  DtRwPropertyInt(const DtString& name, int value,
347  DtReaderWriterRegistry* parentRegistry = 0);
348  DtRwPropertyInt(const DtString& name, const DtRwPropertyInt& orig,
349  DtReaderWriterRegistry* parentRegistry = 0);
350  DtRwPropertyInt(const DtRwPropertyInt& orig,
351  DtReaderWriterRegistry* parentRegistry = 0);
353  virtual ~DtRwPropertyInt() override;
354  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
355 };
356 
358 {
359 public:
360  DtRwPropertyInt8(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
361  DtRwPropertyInt8(const DtString& name, DtInt8 value,
362  DtReaderWriterRegistry* parentRegistry = 0);
363  DtRwPropertyInt8(const DtString& name, const DtRwPropertyInt8& orig,
364  DtReaderWriterRegistry* parentRegistry = 0);
366  DtReaderWriterRegistry* parentRegistry = 0);
368  virtual ~DtRwPropertyInt8() override;
369  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
370 };
371 
373 {
374 public:
375  DtRwPropertyInt16(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
376  DtRwPropertyInt16(const DtString& name, DtInt16 value,
377  DtReaderWriterRegistry* parentRegistry = 0);
378  DtRwPropertyInt16(const DtString& name, const DtRwPropertyInt16& orig,
379  DtReaderWriterRegistry* parentRegistry = 0);
381  DtReaderWriterRegistry* parentRegistry = 0);
383  virtual ~DtRwPropertyInt16() override;
384  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
385 };
386 
388 {
389 public:
390  DtRwPropertyInt32(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
391  DtRwPropertyInt32(const DtString& name, DtInt32 value,
392  DtReaderWriterRegistry* parentRegistry = 0);
393  DtRwPropertyInt32(const DtString& name, const DtRwPropertyInt32& orig,
394  DtReaderWriterRegistry* parentRegistry = 0);
396  DtReaderWriterRegistry* parentRegistry = 0);
398  virtual ~DtRwPropertyInt32() override;
399  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
400 };
401 
403 {
404 public:
405  DtRwPropertyReal(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
406  DtRwPropertyReal(const DtString& name, DtReal value,
407  DtReaderWriterRegistry* parentRegistry = 0);
408  DtRwPropertyReal(const DtString& name, const DtRwPropertyReal& orig,
409  DtReaderWriterRegistry* parentRegistry = 0);
411  DtReaderWriterRegistry* parentRegistry = 0);
413  virtual ~DtRwPropertyReal() override;
414  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
415 };
416 
418 {
419 public:
420  DtRwPropertyReal32(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
421  DtRwPropertyReal32(const DtString& name, DtFloat32 value,
422  DtReaderWriterRegistry* parentRegistry = 0);
423  DtRwPropertyReal32(const DtString& name, const DtRwPropertyReal32& orig,
424  DtReaderWriterRegistry* parentRegistry = 0);
426  DtReaderWriterRegistry* parentRegistry = 0);
428  virtual ~DtRwPropertyReal32() override;
429  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
430 };
431 
433 {
434 public:
435  DtRwPropertyReal64(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
436  DtRwPropertyReal64(const DtString& name, DtFloat64 value,
437  DtReaderWriterRegistry* parentRegistry = 0);
438  DtRwPropertyReal64(const DtString& name, const DtRwPropertyReal64& orig,
439  DtReaderWriterRegistry* parentRegistry = 0);
441  DtReaderWriterRegistry* parentRegistry = 0);
443  virtual ~DtRwPropertyReal64() override;
444  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
445 };
446 
448 {
449 public:
450  DtRwPropertyVector(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
451  DtRwPropertyVector(const DtString& name, const DtVector& value,
452  DtReaderWriterRegistry* parentRegistry = 0);
453  DtRwPropertyVector(const DtString& name, const DtRwPropertyVector& orig,
454  DtReaderWriterRegistry* parentRegistry = 0);
456  DtReaderWriterRegistry* parentRegistry = 0);
458  virtual ~DtRwPropertyVector() override;
459 };
460 
461 
463 {
464 public:
465  DtRwPropertyOffsetVector(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
466  DtRwPropertyOffsetVector(const DtString& name, const DtVector& value,
467  DtReaderWriterRegistry* parentRegistry = 0);
469  DtReaderWriterRegistry* parentRegistry = 0);
471  DtReaderWriterRegistry* parentRegistry = 0);
473  virtual ~DtRwPropertyOffsetVector() override;
474 };
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:319
virtual void writePublishInformation(std::string &fp, int indentLevel) override
Writes threshold specific information.
double myThreshold
Definition: rwProperty.h:262
#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:141
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:160
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:328
static DtThresholdAlgorithm myDefaultThresholdAlgorithm
Definition: rwProperty.h:258
virtual bool keepPublishingSettings() const override
Definition: rwProperty.h:432
DtThresholdAlgorithm
Definition: rwProperty.h:148
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:150
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:402
Definition: rwProperty.h:271
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:372
DtTime myUpdateTime
Definition: rwProperty.h:140
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:261
DtTime myMaxUnchangedUpdateInterval
Definition: rwProperty.h:268
Definition: rwProperty.h:417
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:267
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:152
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:143
double DtFloat64
Definition: vrvControlStructTypes.h:36
DtRwPropertyWithThreshold & operator=(const DtRwPropertyWithThreshold &orig)
Definition: rwProperty.h:387
Definition: rwProperty.h:357
short DtInt16
Definition: vrvControlStructTypes.h:29
Definition: rwProperty.h:287
DtRwProperty()
Not implemented.
_RwType myLastEncodedValue
The value at the last time the value was encoded.
Definition: rwProperty.h:253
Definition: rwProperty.h:462
bool myDebugEnabled
Definition: rwProperty.h:145
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:256
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:259
Definition: rwProperty.h:342
bool myIsPublished
Definition: rwProperty.h:142
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:151
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:264
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:265
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:447
MergeFlags
Determines how two lists of properties will be merged by the merge function.
Definition: propertyInterface.h:58

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)