VR-Forces 5.0.3 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 
100  virtual bool wasUpdatedSince(DtTime t) const;
101 
104  virtual bool isPublished() const;
105  virtual void setIsPublished(bool isPub);
107 
111  virtual unsigned disRecordType() const;
112  virtual void setDisRecordType(unsigned recType);
114 
117  virtual bool isDebugEnabled() const;
118  virtual void setDebugEnabled(bool en);
120 
121  virtual void reset();
122 
123 protected:
124 
127  unsigned myDisRecordType;
129 
131 };
132 
137 template <typename _RwType>
139 {
140 private:
143 
144 public:
145 
146  DtRwPropertyWithThreshold(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
148  DtReaderWriterRegistry* parentRegistry = 0);
150  virtual ~DtRwPropertyWithThreshold();
151 
156  virtual char* encode(char*) const;
157 
161  virtual bool wasUpdatedSince(DtTime t) const;
162 
164  virtual void enableThresholding(bool enable);
165 
169  virtual void setThreshold(double percentage);
170 
173  static void setDefaultThreshold(double percentage);
174 
179  virtual void setMaxUpdateInterval(DtTime interval);
180 
183  static void setDefaultMaxUpdateInterval(DtTime interval);
184 
193  virtual void setMaxUnchangedUpdateInterval(DtTime interval);
194 
197  static void setDefaultMaxUnchangedUpdateInterval(DtTime interval);
198 
199 protected:
200 
203 
205  mutable _RwType myLastEncodedValue;
206 
209 
210  static double myDefaultThreshold;
211  double myThreshold;
212 
215 
218 };
219 
221 {
222 public:
223  DtRwPropertyString(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
224  DtRwPropertyString(const DtString& name, const DtString& value,
225  DtReaderWriterRegistry* parentRegistry = 0);
226  DtRwPropertyString(const DtString& name, const DtRwPropertyString& orig,
227  DtReaderWriterRegistry* parentRegistry = 0);
229  DtReaderWriterRegistry* parentRegistry = 0);
230 
232 
233  virtual ~DtRwPropertyString();
234 };
235 
237 {
238 public:
239  DtRwPropertySizedString(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
240  DtRwPropertySizedString(const DtString& name, const DtString& value,
241  DtReaderWriterRegistry* parentRegistry = 0);
243  DtReaderWriterRegistry* parentRegistry = 0);
245  DtReaderWriterRegistry* parentRegistry = 0);
246 
247  virtual ~DtRwPropertySizedString();
248 
251  virtual char* encode(char*) const;
252 
255  virtual const char* decode(const char*);
256 
259  virtual void getSize(int& size) const;
260 
262  virtual int hlaAlignment() const;
263 
264  const char* readerWriterType() const;
265 
266  static const char* theXmlType();
267 
268  virtual const char* xmlType() const
269  {
270  return theXmlType();
271  }
272 };
273 
275 {
276 public:
277  DtRwPropertyBoolean(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
278  DtRwPropertyBoolean(const DtString& name, bool value,
279  DtReaderWriterRegistry* parentRegistry = 0);
280  DtRwPropertyBoolean(const DtString& name, const DtRwPropertyBoolean& orig,
281  DtReaderWriterRegistry* parentRegistry = 0);
283  DtReaderWriterRegistry* parentRegistry = 0);
285  virtual ~DtRwPropertyBoolean();
286 };
287 
289 {
290 public:
291  DtRwPropertyInt(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
292  DtRwPropertyInt(const DtString& name, int value,
293  DtReaderWriterRegistry* parentRegistry = 0);
294  DtRwPropertyInt(const DtString& name, const DtRwPropertyInt& orig,
295  DtReaderWriterRegistry* parentRegistry = 0);
296  DtRwPropertyInt(const DtRwPropertyInt& orig,
297  DtReaderWriterRegistry* parentRegistry = 0);
299  virtual ~DtRwPropertyInt();
300  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
301 };
302 
304 {
305 public:
306  DtRwPropertyInt8(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
307  DtRwPropertyInt8(const DtString& name, DtInt8 value,
308  DtReaderWriterRegistry* parentRegistry = 0);
309  DtRwPropertyInt8(const DtString& name, const DtRwPropertyInt8& orig,
310  DtReaderWriterRegistry* parentRegistry = 0);
312  DtReaderWriterRegistry* parentRegistry = 0);
314  virtual ~DtRwPropertyInt8();
315  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
316 };
317 
319 {
320 public:
321  DtRwPropertyInt16(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
322  DtRwPropertyInt16(const DtString& name, DtInt16 value,
323  DtReaderWriterRegistry* parentRegistry = 0);
324  DtRwPropertyInt16(const DtString& name, const DtRwPropertyInt16& orig,
325  DtReaderWriterRegistry* parentRegistry = 0);
327  DtReaderWriterRegistry* parentRegistry = 0);
329  virtual ~DtRwPropertyInt16();
330  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
331 };
332 
334 {
335 public:
336  DtRwPropertyInt32(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
337  DtRwPropertyInt32(const DtString& name, DtInt32 value,
338  DtReaderWriterRegistry* parentRegistry = 0);
339  DtRwPropertyInt32(const DtString& name, const DtRwPropertyInt32& orig,
340  DtReaderWriterRegistry* parentRegistry = 0);
342  DtReaderWriterRegistry* parentRegistry = 0);
344  virtual ~DtRwPropertyInt32();
345  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
346 };
347 
349 {
350 public:
351  DtRwPropertyReal(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
352  DtRwPropertyReal(const DtString& name, DtReal value,
353  DtReaderWriterRegistry* parentRegistry = 0);
354  DtRwPropertyReal(const DtString& name, const DtRwPropertyReal& orig,
355  DtReaderWriterRegistry* parentRegistry = 0);
357  DtReaderWriterRegistry* parentRegistry = 0);
359  virtual ~DtRwPropertyReal();
360  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
361 };
362 
364 {
365 public:
366  DtRwPropertyReal32(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
367  DtRwPropertyReal32(const DtString& name, DtFloat32 value,
368  DtReaderWriterRegistry* parentRegistry = 0);
369  DtRwPropertyReal32(const DtString& name, const DtRwPropertyReal32& orig,
370  DtReaderWriterRegistry* parentRegistry = 0);
372  DtReaderWriterRegistry* parentRegistry = 0);
374  virtual ~DtRwPropertyReal32();
375  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
376 };
377 
379 {
380 public:
381  DtRwPropertyReal64(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
382  DtRwPropertyReal64(const DtString& name, DtFloat64 value,
383  DtReaderWriterRegistry* parentRegistry = 0);
384  DtRwPropertyReal64(const DtString& name, const DtRwPropertyReal64& orig,
385  DtReaderWriterRegistry* parentRegistry = 0);
387  DtReaderWriterRegistry* parentRegistry = 0);
389  virtual ~DtRwPropertyReal64();
390  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
391 };
392 
394 {
395 public:
396  DtRwPropertyVector(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
397  DtRwPropertyVector(const DtString& name, const DtVector& value,
398  DtReaderWriterRegistry* parentRegistry = 0);
399  DtRwPropertyVector(const DtString& name, const DtRwPropertyVector& orig,
400  DtReaderWriterRegistry* parentRegistry = 0);
402  DtReaderWriterRegistry* parentRegistry = 0);
404  virtual ~DtRwPropertyVector();
405 };
406 
407 
409 {
410 public:
411  DtRwPropertyOffsetVector(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
412  DtRwPropertyOffsetVector(const DtString& name, const DtVector& value,
413  DtReaderWriterRegistry* parentRegistry = 0);
415  DtReaderWriterRegistry* parentRegistry = 0);
417  DtReaderWriterRegistry* parentRegistry = 0);
419  virtual ~DtRwPropertyOffsetVector();
420 };
421 
422 #define rwProperties_INL_
423 #include <readerWriter/rwProperty.inl>
424 #undef rwProperties_INL_
virtual unsigned disRecordType() const
If this property is published, which DIS record type should it use. Default is 0, which indicates tha...
static void setDefaultThreshold(double percentage)
Changes the default threshold for cases when setThreshold() has not been called.
double myThreshold
Definition: rwProperty.h:211
DtClock myClock
Definition: rwProperty.h:125
#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.
Definition: symbolString.h:20
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:127
This class is similar to DtRwProperty, but allows you to specify a threshold at which the value shoul...
Definition: rwProperty.h:138
virtual const char * decode(const char *)
Decodes the property from the specified buffer. Assumes buffer is the start of the property and prece...
virtual void reset()
Override to clear out variable value.
Definition: rwProperty.h:274
virtual int hlaAlignment() const
Returns alignment necessary to encode this item in HLA.
Definition: rwProperty.h:378
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:268
Definition: rwProperty.h:348
virtual bool wasUpdatedSince(DtTime t) const
Returns true if an update occurred since the specified time.
Definition: rwProperty.h:220
Interface class used to define minimal interface for a property. The DtPropertyInterface class provid...
Definition: propertyInterface.h:48
Definition: rwProperty.h:318
virtual DtString stringRep(const DtString &root="") const
DtTime myUpdateTime
Definition: rwProperty.h:126
DtRwPropertyWithThreshold()
Not implemented.
float DtFloat32
Definition: vrvControlStructTypes.h:35
static double myDefaultThreshold
Definition: rwProperty.h:210
DtTime myMaxUnchangedUpdateInterval
Definition: rwProperty.h:217
virtual DtReaderWriter * readerWriter()
Returns a ReaderWriter pointer of the property.
Definition: rwProperty.h:363
std::list< const DtRwVariableBindings * > DtVariableBindingsList
Definition: readerWriterRegistry.h:29
bool myThresholdingEnabled
Whether thresholding is currently enabled.
Definition: rwProperty.h:202
int DtInt32
Definition: vrvControlStructTypes.h:31
std::vector< DtFilename > SearchPaths
Definition: readerWriter.h:92
static DtTime myDefaultMaxUnchangedUpdateInterval
Definition: rwProperty.h:216
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...
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...
double DtFloat64
Definition: vrvControlStructTypes.h:36
DtRwPropertyWithThreshold & operator=(const DtRwPropertyWithThreshold &orig)
Definition: rwProperty.h:333
virtual bool isDebugEnabled() const
Enables debug output. Generally this should be left off.
Definition: rwProperty.h:303
short DtInt16
Definition: vrvControlStructTypes.h:29
Definition: rwProperty.h:236
DtRwProperty()
Not implemented.
_RwType myLastEncodedValue
The value at the last time the value was encoded.
Definition: rwProperty.h:205
Definition: rwProperty.h:408
virtual ~DtRwPropertyWithThreshold()
bool myDebugEnabled
Definition: rwProperty.h:130
static const DtVariableBindingsList & nullVariableReference()
DtTime myLastEncodeTime
The time the value was last encoded.
Definition: rwProperty.h:208
DtRwProperty & operator=(const DtRwProperty &orig)
Defines the DtPropertyInterface class, the interface for all property classes.
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:288
virtual bool isPublished() const
Whether this property should be published.
virtual void setThreshold(double percentage)
Changes the threshold for when an update should be sent. If the percentage change of the value is gre...
bool myIsPublished
Definition: rwProperty.h:128
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
virtual bool wasUpdatedSince(DtTime t) const
Returns true if an update occurred since the specified time and the current value is at least _Thresh...
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 void setDisRecordType(unsigned recType)
If this property is published, which DIS record type should it use. Default is 0, which indicates tha...
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...
virtual void enableThresholding(bool enable)
Enables or disables thresholding of this property. Enabled by default.
static DtTime myDefaultMaxUpdateInterval
Definition: rwProperty.h:213
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:214
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:393
MergeFlags
Determines how two lists of properties will be merged by the merge function.
Definition: propertyInterface.h:53

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)