VR-Forces 4.7 Class Documentation
 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) 2013 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 #pragma once
10 
12 #include <vlutil/vlString.h>
15 
16 namespace tbb
17 {
18  class spin_mutex;
19 }
20 
21 class DtRwProperties;
22 
26 {
27 public:
28 
32 
34 
35  bool operator==(const DtPropertiesIterator& other) const;
36  bool operator!=(const DtPropertiesIterator& other) const;
37 
38  DtPropertiesIterator& operator=(const DtPropertiesIterator& other);
39 
40  DtPropertiesIterator& operator++();
41  DtPropertiesIterator operator++(int);
42  DtPropertiesIterator& operator--();
43  DtPropertiesIterator operator--(int);
44 
45  DtPropertyInterface& operator*();
46  DtPropertyInterface* operator->();
47 
48  DtPropertyInterface* property();
49  const DtPropertyInterface* property() const;
50 
51  template <typename KeyType>
52  KeyType key() const;
53 
54  const DtRwProperties* properties() const;
55 
57  void setRegistryIterator(std::vector<DtReaderWriterRegistryData*>::iterator iter);
58 
59  std::vector<DtReaderWriterRegistryData*>::iterator registryIterator() const;
60 
61 protected:
62 
64  std::vector<DtReaderWriterRegistryData*>::iterator myRegIter;
65 };
66 
70 {
71 public:
72 
77 
79 
80  bool operator==(const DtPropertiesConstIterator& other) const;
81  bool operator!=(const DtPropertiesConstIterator& other) const;
82 
84  DtPropertiesConstIterator& operator=(const DtPropertiesIterator& other);
85 
86  DtPropertiesConstIterator& operator++();
87  DtPropertiesConstIterator operator++(int);
88  DtPropertiesConstIterator& operator--();
89  DtPropertiesConstIterator operator--(int);
90 
91  const DtPropertyInterface& operator*() const;
92  const DtPropertyInterface* operator->() const;
93 
94  const DtPropertyInterface* property() const;
95 
96  template <typename KeyType>
97  KeyType key() const;
98 
99  const DtRwProperties* properties() const;
100 
102  void setRegistryIterator(std::vector<DtReaderWriterRegistryData*>::const_iterator iter);
103 
104  std::vector<DtReaderWriterRegistryData*>::const_iterator registryIterator() const;
105 
106 protected:
107 
109  std::vector<DtReaderWriterRegistryData*>::const_iterator myRegIter;
110 };
111 
127 {
128 private:
130  DtRwProperties();
131 
132 public:
133 
136 
139  DtRwProperties(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
140  DtRwProperties(const DtString& name, const DtRwProperties& orig,
141  DtReaderWriterRegistry* parentRegistry = 0);
142  DtRwProperties(const DtRwProperties& orig,
143  DtReaderWriterRegistry* parentRegistry = 0);
145 
147  virtual ~DtRwProperties();
148 
152  virtual const_iterator begin() const;
153  virtual iterator begin();
155 
159  virtual const_iterator end() const;
160  virtual iterator end();
162 
164  virtual unsigned size() const;
165 
169  virtual const DtPropertyInterface* findPropertyInterface(const DtString& propertyName) const;
170  virtual DtPropertyInterface* findPropertyInterface(const DtString& propertyName);
172 
174  virtual bool addProperty(DtPropertyInterface*);
175 
179  virtual bool removeProperty(const DtString& propertyName);
180  virtual bool removeProperty(const DtPropertyInterface* property);
182 
184  virtual void getSelf(DtlObjPtr args,
185  const DtReaderWriter::SearchPaths& searchPaths = SearchPaths(),
186  const DtVariableBindingsList& variableBindings = nullVariableReference());
187  virtual DtlObjPtr getData(DtlObjPtr args,
188  const DtReaderWriter::SearchPaths& searchPaths = SearchPaths(),
189  const DtVariableBindingsList& variableBindings = nullVariableReference());
190 
194  virtual const char* readerWriterType() const;
195 
197  virtual bool isValidProperty(const DtPropertyInterface*) const;
198 
200  virtual DtPropertyInterface* createProperty(DtlObjPtr args, DtReaderWriterRegistry* parentRegistry);
201 
203  virtual char* encode(char*) const;
204 
206  virtual const char* decode(const char*);
207 
209  virtual void getSize(int& size) const;
210 
211  //
213  static DtReaderWriterPropertyFactory* propertyFactory();
214  static void cleanupPropertyFactory();
215 
217  virtual void copyVariables(const DtRwVariableBindings& other);
218 
219  virtual bool isReadonly() const;
220 
222  virtual int hlaAlignment() const;
223 
226  virtual int requiredPadding(const char* buf, const DtPropertyInterface* field) const;
227 
229  virtual const char* propertyType() const;
230 
232  virtual int count() const;
233 
237  virtual const DtReaderWriter* findPropertyRw(const DtString& propName) const;
238  virtual DtReaderWriter* findPropertyRw(const DtString& propName);
240 
241  virtual DtString stringRep(const DtString& root = "") const;
242 
254  virtual bool merge(const DtPropertyInterface& target, MergeFlags, const DtMergePath& path = DtMergePath(),
255  const std::set<DtString>& ignore = std::set<DtString>());
256 
261  virtual DtRwProperties createFromPercentages(const DtRwProperties& percentages, const DtRwProperties& baseValues,
262  const DtString& base = "Base-");
263 
266  virtual bool findRootAndVariable(const DtString& varName, DtReaderWriter*& root, DtReaderWriter*& variable) const;
269  virtual DtReaderWriter* readerWriter();
270  virtual const DtReaderWriter* readerWriter() const;
272 
275  virtual DtPropertyInterface* property();
276  virtual const DtPropertyInterface* property() const;
278 
280  virtual DtSymbolString propertyName() const { return name(); };
281 
283  virtual void setPropertyName(const DtString& propertyName) { setName(propertyName); };
284 
286  virtual bool wasUpdatedSince(DtTime t) const;
287 
290  virtual bool isPublished() const;
291  virtual void setIsPublished(bool isPub);
293 
297  virtual unsigned disRecordType() const;
298  virtual void setDisRecordType(unsigned recType);
300 
302  virtual void clearVariables();
303 
305  virtual void reset();
306 
309  virtual void removeVariable(DtReaderWriter*);
310  virtual void removeVariable(const DtReaderWriter*);
312 
314  virtual void invalidateCache();
315 
317  virtual void invalidateCacheForProperty(const DtString& propName);
318 
319  static const DtRwProperties& emptyProperties();
320 
323 
325  static bool rollUpInteger(const DtReaderWriter* source, DtReaderWriter* destination, const DtMergePath& path);
326 
328  static bool rollUpReal(const DtReaderWriter* source, DtReaderWriter* destination, const DtMergePath& path);
329 
331  static bool rollUpString(const DtReaderWriter* source, DtReaderWriter* destination, const DtMergePath& path);
332 
334  static bool rollUpBoolean(const DtReaderWriter* source, DtReaderWriter* destination, const DtMergePath& path);
336 
337  virtual bool setWritePrototypeHeader(bool);
338  virtual bool writePrototypeHeader() const;
339 
341  virtual void cloneAndAddProperty(const DtReaderWriter& rw);
342 
343 protected:
345  virtual void filterIgnoredProperties(DtReaderWriter* rw, const std::set<DtString>& ignore);
346 
348  virtual void getInterface(DtPropertyInterface* pFace, DtlObjPtr args,
349  const DtReaderWriter::SearchPaths& searchPaths = SearchPaths(),
350  const DtVariableBindingsList& variableBindings = nullVariableReference());
351 
352  virtual void writeSelf(std::string& fp, int indentLevel, bool writeUnspecified, const DtFilename& path);
353  virtual void writeData(std::string& fp, int indentLevel, bool writeUnspecified, const DtFilename& path);
354 
355  virtual void putData(std::string&, int indentLevel = 0);
356 
357  virtual int hlaAlignment(const DtPropertyInterface* field) const;
358 
360  virtual void getSize(const DtPropertyInterface*, int& size) const;
361 
362  virtual char* encode(const DtPropertyInterface*, char* buf) const;
363  virtual const char* decode(DtPropertyInterface* iFace, const char* buf);
364 
366  virtual void unrecognizedItem(const DtEnvironmentSP env, const DtEnvValueSP root,
367  const DtReaderWriter::SearchPaths& searchPaths, const DtVariableBindingsList& varBindings);
368 
370  virtual bool traverseAndModifyPercentage(DtRwProperties& results, const DtRwProperties& baseValues,
371  const DtReaderWriter* percentage, const DtString& base) const;
372 
373  virtual void writePrototypeHeader(std::string& fp, const DtReaderWriter* rw, int indentLevel) const;
374 
376  virtual void writePropertyData(DtReaderWriter* rw, std::string& fp, int indentLevel, bool writeUnspecified, const DtFilename& path);
377 
378 protected:
380 
381  mutable std::multimap<DtString, DtReaderWriter*> myRwPropertyCache;
382  mutable tbb::spin_mutex* myCacheMutex;
383 
385 
389 
392  mutable int mySizeAtLastCheck;
393 
395  unsigned myDisRecordType;
396 
398 
401 };
402 
403 template <typename KeyType>
405 {
406  DtWarn << "Could not convert key, \"" << property()->propertyName()
407  << "\", to the specified type." << std::endl;
408 
409  return KeyType();
410 }
411 
412 template <>
413 inline int DtPropertiesIterator::key<int>() const
414 {
415  bool ok = false;
416  DtString keyStr(property()->propertyName().string());
417  int result = keyStr.toInt(&ok);
418 
419  if (!ok)
420  {
421  DtWarn << "Could not convert key, \"" << property()->propertyName()
422  << "\", to an int." << std::endl;
423  }
424 
425  return result;
426 }
427 
428 template <>
429 inline double DtPropertiesIterator::key<double>() const
430 {
431  bool ok = false;
432  DtString keyStr(property()->propertyName().string());
433  int result = keyStr.toDouble(&ok);
434 
435  if (!ok)
436  {
437  DtWarn << "Could not convert key, \"" << property()->propertyName()
438  << "\", to an double." << std::endl;
439  }
440 
441  return result;
442 }
443 
444 template <>
445 inline DtString DtPropertiesIterator::key<DtString>() const
446 {
447  return property()->propertyName().string();
448 }
449 
450 template <typename KeyType>
452 {
453  DtWarn << "Could not convert key, \"" << property()->propertyName()
454  << "\", to the specified type." << std::endl;
455 }
456 
457 template <>
458 inline int DtPropertiesConstIterator::key<int>() const
459 {
460  bool ok = false;
461  DtString keyStr(property()->propertyName().string());
462  int result = keyStr.toInt(&ok);
463 
464  if (!ok)
465  {
466  DtWarn << "Could not convert key, \"" << property()->propertyName()
467  << "\", to an int." << std::endl;
468  }
469 
470  return result;
471 }
472 
473 template <>
474 inline double DtPropertiesConstIterator::key<double>() const
475 {
476  bool ok = false;
477  DtString keyStr(property()->propertyName().string());
478  int result = keyStr.toDouble(&ok);
479 
480  if (!ok)
481  {
482  DtWarn << "Could not convert key, \"" << property()->propertyName()
483  << "\", to an double." << std::endl;
484  }
485 
486  return result;
487 }
488 
489 template <>
490 inline DtString DtPropertiesConstIterator::key<DtString>() const
491 {
492  return property()->propertyName().string();
493 }

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)