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) 2018 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();
39 
41  virtual void copy(const DtPropertyInterface& rhs);
42 
45 
48  virtual char* encode(char*) const;
49 
52  virtual const char* decode(const char*);
53 
56  virtual void getSize(int& size) const;
57 
59  virtual int hlaAlignment() const;
61 
62  virtual DtString stringRep(const DtString& root = "") const;
63 
65  virtual const char* propertyType() const;
66 
68  virtual DtSymbolString propertyName() const { return _RwType::name(); };
69 
71  virtual void setPropertyName(const DtString& propertyName) { _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);
79 
81  virtual bool merge(const DtPropertyInterface& target, MergeFlags,
82  const DtMergePath& path = DtMergePath(), const std::set<DtString>& ignore = std::set<DtString>());
83 
86  virtual DtReaderWriter* readerWriter();
87  virtual const DtReaderWriter* readerWriter() const;
89 
92  virtual DtPropertyInterface* property();
93  virtual const DtPropertyInterface* property() const;
95 
97  virtual void recordUpdateTime() const;
98 
101  virtual bool isUpdateNeeded(DtTime t) const;
102 
104  virtual bool hasReceivedUpdateSince(DtTime t) const;
105 
109  virtual DtTime updateClockTime() const;
110 
113  virtual bool isPublished() const;
114  virtual void setIsPublished(bool isPub);
116 
120  virtual unsigned disRecordType() const;
121  virtual void setDisRecordType(unsigned recType);
123 
126  virtual bool isDebugEnabled() const;
127  virtual void setDebugEnabled(bool en);
129 
130  virtual void reset();
131 
134  virtual void setKeepPublishingSettings(bool keep);
135  virtual bool keepPublishingSettings() const;
136 
137 protected:
138 
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();
173 
178  virtual char* encode(char*) const;
179 
182  virtual bool isUpdateNeeded(DtTime t) const;
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);
232 
234  virtual void copyPublishingSettings(const DtPropertyInterface& prop);
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(), const std::set<DtString>& ignore = std::set<DtString>());
245 
246 protected:
247 
249  mutable _RwType myLastEncodedValue;
250 
253 
256 
257  static double myDefaultThreshold;
258  double myThreshold;
259 
262 
265 };
266 
268 {
269 public:
270  DtRwPropertyString(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
271  DtRwPropertyString(const DtString& name, const DtString& value,
272  DtReaderWriterRegistry* parentRegistry = 0);
273  DtRwPropertyString(const DtString& name, const DtRwPropertyString& orig,
274  DtReaderWriterRegistry* parentRegistry = 0);
276  DtReaderWriterRegistry* parentRegistry = 0);
277 
279 
280  virtual ~DtRwPropertyString();
281 };
282 
284 {
285 public:
286  DtRwPropertySizedString(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
287  DtRwPropertySizedString(const DtString& name, const DtString& value,
288  DtReaderWriterRegistry* parentRegistry = 0);
290  DtReaderWriterRegistry* parentRegistry = 0);
292  DtReaderWriterRegistry* parentRegistry = 0);
293 
294  virtual ~DtRwPropertySizedString();
295 
298  virtual char* encode(char*) const;
299 
302  virtual const char* decode(const char*);
303 
306  virtual void getSize(int& size) const;
307 
309  virtual int hlaAlignment() const;
310 
311  const char* readerWriterType() const;
312 
313  static const char* theXmlType();
314 
315  virtual const char* xmlType() const
316  {
317  return theXmlType();
318  }
319 };
320 
321 #define rwProperties_INL_
322 #include <readerWriter/rwProperty.inl>
323 #undef rwProperties_INL_
324 
326 {
327 public:
328  DtRwPropertyBoolean(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
329  DtRwPropertyBoolean(const DtString& name, bool value,
330  DtReaderWriterRegistry* parentRegistry = 0);
331  DtRwPropertyBoolean(const DtString& name, const DtRwPropertyBoolean& orig,
332  DtReaderWriterRegistry* parentRegistry = 0);
334  DtReaderWriterRegistry* parentRegistry = 0);
336  virtual ~DtRwPropertyBoolean();
337 };
338 
340 {
341 public:
342  DtRwPropertyInt(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
343  DtRwPropertyInt(const DtString& name, int value,
344  DtReaderWriterRegistry* parentRegistry = 0);
345  DtRwPropertyInt(const DtString& name, const DtRwPropertyInt& orig,
346  DtReaderWriterRegistry* parentRegistry = 0);
347  DtRwPropertyInt(const DtRwPropertyInt& orig,
348  DtReaderWriterRegistry* parentRegistry = 0);
350  virtual ~DtRwPropertyInt();
351  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
352 };
353 
355 {
356 public:
357  DtRwPropertyInt8(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
358  DtRwPropertyInt8(const DtString& name, DtInt8 value,
359  DtReaderWriterRegistry* parentRegistry = 0);
360  DtRwPropertyInt8(const DtString& name, const DtRwPropertyInt8& orig,
361  DtReaderWriterRegistry* parentRegistry = 0);
363  DtReaderWriterRegistry* parentRegistry = 0);
365  virtual ~DtRwPropertyInt8();
366  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
367 };
368 
370 {
371 public:
372  DtRwPropertyInt16(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
373  DtRwPropertyInt16(const DtString& name, DtInt16 value,
374  DtReaderWriterRegistry* parentRegistry = 0);
375  DtRwPropertyInt16(const DtString& name, const DtRwPropertyInt16& orig,
376  DtReaderWriterRegistry* parentRegistry = 0);
378  DtReaderWriterRegistry* parentRegistry = 0);
380  virtual ~DtRwPropertyInt16();
381  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
382 };
383 
385 {
386 public:
387  DtRwPropertyInt32(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
388  DtRwPropertyInt32(const DtString& name, DtInt32 value,
389  DtReaderWriterRegistry* parentRegistry = 0);
390  DtRwPropertyInt32(const DtString& name, const DtRwPropertyInt32& orig,
391  DtReaderWriterRegistry* parentRegistry = 0);
393  DtReaderWriterRegistry* parentRegistry = 0);
395  virtual ~DtRwPropertyInt32();
396  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
397 };
398 
400 {
401 public:
402  DtRwPropertyReal(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
403  DtRwPropertyReal(const DtString& name, DtReal value,
404  DtReaderWriterRegistry* parentRegistry = 0);
405  DtRwPropertyReal(const DtString& name, const DtRwPropertyReal& orig,
406  DtReaderWriterRegistry* parentRegistry = 0);
408  DtReaderWriterRegistry* parentRegistry = 0);
410  virtual ~DtRwPropertyReal();
411  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
412 };
413 
415 {
416 public:
417  DtRwPropertyReal32(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
418  DtRwPropertyReal32(const DtString& name, DtFloat32 value,
419  DtReaderWriterRegistry* parentRegistry = 0);
420  DtRwPropertyReal32(const DtString& name, const DtRwPropertyReal32& orig,
421  DtReaderWriterRegistry* parentRegistry = 0);
423  DtReaderWriterRegistry* parentRegistry = 0);
425  virtual ~DtRwPropertyReal32();
426  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
427 };
428 
430 {
431 public:
432  DtRwPropertyReal64(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
433  DtRwPropertyReal64(const DtString& name, DtFloat64 value,
434  DtReaderWriterRegistry* parentRegistry = 0);
435  DtRwPropertyReal64(const DtString& name, const DtRwPropertyReal64& orig,
436  DtReaderWriterRegistry* parentRegistry = 0);
438  DtReaderWriterRegistry* parentRegistry = 0);
440  virtual ~DtRwPropertyReal64();
441  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
442 };
443 
445 {
446 public:
447  DtRwPropertyVector(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
448  DtRwPropertyVector(const DtString& name, const DtVector& value,
449  DtReaderWriterRegistry* parentRegistry = 0);
450  DtRwPropertyVector(const DtString& name, const DtRwPropertyVector& orig,
451  DtReaderWriterRegistry* parentRegistry = 0);
453  DtReaderWriterRegistry* parentRegistry = 0);
455  virtual ~DtRwPropertyVector();
456 };
457 
458 
460 {
461 public:
462  DtRwPropertyOffsetVector(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
463  DtRwPropertyOffsetVector(const DtString& name, const DtVector& value,
464  DtReaderWriterRegistry* parentRegistry = 0);
466  DtReaderWriterRegistry* parentRegistry = 0);
468  DtReaderWriterRegistry* parentRegistry = 0);
470  virtual ~DtRwPropertyOffsetVector();
471 };
virtual void copyPublishingSettings(const DtPropertyInterface &prop)
Copies the publishing settings from another property to use for this one.
virtual unsigned disRecordType() const
If this property is published, which DIS record type should it use. Default is 0, which indicates tha...
double myThreshold
Definition: rwProperty.h:258
DtClock myClock
Definition: rwProperty.h:139
#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 void setPropertyName(const DtString &propertyName)
Sets name of this property. Should generally only be called when initially created.
Definition: rwProperty.h:71
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 DtPropertyInterface * property()
Returns a PropertyInterface pointer of the ReaderWriter.
virtual char * encode(char *) const
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.
unsigned myDisRecordType
Definition: rwProperty.h:141
This class is similar to DtRwProperty, but allows you to specify a threshold at which the value shoul...
Definition: rwProperty.h:160
virtual bool isUpdateNeeded(DtTime t) const
Returns true if the value has been updated since the specified time and needs to be sent on the netwo...
virtual const char * decode(const char *)
Decodes the property from the specified buffer. Assumes buffer is the start of the property and prece...
virtual DtThresholdAlgorithm thresholdAlgorithm() const
virtual void reset()
Override to clear out variable value.
virtual DtTime maxUnchangedUpdateInterval() const
Definition: rwProperty.h:325
static DtThresholdAlgorithm myDefaultThresholdAlgorithm
Definition: rwProperty.h:254
virtual int hlaAlignment() const
Returns alignment necessary to encode this item in HLA.
Definition: rwProperty.h:429
DtThresholdAlgorithm
Definition: rwProperty.h:148
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 ...
Definition: readerWriterRegistry.h:39
virtual const char * xmlType() const
Routines to archive/dearchive from an XML Environment.
Definition: rwProperty.h:315
Definition: rwProperty.h:399
Definition: rwProperty.h:267
Interface class used to define minimal interface for a property. The DtPropertyInterface class provid...
Definition: propertyInterface.h:48
virtual void setKeepPublishingSettings(bool keep)
Specifies whether the publishing settings for this property should be retained when it is updated fro...
Definition: rwProperty.h:369
virtual DtString stringRep(const DtString &root="") const
DtTime myUpdateTime
Definition: rwProperty.h:140
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:257
DtTime myMaxUnchangedUpdateInterval
Definition: rwProperty.h:264
virtual bool hasReceivedUpdateSince(DtTime t) const
Returns true if an update was received remotely since the specified time.
virtual DtReaderWriter * readerWriter()
Returns a ReaderWriter pointer of the property.
Definition: rwProperty.h:414
std::list< const DtRwVariableBindings * > DtVariableBindingsList
Definition: readerWriterRegistry.h:29
virtual DtTime updateClockTime() const
Returns the current time on the update clock. Can be used to pass into a future call to hasReceivedUp...
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...
std::vector< DtFilename > SearchPaths
Definition: readerWriter.h:92
static DtTime myDefaultMaxUnchangedUpdateInterval
Definition: rwProperty.h:263
virtual void setDebugEnabled(bool en)
Enables debug output. Generally this should be left off.
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:384
virtual bool isDebugEnabled() const
Enables debug output. Generally this should be left off.
Definition: rwProperty.h:354
short DtInt16
Definition: vrvControlStructTypes.h:29
Definition: rwProperty.h:283
DtRwProperty()
Not implemented.
_RwType myLastEncodedValue
The value at the last time the value was encoded.
Definition: rwProperty.h:249
Definition: rwProperty.h:459
virtual ~DtRwPropertyWithThreshold()
bool myDebugEnabled
Definition: rwProperty.h:145
virtual bool merge(const DtPropertyInterface &target, DtPropertyInterface::MergeFlags, const DtMergePath &path=DtMergePath(), const std::set< DtString > &ignore=std::set< DtString >())
In this case replace does not matter – will replace value regardless.
static const DtVariableBindingsList & nullVariableReference()
virtual double threshold() const
DtTime myLastEncodeTime
The time the value was last encoded.
Definition: rwProperty.h:252
DtRwProperty & operator=(const DtRwProperty &orig)
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.
DtThresholdAlgorithm myThresholdAlgorithm
Definition: rwProperty.h:255
virtual void processPublicationArg(DtlObjPtr arg)
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, MergeFlags, const DtMergePath &path=DtMergePath(), const std::set< DtString > &ignore=std::set< DtString >())
In this case replace does not matter – will replace value regardless.
Definition: rwProperty.h:339
virtual bool isPublished() const
Whether this property should be published.
bool myIsPublished
Definition: rwProperty.h:142
virtual void setIsPublished(bool isPub)
Whether this property should be published.
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 DtlObjPtr getData(DtlObjPtr args, const DtReaderWriter::SearchPaths &searchPaths, const DtVariableBindingsList &variableBindings)
Override to allow a variable to be assigned to a property of derived type.
virtual bool keepPublishingSettings() const
static void setDefaultThreshold(double value)
Changes the default threshold for cases when setThreshold() has not been called.
virtual bool isUpdateNeeded(DtTime t) const
Returns true if the value has been updated since the specified time and needs to be sent on the netwo...
virtual void setDisRecordType(unsigned recType)
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 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.
virtual DtSymbolString propertyName() const
The name of this property.
Definition: rwProperty.h:68
virtual const char * readerWriterType() const
Used to supply a string type that this reader writer type is. This can be used in place of dynamic-ca...
virtual ~DtRwProperty()
virtual char * encode(char *) const
Encodes the property into the supplied buffer. Does not align the property. Buffer must already be al...
static DtTime myDefaultMaxUpdateInterval
Definition: rwProperty.h:260
File: rwVector.h.
virtual void copy(const DtPropertyInterface &rhs)
Copies the given property into the current one as long as the types are the same. ...
DtTime myMaxUpdateInterval
Definition: rwProperty.h:261
virtual const char * propertyType() const
Typically returns reader/writer type.
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:444
MergeFlags
Determines how two lists of properties will be merged by the merge function.
Definition: propertyInterface.h:53

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)