World Builder  0.1.0-pre
A geodyanmic initial conditions generator
parameters.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2018 by the authors of the World Builder code.
3 
4  This file is part of the World Builder.
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19 #include <fstream>
20 #include <vector>
21 #include <tuple>
22 
23 #include <boost/property_tree/json_parser.hpp>
24 
25 #include <world_builder/assert.h>
30 #include <config.h>
31 
32 using boost::property_tree::ptree;
33 
34 namespace WorldBuilder
35 {
36  Parameters::Parameters(std::string &filename, World &world)
37  :
38  world(world),
39  path_level(0)
40  {
41  // Get world builder file and check wether it exists
42  WBAssertThrow(access( filename.c_str(), F_OK ) != -1,
43  "Could not find the world builder file at the specified location: " + filename);
44 
45  // Now read in the world builder file into a file stream and
46  // put it into a boost property tree.
47  std::ifstream json_input_stream(filename.c_str());
48  boost::property_tree::json_parser::read_json (json_input_stream, tree);
49  local_tree = &tree;
50  }
51 
53  {}
54 
55  bool
56  Parameters::load_entry(const std::string &name, const bool required, const Types::Interface &type)
57  {
58  //Todo: the loading of the entry should actually be performed by the type
59  unsigned int location;
60  return this->load_entry(name, required, type, location);
61  }
62 
63  bool
64  Parameters::load_entry(const std::string &name, const bool required, const Types::Interface &type, unsigned int &location)
65  {
66  bool found_value = false;
67 
68  const std::string path_plus_name = (get_full_path() == "") ? name : (get_full_path() + path_seperator + name);
69  if (type.get_type() == Types::type::UnsignedInt)
70  {
71  // First check whether the value is in the tree. If not Assert when the value is required,
72  // otherwise set found_value to false.
73  boost::optional<std::string> value_tree = Utilities::get_from_ptree_abs(*local_tree,
74  get_relative_path_without_arrays(),
75  (name.front() == '[' && name.back() == ']' ? "" : name),
76  required,
78 
79  found_value = value_tree ? true : false;
80 
81  WBAssertThrow((found_value == true && required == true) || required == false,
82  "Could not find " + get_full_path() + ", while it is set as required.");
83 
84  // Store the value
85  const Types::UnsignedInt &natural_type = dynamic_cast<const Types::UnsignedInt &>(type);
86 
87  const unsigned int value = found_value == true ? Utilities::string_to_unsigned_int(value_tree.get())
88  : natural_type.default_value;
89 
90  vector_unsigned_int.push_back(Types::UnsignedInt(value,natural_type.default_value,natural_type.description));
91  location = vector_unsigned_int.size()-1;
92  string_to_type_map[path_plus_name] = location;
93 
94  }
95  else if (type.get_type() == Types::type::Double)
96  {
97  // First check whether the value is in the tree. If not Assert when the value is required,
98  // otherwise set found_value to false.
99  boost::optional<std::string> value_tree = Utilities::get_from_ptree_abs(*local_tree,
100  get_relative_path_without_arrays(),
101  (name.front() == '[' && name.back() == ']' ? "" : name),
102  required,
104  found_value = value_tree ? true : false;
105 
106  WBAssertThrow((found_value == true && required == true) || required == false,
107  "Could not find " + get_full_path() + ", while it is set as required.");
108 
109 
110  // The value is present and we have retrieved it. Now store it
111  const Types::Double &natural_type = dynamic_cast<const Types::Double &>(type);
112  const double value = found_value == true ? Utilities::string_to_double(value_tree.get()) : natural_type.default_value;
113  vector_double.push_back(Types::Double(value,natural_type.default_value,natural_type.description));
114  location = vector_double.size()-1;
115  string_to_type_map[path_plus_name] = location;
116 
117  }
118  else if (type.get_type() == Types::type::String)
119  {
120  // First check whether the value is in the tree. If not Assert when the value is required,
121  // otherwise set found_value to false.
122  boost::optional<std::string> value_tree = Utilities::get_from_ptree_abs(*local_tree,
123  get_relative_path_without_arrays(),
124  (name.front() == '[' && name.back() == ']' ? "" : name),
125  required,
127 
128  found_value = value_tree ? true : false;
129 
130  WBAssertThrow((found_value == true && required == true) || required == false,
131  "Could not find " + get_full_path() + ", while it is set as required.");
132 
133  // The value is present and we have retrieved it. Now store it
134  const Types::String &natural_type = dynamic_cast<const Types::String &>(type);
135  const std::string value = value_tree ? value_tree.get() : natural_type.default_value;
136  vector_string.push_back(Types::String(natural_type.default_value,natural_type.description));
137 
138  vector_string[vector_string.size()-1].set_value(value);
139  location = vector_string.size()-1;
140  string_to_type_map[path_plus_name] = location;
141 
142  }
143  else if (type.get_type() == Types::type::CoordinateSystem)
144  {
145  const Types::CoordinateSystem &natural_type = dynamic_cast<const Types::CoordinateSystem &>(type);
146  const std::string path_tmp = (get_full_path() == "") ? name : (get_full_path() + path_seperator + name);
147 
148  boost::optional<ptree &> child = local_tree->get_child_optional(path_tmp);
149 
150  found_value = child ? true : false;
151 
152  WBAssertThrow((found_value == false && required == true) || required == false, "Could not find " + path_tmp + ", while it is set as required.");
153  // only one entry allowed. For now we take the first one
154  // Todo: assert when there are more entries
155  std::string system = found_value == true ? child.get().begin()->first : natural_type.default_value;
157 
158  }
159  else if (type.get_type() == Types::type::Feature)
160  {
161  const Types::Feature &natural_type = dynamic_cast<const Types::Feature &>(type);
162  std::string path_tmp = (get_relative_path() == "") ? name : (get_relative_path() + path_seperator + name);
163 
164  enter_subsection(name);
165  {
166  path_level++;
167  features.push_back(Features::create_feature(name, &world));
168  path_level--;
169  }
171  //std::string path_tmp2 = "Surface objects" + World::path_seperator + name;
172 
173  features.back()->decare_entries(path_tmp);
174 
175  found_value = true;
176  }
177  else if (type.get_type() == Types::type::List)
178  {
179  const std::string path_plus_name_without_arrays = ((get_full_path_without_arrays() == "")
180  ?
181  name
182  :
184 
185  boost::optional<ptree &> child = local_tree->get_child_optional(path_plus_name_without_arrays);
186 
187  found_value = child ? true : false;
188 
189  WBAssertThrow((found_value == true && required == true) || required == false,
190  "Could not find " + get_full_path() + path_seperator + name + ", while it is set as required.");
191  if (child)
192  {
193  const Types::List &natural_type = dynamic_cast<const Types::List &>(type);
194  // Todo: assert size of inner_type is one
195  vector_list.push_back(Types::List(name, std::vector<unsigned int>(), natural_type.inner_type, natural_type.description));
196  location = vector_list.size()-1;
197  string_to_type_map[path_plus_name] = location;
198 
199  enter_subsection(name);
200  {
201  path_level++;
202  unsigned int current_size = 0;
203  for (boost::property_tree::ptree::iterator it = child.get().begin(); it != child.get().end(); ++it)
204  {
205  //TODO add a mangle for the name
206  ptree *parent = local_tree;
207  local_tree = &(it->second);
208  unsigned int child_location;
209  found_value = this->load_entry(it->first, required, *natural_type.inner_type_ptr, child_location);
210  vector_list[location].inner_type_index.push_back(child_location);
211  local_tree = parent;
212  current_size++;
213  }
214  path_level--;
215  }
217  }
218  else
219  {
220  // TODO: set default value
221  }
222  }
223  else if (type.get_type() == Types::type::Array)
224  {
225 
226  const std::string path_plus_name_without_arrays = ((get_relative_path_without_arrays() == "") ? "" : (get_relative_path_without_arrays() + path_seperator + ""))
227  + (name.front() == '[' && name.back() == ']' ? path_seperator : name);
228 
229  boost::optional<ptree &> child = local_tree->get_child_optional(path_plus_name_without_arrays);
230 
231  found_value = child ? true : false;
232 
233  WBAssertThrow((found_value == true && required == true) || required == false, "Could not find " + get_full_path() + path_seperator + name + ", while it is set as required.");
234 
235 
236  if (child)
237  {
238  const Types::Array &natural_type = dynamic_cast<const Types::Array &>(type);
239 
240  vector_array.push_back(Types::Array(std::vector<unsigned int>(), natural_type.inner_type,natural_type.description));
241 
242  location = vector_array.size()-1;
243  string_to_type_map[path_plus_name] = location;
244 
245  unsigned int current_size = 0;
246  enter_subsection(name);
247  {
248  path_level++;
249  for (boost::property_tree::ptree::iterator it = child.get().begin(); it != child.get().end(); ++it)
250  {
251  unsigned int diff = path.size()-path_level;
252  path_level+=diff;
253  //TODO add a mangle for the name
254  ptree *parent = local_tree;
255  local_tree = &(it->second);
256  unsigned int child_location;
257  found_value = this->load_entry("["+ std::to_string(current_size) + "]", required, *natural_type.inner_type_ptr, child_location);
258  vector_array[location].inner_type_index.push_back(child_location);
259  local_tree = parent;
260  current_size++;
261  path_level -= diff;
262  }
263  path_level--;
264  }
266  }
267  else
268  {
269  // TODO: set default value
270  }
271  }
272  else if (type.get_type() == Types::type::Point2D)
273  {
274  const std::string path_plus_name_without_arrays = ((get_relative_path_without_arrays() == "") ? "" : (get_relative_path_without_arrays() + path_seperator + ""))
275  + (name.front() == '[' && name.back() == ']' ? "" : name);
276 
277  boost::optional<ptree &> child = local_tree->get_child_optional(path_plus_name_without_arrays);
278 
279  found_value = child ? true : false;
280 
281  WBAssertThrow((found_value == true && required == true) || required == false,
282  "Could not find " + get_full_path() + path_seperator + name + ", while it is set as required.");
283 
284  unsigned int diff = path.size()-path_level;
285  path_level+=diff;
286  const Types::Point<2> &natural_type = dynamic_cast<const Types::Point<2> &>(type);
287  if (found_value == true)
288  {
290  unsigned int current_size = 0;
291  for (boost::property_tree::ptree::iterator it = child.get().begin(); it != child.get().end(); ++it)
292  {
293  // First check whether the value is in the tree. If not Assert when the value is required,
294  // otherwise return false.
295  boost::optional<std::string> value_tree = Utilities::get_from_ptree_abs(it->second,
296  get_relative_path_without_arrays(),
297  "", required, path_seperator);
298 
299  found_value = value_tree ? true : false;
300 
301  WBAssertThrow((found_value == true && required == true) || required == false,
302  "Could not find " + get_full_path() + ", while it is set as required.");
303  const double value = found_value == true ? Utilities::string_to_double(value_tree.get()) : natural_type.default_value[current_size];
304 
305  point[current_size] = value;
306  current_size++;
307  }
308  WBAssertThrow(current_size == 2,
309  "The entry " + get_full_path() + path_seperator + name +
310  " should represent a 2d point, but the size was not 2, it was "
311  << current_size << ".");
312 
313  vector_point_2d.push_back(Types::Point<2>(point, point,natural_type.description));
314  location = vector_point_2d.size()-1;
315  string_to_type_map[path_plus_name] = location;
316  }
317  else
318  {
319  vector_point_2d.push_back(natural_type);
320  location = vector_point_2d.size()-1;
321  string_to_type_map[path_plus_name] = location;
322  }
323  path_level -= diff;
324  }
325  else if (type.get_type() == Types::type::Point3D)
326  {
327  const std::string path_plus_name_without_arrays = ((get_relative_path_without_arrays() == "") ? "" : (get_relative_path_without_arrays() + path_seperator + ""))
328  + (name.front() == '[' && name.back() == ']' ? "" : name);
329 
330  boost::optional<ptree &> child = local_tree->get_child_optional(path_plus_name_without_arrays);
331 
332  found_value = child ? true : false;
333 
334  WBAssertThrow((found_value == true && required == true) || required == false,
335  "Could not find " + get_full_path() + path_seperator + name + ", while it is set as required.");
336 
337  unsigned int diff = path.size()-path_level;
338  path_level+=diff;
339  const Types::Point<3> &natural_type = dynamic_cast<const Types::Point<3> &>(type);
340  if (found_value == true)
341  {
343  unsigned int current_size = 0;
344  for (boost::property_tree::ptree::iterator it = child.get().begin(); it != child.get().end(); ++it)
345  {
346  // First check whether the value is in the tree. If not Assert when the value is required,
347  // otherwise return false.
348  boost::optional<std::string> value_tree = Utilities::get_from_ptree_abs(it->second,
349  get_relative_path_without_arrays(),
350  "", required, path_seperator);
351 
352  found_value = value_tree ? true : false;
353 
354  WBAssertThrow((found_value == true && required == true) || required == false,
355  "Could not find " + get_full_path() + ", while it is set as required.");
356  const double value = found_value == true ? Utilities::string_to_double(value_tree.get()) : natural_type.default_value[current_size];
357 
358  point[current_size] = value;
359  current_size++;
360  }
361  WBAssertThrow(current_size == 3,
362  "The entry " + get_full_path() + path_seperator + name +
363  " should represent a 3d point, but the size was not 3, it was "
364  << current_size << ".");
365 
366  vector_point_3d.push_back(Types::Point<3>(point, point,natural_type.description));
367  location = vector_point_3d.size()-1;
368  string_to_type_map[path_plus_name] = location;
369  }
370  else
371  {
372  vector_point_3d.push_back(natural_type);
373  location = vector_point_3d.size()-1;
374  string_to_type_map[path_plus_name] = location;
375  }
376  path_level -= diff;
377  }
378  else
379  {
380  WBAssertThrow(false,"Type not defined: " << (int)type.get_type());
381  }
382 
383  return found_value;
384  }
385 
386  bool
387  Parameters::set_entry(const std::string &name, const Types::Interface &type)
388  {
389  unsigned int location;
390  this->set_entry(name, type, location);
391  }
392 
393  bool
394  Parameters::set_entry(const std::string &name, const Types::Interface &type, unsigned int &location)
395  {
396 
397  const std::string path_plus_name = (get_full_path() == "") ? name : (get_full_path() + path_seperator + name);
398 
399  if (type.get_type() == Types::type::Double)
400  {
401  // The value is present and we have retrieved it. Now store it
402  const Types::Double &natural_type = dynamic_cast<const Types::Double &>(type);
403  vector_double.push_back(natural_type);
404  location = vector_double.size()-1;
405  string_to_type_map[path_plus_name] = location;
406  }
407  else if (type.get_type() == Types::type::UnsignedInt)
408  {
409  // The value is present and we have retrieved it. Now store it
410  const Types::UnsignedInt &natural_type = dynamic_cast<const Types::UnsignedInt &>(type);
411  vector_unsigned_int.push_back(natural_type);
412  string_to_type_map[path_plus_name] = vector_unsigned_int.size()-1;
413 
414  return true;
415  }
416  else if (type.get_type() == Types::type::String)
417  {
418  // The value is present and we have retrieved it. Now store it
419  const Types::String &natural_type = dynamic_cast<const Types::String &>(type);
420  vector_string.push_back(natural_type);
421  string_to_type_map[path_plus_name] = vector_string.size()-1;
422 
423  return true;
424  }
425  else if (type.get_type() == Types::type::CoordinateSystem)
426  {
427 
428  WBAssert(false, "A Coordinate system can not be directly set, use the load_entry function.");
429  /*const Types::CoordinateSystem &natural_type = dynamic_cast<const Types::CoordinateSystem &>(type);
430  std::string system = natural_type.;
431  coordinate_system = CoordinateSystems::create_coordinate_system(system);*/
432  }
433 
434  else if (type.get_type() == Types::type::Feature)
435  {
436  WBAssert(false, "A Feature can not be directly set, use the load_entry function.");
437  }
438  /*else if (type.get_type() == Types::type::List)
439  {
440  const std::string path_plus_name_without_arrays = ((get_current_path_without_arrays() == "") ? name : (get_current_path_without_arrays() + path_seperator + name));
441 
442 
443  const Types::List &natural_type = dynamic_cast<const Types::List &>(type);
444  vector_list.push_back(natural_type);
445  string_to_type_map[get_full_path() + path_seperator + name] = vector_list.size()-1;
446 
447  for (unsigned int i = 0; i < natural_type.inner_type.size(); ++i)
448  {
449  //TODO add a mangle for the name
450  this->set_entry(local_path, natural_type.name, *(natural_type.inner_type[i]));
451  }
452 
453  }*/
454  else if (type.get_type() == Types::type::Array)
455  {
456  const Types::Array &natural_type = dynamic_cast<const Types::Array &>(type);
457  vector_array.push_back(Types::Array(natural_type.inner_type_index,natural_type.get_type(),natural_type.description));
458  location = vector_array.size()-1;
459  string_to_type_map[path_plus_name] = location;
460 
461 
462  //unsigned int size = natural_type.inner_type.size();
463  for (unsigned int i = 0; i < natural_type.inner_type_index.size(); ++i)
464  {
465  //TODO add a mangle for the name
466  unsigned int child_location;
467  this->set_entry("["+ std::to_string(i) + "]", *(natural_type.inner_type_ptr), child_location);
468  vector_array[location].inner_type_index.push_back(child_location);
469  }
470  }
471  else if (type.get_type() == Types::type::Point2D)
472  {
473  // 2d
474  const Types::Point<2> &natural_type = dynamic_cast<const Types::Point<2> &>(type);
475 
476  vector_point_2d.push_back(natural_type);
477  location = vector_point_2d.size()-1;
478  string_to_type_map[path_plus_name] = location;
479  }
480  else if (type.get_type() == Types::type::Point3D)
481  {
482  const Types::Point<3> &natural_type = dynamic_cast<const Types::Point<3> &>(type);
483 
484  vector_point_3d.push_back(natural_type);
485  location = vector_point_3d.size()-1;
486  string_to_type_map[path_plus_name] = location;
487  }
488  else
489  {
490  WBAssertThrow(false,"Type not defined.");
491  }
492  }
493 
494  void
495  Parameters::enter_subsection(const std::string name)
496  {
497  path.push_back(name);
498  //TODO: WBAssert(is path valid?)
499  }
500 
501  void
503  {
504  path.pop_back();
505  }
506 
507  unsigned int
508  Parameters::get_unsigned_int(const std::string &name) const
509  {
510  const std::string path_plus_name = get_full_path() == "" ? name : get_full_path() + path_seperator + name;
511  WBAssert(string_to_type_map.count(path_plus_name) > 0, "Could not find entry \'" << name << "\' not found. Make sure it is loaded or set.");
512  return vector_unsigned_int[string_to_type_map.at(path_plus_name)].value;
513  }
514 
515  double
516  Parameters::get_double(const std::string &name) const
517  {
518  const std::string path_plus_name = get_full_path() == "" ? name : get_full_path() + path_seperator + name;
519  WBAssert(string_to_type_map.count(path_plus_name) > 0, "Could not find entry \'" << name << "\' not found. Make sure it is loaded or set.");
520  return vector_double[string_to_type_map.at(path_plus_name)].value;
521  }
522 
523  std::string
524  Parameters::get_string(const std::string &name) const
525  {
526  const std::string path_plus_name = get_full_path() == "" ? name : get_full_path() + path_seperator + name;
527  WBAssert(string_to_type_map.count(path_plus_name) > 0, "Could not find entry \'" << name << "\' not found. Make sure it is loaded or set.");
528  return vector_string[string_to_type_map.at(path_plus_name)].value;
529  }
530 
531  template<>
532  Point<2>
533  Parameters::get_point(const std::string &name) const
534  {
535  const std::string path_plus_name = get_full_path() == "" ? name : get_full_path() + path_seperator + name;
536  WBAssert(string_to_type_map.count(path_plus_name) > 0, "Could not find entry \'" << name << "\' not found. Make sure it is loaded or set.");
537  return vector_point_2d[string_to_type_map.at(path_plus_name)].value;
538  }
539 
540  template<>
541  Point<3>
542  Parameters::get_point(const std::string &name) const
543  {
544  const std::string path_plus_name = get_full_path() == "" ? name : get_full_path() + path_seperator + name;
545  WBAssert(string_to_type_map.count(path_plus_name) > 0, "Could not find entry \'" << name << "\' not found. Make sure it is loaded or set.");
546  return vector_point_3d[string_to_type_map.at(path_plus_name)].value;
547  }
548 
549 
550  const Types::Array &
551  Parameters::get_array(const std::string &name) const
552  {
553  //TODO: Assert that the size of the vector is larger then zero.
554  const std::string path_plus_name = get_full_path() == "" ? name : get_full_path() + path_seperator + name;
555  WBAssert(string_to_type_map.count(path_plus_name) > 0, "Could not find entry \'" << name << "\' not found. Make sure it is loaded or set.");
556 
557  return vector_array[string_to_type_map.at(path_plus_name)];
558  }
559 
560  template<class T>
561  const std::vector<T *>
562  Parameters::get_array(const std::string &name) const
563  {
564  //TODO: Assert that the size of the vector is larger then zero.
565  const std::string path_plus_name = get_full_path() == "" ? name : get_full_path() + path_seperator + name;
566  WBAssert(string_to_type_map.count(path_plus_name) > 0, "Could not find entry \'" << name << "\' not found. Make sure it is loaded or set.");
567 
568  const Types::Array typed_array = vector_array[string_to_type_map.at(path_plus_name)];
569 
570  std::vector<T *> array(typed_array.inner_type_index.size());
571 
572  for (unsigned int i = 0; i < typed_array.inner_type_index.size(); ++i)
573  {
574  if (typed_array.inner_type == Types::type::Double)
575  {
576  array[i] = dynamic_cast<T *>(&vector_double[typed_array.inner_type_index[i]]);
577  WBAssert(array[i] != NULL, "Could not get " << get_full_path() << (get_full_path() == "" ? "" : path_seperator) << name << ", because it is not a Double.");
578  }
579  else if (typed_array.inner_type == Types::type::Point2D)
580  {
581  array[i] = dynamic_cast<T *>(&vector_point_2d[typed_array.inner_type_index[i]]);
582  WBAssert(array[i] != NULL, "Could not get " << get_full_path() << (get_full_path() == "" ? "" : path_seperator) << name << ", because it is not a 2d Point.");
583  }
584  else if (typed_array.inner_type == Types::type::Point3D)
585  {
586  array[i] = dynamic_cast<T *>(&vector_point_3d[typed_array.inner_type_index[i]]);
587  WBAssert(array[i] != NULL, "Could not get " << get_full_path() << (get_full_path() == "" ? "" : path_seperator) << name << ", because it is not a 3d Point.");
588  }
589  else
590  {
591  WBAssert(false, "type conversion not implemented for type with number " << (int)typed_array.inner_type << ".");
592  }
593 
594  }
595 
596  return array;
597  }
598 
599 //TODO:
600  /*
601  template<class T>
602  T Parameters::get(const std::string &name)
603  {
604 
605  }*/
606 
607  std::string
609  {
610  std::string collapse = "";
611  for (unsigned int i = 0; i < path.size(); i++)
612  {
613  collapse += path[i] + path_seperator;
614  }
615  return collapse.substr(0,collapse.size()-path_seperator.size());
616  }
617 
618  std::string
619  Parameters::get_relative_path() const
620  {
621  std::string collapse = "";
622  for (unsigned int i = path_level; i < path.size(); i++)
623  {
624  collapse += path[i] + path_seperator;
625  }
626  return collapse.substr(0,collapse.size()-path_seperator.size());
627  }
628 
629  std::string
631  {
632  std::string collapse = "";
633  for (unsigned int i = 0; i < path.size(); i++)
634  {
635  collapse += (path[i].front() == '[' && path[i].back() == ']' ? "" : path[i]) + path_seperator;
636  }
637  return collapse.substr(0,collapse.size()-path_seperator.size());
638  }
639 
640 
641  std::string
642  Parameters::get_relative_path_without_arrays() const
643  {
644  std::string collapse = "";
645  for (unsigned int i = path_level; i < path.size(); i++)
646  {
647  collapse += (path[i].front() == '[' && path[i].back() == ']' ? "" : path[i]) + path_seperator;
648  }
649  return collapse.substr(0,collapse.size()-path_seperator.size());
650  }
651 
652  template Point<2> Parameters::get_point<2>(const std::string &name) const;
653  template Point<3> Parameters::get_point<3>(const std::string &name) const;
654  template const std::vector<const Types::Double * > Parameters::get_array<const Types::Double >(const std::string &name) const;
655  template const std::vector<const Types::Point<2>* > Parameters::get_array<const Types::Point<2> >(const std::string &name) const;
656  template const std::vector<const Types::Point<3>* > Parameters::get_array<const Types::Point<3> >(const std::string &name) const;
657 }
658 
std::vector< Types::Array > vector_array
Definition: parameters.h:276
std::string description
Definition: string.h:70
std::vector< Types::List > vector_list
Definition: parameters.h:284
std::vector< unsigned int > inner_type_index
Definition: array.h:113
std::string description
Definition: list.h:109
std::unique_ptr< Interface > create_feature(const std::string name, World *world)
Definition: interface.cc:38
std::vector< Types::Double > vector_double
Definition: parameters.h:256
const Types::Array & get_array(const std::string &name) const
Definition: parameters.cc:551
const std::string path_seperator
Definition: parameters.h:208
double string_to_unsigned_int(const std::string &string)
Definition: utilities.cc:387
std::string get_full_path_without_arrays() const
Definition: parameters.cc:630
std::vector< Types::String > vector_string
Definition: parameters.h:266
#define WBAssert(condition, message)
Definition: assert.h:28
WorldBuilder::Point< dim > default_value
Definition: point.h:99
std::unique_ptr< Interface > inner_type_ptr
Definition: array.h:102
std::unordered_map< std::string, unsigned int > string_to_type_map
Definition: parameters.h:236
std::string description
Definition: array.h:119
std::vector< Types::Point< 2 > > vector_point_2d
Definition: parameters.h:294
std::string description
Definition: double.h:61
std::string get_string(const std::string &name) const
Definition: parameters.cc:524
void enter_subsection(const std::string name)
Definition: parameters.cc:495
boost::optional< std::string > get_from_ptree_abs(const ptree &tree, const std::string &path, const std::string &key, const bool required, const std::string &path_separator)
Definition: utilities.cc:423
Types::type inner_type
Definition: list.h:81
std::string description
Definition: point.h:100
std::unique_ptr< Interface > inner_type_ptr
Definition: list.h:92
std::string default_value
Definition: string.h:69
virtual type get_type() const
Definition: interface.cc:45
bool load_entry(const std::string &name, const bool required, const Types::Interface &type)
Definition: parameters.cc:56
Parameters(std::string &filename, World &)
Definition: parameters.cc:36
#define WBAssertThrow(condition, message)
Definition: assert.h:41
double string_to_double(const std::string &string)
Definition: utilities.cc:340
Point< dim > get_point(const std::string &name) const
std::vector< std::unique_ptr< WorldBuilder::Features::Interface > > features
Definition: parameters.h:313
std::unique_ptr< WorldBuilder::CoordinateSystems::Interface > coordinate_system
Definition: parameters.h:321
std::unique_ptr< Interface > create_coordinate_system(const std::string name)
Definition: interface.cc:38
Types::type inner_type
Definition: array.h:91
std::string get_full_path() const
Definition: parameters.cc:608
std::vector< std::string > path
Definition: parameters.h:215
std::vector< Types::Point< 3 > > vector_point_3d
Definition: parameters.h:304
std::vector< Types::UnsignedInt > vector_unsigned_int
Definition: parameters.h:246
bool set_entry(const std::string &name, const Types::Interface &type)
Definition: parameters.cc:387
unsigned int get_unsigned_int(const std::string &name) const
Definition: parameters.cc:508
double get_double(const std::string &name) const
Definition: parameters.cc:516