VR-Forces 4.7 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
rwPropertiesMap.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 
42 {
43 private:
46 
47 public:
48 
51  DtRwPropertiesMap(const DtString& name, DtReaderWriterRegistry* parentRegistry = 0);
52  DtRwPropertiesMap(const DtString& name, const DtString& keyType,
53  const DtPropertyInterface* prototype, DtReaderWriterRegistry* parentRegistry = 0);
54  DtRwPropertiesMap(const DtString& name, const DtRwPropertiesMap& orig,
55  DtReaderWriterRegistry* parentRegistry = 0);
56  virtual ~DtRwPropertiesMap();
58 
70  virtual DtPropertyInterface* findItem(const DtString& key);
71 
73  virtual DtPropertyInterface* findItem(int key);
74 
76  virtual DtPropertyInterface* findItem(double key);
77 
80  virtual const DtPropertyInterface* findItem(const DtString& key) const;
81 
83  virtual const DtPropertyInterface* findItem(int key) const;
84 
86  virtual const DtPropertyInterface* findItem(double key) const;
87 
95  template <typename ValueType>
96  boost::optional<ValueType> findItemValue(const DtString& key) const;
97 
99  template <typename ValueType>
100  boost::optional<ValueType> findItemValue(int key) const;
101 
103  template <typename ValueType>
104  boost::optional<ValueType> findItemValue(double key) const;
106 
118  virtual bool insert(const DtString& key, DtPropertyInterface* item);
119  virtual bool insert(int key, DtPropertyInterface* item);
120  virtual bool insert(double key, DtPropertyInterface* item);
122 
134  virtual DtPropertyInterface* addItem(const DtString& key);
135  virtual DtPropertyInterface* addItem(int key);
136  virtual DtPropertyInterface* addItem(double key);
138 
146  virtual bool erase(const DtString& key);
147  virtual bool erase(int key);
148  virtual bool erase(double key);
150 
167  DtPropertyInterface& operator[](const DtString& key);
168  const DtPropertyInterface& operator[](const DtString& key) const;
169  DtPropertyInterface& operator[](double key);
170  const DtPropertyInterface& operator[](double key) const;
171  DtPropertyInterface& operator[](int key);
172  const DtPropertyInterface& operator[](int key) const;
174 
178  virtual const char* readerWriterType() const;
179 
181  static const char* theXmlType();
182 
183  virtual const char* xmlType() const
184  {
185  return theXmlType();
186  }
187 
189 
192  virtual void setKeyType(const DtString&);
193  virtual const DtReaderWriter* keyType() const;
195 
198  virtual bool keyIsInt() const;
199  virtual bool keyIsReal() const;
200  virtual bool keyIsString() const;
202 
204  virtual bool isSimilarProperty(const DtPropertyInterface* rhs, bool strict = true) const;
205 
206  bool operator==(const DtRwPropertiesMap&) const;
207 
208 protected:
209 
211  virtual bool convertKeyToString(int key, DtString& str) const;
212 
214  virtual bool convertKeyToString(double key, DtString& str) const;
215 
217  virtual bool convertStringToKey(const DtString& str, int& key) const;
218 
220  virtual bool convertStringToKey(const DtString& str, double& key) const;
221 
223  virtual DtPropertyInterface* createPrototype(DtlObjPtr args);
224  virtual DtlObjPtr variablesStart(DtlObjPtr args) const;
225 
227  virtual int hlaAlignment(const DtPropertyInterface* field) const;
228 
230  virtual void getSize(const DtPropertyInterface*, int& size) const;
231 
232  virtual void createListEntry(DtPropertyInterface* iFace, DtlObjPtr variableItem,
233  const DtReaderWriter::SearchPaths& searchPaths,
234  const DtVariableBindingsList& variableBindings);
235 
236  virtual char* encode(const DtPropertyInterface*, char* buf) const;
237  virtual const char* decode(DtPropertyInterface* iFace, const char* buf);
238 
239  virtual void getData(const DtEnvironmentSP env, const DtEnvValueSP root,
240  const DtReaderWriter::SearchPaths& searchPaths,
241  const DtVariableBindingsList& varBindings);
242  virtual void putData(DtEnvironmentSP env, DtEnvValueSP value) const;
243  virtual void postWriteItem(std::string& fp, DtReaderWriter* rw, int indentLevel);
244  virtual void preWriteItem(std::string& fp, DtReaderWriter* rw, int indentLevel);
245 
246  virtual DtPropertyInterface* scratchItem() const;
247 
248 protected:
250 
252 };
253 
254 template <typename ValueType>
255 boost::optional<ValueType> DtRwPropertiesMap::findItemValue(const DtString& key) const
256 {
257  if (keyIsString())
258  {
259  return findPropertyValue<ValueType>(key);
260  }
261 
262  return boost::optional<ValueType>();
263 }
264 
265 template <typename ValueType>
266 boost::optional<ValueType> DtRwPropertiesMap::findItemValue(int key) const
267 {
268  DtString keyStr;
269  if (convertKeyToString(key, keyStr))
270  {
271  return findPropertyValue<ValueType>(keyStr);
272  }
273 
274  return boost::optional<ValueType>();
275 }
276 
277 template <typename ValueType>
278 boost::optional<ValueType> DtRwPropertiesMap::findItemValue(double key) const
279 {
280  DtString keyStr;
281  if (convertKeyToString(key, keyStr))
282  {
283  return findPropertyValue<ValueType>(keyStr);
284  }
285 
286  return boost::optional<ValueType>();
287 }

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)