World Builder  1.1.0-pre
A geodynamic initial conditions generator
value_at_points.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2018-2024 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 <utility>
20 
22 
24 
25 
26 namespace WorldBuilder
27 {
28  namespace Types
29  {
30 
31  ValueAtPoints::ValueAtPoints(const double default_value_,
32  uint64_t max_values_in_array_,
33  std::vector<Point<2>> default_points_)
34  :
35  default_value(default_value_),
36  max_values_in_array(max_values_in_array_),
37  default_points(std::move(std::move(default_points_)))
38  {
40 
41  WBAssert(default_points_.size() == 0, "default points are not implemented.");
42  }
43 
45  :
49  {
51  }
52 
53 
55  = default;
56 
57 
58  void
60  const std::string &name,
61  const std::string &documentation) const
62  {
63  using namespace rapidjson;
64  prm.enter_subsection(name);
65  {
66  Document &declarations = prm.declarations;
67  const std::string base = prm.get_full_json_path();
68 
69  Pointer((base + "/type").c_str()).Set(declarations,"array");
70  Pointer((base + "/additionalProperties").c_str()).Set(declarations,false);
71  Pointer((base + "/minItems").c_str()).Set(declarations,1);
72  Pointer((base + "/maxItems").c_str()).Set(declarations, max_values_in_array);
73  Pointer((base + "/description").c_str()).Set(declarations,documentation.c_str());
74 
75  {
76  Pointer((base + "/items/anyOf/0/type").c_str()).Set(declarations,"number");
77  Pointer((base + "/items/anyOf/0/default value").c_str()).Set(declarations,default_value);
78 
79  Pointer((base + "/items/anyOf/1/type").c_str()).Set(declarations,"array");
80  Pointer((base + "/items/anyOf/1/minItems").c_str()).Set(declarations,1);
81  Pointer((base + "/items/anyOf/1/maxItems").c_str()).Set(declarations,std::numeric_limits<unsigned int>::max());
82 
83  Pointer((base + "/items/anyOf/1/items/type").c_str()).Set(declarations,"array");
84  Pointer((base + "/items/anyOf/1/items/minItems").c_str()).Set(declarations,1);
85  Pointer((base + "/items/anyOf/1/items/maxItems").c_str()).Set(declarations, max_values_in_array);
86 
87  Pointer((base + "/items/anyOf/1/items/items/type").c_str()).Set(declarations,"number");
88  }
89  }
90  prm.leave_subsection();
91  }
92 
93  } // namespace Types
94 } // namespace WorldBuilder
95 
96 
void enter_subsection(const std::string &name)
Definition: parameters.cc:1871
void write_schema(Parameters &prm, const std::string &name, const std::string &documentation) const override final
#define WBAssert(condition, message)
Definition: assert.h:27
std::string get_full_json_path(size_t max_size=std::numeric_limits< size_t >::max()) const
Definition: parameters.cc:1933
ValueAtPoints(const double default_value, uint64_t max_values_in_array, std::vector< Point< 2 >> default_points_=std::vector< Point< 2 >>())
rapidjson::Document declarations
Definition: parameters.h:248
std::vector< Point< 2 > > default_points