VR-Forces 4.7 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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>
15 #include <readerWriter/rwInt.h>
16 #include <readerWriter/rwReal.h>
17 #include <readerWriter/rwString.h>
18 #include <readerWriter/rwBoolean.h>
19 #include "readerWriter/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 
272 
278 
285 
291 
298 
306 
312 
319 
325 
332 
337 
344 
350 
356 
361 
367 
374 
379 
384 
389 
394 
398 
402 
406 
410 
414 
421 
428 
436 
444 
454 
466 
471 
475 
476  static void setModelDefinitionDefault(const std::string&);
477 
478  std::string modelDefinitionPath() const;
479 
480  std::string simCachePath() const;
481 
482  std::string featureConfigFile() const;
483 
484 protected:
489 
493 
497 };
498 
499 DT_DLL_vrfutil std::ostream& operator<<(std::ostream&, const DtTerrainInterfaceConfig&);

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)