| 13 | namespace nb = nanobind; |
| 14 | |
| 15 | void init_EngineConfig(nb::module_ &m) |
| 16 | { |
| 17 | using osrm::engine::EngineConfig; |
| 18 | |
| 19 | nb::class_<EngineConfig>(m, "EngineConfig", nb::is_final()) |
| 20 | .def(nb::init<>()) |
| 21 | .def("__init__", |
| 22 | [](EngineConfig *t, const nb::kwargs &kwargs) |
| 23 | { |
| 24 | new (t) EngineConfig(); |
| 25 | |
| 26 | osrm_nb_util::populate_cfg_from_kwargs(kwargs, *t); |
| 27 | |
| 28 | if (!t->IsValid()) |
| 29 | { |
| 30 | throw std::runtime_error("Config Parameters are Invalid"); |
| 31 | } |
| 32 | }) |
| 33 | .def("IsValid", &EngineConfig::IsValid) |
| 34 | .def("SetStorageConfig", |
| 35 | [](EngineConfig &self, const std::string &path) |
| 36 | { self.storage_config = osrm::storage::StorageConfig(path); }) |
| 37 | .def_rw("max_locations_trip", &EngineConfig::max_locations_trip) |
| 38 | .def_rw("max_locations_viaroute", &EngineConfig::max_locations_viaroute) |
| 39 | .def_rw("max_locations_distance_table", &EngineConfig::max_locations_distance_table) |
| 40 | .def_rw("max_locations_map_matching", &EngineConfig::max_locations_map_matching) |
| 41 | .def_rw("max_radius_map_matching", &EngineConfig::max_radius_map_matching) |
| 42 | .def_rw("max_results_nearest", &EngineConfig::max_results_nearest) |
| 43 | .def_rw("default_radius", &EngineConfig::default_radius) |
| 44 | .def_rw("max_alternatives", &EngineConfig::max_alternatives) |
| 45 | .def_rw("use_shared_memory", &EngineConfig::use_shared_memory) |
| 46 | .def_prop_rw( |
| 47 | "memory_file", |
| 48 | [](const EngineConfig &c) { return c.memory_file.string(); }, |
| 49 | [](EngineConfig &c, const std::string &val) |
| 50 | { c.memory_file = std::filesystem::path(val); }) |
| 51 | .def_rw("use_mmap", &EngineConfig::use_mmap) |
| 52 | .def_rw("algorithm", &EngineConfig::algorithm) |
| 53 | .def_rw("verbosity", &EngineConfig::verbosity) |
| 54 | .def_rw("dataset_name", &EngineConfig::dataset_name); |
| 55 | |
| 56 | nb::class_<EngineConfig::Algorithm>(m, "Algorithm") |
| 57 | .def("__init__", |
| 58 | [](EngineConfig::Algorithm *t, const std::string &str) |
| 59 | { |
| 60 | EngineConfig::Algorithm algorithm = |
| 61 | osrm_nb_util::str_to_enum(str, "Algorithm", algorithm_map); |
| 62 | new (t) EngineConfig::Algorithm(algorithm); |
| 63 | }) |
| 64 | .def("__repr__", |
| 65 | [](EngineConfig::Algorithm type) |
| 66 | { return osrm_nb_util::enum_to_str(type, "Algorithm", algorithm_map); }); |
| 67 | nb::implicitly_convertible<std::string, EngineConfig::Algorithm>(); |
| 68 | } |
no test coverage detected