VR-Forces 4.10 Class Documentation
 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 
46  virtual char* encode(char*) const;
47 
49  virtual const char* decode(const char*);
50 
52  virtual void getSize(int& size) const;
53 
54  virtual int hlaAlignment() const;
55 
56  virtual DtString stringRep(const DtString& root = "") const;
57 
59  virtual const char* propertyType() const;
60 
62  virtual DtSymbolString propertyName() const { return _RwType::name(); };
63 
65  virtual void setPropertyName(const DtString& propertyName) { _RwType::setName(propertyName); };
66 
67  virtual void getSelf(DtlObjPtr args,
70 
71  virtual DtlObjPtr getData(DtlObjPtr args, const DtReaderWriter::SearchPaths& searchPaths,
72  const DtVariableBindingsList& variableBindings);
73 
75  virtual bool merge(const DtPropertyInterface& target, MergeFlags,
76  const DtMergePath& path = DtMergePath(), const std::set<DtString>& ignore = std::set<DtString>());
77 
80  virtual DtReaderWriter* readerWriter();
81  virtual const DtReaderWriter* readerWriter() const;
83 
86  virtual DtPropertyInterface* property();
87  virtual const DtPropertyInterface* property() const;
89 
91  virtual void recordUpdateTime() const;
92 
94  virtual bool wasUpdatedSince(DtTime t) const;
95 
98  virtual bool isPublished() const;
99  virtual void setIsPublished(bool isPub);
101 
105  virtual unsigned disRecordType() const;
106  virtual void setDisRecordType(unsigned recType);
108 
111  virtual bool isDebugEnabled() const;
112  virtual void setDebugEnabled(bool en);
114 
115  virtual void reset();
116 
117 protected:
118 
121  unsigned myDisRecordType;
123 
125 };
126 
131 template <typename _RwType>
133 {
134 private:
137 
138 public:
139 
140  DtRwPropertyWithThreshold(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
142  DtReaderWriterRegistry* parentRegistry = 0);
144  virtual ~DtRwPropertyWithThreshold();
145 
150  virtual char* encode(char*) const;
151 
155  virtual bool wasUpdatedSince(DtTime t) const;
156 
158  virtual void enableThresholding(bool enable);
159 
163  virtual void setThreshold(double percentage);
164 
167  static void setDefaultThreshold(double percentage);
168 
173  virtual void setMaxUpdateInterval(DtTime interval);
174 
177  static void setDefaultMaxUpdateInterval(DtTime interval);
178 
187  virtual void setMaxUnchangedUpdateInterval(DtTime interval);
188 
191  static void setDefaultMaxUnchangedUpdateInterval(DtTime interval);
192 
193 protected:
194 
197 
199  mutable _RwType myLastEncodedValue;
200 
203 
204  static double myDefaultThreshold;
205  double myThreshold;
206 
209 
212 };
213 
215 {
216 public:
217  DtRwPropertyString(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
218  DtRwPropertyString(const DtString& name, const DtString& value,
219  DtReaderWriterRegistry* parentRegistry = 0);
220  DtRwPropertyString(const DtString& name, const DtRwPropertyString& orig,
221  DtReaderWriterRegistry* parentRegistry = 0);
223  DtReaderWriterRegistry* parentRegistry = 0);
224 
226 
227  virtual ~DtRwPropertyString();
228 };
229 
231 {
232 public:
233  DtRwPropertySizedString(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
234  DtRwPropertySizedString(const DtString& name, const DtString& value,
235  DtReaderWriterRegistry* parentRegistry = 0);
237  DtReaderWriterRegistry* parentRegistry = 0);
239  DtReaderWriterRegistry* parentRegistry = 0);
240 
241  virtual ~DtRwPropertySizedString();
242 
243  virtual char* encode(char*) const;
244 
245  virtual const char* decode(const char*);
246 
247  virtual void getSize(int& size) const;
248 
249  virtual int hlaAlignment() const;
250 
251  const char* readerWriterType() const;
252 
253  static const char* theXmlType();
254 
255  virtual const char* xmlType() const
256  {
257  return theXmlType();
258  }
259 };
260 
262 {
263 public:
264  DtRwPropertyBoolean(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
265  DtRwPropertyBoolean(const DtString& name, bool value,
266  DtReaderWriterRegistry* parentRegistry = 0);
267  DtRwPropertyBoolean(const DtString& name, const DtRwPropertyBoolean& orig,
268  DtReaderWriterRegistry* parentRegistry = 0);
270  DtReaderWriterRegistry* parentRegistry = 0);
272  virtual ~DtRwPropertyBoolean();
273 };
274 
276 {
277 public:
278  DtRwPropertyInt(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
279  DtRwPropertyInt(const DtString& name, int value,
280  DtReaderWriterRegistry* parentRegistry = 0);
281  DtRwPropertyInt(const DtString& name, const DtRwPropertyInt& orig,
282  DtReaderWriterRegistry* parentRegistry = 0);
283  DtRwPropertyInt(const DtRwPropertyInt& orig,
284  DtReaderWriterRegistry* parentRegistry = 0);
286  virtual ~DtRwPropertyInt();
287  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
288 };
289 
291 {
292 public:
293  DtRwPropertyInt8(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
294  DtRwPropertyInt8(const DtString& name, DtInt8 value,
295  DtReaderWriterRegistry* parentRegistry = 0);
296  DtRwPropertyInt8(const DtString& name, const DtRwPropertyInt8& orig,
297  DtReaderWriterRegistry* parentRegistry = 0);
299  DtReaderWriterRegistry* parentRegistry = 0);
301  virtual ~DtRwPropertyInt8();
302  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
303 };
304 
306 {
307 public:
308  DtRwPropertyInt16(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
309  DtRwPropertyInt16(const DtString& name, DtInt16 value,
310  DtReaderWriterRegistry* parentRegistry = 0);
311  DtRwPropertyInt16(const DtString& name, const DtRwPropertyInt16& orig,
312  DtReaderWriterRegistry* parentRegistry = 0);
314  DtReaderWriterRegistry* parentRegistry = 0);
316  virtual ~DtRwPropertyInt16();
317  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
318 };
319 
321 {
322 public:
323  DtRwPropertyInt32(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
324  DtRwPropertyInt32(const DtString& name, DtInt32 value,
325  DtReaderWriterRegistry* parentRegistry = 0);
326  DtRwPropertyInt32(const DtString& name, const DtRwPropertyInt32& orig,
327  DtReaderWriterRegistry* parentRegistry = 0);
329  DtReaderWriterRegistry* parentRegistry = 0);
331  virtual ~DtRwPropertyInt32();
332  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
333 };
334 
336 {
337 public:
338  DtRwPropertyReal(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
339  DtRwPropertyReal(const DtString& name, DtReal value,
340  DtReaderWriterRegistry* parentRegistry = 0);
341  DtRwPropertyReal(const DtString& name, const DtRwPropertyReal& orig,
342  DtReaderWriterRegistry* parentRegistry = 0);
344  DtReaderWriterRegistry* parentRegistry = 0);
346  virtual ~DtRwPropertyReal();
347  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
348 };
349 
351 {
352 public:
353  DtRwPropertyReal32(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
354  DtRwPropertyReal32(const DtString& name, DtFloat32 value,
355  DtReaderWriterRegistry* parentRegistry = 0);
356  DtRwPropertyReal32(const DtString& name, const DtRwPropertyReal32& orig,
357  DtReaderWriterRegistry* parentRegistry = 0);
359  DtReaderWriterRegistry* parentRegistry = 0);
361  virtual ~DtRwPropertyReal32();
362  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
363 };
364 
366 {
367 public:
368  DtRwPropertyReal64(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
369  DtRwPropertyReal64(const DtString& name, DtFloat64 value,
370  DtReaderWriterRegistry* parentRegistry = 0);
371  DtRwPropertyReal64(const DtString& name, const DtRwPropertyReal64& orig,
372  DtReaderWriterRegistry* parentRegistry = 0);
374  DtReaderWriterRegistry* parentRegistry = 0);
376  virtual ~DtRwPropertyReal64();
377  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict) const override;
378 };
379 
381 {
382 public:
383  DtRwPropertyVector(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
384  DtRwPropertyVector(const DtString& name, const DtVector& value,
385  DtReaderWriterRegistry* parentRegistry = 0);
386  DtRwPropertyVector(const DtString& name, const DtRwPropertyVector& orig,
387  DtReaderWriterRegistry* parentRegistry = 0);
389  DtReaderWriterRegistry* parentRegistry = 0);
391  virtual ~DtRwPropertyVector();
392 };
393 
394 
396 {
397 public:
398  DtRwPropertyOffsetVector(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
399  DtRwPropertyOffsetVector(const DtString& name, const DtVector& value,
400  DtReaderWriterRegistry* parentRegistry = 0);
402  DtReaderWriterRegistry* parentRegistry = 0);
404  DtReaderWriterRegistry* parentRegistry = 0);
406  virtual ~DtRwPropertyOffsetVector();
407 };
408 
409 #define rwProperties_INL_
410 #include <readerWriter/rwProperty.inl>
411 #undef rwProperties_INL_
virtual unsigned disRecordType() const
If this property is published, which DIS record type should it use.
static void setDefaultThreshold(double percentage)
Changes the default threshold for cases when setThreshold() has not been called.
double myThreshold
Definition: rwProperty.h:205
DtClock myClock
Definition: rwProperty.h:119
#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:65
static const char * theXmlType()
The type that is used when archiving to an XML stream.
Definition: symbolString.h:20
virtual DtPropertyInterface * property()
virtual char * encode(char *) const
These methods are for network encoding/decoding for Hla encoding decoding reasons.
unsigned myDisRecordType
Definition: rwProperty.h:121
This class is similar to DtRwProperty, but allows you to specify a threshold at which the value shoul...
Definition: rwProperty.h:132
virtual const char * decode(const char *)
Decodes the variable bindings from the specified buffer.
virtual void reset()
Override to clear out variable value.
Definition: rwProperty.h:261
virtual int hlaAlignment() const
Returns alignment necessary to encode this item in HLA.
Definition: rwProperty.h:365
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
Definition: rwProperty.h:255
Definition: rwProperty.h:335
virtual bool wasUpdatedSince(DtTime t) const
Returns true if an update occurred since the specified time.
Definition: rwProperty.h:214
Interface class used to define minimal interface for a property.
Definition: propertyInterface.h:48
Definition: rwProperty.h:305
virtual DtString stringRep(const DtString &root="") const
DtTime myUpdateTime
Definition: rwProperty.h:120
DtRwPropertyWithThreshold()
Not implemented.
float DtFloat32
Definition: vrvControlStructTypes.h:35
static double myDefaultThreshold
Definition: rwProperty.h:204
DtTime myMaxUnchangedUpdateInterval
Definition: rwProperty.h:211
virtual DtReaderWriter * readerWriter()
Definition: rwProperty.h:350
std::list< const DtRwVariableBindings * > DtVariableBindingsList
Definition: readerWriterRegistry.h:29
bool myThresholdingEnabled
Whether thresholding is currently enabled.
Definition: rwProperty.h:196
int DtInt32
Definition: vrvControlStructTypes.h:31
std::vector< DtFilename > SearchPaths
Definition: readerWriter.h:92
static DtTime myDefaultMaxUnchangedUpdateInterval
Definition: rwProperty.h:210
virtual void setDebugEnabled(bool en)
int getSize() const
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:320
virtual bool isDebugEnabled() const
Enables debug output.
Definition: rwProperty.h:290
short DtInt16
Definition: vrvControlStructTypes.h:29
Definition: rwProperty.h:230
DtRwProperty()
Not implemented.
_RwType myLastEncodedValue
The value at the last time the value was encoded.
Definition: rwProperty.h:199
Definition: rwProperty.h:395
virtual ~DtRwPropertyWithThreshold()
bool myDebugEnabled
Definition: rwProperty.h:124
static const DtVariableBindingsList & nullVariableReference()
DtTime myLastEncodeTime
The time the value was last encoded.
Definition: rwProperty.h:202
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:275
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.
bool myIsPublished
Definition: rwProperty.h:122
virtual void setIsPublished(bool isPub)
Templated class that allows for the definition of a property.
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)
virtual bool isSimilarProperty(const DtPropertyInterface *rhs, bool strict=true) const
Returns true if the readerWriterType is the same.
virtual DtSymbolString propertyName() const
The name of this property.
Definition: rwProperty.h:62
virtual const char * readerWriterType() const
Used to supply a string type that this reader writer type is.
virtual ~DtRwProperty()
virtual char * encode(char *) const
These methods are for network encoding/decoding for HLA encoding decoding reasons.
virtual void enableThresholding(bool enable)
Enables or disables thresholding of this property. Enabled by default.
static DtTime myDefaultMaxUpdateInterval
Definition: rwProperty.h:207
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:208
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:380
MergeFlags
Determines how two lists of properties will be merged by the merge function.
Definition: propertyInterface.h:53

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)