VR-Forces 4.3 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
propertyInterface.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 
11 #include <vrfutil/vrfutilDefines.h>
12 #include <vrfutil/rwBoolean.h>
13 #include <vrfutil/rwString.h>
14 #include <vrfutil/rwInt.h>
15 #include <vrfutil/rwReal.h>
17 #include <vlutil/vlTime.h>
18 
19 #include <string>
20 
23 {
24 public:
26  {
27  Replace = 0x00000001,
28  MinimalSimilarityCheck = 0x00000002,
29  RollUp = 0x00000004
30 
31 
32  };
33 
34  virtual ~DtPropertyInterface() {};
35 
39  virtual char* encode(char*) const = 0;
40 
42  virtual const char* decode(const char*) = 0;
43 
45  virtual void getSize(int& size) const = 0;
46 
48  virtual int hlaAlignment() const = 0;
49 
51  virtual const char* propertyType() const = 0;
52 
53  virtual DtString stringRep(const DtString& root = "") const = 0;
54 
55  int getSize() const
56  {
57  int size = 0;
58  getSize(size);
59 
60  return size;
61  }
62 
66  virtual DtReaderWriter* readerWriter() = 0;
67  virtual const DtReaderWriter* readerWriter() const = 0;
69 
72  virtual bool isSimilarProperty(const DtPropertyInterface* rhs) const
73  {
74  return (std::string(rhs->propertyType()) == std::string(propertyType()));
75  }
76 
88  virtual bool merge(const DtPropertyInterface& target, MergeFlags,
89  const DtMergePath& path = DtMergePath(), const std::set<DtString>& ignore = std::set<DtString>()) = 0;
90 
92  virtual DtlObjPtr getData(DtlObjPtr args, const DtReaderWriter::SearchPaths& searchPaths,
93  const DtVariableBindingsList& variableBindings) = 0;
94 
96  virtual void reset() = 0;
97 };
98 
101 template <typename _RwType>
102 class DtRwProperty : public _RwType, public DtPropertyInterface
103 {
104 private:
106  DtRwProperty();
107 
108 public:
109 
110  DtRwProperty(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
111  DtRwProperty(const DtString& name, const DtRwProperty& orig,
112  DtReaderWriterRegistry* parentRegistry = 0);
113  DtRwProperty& operator=(const DtRwProperty& orig);
114  virtual ~DtRwProperty();
115 
119  virtual char* encode(char*) const;
120 
122  virtual const char* decode(const char*);
123 
124  virtual DtString stringRep(const DtString& root = "") const;
125 
127  virtual void getSize(int& size) const;
128 
129  virtual int hlaAlignment() const;
130 
132  virtual const char* propertyType() const;
133 
134  virtual DtlObjPtr getData(DtlObjPtr args, const DtReaderWriter::SearchPaths& searchPaths,
135  const DtVariableBindingsList& variableBindings);
136 
138  virtual bool merge(const DtPropertyInterface& target, MergeFlags,
139  const DtMergePath& path = DtMergePath(), const std::set<DtString>& ignore = std::set<DtString>());
140 
143  virtual DtReaderWriter* readerWriter();
144  virtual const DtReaderWriter* readerWriter() const;
146 
149  virtual DtPropertyInterface* property();
150  virtual const DtPropertyInterface* property() const;
152 
154  virtual void recordUpdateTime() const;
155 
157  virtual bool wasUpdatedSince(DtTime t) const;
158 
159  virtual void reset();
160 
161 protected:
162 
165 
166 };
167 
172 template <typename _RwType>
174 {
175 private:
178 
179 public:
180 
181  DtRwPropertyWithThreshold(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
183  DtReaderWriterRegistry* parentRegistry = 0);
185  virtual ~DtRwPropertyWithThreshold();
186 
191  virtual char* encode(char*) const;
192 
196  virtual bool wasUpdatedSince(DtTime t) const;
197 
199  virtual void enableThresholding(bool enable);
200 
204  virtual void setThreshold(double percentage);
205 
208  static void setDefaultThreshold(double percentage);
209 
214  virtual void setMaxUpdateInterval(DtTime interval);
215 
218  static void setDefaultMaxUpdateInterval(DtTime interval);
219 
228  virtual void setMaxUnchangedUpdateInterval(DtTime interval);
229 
232  static void setDefaultMaxUnchangedUpdateInterval(DtTime interval);
233 
234 protected:
235 
238 
240  mutable _RwType myLastEncodedValue;
241 
244 
245  static double myDefaultThreshold;
246  double myThreshold;
247 
250 
253 };
254 

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)