31 std::string
const& context) {
32 namespace fs = std::filesystem;
33 if (fs::exists(path))
return path;
34 auto const p = fs::path(path);
35 if (p == p.filename()) {
36 if (
auto const* root = std::getenv(
"SHIPGEOMETRY_ROOT")) {
37 auto const resolved = fs::path(root) /
"share" /
"geometry" / p;
38 if (fs::exists(resolved))
return resolved.string();
41 throw std::runtime_error(context +
": cannot locate geometry db '" + path +
42 "'; set SHIPGEOMETRY_ROOT or provide an absolute "
47 std::string
tune =
"G18_02a_00_000";
66 void validate(std::string
const& context =
"genie_source")
const {
67 namespace fs = std::filesystem;
69 throw std::runtime_error(context +
": 'tune' must not be empty");
71 throw std::runtime_error(
73 ": 'seed' must be > 0 (GENIE ignores non-positive seeds), got " +
74 std::to_string(
seed));
79 if (
seed > 4294967295L)
80 throw std::runtime_error(
81 context +
": 'seed' must fit in 32 bits (max 4294967295), got " +
82 std::to_string(
seed));
83 auto require_file = [&context](std::string
const& key,
84 std::string
const& path) {
86 throw std::runtime_error(context +
": config key '" + key +
88 if (!fs::exists(path))
89 throw std::runtime_error(context +
": " + key +
" '" + path +
93 throw std::runtime_error(context +
94 ": flux_format must be 'ship' or 'gsimple', "
99 throw std::runtime_error(context +
100 ": config key 'flux_file' is required");
105 throw std::runtime_error(context +
106 ": config key 'geometry_file' is required");
111 if (!dir.empty() && !fs::is_directory(dir))
112 throw std::runtime_error(context +
113 ": cannot create max_path_lengths_file '" +
115 dir.string() +
"' does not exist");
Definition genie_config.hpp:22
std::string resolve_geometry_file(std::string const &path, std::string const &context)
Definition genie_config.hpp:30
Definition genie_config.hpp:46
void validate(std::string const &context="genie_source") const
Definition genie_config.hpp:66
std::string geometry_file
Definition genie_config.hpp:56
std::string max_path_lengths_file
Definition genie_config.hpp:63
std::string flux_format
Definition genie_config.hpp:53
std::string top_volume
Definition genie_config.hpp:59
std::string flux_file
Definition genie_config.hpp:49
std::string tune
Definition genie_config.hpp:47
long seed
Definition genie_config.hpp:60
std::string spline_file
Definition genie_config.hpp:48