VR-Forces 4.8 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 
43  virtual char* encode(char*) const;
44 
46  virtual const char* decode(const char*);
47 
49  virtual void getSize(int& size) const;
50 
51  virtual int hlaAlignment() const;
52 
53  virtual DtString stringRep(const DtString& root = "") const;
54 
56  virtual const char* propertyType() const;
57 
59  virtual DtSymbolString propertyName() const { return _RwType::name(); };
60 
62  virtual void setPropertyName(const DtString& propertyName) { _RwType::setName(propertyName); };
63 
64  virtual void getSelf(DtlObjPtr args,
67 
68  virtual DtlObjPtr getData(DtlObjPtr args, const DtReaderWriter::SearchPaths& searchPaths,
69  const DtVariableBindingsList& variableBindings);
70 
72  virtual bool merge(const DtPropertyInterface& target, MergeFlags,
73  const DtMergePath& path = DtMergePath(), const std::set<DtString>& ignore = std::set<DtString>());
74 
77  virtual DtReaderWriter* readerWriter();
78  virtual const DtReaderWriter* readerWriter() const;
80 
83  virtual DtPropertyInterface* property();
84  virtual const DtPropertyInterface* property() const;
86 
88  virtual void recordUpdateTime() const;
89 
91  virtual bool wasUpdatedSince(DtTime t) const;
92 
95  virtual bool isPublished() const;
96  virtual void setIsPublished(bool isPub);
98 
102  virtual unsigned disRecordType() const;
103  virtual void setDisRecordType(unsigned recType);
105 
106  virtual void reset();
107 
108 protected:
109 
113  unsigned myDisRecordType;
114 };
115 
120 template <typename _RwType>
122 {
123 private:
126 
127 public:
128 
129  DtRwPropertyWithThreshold(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
131  DtReaderWriterRegistry* parentRegistry = 0);
133  virtual ~DtRwPropertyWithThreshold();
134 
139  virtual char* encode(char*) const;
140 
144  virtual bool wasUpdatedSince(DtTime t) const;
145 
147  virtual void enableThresholding(bool enable);
148 
152  virtual void setThreshold(double percentage);
153 
156  static void setDefaultThreshold(double percentage);
157 
162  virtual void setMaxUpdateInterval(DtTime interval);
163 
166  static void setDefaultMaxUpdateInterval(DtTime interval);
167 
176  virtual void setMaxUnchangedUpdateInterval(DtTime interval);
177 
180  static void setDefaultMaxUnchangedUpdateInterval(DtTime interval);
181 
182 protected:
183 
186 
188  mutable _RwType myLastEncodedValue;
189 
192 
193  static double myDefaultThreshold;
194  double myThreshold;
195 
198 
201 };
202 
204 {
205 public:
206  DtRwPropertyString(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
207  DtRwPropertyString(const DtString& name, const DtString& value,
208  DtReaderWriterRegistry* parentRegistry = 0);
209  DtRwPropertyString(const DtString& name, const DtRwPropertyString& orig,
210  DtReaderWriterRegistry* parentRegistry = 0);
212  DtReaderWriterRegistry* parentRegistry = 0);
213 
215 
216  virtual ~DtRwPropertyString();
217 };
218 
220 {
221 public:
222  DtRwPropertySizedString(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
223  DtRwPropertySizedString(const DtString& name, const DtString& value,
224  DtReaderWriterRegistry* parentRegistry = 0);
226  DtReaderWriterRegistry* parentRegistry = 0);
228  DtReaderWriterRegistry* parentRegistry = 0);
229 
230  virtual ~DtRwPropertySizedString();
231 
232  virtual char* encode(char*) const;
233 
234  virtual const char* decode(const char*);
235 
236  virtual void getSize(int& size) const;
237 
238  virtual int hlaAlignment() const;
239 
240  const char* readerWriterType() const;
241 
242  static const char* theXmlType();
243 
244  virtual const char* xmlType() const
245  {
246  return theXmlType();
247  }
248 };
249 
251 {
252 public:
253  DtRwPropertyBoolean(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
254  DtRwPropertyBoolean(const DtString& name, bool value,
255  DtReaderWriterRegistry* parentRegistry = 0);
256  DtRwPropertyBoolean(const DtString& name, const DtRwPropertyBoolean& orig,
257  DtReaderWriterRegistry* parentRegistry = 0);
259  DtReaderWriterRegistry* parentRegistry = 0);
261  virtual ~DtRwPropertyBoolean();
262 };
263 
265 {
266 public:
267  DtRwPropertyInt(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
268  DtRwPropertyInt(const DtString& name, int value,
269  DtReaderWriterRegistry* parentRegistry = 0);
270  DtRwPropertyInt(const DtString& name, const DtRwPropertyInt& orig,
271  DtReaderWriterRegistry* parentRegistry = 0);
272  DtRwPropertyInt(const DtRwPropertyInt& orig,
273  DtReaderWriterRegistry* parentRegistry = 0);
275  virtual ~DtRwPropertyInt();
276 };
277 
279 {
280 public:
281  DtRwPropertyInt8(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
282  DtRwPropertyInt8(const DtString& name, DtInt8 value,
283  DtReaderWriterRegistry* parentRegistry = 0);
284  DtRwPropertyInt8(const DtString& name, const DtRwPropertyInt8& orig,
285  DtReaderWriterRegistry* parentRegistry = 0);
287  DtReaderWriterRegistry* parentRegistry = 0);
289  virtual ~DtRwPropertyInt8();
290 };
291 
293 {
294 public:
295  DtRwPropertyInt16(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
296  DtRwPropertyInt16(const DtString& name, DtInt16 value,
297  DtReaderWriterRegistry* parentRegistry = 0);
298  DtRwPropertyInt16(const DtString& name, const DtRwPropertyInt16& orig,
299  DtReaderWriterRegistry* parentRegistry = 0);
301  DtReaderWriterRegistry* parentRegistry = 0);
303  virtual ~DtRwPropertyInt16();
304 };
305 
307 {
308 public:
309  DtRwPropertyInt32(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
310  DtRwPropertyInt32(const DtString& name, DtInt32 value,
311  DtReaderWriterRegistry* parentRegistry = 0);
312  DtRwPropertyInt32(const DtString& name, const DtRwPropertyInt32& orig,
313  DtReaderWriterRegistry* parentRegistry = 0);
315  DtReaderWriterRegistry* parentRegistry = 0);
317  virtual ~DtRwPropertyInt32();
318 };
319 
321 {
322 public:
323  DtRwPropertyReal(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
324  DtRwPropertyReal(const DtString& name, DtReal value,
325  DtReaderWriterRegistry* parentRegistry = 0);
326  DtRwPropertyReal(const DtString& name, const DtRwPropertyReal& orig,
327  DtReaderWriterRegistry* parentRegistry = 0);
329  DtReaderWriterRegistry* parentRegistry = 0);
331  virtual ~DtRwPropertyReal();
332 };
333 
335 {
336 public:
337  DtRwPropertyReal32(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
338  DtRwPropertyReal32(const DtString& name, DtFloat32 value,
339  DtReaderWriterRegistry* parentRegistry = 0);
340  DtRwPropertyReal32(const DtString& name, const DtRwPropertyReal32& orig,
341  DtReaderWriterRegistry* parentRegistry = 0);
343  DtReaderWriterRegistry* parentRegistry = 0);
345  virtual ~DtRwPropertyReal32();
346 };
347 
349 {
350 public:
351  DtRwPropertyReal64(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
352  DtRwPropertyReal64(const DtString& name, DtFloat64 value,
353  DtReaderWriterRegistry* parentRegistry = 0);
354  DtRwPropertyReal64(const DtString& name, const DtRwPropertyReal64& orig,
355  DtReaderWriterRegistry* parentRegistry = 0);
357  DtReaderWriterRegistry* parentRegistry = 0);
359  virtual ~DtRwPropertyReal64();
360 };
361 
363 {
364 public:
365  DtRwPropertyVector(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
366  DtRwPropertyVector(const DtString& name, const DtVector& value,
367  DtReaderWriterRegistry* parentRegistry = 0);
368  DtRwPropertyVector(const DtString& name, const DtRwPropertyVector& orig,
369  DtReaderWriterRegistry* parentRegistry = 0);
371  DtReaderWriterRegistry* parentRegistry = 0);
373  virtual ~DtRwPropertyVector();
374 };
375 
376 
378 {
379 public:
380  DtRwPropertyOffsetVector(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
381  DtRwPropertyOffsetVector(const DtString& name, const DtVector& value,
382  DtReaderWriterRegistry* parentRegistry = 0);
384  DtReaderWriterRegistry* parentRegistry = 0);
386  DtReaderWriterRegistry* parentRegistry = 0);
388  virtual ~DtRwPropertyOffsetVector();
389 };
390 
391 #define rwProperties_INL_
392 #include <readerWriter/rwProperty.inl>
393 #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:194
DtClock myClock
Definition: rwProperty.h:110
#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:62
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:113
This class is similar to DtRwProperty, but allows you to specify a threshold at which the value shoul...
Definition: rwProperty.h:121
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:250
virtual int hlaAlignment() const
Returns alignment necessary to encode this item in HLA.
Definition: rwProperty.h:348
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:244
Definition: rwProperty.h:320
virtual bool wasUpdatedSince(DtTime t) const
Returns true if an update occurred since the specified time.
Definition: rwProperty.h:203
Interface class used to define minimal interface for a property.
Definition: propertyInterface.h:48
Definition: rwProperty.h:292
virtual DtString stringRep(const DtString &root="") const
DtTime myUpdateTime
Definition: rwProperty.h:111
DtRwPropertyWithThreshold()
Not implemented.
float DtFloat32
Definition: vrvControlStructTypes.h:35
static double myDefaultThreshold
Definition: rwProperty.h:193
DtTime myMaxUnchangedUpdateInterval
Definition: rwProperty.h:200
virtual DtReaderWriter * readerWriter()
Definition: rwProperty.h:334
std::list< const DtRwVariableBindings * > DtVariableBindingsList
Definition: readerWriterRegistry.h:29
bool myThresholdingEnabled
Whether thresholding is currently enabled.
Definition: rwProperty.h:185
int DtInt32
Definition: vrvControlStructTypes.h:31
std::vector< DtFilename > SearchPaths
Definition: readerWriter.h:92
static DtTime myDefaultMaxUnchangedUpdateInterval
Definition: rwProperty.h:199
int getSize() const
std::vector< DtMergePathStruct > DtMergePath
Definition: readerWriterFactory.h:167
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:306
Definition: rwProperty.h:278
short DtInt16
Definition: vrvControlStructTypes.h:29
Definition: rwProperty.h:219
DtRwProperty()
Not implemented.
_RwType myLastEncodedValue
The value at the last time the value was encoded.
Definition: rwProperty.h:188
Definition: rwProperty.h:377
virtual ~DtRwPropertyWithThreshold()
static const DtVariableBindingsList & nullVariableReference()
DtTime myLastEncodeTime
The time the value was last encoded.
Definition: rwProperty.h:191
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:264
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:112
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 DtSymbolString propertyName() const
The name of this property.
Definition: rwProperty.h:59
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:196
File: rwVector.h.
DtTime myMaxUpdateInterval
Definition: rwProperty.h:197
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:362
MergeFlags
Determines how two lists of properties will be merged by the merge function.
Definition: propertyInterface.h:53

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)