VR-Forces 4.3.1 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=DtInfo);
159 
164  virtual bool loadFromSourceSpecificFile(
165  const std::string& file,
166  const std::string& ext = "mtl");
167 
184  virtual void configure(
185  DtTerrainInterfaceConfig& config,
186  const std::string& matchText,
187  bool ignoreUnspecified=true) const;
188 
189  virtual void configure(DtTerrainInterfaceConfig& config, bool ignoreUnspecified=true) const;
190 
193  virtual void configurePaths(std::string& path) const;
194 
196  virtual void print(std::ostream&, bool printUnspecified=true) const;
197 
198  DtString prettyPrint() const;
199 
200  void setName(const DtString&);
201 
207 
214 
220 
226 
232 
237 
242 
248 
255 
260 
265 
272 
278 
285 
293 
300 
305 
311 
317 
322 
328 
335 
340 
345 
350 
355 
359 
363 
367 
371 
375 
376  static void setUserDataDefault(const std::string&);
377 
381 
382  static void setDataDefault(const std::string&);
383 
387 
389  static void setAppDataDefault(const std::string&);
390 
394 
398 
399  static void setModelDefinitionDefault(const std::string&);
400 
401  std::string modelDefinitionPath() const;
402 
403  std::string simCachePath() const;
404 
405  std::string featureConfigFile() const;
406 
407 protected:
411 
415 
419 };
420 
421 DT_DLL_vrfutil std::ostream& operator<<(std::ostream&, const DtTerrainInterfaceConfig&);

Document ID: Generated on Wed Jul 29 00:55:00 EDT 2015 from SVN revision 155257
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)