include/terraingen/config/validate.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // SPDX-License-Identifier: BSD-3-Clause | ||
| 2 | |||
| 3 | /// @file | ||
| 4 | /// @brief Checking a configuration before building it: everything parsing cannot catch. | ||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "terraingen/config/config.h" | ||
| 8 | #include "terraingen/raster/grid.h" | ||
| 9 | |||
| 10 | #include <cstddef> | ||
| 11 | #include <filesystem> | ||
| 12 | #include <optional> | ||
| 13 | #include <vector> | ||
| 14 | |||
| 15 | namespace terraingen { | ||
| 16 | |||
| 17 | /// What a valid configuration generates, as `ValidateConfig` finds it. | ||
| 18 | 1107 | struct ConfigSummary { | |
| 19 | /// The source's grid; none without a source or for one without bounds, such as synthetic | ||
| 20 | /// noise. | ||
| 21 | std::optional<RasterGrid> source; | ||
| 22 | /// The grid each output covers, in order; none for a body mesh or a report. | ||
| 23 | std::vector<std::optional<RasterGrid>> outputGrids; | ||
| 24 | /// Craters the top-level crater layers are expected to generate over the output grid with the | ||
| 25 | /// most; unset when none generate or no output covers a grid. | ||
| 26 | std::optional<double> expectedCraters; | ||
| 27 | }; | ||
| 28 | |||
| 29 | /// Checks everything parsing cannot, building the terrain to check it, and returns what it found. | ||
| 30 | /// @param directory Folder relative input paths resolve against; empty for the folder the | ||
| 31 | /// configuration was read from (`TerrainGenConfig::Directory`). | ||
| 32 | /// @throws ConfigError naming the first invalid value by its JSON path. | ||
| 33 | ConfigSummary ValidateConfig(const TerrainGenConfig& config, | ||
| 34 | const std::filesystem::path& directory = {}); | ||
| 35 | |||
| 36 | } // namespace terraingen | ||
| 37 |