44 #include "rapidjson/error/en.h" 45 #include "rapidjson/istreamwrapper.h" 46 #include "rapidjson/latexwriter.h" 47 #include "rapidjson/mystwriter.h" 48 #include "rapidjson/prettywriter.h" 57 void remove_key(rapidjson::Value &value,
const char *key)
61 auto it = value.FindMember(key);
62 if (it != value.MemberEnd())
63 value.RemoveMember(it);
65 for (
auto &member : value.GetObject())
66 remove_key(member.value, key);
69 else if (value.IsArray())
71 for (
auto &element : value.GetArray())
72 remove_key(element, key);
79 Parameters::Parameters(
World &world_)
97 file.open (output_dir +
"world_builder_declarations.schema.json");
98 WBAssertThrow(file.is_open(),
"Error: Could not open file '" + output_dir +
"world_builder_declarations.schema.json' for string the json declarations.");
99 PrettyWriter<StringBuffer, UTF8<>, UTF8<>, CrtAllocator, kWriteNanAndInfFlag> json_writer(buffer);
101 file << buffer.GetString();
109 file.open (output_dir +
"world_builder_declarations.tex");
110 WBAssertThrow(file.is_open(),
"Error: Could not open file '" + output_dir +
"world_builder_declarations.tex' for string the tex declarations.");
112 LatexWriter<StringBuffer, UTF8<>, UTF8<>, CrtAllocator, kWriteNanAndInfFlag> tex_writer(buffer);
114 file << buffer.GetString();
119 file.open (output_dir +
"world_builder_declarations_open.md");
120 WBAssertThrow(file.is_open(),
"Error: Could not open file '" + output_dir +
"world_builder_declarations_open.md' for string the tex declarations.");
122 MySTWriter<StringBuffer, UTF8<>, UTF8<>, CrtAllocator, kWriteNanAndInfFlag> myst_writer_open(buffer,
true);
124 file << buffer.GetString();
129 file.open (output_dir +
"world_builder_declarations_closed.md");
130 WBAssertThrow(file.is_open(),
"Error: Could not open file '" + output_dir +
"world_builder_declarations_closed.md' for string the tex declarations.");
132 MySTWriter<StringBuffer, UTF8<>, UTF8<>, CrtAllocator, kWriteNanAndInfFlag> myst_writer_closed(buffer,
false);
134 file << buffer.GetString();
143 rapidjson::IStreamWrapper isw(json_input_stream);
148 WBAssertThrowExc(!(
parameters.ParseStream<kParseCommentsFlag | kParseNanAndInfFlag>(isw).HasParseError()), std::ifstream json_input_stream_error(filename.c_str()); ,
149 "Parsing errors world builder file: Error(offset " <<
static_cast<unsigned>(
parameters.GetErrorOffset())
150 <<
"): " << GetParseError_En(
parameters.GetParseError()) << std::endl << std::endl
151 <<
" Showing 50 chars before and after: " 152 << std::string((std::istreambuf_iterator<char>(json_input_stream_error.seekg(0, json_input_stream_error.beg))),
153 std::istreambuf_iterator<char>()).substr(static_cast<unsigned>(
parameters.GetErrorOffset()) <= 50
157 static_cast<unsigned>(
parameters.GetErrorOffset()) - 50, 100
158 ) << std::endl << std::endl
159 <<
" Showing 5 chars before and after: " 160 << std::string((std::istreambuf_iterator<char>(json_input_stream_error.seekg(0, json_input_stream_error.beg))),
161 std::istreambuf_iterator<char>()).substr(static_cast<unsigned>(
parameters.GetErrorOffset()) <= 5
164 static_cast<unsigned>(
parameters.GetErrorOffset())-5,
165 (static_cast<unsigned>(
parameters.GetErrorOffset()) + 10 > json_input_stream_error.seekg(0,std::ios::end).tellg()
167 static_cast<unsigned>(json_input_stream.tellg())-static_cast<unsigned>(
parameters.GetErrorOffset())
176 SchemaValidator validator(schema);
183 std::stringstream string;
184 validator.GetInvalidSchemaPointer().StringifyUriFragment(buffer);
185 string <<
"Invalid schema: " << buffer.GetString() << std::endl;
186 string <<
"Invalid keyword: " << validator.GetInvalidSchemaKeyword();
188 validator.GetInvalidDocumentPointer().StringifyUriFragment(buffer);
189 string <<
"Invalid schema: " << buffer.GetString() << std::endl;
190 PrettyWriter<StringBuffer> writer(buffer);
191 validator.GetError().Accept(writer);
192 WBAssertThrow(
false,
string.str() <<
"Error document: " << std::endl << buffer.GetString());
199 const std::string &documentation)
216 const Value *value = Pointer((base +
"/" + name).c_str()).Get(
parameters);
219 bool required =
false;
220 if (Pointer((base +
"/required").c_str()).Get(
declarations) != NULL)
222 for (
auto &v : Pointer((base +
"/required").c_str()).Get(
declarations)->GetArray())
224 if (v.GetString() == name)
231 WBAssert(value != NULL || required ==
false,
232 "Internal error: Value \"" << base <<
'/' << name <<
"/type\" not found in the input file, while it was set as required.");
234 if (value ==
nullptr)
238 "internal error: could not retrieve the default value at: " 239 << base +
"/" + name +
"/default value");
242 return value->GetString();
250 const Value *value = Pointer((base +
"/" + name).c_str()).Get(
parameters);
253 bool required =
false;
254 if (Pointer((base +
"/required").c_str()).Get(
declarations) != NULL)
256 for (
auto &v : Pointer((base +
"/required").c_str()).Get(
declarations)->GetArray())
258 if (v.GetString() == name)
265 WBAssert(value != NULL || required ==
false,
266 "Internal error: Value \"" << base <<
'/' << name <<
"/type\" not found in the input file, while it was set as required.");
268 if (value ==
nullptr)
272 "internal error: could not retrieve the default value at: " 279 return_value = value->GetDouble();
283 WBAssertThrow(
false,
"Could not convert values of " << base <<
" into doubles.");
293 const Value *value = Pointer((base +
"/" + name).c_str()).Get(
parameters);
296 bool required =
false;
297 if (Pointer((base +
"/required").c_str()).Get(
declarations) != NULL)
299 for (
auto &v : Pointer((base +
"/required").c_str()).Get(
declarations)->GetArray())
301 if (v.GetString() == name)
308 WBAssert(value != NULL || required ==
false,
309 "Internal error: Value \"" << base <<
'/' << name <<
"/type\" not found in the input file, while it was set as required.");
311 if (value ==
nullptr)
315 "internal error: could not retrieve the default value at: " 316 << base +
"/" + name +
"/default value");
319 return value->GetUint();
327 const Value *value = Pointer((base +
"/" + name).c_str()).Get(
parameters);
330 bool required =
false;
331 if (Pointer((base +
"/required").c_str()).Get(
declarations) != NULL)
333 for (
auto &v : Pointer((base +
"/required").c_str()).Get(
declarations)->GetArray())
335 if (v.GetString() == name)
342 WBAssert(value != NULL || required ==
false,
343 "Internal error: Value \"" << base <<
'/' << name <<
"/type\" not found in the input file, while it was set as required.");
345 if (value ==
nullptr)
349 "internal error: could not retrieve the default value at: " 350 << base +
"/" + name +
"/default value");
353 return value->GetUint();
361 const Value *value = Pointer((base +
"/" + name).c_str()).Get(
parameters);
364 bool required =
false;
365 if (Pointer((base +
"/required").c_str()).Get(
declarations) != NULL)
367 for (
auto &v : Pointer((base +
"/required").c_str()).Get(
declarations)->GetArray())
369 if (v.GetString() == name)
376 WBAssert(value != NULL || required ==
false,
377 "Internal error: Value \"" << base <<
'/' << name <<
"/type\" not found in the input file, while it was set as required.");
379 if (value ==
nullptr)
383 "internal error: could not retrieve the default value at: " 384 << base +
"/" + name +
"/default value");
387 return value->GetInt();
395 const Value *value = Pointer((base +
"/" + name).c_str()).Get(
parameters);
398 bool required =
false;
399 if (Pointer((base +
"/required").c_str()).Get(
declarations) != NULL)
401 for (
auto &v : Pointer((base +
"/required").c_str()).Get(
declarations)->GetArray())
403 if (v.GetString() == name)
410 WBAssert(value != NULL || required ==
false,
411 "Internal error: Value \"" << base <<
'/' << name <<
"/type\" not found in the input file, while it was set as required.");
413 if (value ==
nullptr)
417 "internal error: could not retrieve the default value at: " 418 << base +
"/" + name +
"/default value");
421 return value->GetBool();
431 const Value *array = Pointer((strict_base +
"/" + name).c_str()).Get(
parameters);
434 bool required =
false;
435 if (Pointer((strict_base +
"/required").c_str()).Get(
declarations) != NULL)
437 for (
auto &v : Pointer((strict_base +
"/required").c_str()).Get(
declarations)->GetArray())
439 if (v.GetString() == name)
446 WBAssert(array != NULL || required ==
false,
447 "Internal error: Value \"" << strict_base <<
'/' << name <<
"/type\" not found in the input file, while it was set as required.");
449 if (array !=
nullptr)
451 const std::string base = strict_base +
"/" + name;
459 value1 = Pointer((base +
"/0").c_str()).Get(
parameters)->GetDouble();
460 value2 = Pointer((base +
"/1").c_str()).Get(
parameters)->GetDouble();
464 WBAssertThrow(
false,
"Could not convert values of " << base <<
" into Point<2>, because it could not convert the sub-elements into doubles.");
468 WBAssertThrow(
false,
"default values not implemented in get<Point<2> >. Looked in: " + strict_base +
"/" << name);
477 std::vector<bool> vector;
479 if (Pointer((strict_base +
"/" + name).c_str()).Get(
parameters) !=
nullptr)
481 Value *array = Pointer((strict_base +
"/" + name).c_str()).Get(
parameters);
483 for (
size_t i = 0; i < array->Size(); ++i )
485 const std::string base = (strict_base +
"/").append(name).append(
"/").append(std::to_string(i));
487 vector.push_back(Pointer(base.c_str()).Get(
parameters)->GetBool());
494 "internal error: could not retrieve the minItems value at: " 497 const size_t min_size = value->GetUint();
502 for (
size_t i = 0; i < min_size; ++i)
504 vector.push_back(default_value);
511 std::pair<std::vector<double>,std::vector<double>>
513 const std::vector<
Point<2> > &addition_points)
521 std::pair<std::vector<double>,std::vector<double>> result;
527 double default_value = 0;
528 bool is_array =
true;
529 if (Pointer((strict_base +
"/" + name).c_str()).Get(
parameters) !=
nullptr && Pointer((strict_base +
"/" + name).c_str()).Get(
parameters)->IsArray())
531 const std::string value_def_path =
get_full_json_schema_path() +
"/" + name +
"/oneOf/1/items/items/anyOf/0/default value";
532 Value *value_def = Pointer(value_def_path.c_str()).Get(
declarations);
534 "internal error: could not retrieve the default value at: " 539 default_value = value_def->GetDouble();
546 "internal error: could not retrieve the default value at: " 552 default_value = value_def->GetDouble();
557 if (Pointer((strict_base +
"/" + name).c_str()).Get(
parameters) !=
nullptr)
562 Value *array = Pointer((strict_base +
"/" + name).c_str()).Get(
parameters);
564 if (array->Size() == 1
565 && Pointer((strict_base +
"/" + name +
"/0/1").c_str()).Get(
parameters) ==
nullptr)
571 value = Pointer((strict_base +
"/" + name +
"/0/0").c_str()).Get(
parameters)->GetDouble();
575 WBAssertThrow(
false,
"Could not convert values of " << strict_base <<
"/" << name <<
"/0/0 into a double. " 576 <<
"The provided value was \"" << Pointer((strict_base +
"/" + name +
"/0/0").c_str()).Get(
parameters)->GetString() <<
"\".");
578 result.first.emplace_back(value);
586 for (
const auto &addition_point : addition_points)
588 result.first.emplace_back(default_value);
589 result.second.emplace_back(addition_point[0]);
590 result.second.emplace_back(addition_point[1]);
594 for (
size_t i = 0; i < array->Size(); ++i )
597 const std::string base = (strict_base +
"/").append(name).append(
"/").append(std::to_string(i));
603 Value *value_pointer = Pointer((base +
"/0").c_str()).Get(
parameters);
605 WBAssertThrow(value_pointer !=
nullptr,
"internal error: this should not happen.");
609 value = value_pointer->GetDouble();
613 WBAssertThrow(
false,
"Could not convert values of " << base <<
"/0 into doubles. " 614 <<
"The provided value was \"" << Pointer((base +
"/0").c_str()).Get(
parameters)->GetString() <<
"\".");
618 Value *coordinates_array = Pointer((base +
"/1").c_str()).Get(
parameters);
619 if (coordinates_array !=
nullptr)
621 for (
size_t coordinate_i = 0; coordinate_i < coordinates_array->Size(); ++coordinate_i )
629 coordinate_0 = Pointer((base +
"/1/" + std::to_string(coordinate_i) +
"/0").c_str()).Get(
parameters)->GetDouble();
633 WBAssertThrow(
false,
"Could not convert values of " << base +
"/1/" + std::to_string(coordinate_i) +
"/0" 634 <<
" into a Point<2> array, because it could not convert the 1st sub-elements into doubles. " 635 <<
"The provided value was \"" 636 << Pointer((base +
"/1/" + std::to_string(coordinate_i) +
"/0").c_str()).Get(
parameters)->GetString()
641 coordinate_1 = Pointer((base +
"/1/" + std::to_string(coordinate_i) +
"/1").c_str()).Get(
parameters)->GetDouble();
645 WBAssertThrow(
false,
"Could not convert values of " << base +
"/1/" + std::to_string(coordinate_i) +
"/1" 646 <<
" into a Point<2> array, because it could not convert the 2nd sub-elements into doubles. " 647 <<
"The provided value was \"" 648 << Pointer((base +
"/1/" + std::to_string(coordinate_i) +
"/1").c_str()).Get(
parameters)->GetString()
655 bool found_same_point =
false;
656 unsigned int coordinate_pair_i = 0;
657 for (; coordinate_pair_i < result.second.size(); coordinate_pair_i+=2)
661 found_same_point =
true;
665 if (found_same_point)
668 result.first[coordinate_pair_i/2] = value;
673 result.first.emplace_back(value);
674 result.second.emplace_back(coordinate_0);
675 result.second.emplace_back(coordinate_1);
685 for (
unsigned int addition_point_i = 0; addition_point_i < addition_points.size(); ++addition_point_i)
687 result.first[addition_point_i] = value;
699 value = Pointer((strict_base +
"/" + name).c_str()).Get(
parameters)->GetDouble();
703 WBAssertThrow(
false,
"Could not convert values of " << strict_base <<
"/" << name <<
" into a double. " 704 <<
"The provided value was \"" << Pointer((strict_base +
"/" + name).c_str()).Get(
parameters)->GetString() <<
"\".");
706 result.first.emplace_back(value);
712 result.first.emplace_back(default_value);
725 std::pair<std::vector<double>,std::vector<double>> result;
731 double default_value = 0;
732 bool is_array =
true;
733 if (Pointer((strict_base +
"/" + name).c_str()).Get(
parameters) !=
nullptr && Pointer((strict_base +
"/" + name).c_str()).Get(
parameters)->IsArray())
735 const std::string value_def_path =
get_full_json_schema_path() +
"/" + name +
"/oneOf/1/items/items/anyOf/0/default value";
736 Value *value_def = Pointer(value_def_path.c_str()).Get(
declarations);
738 "internal error: could not retrieve the default value at: " 743 default_value = value_def->GetDouble();
750 "internal error: could not retrieve the default value at: " 756 default_value = value_def->GetDouble();
761 if (Pointer((strict_base +
"/" + name).c_str()).Get(
parameters) !=
nullptr)
766 Value *array = Pointer((strict_base +
"/" + name).c_str()).Get(
parameters);
769 for (
size_t i = 0; i < array->Size(); ++i )
772 const std::string base = (strict_base +
"/").append(name).append(
"/").append(std::to_string(i));
778 Value *value_pointer = Pointer((base +
"/0").c_str()).Get(
parameters);
780 WBAssertThrow(value_pointer !=
nullptr,
"internal error: this should not happen.");
784 value = value_pointer->GetDouble();
788 WBAssertThrow(
false,
"Could not convert values of " << base <<
"/0 into doubles. " 789 <<
"The provided value was \"" << Pointer((base +
"/0").c_str()).Get(
parameters)->GetString() <<
"\".");
793 Value *array_of_doubles = Pointer((base +
"/1").c_str()).Get(
parameters);
794 double value_in_array;
795 if (array_of_doubles !=
nullptr)
797 for (
size_t coordinate_i = 0; coordinate_i < array_of_doubles->Size(); ++coordinate_i )
799 Value *coordinate_j_array = Pointer((base +
"/1/" + std::to_string(coordinate_i)).c_str()).Get(
parameters);
800 for (
size_t coordinate_j = 0; coordinate_j < coordinate_j_array->Size(); ++coordinate_j)
806 value_in_array = Pointer((base +
"/1/" + std::to_string(coordinate_i) +
"/" + std::to_string(coordinate_j)).c_str()).Get(
parameters)->GetDouble();
810 WBAssertThrow(
false,
"Could not convert values of " << base +
"/1/" + std::to_string(coordinate_i) +
"/" + std::to_string(coordinate_j)
811 <<
" into a Point<2> array, because it could not convert the 1st sub-elements into doubles. " 812 <<
"The provided value was \"" 813 << Pointer((base +
"/1/" + std::to_string(coordinate_i) +
"/" + std::to_string(coordinate_j)).c_str()).Get(
parameters)->GetString()
817 result.second.emplace_back(value_in_array);
820 result.first.emplace_back(value);
830 value = Pointer((strict_base +
"/" + name).c_str()).Get(
parameters)->GetDouble();
834 WBAssertThrow(
false,
"Could not convert values of " << strict_base <<
"/" << name <<
" into a double. " 835 <<
"The provided value was \"" << Pointer((strict_base +
"/" + name).c_str()).Get(
parameters)->GetString() <<
"\".");
837 result.first.emplace_back(0.0);
838 result.second.emplace_back(value);
844 result.first.emplace_back(0.0);
845 result.second.emplace_back(default_value);
853 std::vector<Point<2> >
856 std::vector<Point<2> > vector;
861 Value *array = Pointer((strict_base +
"/" + name).c_str()).Get(
parameters);
863 for (
size_t i = 0; i < array->Size(); ++i )
865 const std::string base = (strict_base +
"/").append(name).append(
"/").append(std::to_string(i));
873 value1 = Pointer((base +
"/0").c_str()).Get(
parameters)->GetDouble();
874 value2 = Pointer((base +
"/1").c_str()).Get(
parameters)->GetDouble();
878 WBAssertThrow(
false,
"Could not convert values of " << base <<
" into a Point<2> array, because it could not convert the sub-elements into doubles.");
880 vector.emplace_back(value1,value2,this->
coordinate_system->natural_coordinate_system());
887 std::vector<std::array<double,3> >
890 std::vector<std::array<double,3> > vector;
895 Value *array = Pointer((strict_base +
"/" + name).c_str()).Get(
parameters);
897 for (
size_t i = 0; i < array->Size(); ++i )
899 const std::string base = (strict_base +
"/").append(name).append(
"/").append(std::to_string(i));
904 const double value1 = Pointer((base +
"/0").c_str()).Get(
parameters)->GetDouble();
905 const double value2 = Pointer((base +
"/1").c_str()).Get(
parameters)->GetDouble();
906 const double value3 = Pointer((base +
"/2").c_str()).Get(
parameters)->GetDouble();
907 vector.push_back({{value1,value2,value3}});
911 WBAssertThrow(
false,
"Could not convert values of " << base <<
" into doubles.");
919 std::vector<std::vector<double>>
925 std::vector<std::vector<double>> result;
931 double default_value = 0;
932 bool is_array =
true;
933 if (Pointer((strict_base +
"/" + name).c_str()).Get(
parameters) !=
nullptr && Pointer((strict_base +
"/" + name).c_str()).Get(
parameters)->IsArray())
936 Value *value_def = Pointer(value_def_path.c_str()).Get(
declarations);
938 "internal error: could not retrieve the default value at: " 943 default_value = value_def->GetDouble();
950 "internal error: could not retrieve the default value at: " 956 default_value = value_def->GetDouble();
961 if (Pointer((strict_base +
"/" + name).c_str()).Get(
parameters) !=
nullptr)
966 Value *array = Pointer((strict_base +
"/" + name).c_str()).Get(
parameters);
969 for (
size_t i = 0; i < array->Size(); ++i )
972 const std::string base = (strict_base +
"/").append(name).append(
"/").append(std::to_string(i));
976 Value *coordinates_array = Pointer((base).c_str()).Get(
parameters);
977 double value_in_array;
978 std::vector<double> array_of_values;
979 if (coordinates_array !=
nullptr)
981 for (
size_t coordinate_i = 0; coordinate_i < coordinates_array->Size(); ++coordinate_i )
987 value_in_array = Pointer(((base +
"/") + std::to_string(coordinate_i)).c_str()).Get(
parameters)->GetDouble();
991 WBAssertThrow(
false,
"Could not convert values of " << base +
"/" + std::to_string(i) +
"/" + std::to_string(coordinate_i) +
"/" + std::to_string(coordinate_i)
992 <<
" into a Point<2> array, because it could not convert the 1st sub-elements into doubles. " 993 <<
"The provided value was \"" 994 << Pointer((base +
"/" + std::to_string(i) +
"/" + std::to_string(coordinate_i)).c_str()).Get(
parameters)->GetString()
997 array_of_values.emplace_back(value_in_array);
999 result.emplace_back(array_of_values);
1010 value = Pointer((strict_base +
"/" + name).c_str()).Get(
parameters)->GetDouble();
1014 WBAssertThrow(
false,
"Could not convert values of " << strict_base <<
"/" << name <<
" into a double. " 1015 <<
"The provided value was \"" << Pointer((strict_base +
"/" + name).c_str()).Get(
parameters)->GetString() <<
"\".");
1017 result.emplace_back(std::vector<double> {value});
1023 result.emplace_back(std::vector<double> {default_value});
1032 std::vector<std::array<std::array<double,3>,3> >
1035 std::vector<std::array<std::array<double,3>,3> > vector;
1040 Value *array1 = Pointer((strict_base +
"/" + name).c_str()).Get(
parameters);
1042 for (
size_t i = 0; i < array1->Size(); ++i )
1044 const std::string base = (strict_base +
"/").append(name).append(
"/").append(std::to_string(i));
1045 Value *array2 = Pointer((base).c_str()).Get(
parameters);
1050 std::array<std::array<double,3>,3> array;
1051 WBAssertThrow(array2->Size() == 3,
"Array " << i <<
" is supposed to be a 3x3 array, but the outer array dimensions is " 1052 << array2->Size() <<
'.');
1053 for (
size_t j = 0; j < array2->Size(); ++j )
1055 const std::string base_extended = base +
"/" + std::to_string(j);
1058 "Array " << i <<
" is supposed to be a 3x3 array, but the inner array dimensions of " 1059 << j <<
" is " << Pointer((base_extended).c_str()).Get(
parameters)->Size() <<
'.');
1066 value1 = Pointer((base_extended +
"/0").c_str()).Get(
parameters)->GetDouble();
1067 value2 = Pointer((base_extended +
"/1").c_str()).Get(
parameters)->GetDouble();
1068 value3 = Pointer((base_extended +
"/2").c_str()).Get(
parameters)->GetDouble();
1072 WBAssertThrow(
false,
"Could not convert values of " << base <<
" into doubles.");
1074 array[j][0] = value1;
1075 array[j][1] = value2;
1076 array[j][2] = value3;
1078 vector.push_back(array);
1086 std::vector<std::vector<Point<2> > >
1089 std::vector<std::vector<Point<2> > > vector;
1094 Value *array1 = Pointer((strict_base +
"/" + name).c_str()).Get(
parameters);
1096 for (
size_t i = 0; i < array1->Size(); ++i )
1098 const std::string base = (strict_base +
"/").append(name).append(
"/").append(std::to_string(i));
1099 Value *array2 = Pointer((base).c_str()).Get(
parameters);
1105 for (
size_t j = 0; j < array2->Size(); ++j )
1107 const std::string base_extended = base +
"/" + std::to_string(j);
1110 "Array " << i <<
" is supposed to be a 2d point, but the inner array dimensions of " 1111 << j <<
" is " << Pointer((base_extended).c_str()).Get(
parameters)->Size() <<
'.');
1117 value1 = Pointer((base_extended +
"/0").c_str()).Get(
parameters)->GetDouble();
1118 value2 = Pointer((base_extended +
"/1").c_str()).Get(
parameters)->GetDouble();
1122 WBAssertThrow(
false,
"Could not convert values of " << base <<
" into doubles, because it could not covert the sub-elements into doubles.");
1124 sub_vector[j][0] = value1;
1125 sub_vector[j][1] = value2;
1127 vector.push_back(sub_vector);
1140 std::vector<std::shared_ptr<Features::SubductingPlateModels::Temperature::Interface> > &default_temperature_models,
1141 std::vector<std::shared_ptr<Features::SubductingPlateModels::Composition::Interface> > &default_composition_models,
1142 std::vector<std::shared_ptr<Features::SubductingPlateModels::Grains::Interface> > &default_grains_models,
1143 std::vector<std::shared_ptr<Features::SubductingPlateModels::Velocity::Interface> > &default_velocity_models)
1145 using namespace Features::SubductingPlateModels;
1146 std::vector<Objects::Segment<Temperature::Interface,Composition::Interface,Grains::Interface,Velocity::Interface> > vector;
1153 Value *array = Pointer((strict_base).c_str()).Get(
parameters);
1155 for (
size_t i = 0; i < array->Size(); ++i )
1161 const double length = Pointer((base +
"/length").c_str()).Get(
parameters)->GetDouble();
1164 Value *point_array = Pointer((base +
"/thickness").c_str()).Get(
parameters);
1167 <<
" was not defined in " << strict_base <<
"/thickness, schema path: " << this->
get_full_json_schema_path() <<
"/thickness.");
1169 if (point_array->Size() == 1)
1172 const double local0 = Pointer((base +
"/thickness/0").c_str()).Get(
parameters)->GetDouble();
1177 const double local0 = Pointer((base +
"/thickness/0").c_str()).Get(
parameters)->GetDouble();
1178 const double local1 = Pointer((base +
"/thickness/1").c_str()).Get(
parameters)->GetDouble();
1184 point_array = Pointer((base +
"/top truncation").c_str()).Get(
parameters);
1186 if (point_array !=
nullptr)
1188 if (point_array->Size() == 1)
1191 const double local0 = Pointer((base +
"/top truncation/0").c_str()).Get(
parameters)->GetDouble();
1196 const double local0 = Pointer((base +
"/top truncation/0").c_str()).Get(
parameters)->GetDouble();
1197 const double local1 = Pointer((base +
"/top truncation/1").c_str()).Get(
parameters)->GetDouble();
1202 point_array = Pointer((base +
"/angle").c_str()).Get(
parameters);
1207 if (point_array->Size() == 1)
1210 const double local0 = Pointer((base +
"/angle/0").c_str()).Get(
parameters)->GetDouble();
1215 const double local0 = Pointer((base +
"/angle/0").c_str()).Get(
parameters)->GetDouble();
1216 const double local1 = Pointer((base +
"/angle/1").c_str()).Get(
parameters)->GetDouble();
1222 std::vector<std::shared_ptr<Temperature::Interface> > temperature_models;
1225 size_t searchback = 0;
1226 if (!this->get_shared_pointers<Temperature::Interface>(
"temperature models", temperature_models) ||
1227 Pointer((base +
"/temperature model default entry").c_str()).Get(
parameters) !=
nullptr)
1229 temperature_models = default_temperature_models;
1232 for (searchback = 0; searchback <
path.size(); ++searchback)
1241 if (searchback <
path.size())
1249 value2.CopyFrom(value1,
parameters.GetAllocator());
1254 Pointer((base).c_str()).Get(
parameters)->AddMember(
"temperature models", value2,
parameters.GetAllocator());
1255 Pointer((base +
"/temperature model default entry").c_str()).Set(
parameters,
true);
1260 std::vector<std::shared_ptr<Composition::Interface> > composition_models;
1261 if (!this->get_shared_pointers<Composition::Interface>(
"composition models", composition_models) ||
1262 Pointer((base +
"/composition model default entry").c_str()).Get(
parameters) !=
nullptr)
1264 composition_models = default_composition_models;
1268 for (searchback = 0; searchback <
path.size(); ++searchback)
1277 if (searchback <
path.size())
1285 value2.CopyFrom(value1,
parameters.GetAllocator());
1290 Pointer((base).c_str()).Get(
parameters)->AddMember(
"composition models", value2,
parameters.GetAllocator());
1291 Pointer((base +
"/composition model default entry").c_str()).Set(
parameters,
true);
1296 std::vector<std::shared_ptr<Grains::Interface> > grains_models;
1297 if (!this->get_shared_pointers<Grains::Interface>(
"grains models", grains_models) ||
1298 Pointer((base +
"/grains model default entry").c_str()).Get(
parameters) !=
nullptr)
1300 grains_models = default_grains_models;
1304 for (searchback = 0; searchback <
path.size(); ++searchback)
1313 if (searchback <
path.size())
1321 value2.CopyFrom(value1,
parameters.GetAllocator());
1326 Pointer((base).c_str()).Get(
parameters)->AddMember(
"grains models", value2,
parameters.GetAllocator());
1327 Pointer((base +
"/grains model default entry").c_str()).Set(
parameters,
true);
1332 std::vector<std::shared_ptr<Velocity::Interface> > velocity_models;
1333 if (!this->get_shared_pointers<Velocity::Interface>(
"velocity models", velocity_models) ||
1334 Pointer((base +
"/velocity model default entry").c_str()).Get(
parameters) !=
nullptr)
1336 velocity_models = default_velocity_models;
1340 for (searchback = 0; searchback <
path.size(); ++searchback)
1349 if (searchback <
path.size())
1357 value2.CopyFrom(value1,
parameters.GetAllocator());
1362 Pointer((base).c_str()).Get(
parameters)->AddMember(
"velocity models", value2,
parameters.GetAllocator());
1363 Pointer((base +
"/velocity model default entry").c_str()).Set(
parameters,
true);
1366 vector.emplace_back(length, thickness, top_truncation, angle, temperature_models, composition_models, grains_models, velocity_models);
1377 std::vector<Objects::Segment<Features::FaultModels::Temperature::Interface,Features::FaultModels::Composition::Interface, Features::FaultModels::Grains::Interface, Features::FaultModels::Velocity::Interface> >
1379 std::vector<std::shared_ptr<Features::FaultModels::Temperature::Interface> > &default_temperature_models,
1380 std::vector<std::shared_ptr<Features::FaultModels::Composition::Interface> > &default_composition_models,
1381 std::vector<std::shared_ptr<Features::FaultModels::Grains::Interface> > &default_grains_models,
1382 std::vector<std::shared_ptr<Features::FaultModels::Velocity::Interface> > &default_velocity_models)
1384 using namespace Features::FaultModels;
1385 std::vector<Objects::Segment<Temperature::Interface,Composition::Interface,Grains::Interface,Velocity::Interface> > vector;
1392 Value *array = Pointer((strict_base).c_str()).Get(
parameters);
1394 for (
size_t i = 0; i < array->Size(); ++i )
1400 const double length = Pointer((base +
"/length").c_str()).Get(
parameters)->GetDouble();
1403 Value *point_array = Pointer((base +
"/thickness").c_str()).Get(
parameters);
1406 <<
" was not defined in " << strict_base <<
"/thickness, schema path: " << this->
get_full_json_schema_path() <<
"/thickness.");
1408 if (point_array->Size() == 1)
1411 const double local0 = Pointer((base +
"/thickness/0").c_str()).Get(
parameters)->GetDouble();
1416 const double local0 = Pointer((base +
"/thickness/0").c_str()).Get(
parameters)->GetDouble();
1417 const double local1 = Pointer((base +
"/thickness/1").c_str()).Get(
parameters)->GetDouble();
1423 point_array = Pointer((base +
"/top truncation").c_str()).Get(
parameters);
1425 if (point_array !=
nullptr)
1427 if (point_array->Size() == 1)
1430 const double local0 = Pointer((base +
"/top truncation/0").c_str()).Get(
parameters)->GetDouble();
1435 const double local0 = Pointer((base +
"/top truncation/0").c_str()).Get(
parameters)->GetDouble();
1436 const double local1 = Pointer((base +
"/top truncation/1").c_str()).Get(
parameters)->GetDouble();
1441 point_array = Pointer((base +
"/angle").c_str()).Get(
parameters);
1446 if (point_array->Size() == 1)
1449 const double local0 = Pointer((base +
"/angle/0").c_str()).Get(
parameters)->GetDouble();
1454 const double local0 = Pointer((base +
"/angle/0").c_str()).Get(
parameters)->GetDouble();
1455 const double local1 = Pointer((base +
"/angle/1").c_str()).Get(
parameters)->GetDouble();
1461 std::vector<std::shared_ptr<Temperature::Interface> > temperature_models;
1464 size_t searchback = 0;
1465 if (!this->get_shared_pointers<Temperature::Interface>(
"temperature models", temperature_models) ||
1466 Pointer((base +
"/temperature model default entry").c_str()).Get(
parameters) !=
nullptr)
1468 temperature_models = default_temperature_models;
1471 for (searchback = 0; searchback <
path.size(); ++searchback)
1480 if (searchback <
path.size())
1488 value2.CopyFrom(value1,
parameters.GetAllocator());
1493 Pointer((base).c_str()).Get(
parameters)->AddMember(
"temperature models", value2,
parameters.GetAllocator());
1494 Pointer((base +
"/temperature model default entry").c_str()).Set(
parameters,
true);
1499 std::vector<std::shared_ptr<Composition::Interface> > composition_models;
1500 if (!this->get_shared_pointers<Composition::Interface>(
"composition models", composition_models) ||
1501 Pointer((base +
"/composition model default entry").c_str()).Get(
parameters) !=
nullptr)
1503 composition_models = default_composition_models;
1507 for (searchback = 0; searchback <
path.size(); ++searchback)
1516 if (searchback <
path.size())
1524 value2.CopyFrom(value1,
parameters.GetAllocator());
1529 Pointer((base).c_str()).Get(
parameters)->AddMember(
"composition models", value2,
parameters.GetAllocator());
1530 Pointer((base +
"/composition model default entry").c_str()).Set(
parameters,
true);
1535 std::vector<std::shared_ptr<Grains::Interface> > grains_models;
1536 if (!this->get_shared_pointers<Grains::Interface>(
"grains models", grains_models) ||
1537 Pointer((base +
"/grains model default entry").c_str()).Get(
parameters) !=
nullptr)
1539 grains_models = default_grains_models;
1543 for (searchback = 0; searchback <
path.size(); ++searchback)
1552 if (searchback <
path.size())
1560 value2.CopyFrom(value1,
parameters.GetAllocator());
1565 Pointer((base).c_str()).Get(
parameters)->AddMember(
"grains models", value2,
parameters.GetAllocator());
1566 Pointer((base +
"/grains model default entry").c_str()).Set(
parameters,
true);
1571 std::vector<std::shared_ptr<Velocity::Interface> > velocity_models;
1572 if (!this->get_shared_pointers<Velocity::Interface>(
"velocity models", velocity_models) ||
1573 Pointer((base +
"/velocity model default entry").c_str()).Get(
parameters) !=
nullptr)
1575 velocity_models = default_velocity_models;
1579 for (searchback = 0; searchback <
path.size(); ++searchback)
1588 if (searchback <
path.size())
1596 value2.CopyFrom(value1,
parameters.GetAllocator());
1601 Pointer((base).c_str()).Get(
parameters)->AddMember(
"velocity models", value2,
parameters.GetAllocator());
1602 Pointer((base +
"/velocity model default entry").c_str()).Set(
parameters,
true);
1606 vector.emplace_back(length, thickness, top_truncation, angle, temperature_models, composition_models, grains_models, velocity_models);
1619 std::vector<double> vector;
1621 if (Pointer((strict_base +
"/" + name).c_str()).Get(
parameters) !=
nullptr)
1623 Value *array = Pointer((strict_base +
"/" + name).c_str()).Get(
parameters);
1625 for (
size_t i = 0; i < array->Size(); ++i )
1627 const std::string base = (strict_base +
"/").append(name).append(
"/").append(std::to_string(i));
1629 vector.push_back(Pointer(base.c_str()).Get(
parameters)->GetDouble());
1636 "internal error: could not retrieve the minItems value at: " 1639 const size_t min_size = value->GetUint();
1643 "internal error: could not retrieve the default value at: " 1646 const double default_value = value->GetDouble();
1649 for (
size_t i = 0; i < min_size; ++i)
1651 vector.push_back(default_value);
1661 std::vector<size_t> vector;
1663 if (Pointer((strict_base +
"/" + name).c_str()).Get(
parameters) !=
nullptr)
1665 Value *array = Pointer((strict_base +
"/" + name).c_str()).Get(
parameters);
1667 for (
size_t i = 0; i < array->Size(); ++i )
1669 const std::string base = (strict_base +
"/").append(name).append(
"/").append(std::to_string(i));
1671 vector.push_back(Pointer(base.c_str()).Get(
parameters)->GetUint());
1678 "internal error: could not retrieve the minItems value at: " 1681 const size_t min_size = value->GetUint();
1685 "internal error: could not retrieve the default value at: " 1688 const size_t default_value = value->GetUint();
1691 for (
size_t i = 0; i < min_size; ++i)
1693 vector.push_back(default_value);
1700 std::vector<unsigned int>
1703 std::vector<unsigned int> vector;
1705 if (Pointer((strict_base +
"/" + name).c_str()).Get(
parameters) !=
nullptr)
1707 Value *array = Pointer((strict_base +
"/" + name).c_str()).Get(
parameters);
1709 for (
size_t i = 0; i < array->Size(); ++i )
1711 const std::string base = (strict_base +
"/").append(name).append(
"/").append(std::to_string(i));
1713 vector.push_back(Pointer(base.c_str()).Get(
parameters)->GetUint());
1720 "internal error: could not retrieve the minItems value at: " 1723 const size_t min_size = value->GetUint();
1728 for (
size_t i = 0; i < min_size; ++i)
1730 vector.push_back(default_value);
1741 Value *value = Pointer((base +
"/" + name +
"/model").c_str()).Get(
parameters);
1744 bool required =
false;
1745 if (Pointer((base +
"/required").c_str()).Get(
declarations) != NULL)
1746 for (
auto &v : Pointer((base +
"/required").c_str()).Get(
declarations)->GetArray())
1748 if (v.GetString() == name)
1754 WBAssert(value != NULL || required ==
false,
1755 "Internal error: Value \"" << base <<
'/' << name <<
"/model\" not found in the input file, while it was set as required.");
1757 if (value ==
nullptr)
1761 "internal error: could not retrieve the default value at: " 1762 << base +
"/" + name +
"/default value. Make sure the value has been declared.");
1765 return T::create(value->GetString(),&
world);
1774 if (Pointer((strict_base +
"/" + name).c_str()).Get(
parameters) !=
nullptr)
1776 Value *array = Pointer((strict_base +
"/" + name).c_str()).Get(
parameters);
1778 for (
size_t i = 0; i < array->Size(); ++i )
1780 const std::string base = (strict_base +
"/").append(name).append(
"/").append(std::to_string(i));
1782 const std::string value = Pointer((base +
"/model").c_str()).Get(
parameters)->GetString();
1784 vector.push_back(std::move(T::create(value, &
world)));
1801 if (Pointer((strict_base +
"/" + name).c_str()).Get(
parameters) !=
nullptr)
1803 Value *array = Pointer((strict_base +
"/" + name).c_str()).Get(
parameters);
1805 for (
size_t i = 0; i < array->Size(); ++i )
1807 vector.push_back(std::make_unique<Features::SubductingPlate>(&
world));
1824 if (Pointer((strict_base +
"/" + name).c_str()).Get(
parameters) !=
nullptr)
1826 Value *array = Pointer((strict_base +
"/" + name).c_str()).Get(
parameters);
1828 for (
size_t i = 0; i < array->Size(); ++i )
1830 vector.push_back(std::make_unique<Features::Fault>(&
world));
1849 if (Pointer((strict_base +
"/" + name).c_str()).Get(
parameters) !=
nullptr)
1851 Value *array = Pointer((strict_base +
"/" + name).c_str()).Get(
parameters);
1853 for (
size_t i = 0; i < array->Size(); ++i )
1855 const std::string base = (strict_base +
"/").append(name).append(
"/").append(std::to_string(i));
1857 const std::string value = Pointer((base +
"/model").c_str()).Get(
parameters)->GetString();
1859 vector.push_back(std::move(T::create(value, &
world)));
1873 path.push_back(name);
1887 const std::string &parent_name,
1888 const std::map<std::string,
void ( *)(
Parameters &,
const std::string &)> &declare_map,
1889 const std::vector<std::string> &required_entries,
1890 const std::vector<std::tuple<std::string,const WorldBuilder::Types::Interface &, std::string> > &extra_declarations)
1892 unsigned int counter = 0;
1893 for (
const auto &it : declare_map)
1895 typedef std::tuple<std::string,const WorldBuilder::Types::Interface &, std::string> DeclareEntry;
1897 if (it.first != parent_name)
1908 "The name of the " + model_group_name +
" model.");
1910 for (DeclareEntry extra_declaration : extra_declarations)
1912 declare_entry(std::get<0>(extra_declaration),std::get<1>(extra_declaration),std::get<2>(extra_declaration));
1916 it.second(*
this, parent_name);
1935 std::string collapse;
1936 for (
size_t i = 0; i <
path.size() && i < max_size; i++)
1938 collapse +=
"/" +
path[i];
1946 std::string collapse =
"/properties";
1947 for (
size_t i = 0; i <
path.size(); i++)
1952 const std::string base_path = Pointer((collapse +
"/" +
path[i] +
"/type").c_str()).Get(
declarations) !=
nullptr 1954 collapse +
"/" +
path[i]
1958 const std::string
type = Pointer((base_path +
"/type").c_str()).Get(
declarations)->GetString();
1960 if (type ==
"array")
1965 if (Pointer((base_path +
"/items/oneOf").c_str()).Get(
declarations) !=
nullptr)
1970 const size_t size = Pointer((base_path +
"/items/oneOf").c_str()).Get(
declarations)->Size();
1975 for (; index < size; ++index)
1977 const std::string declarations_string = Pointer((base_path +
"/items/oneOf/" + std::to_string(index)
1978 +
"/properties/model/enum/0").c_str()).Get(
declarations)->GetString();
1986 if (declarations_string == parameters_string)
1997 "Internal error: This is an array with several possible values, " 1998 "but could not find the correct value " << collapse +
"/" +
path[i] +
"/items/oneOf");
2000 collapse +=
"/" +
path[i] +
"/items/oneOf/" + std::to_string(index) +
"/properties";
2006 collapse = base_path +
"/items";
2009 else if (type ==
"object")
2012 if (Pointer((base_path +
"/oneOf").c_str()).Get(
declarations) !=
nullptr)
2017 const size_t size = Pointer((base_path +
"/oneOf").c_str()).Get(
declarations)->Size();
2022 for (; index < size; ++index)
2024 const std::string declarations_string = Pointer((base_path +
"/oneOf/" + std::to_string(index)
2025 +
"/properties/model/enum/0").c_str()).Get(
declarations)->GetString();
2032 if (value ==
nullptr)
2034 value = Pointer((collapse +
"/" +
path[i] +
"/default value").c_str()).Get(
declarations);
2036 "internal error: could not retrieve the default value at: " 2037 << collapse +
"/" +
path[i] +
"/default value, for value: ");
2040 const std::string parameters_string = value->GetString();
2043 if (declarations_string == parameters_string)
2054 "Internal error: This is an array with several possible values, " 2055 "but could not find the correct value " << collapse +
"/" +
path[i] +
"/items/oneOf");
2057 collapse +=
"/" +
path[i] +
"/oneOf/" + std::to_string(index) +
"/properties";
2064 collapse +=
"/properties";
2069 collapse +=
"/" +
path[i];
2083 template std::unique_ptr<CoordinateSystems::Interface> Parameters::get_unique_pointer<CoordinateSystems::Interface>(
const std::string &name);
2090 template std::unique_ptr<GravityModel::Interface> Parameters::get_unique_pointer<GravityModel::Interface>(
const std::string &name);
2099 Parameters::get_unique_pointers<Features::Interface>(
const std::string &name,
2100 std::vector<std::unique_ptr<Features::Interface> > &vector);
2108 Parameters::get_unique_pointers<Features::ContinentalPlateModels::Temperature::Interface>(
const std::string &name,
2109 std::vector<std::unique_ptr<Features::ContinentalPlateModels::Temperature::Interface> > &vector);
2116 Parameters::get_unique_pointers<Features::ContinentalPlateModels::Composition::Interface>(
const std::string &name,
2117 std::vector<std::unique_ptr<Features::ContinentalPlateModels::Composition::Interface> > &vector);
2124 Parameters::get_unique_pointers<Features::ContinentalPlateModels::Grains::Interface>(
const std::string &name,
2125 std::vector<std::unique_ptr<Features::ContinentalPlateModels::Grains::Interface> > &vector);
2132 Parameters::get_unique_pointers<Features::ContinentalPlateModels::Velocity::Interface>(
const std::string &name,
2133 std::vector<std::unique_ptr<Features::ContinentalPlateModels::Velocity::Interface> > &vector);
2141 Parameters::get_unique_pointers<Features::PlumeModels::Temperature::Interface>(
const std::string &name,
2142 std::vector<std::unique_ptr<Features::PlumeModels::Temperature::Interface> > &vector);
2149 Parameters::get_unique_pointers<Features::PlumeModels::Composition::Interface>(
const std::string &name,
2150 std::vector<std::unique_ptr<Features::PlumeModels::Composition::Interface> > &vector);
2157 Parameters::get_unique_pointers<Features::PlumeModels::Grains::Interface>(
const std::string &name,
2158 std::vector<std::unique_ptr<Features::PlumeModels::Grains::Interface> > &vector);
2165 Parameters::get_unique_pointers<Features::PlumeModels::Velocity::Interface>(
const std::string &name,
2166 std::vector<std::unique_ptr<Features::PlumeModels::Velocity::Interface> > &vector);
2175 Parameters::get_unique_pointers<Features::OceanicPlateModels::Temperature::Interface>(
const std::string &name,
2176 std::vector<std::unique_ptr<Features::OceanicPlateModels::Temperature::Interface> > &vector);
2183 Parameters::get_unique_pointers<Features::OceanicPlateModels::Composition::Interface>(
const std::string &name,
2184 std::vector<std::unique_ptr<Features::OceanicPlateModels::Composition::Interface> > &vector);
2191 Parameters::get_unique_pointers<Features::OceanicPlateModels::Grains::Interface>(
const std::string &name,
2192 std::vector<std::unique_ptr<Features::OceanicPlateModels::Grains::Interface> > &vector);
2199 Parameters::get_unique_pointers<Features::OceanicPlateModels::Velocity::Interface>(
const std::string &name,
2200 std::vector<std::unique_ptr<Features::OceanicPlateModels::Velocity::Interface> > &vector);
2209 Parameters::get_unique_pointers<Features::MantleLayerModels::Temperature::Interface>(
const std::string &name,
2210 std::vector<std::unique_ptr<Features::MantleLayerModels::Temperature::Interface> > &vector);
2217 Parameters::get_unique_pointers<Features::MantleLayerModels::Composition::Interface>(
const std::string &name,
2218 std::vector<std::unique_ptr<Features::MantleLayerModels::Composition::Interface> > &vector);
2225 Parameters::get_unique_pointers<Features::MantleLayerModels::Grains::Interface>(
const std::string &name,
2226 std::vector<std::unique_ptr<Features::MantleLayerModels::Grains::Interface> > &vector);
2233 Parameters::get_unique_pointers<Features::MantleLayerModels::Velocity::Interface>(
const std::string &name,
2234 std::vector<std::unique_ptr<Features::MantleLayerModels::Velocity::Interface> > &vector);
2243 Parameters::get_unique_pointers<Features::SubductingPlateModels::Temperature::Interface>(
const std::string &name,
2244 std::vector<std::unique_ptr<Features::SubductingPlateModels::Temperature::Interface> > &vector);
2251 Parameters::get_unique_pointers<Features::SubductingPlateModels::Composition::Interface>(
const std::string &name,
2252 std::vector<std::unique_ptr<Features::SubductingPlateModels::Composition::Interface> > &vector);
2259 Parameters::get_unique_pointers<Features::SubductingPlateModels::Grains::Interface>(
const std::string &name,
2260 std::vector<std::unique_ptr<Features::SubductingPlateModels::Grains::Interface> > &vector);
2267 Parameters::get_unique_pointers<Features::SubductingPlateModels::Velocity::Interface>(
const std::string &name,
2268 std::vector<std::unique_ptr<Features::SubductingPlateModels::Velocity::Interface> > &vector);
2277 Parameters::get_unique_pointers<Features::FaultModels::Temperature::Interface>(
const std::string &name,
2278 std::vector<std::unique_ptr<Features::FaultModels::Temperature::Interface> > &vector);
2285 Parameters::get_unique_pointers<Features::FaultModels::Composition::Interface>(
const std::string &name,
2286 std::vector<std::unique_ptr<Features::FaultModels::Composition::Interface> > &vector);
2292 Parameters::get_unique_pointers<Features::FaultModels::Grains::Interface>(
const std::string &name,
2293 std::vector<std::unique_ptr<Features::FaultModels::Grains::Interface> > &vector);
2299 Parameters::get_unique_pointers<Features::FaultModels::Velocity::Interface>(
const std::string &name,
2300 std::vector<std::unique_ptr<Features::FaultModels::Velocity::Interface> > &vector);
2309 Parameters::get_shared_pointers<Features::SubductingPlateModels::Temperature::Interface>(
const std::string &name,
2310 std::vector<std::shared_ptr<Features::SubductingPlateModels::Temperature::Interface> > &vector);
2317 Parameters::get_shared_pointers<Features::SubductingPlateModels::Composition::Interface>(
const std::string &name,
2318 std::vector<std::shared_ptr<Features::SubductingPlateModels::Composition::Interface> > &vector);
2325 Parameters::get_shared_pointers<Features::SubductingPlateModels::Grains::Interface>(
const std::string &name,
2326 std::vector<std::shared_ptr<Features::SubductingPlateModels::Grains::Interface> > &vector);
2333 Parameters::get_shared_pointers<Features::SubductingPlateModels::Velocity::Interface>(
const std::string &name,
2334 std::vector<std::shared_ptr<Features::SubductingPlateModels::Velocity::Interface> > &vector);
2342 Parameters::get_shared_pointers<Features::FaultModels::Temperature::Interface>(
const std::string &name,
2343 std::vector<std::shared_ptr<Features::FaultModels::Temperature::Interface> > &vector);
2350 Parameters::get_shared_pointers<Features::FaultModels::Composition::Interface>(
const std::string &name,
2351 std::vector<std::shared_ptr<Features::FaultModels::Composition::Interface> > &vector);
2357 Parameters::get_shared_pointers<Features::FaultModels::Grains::Interface>(
const std::string &name,
2358 std::vector<std::shared_ptr<Features::FaultModels::Grains::Interface> > &vector);
2364 Parameters::get_shared_pointers<Features::FaultModels::Velocity::Interface>(
const std::string &name,
2365 std::vector<std::shared_ptr<Features::FaultModels::Velocity::Interface> > &vector);
bool check_entry(const std::string &name) const
#define WBAssertThrowExc(condition, exc, message)
bool approx(double a, double b, double error_factor=1e4)
void enter_subsection(const std::string &name)
rapidjson::Document parameters
std::unique_ptr< T > get_unique_pointer(const std::string &name)
bool get_shared_pointers(const std::string &name, std::vector< std::shared_ptr< T > > &)
void initialize(std::string &filename, bool has_output_dir=false, const std::string &output_dir="")
virtual void write_schema(Parameters &prm, const std::string &name, const std::string &documentation) const =0
std::string read_and_distribute_file_content(const std::string &filename)
#define WBAssert(condition, message)
std::string get_full_json_path(size_t max_size=std::numeric_limits< size_t >::max()) const
std::string get_full_json_schema_path() const
#define WBAssertThrow(condition, message)
bool get_unique_pointers(const std::string &name, std::vector< std::unique_ptr< T > > &vector)
std::unique_ptr< WorldBuilder::CoordinateSystems::Interface > coordinate_system
std::pair< std::vector< double >, std::vector< double > > get_value_at_array(const std::string &name)
std::vector< std::vector< double > > get_vector_or_double(const std::string &name)
void declare_model_entries(const std::string &model_group_name, const std::string &parent_name, const std::map< std::string, void(*)(Parameters &, const std::string &)> &declare_map, const std::vector< std::string > &required_entries={}, const std::vector< std::tuple< std::string, const WorldBuilder::Types::Interface &, std::string > > &extra_declarations={})
void declare_entry(const std::string &name, const Types::Interface &type, const std::string &documentation)
std::vector< std::string > path
std::vector< T > get_vector(const std::string &name)
T get(const std::string &name)
rapidjson::Document declarations