VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
rwProperties.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 
12 #include <vlutil/vlString.h>
15 #include <tbb/spin_mutex.h>
16 
17 class DtRwProperties;
18 
22 {
23 public:
24 
28 
30 
31  bool operator==(const DtPropertiesIterator& other) const;
32  bool operator!=(const DtPropertiesIterator& other) const;
33 
34  DtPropertiesIterator& operator=(const DtPropertiesIterator& other);
35 
36  DtPropertiesIterator& operator++();
37  DtPropertiesIterator operator++(int);
38  DtPropertiesIterator& operator--();
39  DtPropertiesIterator operator--(int);
40 
41  DtPropertyInterface& operator*();
42  DtPropertyInterface* operator->();
43 
44  DtPropertyInterface* property();
45  const DtPropertyInterface* property() const;
46 
47  template <typename KeyType>
48  KeyType key() const;
49 
50  const DtRwProperties* properties() const;
51 
53  void setRegistryIterator(std::vector<DtReaderWriterRegistryData*>::iterator iter);
54 
55  std::vector<DtReaderWriterRegistryData*>::iterator registryIterator() const;
56 
57 protected:
58 
60  std::vector<DtReaderWriterRegistryData*>::iterator myRegIter;
61 };
62 
66 {
67 public:
68 
73 
75 
76  bool operator==(const DtPropertiesConstIterator& other) const;
77  bool operator!=(const DtPropertiesConstIterator& other) const;
78 
80  DtPropertiesConstIterator& operator=(const DtPropertiesIterator& other);
81 
82  DtPropertiesConstIterator& operator++();
83  DtPropertiesConstIterator operator++(int);
84  DtPropertiesConstIterator& operator--();
85  DtPropertiesConstIterator operator--(int);
86 
87  const DtPropertyInterface& operator*() const;
88  const DtPropertyInterface* operator->() const;
89 
90  const DtPropertyInterface* property() const;
91 
92  template <typename KeyType>
93  KeyType key() const;
94 
95  const DtRwProperties* properties() const;
96 
98  void setRegistryIterator(std::vector<DtReaderWriterRegistryData*>::const_iterator iter);
99 
100  std::vector<DtReaderWriterRegistryData*>::const_iterator registryIterator() const;
101 
102 protected:
103 
105  std::vector<DtReaderWriterRegistryData*>::const_iterator myRegIter;
106 };
107 
123 {
124 private:
126  DtRwProperties();
127 
128 public:
129 
132 
135  DtRwProperties(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
136  DtRwProperties(const DtString& name, const DtRwProperties& orig,
137  DtReaderWriterRegistry* parentRegistry = 0);
138  DtRwProperties(const DtRwProperties& orig,
139  DtReaderWriterRegistry* parentRegistry = 0);
141 
143  virtual ~DtRwProperties() override;
144 
148  virtual const_iterator begin() const;
149  virtual iterator begin();
151 
155  virtual const_iterator end() const;
156  virtual iterator end();
158 
160  virtual unsigned size() const;
161 
165  virtual const DtPropertyInterface *
166  findPropertyInterface(const DtString &propertyName) const override;
167  virtual DtPropertyInterface *
168  findPropertyInterface(const DtString &propertyName) override;
170 
172  virtual bool addProperty(DtPropertyInterface *) override;
173 
175  virtual bool addPropertyAtIndex(DtPropertyInterface*, unsigned index);
176 
180  virtual bool removeProperty(const DtString &propertyName) override;
181  virtual bool removeProperty(const DtPropertyInterface *property) override;
183 
188  virtual void copy(const DtPropertyInterface &rhs) override;
189 
191  virtual void getSelf(DtlObjPtr args,
192  const DtReaderWriter::SearchPaths &searchPaths = SearchPaths(),
193  const DtVariableBindingsList &variableBindings =
194  nullVariableReference()) override;
195  virtual DtlObjPtr getData(DtlObjPtr args,
196  const DtReaderWriter::SearchPaths &searchPaths = SearchPaths(),
197  const DtVariableBindingsList &variableBindings =
198  nullVariableReference()) override;
199 
203  virtual const char *readerWriterType() const override;
204 
206  virtual bool isValidProperty(const DtPropertyInterface*) const;
207 
209  virtual DtPropertyInterface* createProperty(DtlObjPtr args, DtReaderWriterRegistry* parentRegistry);
210 
213  virtual char *encode(char *) const override;
214 
217  virtual const char *decode(const char *) override;
218 
222  virtual void getSize(int &size) const override;
223 
225  static DtReaderWriterPropertyFactory* propertyFactory();
226  static void cleanupPropertyFactory();
227 
229  virtual void copyVariables(const DtRwVariableBindings &other) override;
230 
231  virtual bool isReadonly() const;
232 
234  virtual int hlaAlignment() const override;
235 
238  virtual int requiredPadding(const char* buf, const DtPropertyInterface* field) const;
239 
241  virtual const char *propertyType() const override;
242 
244  virtual int count() const;
245 
249  virtual const DtReaderWriter* findPropertyRw(const DtString& propName) const;
250  virtual DtReaderWriter* findPropertyRw(const DtString& propName);
252 
253  virtual DtString stringRep(const DtString &root = "") const override;
254 
266  virtual bool merge(const DtPropertyInterface &target, MergeFlags,
267  const DtMergePath &path = DtMergePath(),
268  const std::set<DtString> &ignore = std::set<DtString>()) override;
269 
274  virtual DtRwProperties createFromPercentages(const DtRwProperties& percentages, const DtRwProperties& baseValues,
275  const DtString& base = "Base-");
276 
279  virtual bool findRootAndVariable(const DtString& varName, DtReaderWriter*& root, DtReaderWriter*& variable) const;
280 
283  virtual DtReaderWriter *readerWriter() override;
284  virtual const DtReaderWriter *readerWriter() const override;
286 
289  virtual DtPropertyInterface *property() override;
290  virtual const DtPropertyInterface *property() const override;
292 
294  virtual DtSymbolString propertyName() const override { return name(); };
295 
297  virtual void setPropertyName(const DtString &propertyName) override { setName(propertyName); };
298 
301  virtual bool isUpdateNeeded(DtTime t) const override;
302 
304  virtual bool hasReceivedUpdateSince(DtTime t) const override;
305 
309  virtual DtTime updateClockTime() const override;
310 
313  virtual bool isPublished() const override;
314  virtual void setIsPublished(bool isPub) override;
316 
320  virtual unsigned disRecordType() const override;
321  virtual void setDisRecordType(unsigned recType) override;
323 
325  virtual void clearVariables() override;
326 
328  virtual void reset() override;
329 
332  virtual void removeVariable(DtReaderWriter *) override;
333  virtual void removeVariable(const DtReaderWriter *) override;
335 
337  virtual void invalidateCache();
338 
340  virtual void invalidateCacheForProperty(const DtString& propName);
341 
342  static const DtRwProperties& emptyProperties();
343 
346 
348  static bool rollUpInteger(const DtReaderWriter* source, DtReaderWriter* destination, const DtMergePath& path);
349 
351  static bool rollUpReal(const DtReaderWriter* source, DtReaderWriter* destination, const DtMergePath& path);
352 
354  static bool rollUpString(const DtReaderWriter* source, DtReaderWriter* destination, const DtMergePath& path);
355 
357  static bool rollUpBoolean(const DtReaderWriter* source, DtReaderWriter* destination, const DtMergePath& path);
359 
360  virtual bool setWritePrototypeHeader(bool);
361  virtual bool writePrototypeHeader() const;
362 
364  virtual void cloneAndAddProperty(const DtReaderWriter& rw);
365 
368  virtual void setKeepPublishingSettings(bool keep) override;
369  virtual bool keepPublishingSettings() const override;
370 
371 protected:
373  virtual void filterIgnoredProperties(DtReaderWriter* rw, const std::set<DtString>& ignore);
374 
376  virtual void getInterface(DtPropertyInterface* pFace, DtlObjPtr args,
377  const DtReaderWriter::SearchPaths& searchPaths = SearchPaths(),
378  const DtVariableBindingsList& variableBindings = nullVariableReference());
379 
380  virtual void writeSelf(std::string &fp, int indentLevel,
381  bool writeUnspecified,
382  const DtFilename &path) override;
383  virtual void writeData(std::string& fp, int indentLevel, bool writeUnspecified, const DtFilename& path);
384 
385  virtual void putData(std::string &, int indentLevel = 0) override;
386 
387  virtual int hlaAlignment(const DtPropertyInterface* field) const;
388 
390  virtual void getSize(const DtPropertyInterface*, int& size) const;
391 
392  virtual char* encode(const DtPropertyInterface*, char* buf) const;
393  virtual const char* decode(DtPropertyInterface* iFace, const char* buf);
394 
396  virtual void unrecognizedItem(const DtEnvironmentSP env, const DtEnvValueSP root,
397  const DtReaderWriter::SearchPaths &searchPaths,
398  const DtVariableBindingsList &varBindings) override;
399 
401  virtual bool traverseAndModifyPercentage(DtRwProperties& results, const DtRwProperties& baseValues,
402  const DtReaderWriter* percentage, const DtString& base) const;
403 
404  virtual void writePrototypeHeader(std::string& fp, const DtReaderWriter* rw, int indentLevel) const;
405 
407  virtual void writePropertyData(DtReaderWriter* rw, std::string& fp, int indentLevel, bool writeUnspecified, const DtFilename& path);
408 
411  virtual void getSortedProperties(const DtRwVariableBindings& varBindings, std::vector<const DtReaderWriter*>& propertyList) const;
412  virtual void getSortedProperties(DtRwVariableBindings& varBindings, std::vector<DtReaderWriter*>& propertyList);
414 
417  virtual bool isDebugEnabled() const override;
418  virtual void setDebugEnabled(bool en) override;
420 
422  virtual void writePublishInformation(std::string& fp, int indentLevel) override;
423 
424 protected:
426 
427  mutable std::multimap<DtString, DtReaderWriter*> myRwPropertyCache;
428  mutable tbb::spin_mutex* myCacheMutex;
429 
431 
435 
438  mutable int mySizeAtLastCheck;
439 
440  unsigned myDisRecordType;
441 
443 
445 
447 
449 
452 };
453 
454 template <typename KeyType>
456 {
457  DtWarn << "Could not convert key, \"" << property()->propertyName()
458  << "\", to the specified type." << std::endl;
459 
460  return KeyType();
461 }
462 
463 template <>
464 inline int DtPropertiesIterator::key<int>() const
465 {
466  bool ok = false;
467  DtString keyStr(property()->propertyName().string());
468  int result = keyStr.toInt(&ok);
469 
470  if (!ok)
471  {
472  DtWarn << "Could not convert key, \"" << property()->propertyName()
473  << "\", to an int." << std::endl;
474  }
475 
476  return result;
477 }
478 
479 template <>
480 inline double DtPropertiesIterator::key<double>() const
481 {
482  bool ok = false;
483  DtString keyStr(property()->propertyName().string());
484  int result = keyStr.toDouble(&ok);
485 
486  if (!ok)
487  {
488  DtWarn << "Could not convert key, \"" << property()->propertyName()
489  << "\", to an double." << std::endl;
490  }
491 
492  return result;
493 }
494 
495 template <>
496 inline DtString DtPropertiesIterator::key<DtString>() const
497 {
498  return property()->propertyName().string();
499 }
500 
501 template <>
502 inline std::string DtPropertiesIterator::key<std::string>() const
503 {
504  return property()->propertyName().string();
505 }
506 
507 template <typename KeyType>
509 {
510  DtWarn << "Could not convert key, \"" << property()->propertyName()
511  << "\", to the specified type." << std::endl;
512 }
513 
514 template <>
515 inline int DtPropertiesConstIterator::key<int>() const
516 {
517  bool ok = false;
518  DtString keyStr(property()->propertyName().string());
519  int result = keyStr.toInt(&ok);
520 
521  if (!ok)
522  {
523  DtWarn << "Could not convert key, \"" << property()->propertyName()
524  << "\", to an int." << std::endl;
525  }
526 
527  return result;
528 }
529 
530 template <>
531 inline double DtPropertiesConstIterator::key<double>() const
532 {
533  bool ok = false;
534  DtString keyStr(property()->propertyName().string());
535  int result = keyStr.toDouble(&ok);
536 
537  if (!ok)
538  {
539  DtWarn << "Could not convert key, \"" << property()->propertyName()
540  << "\", to an double." << std::endl;
541  }
542 
543  return result;
544 }
545 
546 template <>
547 inline DtString DtPropertiesConstIterator::key<DtString>() const
548 {
549  return property()->propertyName().string();
550 }
551 
552 template <>
553 inline std::string DtPropertiesConstIterator::key<std::string>() const
554 {
555  return property()->propertyName().string();
556 }
virtual DtTime updateClockTime() const =0
Returns the current time on the update clock. Can be used to pass into a future call to hasReceivedUp...
DtString myPreviousParentPropFullName
Definition: rwProperties.h:451
virtual void setName(const DtString &)
Set the name of the object. Uses the myName variable. Only set if you understand that this could have...
tbb::spin_mutex * myCacheMutex
Definition: rwProperties.h:428
int mySizeAtLastCheck
Stores the number of items in the last at the last time it was discovered the size changed...
Definition: rwProperties.h:438
#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
This class allows one to collect and compare strings using an index number instead of having to do st...
Definition: symbolString.h:27
DtPropertiesConstIterator const_iterator
Definition: rwProperties.h:131
virtual void writePublishInformation(std::string &fp, int indentLevel)
Writes information specific to publishing on the network.
virtual void getSelf(DtlObjPtr args, const std::vector< DtFilename > &searchPaths=std::vector< DtFilename >(), const DtVariableBindingsList &variableBindings=nullVariableReference()) override
Reads in items, using the factory to read the correct types.
virtual DtString stringRep(const DtString &root="") const =0
virtual void unrecognizedItem(const DtEnvironmentSP env, const DtEnvValueSP root, const SearchPaths &searchPaths, const DtVariableBindingsList &varBindings)
Called when the xml reader tries to parse an unknown reader/writer item. Default is a no-op...
virtual void copy(const DtPropertyInterface &rhs)=0
Copies the given property into the current one as long as the types are the same. The details of how ...
const DtPropertyInterface * property() const
virtual void setKeepPublishingSettings(bool keep)=0
Specifies whether the publishing settings for this property should be retained when it is updated fro...
DtRwVariableBindings & operator=(const DtRwVariableBindings &orig)
std::vector< DtReaderWriterRegistryData * >::iterator myRegIter
Definition: rwProperties.h:60
virtual const char * decode(const char *)=0
Decodes the property from the specified buffer. Assumes buffer is the start of the property and prece...
virtual DtSymbolString propertyName() const override
The name of this property.
Definition: rwProperties.h:294
DtClock myClock
Definition: rwProperties.h:430
virtual void writeSelf(std::string &fp, int indentLevel=0, bool writeUnspecified=false, const DtFilename &path=DtFilename::nullFilename()) override
Writes out registry data, but includes the type strings when writing.
virtual void setIsPublished(bool isPub)=0
Whether this property should be published.
bool myIsPublished
Definition: rwProperties.h:442
voidpf void uLong size
Definition: ioapi.h:39
virtual void setDebugEnabled(bool en)=0
Enables debug output. Generally this should be left off.
DT_DLL_terrainCS bool operator==(const DtDegMinSec &lhs, const DtDegMinSec &rhs)
Definition: readerWriter.h:85
virtual void removeVariable(DtReaderWriter *)
bool myWritePrototypeHeader
Definition: rwProperties.h:444
virtual bool isDebugEnabled() const =0
Enables debug output. Generally this should be left off.
Definition: readerWriterRegistry.h:39
std::multimap< DtString, DtReaderWriter * > myRwPropertyCache
Definition: rwProperties.h:427
DtPropertiesIterator iterator
Definition: rwProperties.h:130
bool myKeepPublishingSettingsOnCopy
Definition: rwProperties.h:448
virtual bool removeProperty(const DtString &propertyName)
Definition: propertyInterface.h:245
DtTime myLastTimeSizeChanged
Stores the last time at which it was discovered that the size of the list changed.
Definition: rwProperties.h:434
voidpf void * buf
Definition: ioapi.h:39
virtual int hlaAlignment() const =0
Returns alignment necessary to encode this item in HLA.
Iterator for traversing DtRwProperties or its subclasses.
Definition: rwProperties.h:65
virtual DtlObjPtr getData(DtlObjPtr args, const DtReaderWriter::SearchPaths &searchPaths, const DtVariableBindingsList &variableBindings)=0
Override to allow a variable to be assigned to a property of derived type.
Interface class used to define minimal interface for a property. The DtPropertyInterface class provid...
Definition: propertyInterface.h:53
virtual char * encode(char *) const =0
Encodes the property into the supplied buffer. Does not align the property. Buffer must already be al...
ReaderWriter object that maintains a list of reader-writer variable bindings. It keeps a list of name...
Definition: rwVariableBindings.h:27
static DtReaderWriterPropertyFactory * thePropertyFactory
Definition: rwProperties.h:425
bool myDebugEnabled
Definition: rwProperties.h:446
virtual bool addProperty(DtPropertyInterface *property)
Adds an existing property to the properties container. The container will take ownership of the given...
Definition: propertyInterface.h:223
virtual void clearVariables()
Removes and deletes all variable items.
unsigned myDisRecordType
Definition: rwProperties.h:440
virtual void copyVariables(const DtRwVariableBindings &other)
Copies all variable items from another bindings list and adds them to the local one.
virtual bool merge(const DtPropertyInterface &target, MergeFlags, const DtMergePath &path=DtMergePath(), const std::set< DtString > &ignore=std::set< DtString >())=0
Takes the contents of the supplied properties and merges with the following rules if replace is false...
const DtRwProperties * myProperties
Definition: rwProperties.h:104
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...
Specialized type of reader/writer factory that supports properties.
Definition: readerWriterFactory.h:187
std::list< const DtRwVariableBindings * > DtVariableBindingsList
Definition: readerWriterRegistry.h:29
DtRwProperties * myProperties
Definition: rwProperties.h:59
bool isReadonly() const
Definition: readerWriter.h:214
const DtReaderWriter * findPropertyRw(const DtReaderWriter &properties, const DtString &propertyName)
Contains utility functions to make it easier to find and extract data from a set of extended properti...
std::vector< DtFilename > SearchPaths
Definition: readerWriter.h:92
KeyType key() const
Definition: rwProperties.h:455
int getSize() const
Returns the network size of this item in bytes. This does not include any upfront padding for alignme...
virtual void setPropertyName(const DtString &propertyName) override
Sets name of this property. Should generally only be called when initially created.
Definition: rwProperties.h:297
std::vector< DtMergePathStruct > DtMergePath
Definition: readerWriterFactory.h:181
virtual DtPropertyInterface * property()
Returns a PropertyInterface pointer of the ReaderWriter. Returns 0 by default, must by overridden by ...
virtual bool hasReceivedUpdateSince(DtTime t) const =0
Returns true if an update was received remotely since the specified time.
const char * source
Definition: lz4.h:442
virtual DtReaderWriter * readerWriter()=0
Returns a ReaderWriter pointer of the property. If property is not a ReaderWriter, this should be overridden to return 0.
virtual bool isPublished() const =0
Whether this property should be published.
static const DtVariableBindingsList & nullVariableReference()
virtual void setDisRecordType(unsigned recType)=0
If this property is published, which DIS record type should it use. Default is 0, which indicates tha...
DtPropertyInterface * property()
Defines the DtPropertyInterface class, the interface for all property classes.
virtual unsigned disRecordType() const =0
If this property is published, which DIS record type should it use. Default is 0, which indicates tha...
virtual void putData(std::string &fp, int indentLevel=0)
Deriving class overrides these to get/put class specific data.
KeyType key() const
Definition: rwProperties.h:508
virtual DtSymbolString propertyName() const =0
The name of this property.
std::vector< DtReaderWriterRegistryData * >::const_iterator myRegIter
Definition: rwProperties.h:105
DtPropertyInterface * myPreviousParentProp
Definition: rwProperties.h:450
Definition: rwProperties.h:21
virtual const DtPropertyInterface * findPropertyInterface(const DtString &propertyName) const
Definition: propertyInterface.h:124
A list of properties. A DtPropertyInterface object that is a specialized version of DtRwVariableBindi...
Definition: rwProperties.h:122
DT_DLL_terrainCS bool operator!=(const DtDegMinSec &lhs, const DtDegMinSec &rhs)
virtual const char * propertyType() const =0
Typically returns reader/writer type.
virtual bool isUpdateNeeded(DtTime t) const =0
Returns true if the value has been updated since the specified time and needs to be sent on the netwo...
DT_DLL_readerWriter std::shared_ptr< DtEnvironment > DtEnvironmentSP
Definition: readerWriter.h:30
virtual DtSymbolString name() const
Accessor for name of this readable/writable object.
virtual bool keepPublishingSettings() const =0
virtual void reset()=0
Override to clear out variable value.
MergeFlags
Determines how two lists of properties will be merged by the merge function.
Definition: propertyInterface.h:58

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)