VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
terrainInterfaceConfig.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2014 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
10 
11 #pragma once
12 
13 #include <vrfutil/vrfutilDefines.h>
14 #include <vrfutil/readerWriter.h>
15 #include <vrfutil/rwInt.h>
16 #include <vrfutil/rwReal.h>
17 #include <vrfutil/rwString.h>
18 #include <vrfutil/rwBoolean.h>
19 #include <vrfutil/rwVector.h>
21 
22 #include <iosfwd>
23 
24 #include <boost/noncopyable.hpp>
25 
27 
33  : public DtReaderWriter
34  , boost::noncopyable
35 {
36  class DT_DLL_vrfutil Configator : boost::noncopyable
37  {
38  public:
39  virtual ~Configator();
40  virtual bool configure(DtReaderWriter&, bool ignoreUnspecified=true) const = 0;
41  };
42 
43  template <typename D>
44  class TerrainParam : public D, public Configator
45  {
46  public:
47  explicit TerrainParam(
48  const std::string& name, DtReaderWriterRegistry* parentRegistry)
49  : D(name, parentRegistry)
50  {
51  //this->setValueSpecified(false, true);
52  this->myValueSpecified = true;
53  }
54 
55  explicit TerrainParam(const std::string& name, bool def, DtReaderWriterRegistry* parent)
56  : D(def, name, parent)
57  {
58  //this->setValueSpecified(false, true);
59  this->myValueSpecified = true;
60  }
61 
62  template <typename T>
63  explicit TerrainParam(const std::string& name, T def, DtReaderWriterRegistry* parent)
64  : D(name, def, parent)
65  {
66  //this->setValueSpecified(false, true);
67  this->myValueSpecified = true;
68  }
69 
70  virtual bool valuePresent() const
71  {
72  return this->valueSpecified();
73  }
74 
75  virtual bool configure(DtReaderWriter& rw, bool ignoreUnspecified) const
76  {
77  if (ignoreUnspecified && !valuePresent())
78  return true;
79 
80  if (D* rwD = dynamic_cast<D*>(&rw))
81  {
82  *rwD = *this;
83  return true;
84  }
85 
86  return false;
87  }
88 
89  template <typename T>
90  TerrainParam& operator=(T t)
91  {
92  D::operator=(t);
93  this->setValueSpecified(true);
94  return *this;
95  }
96  };
97 
98  template <typename T>
99  class ListT : public DtRwTemplatedListPtr<T, true>
100  , public Configator
101  {
103 
104  public:
105  ListT(const std::string& name, DtReaderWriterRegistry* parentRegistry)
106  : ListBase(name, parentRegistry)
107  {
108  }
109 
110  virtual bool configure(DtReaderWriter& rw, bool ignoreUnspecified) const
111  {
112  ListBase* rwlist = dynamic_cast<ListBase*>(&rw);
113  if (!rwlist)
114  return false;
115 
116  rwlist->removeAndDeleteAll();
117 
118  bool success = true;
119  typename ListBase::iterator iter(*this);
120  for (T* info=iter.first(); info; info=iter.next())
121  {
122  std::auto_ptr<T> t(new T());
123  info->configure(*t, ignoreUnspecified);
124  rwlist->add(t.release());
125  }
126 
127  return success;
128  }
129 
130  //using ListBase::operator=;
131  };
132 
139 
146 
147 public:
153  explicit DtTerrainInterfaceConfig(const std::string& matchPattern = "");
154 
156 
158  virtual bool loadFromFile(const std::string& file, std::ostream& log);
159  virtual bool loadFromFile(const std::string& file);
160 
165  virtual bool loadFromSourceSpecificFile(
166  const std::string& file,
167  const std::string& ext = "mtl");
168 
185  virtual void configure(
186  DtTerrainInterfaceConfig& config,
187  const std::string& matchText,
188  bool ignoreUnspecified=true) const;
189 
190  virtual void configure(DtTerrainInterfaceConfig& config, bool ignoreUnspecified=true) const;
191 
194  virtual void configurePaths(std::string& path) const;
195 
197  virtual void print(std::ostream&, bool printUnspecified=true) const;
198 
199  DtString prettyPrint() const;
200 
201  void setName(const DtString&);
202 
208 
215 
221 
227 
233 
238 
243 
249 
256 
261 
266 
273 
279 
286 
294 
300 
307 
313 
320 
325 
331 
337 
342 
348 
355 
360 
365 
370 
375 
379 
383 
387 
391 
395 
399 
400  static void setModelDefinitionDefault(const std::string&);
401 
402  std::string modelDefinitionPath() const;
403 
404  std::string simCachePath() const;
405 
406  std::string featureConfigFile() const;
407 
408 protected:
413 
417 
421 };
422 
423 DT_DLL_vrfutil std::ostream& operator<<(std::ostream&, const DtTerrainInterfaceConfig&);

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)