12#include "detray/io/frontend/detail/detector_components_writer.hpp"
13#include "detray/io/frontend/detector_writer_config.hpp"
14#include "detray/io/frontend/impl/json_writers.hpp"
15#include "detray/io/utils/create_path.hpp"
16#include "detray/utils/logging.hpp"
31template <
class detector_t>
32void write_detector(detector_t& det,
const typename detector_t::name_map& names,
35 const std::ios_base::openmode out_mode{std::ios_base::out |
36 std::ios_base::binary};
38 cfg.
replace_files() ? (out_mode | std::ios_base::trunc) : out_mode;
42 if (det.material_store().all_empty()) {
47 io::detail::detector_components_writer<detector_t> writer{};
48 if (cfg.
format() == io::format::json) {
49 detail::add_json_writers(writer, cfg);
53 DETRAY_ERROR_HOST(
"Compactifying json files is not yet implemented");
56 writer.write(det, names, mode, file_path);
The following enums are global for all detectors.
Definition concepts.hpp:18
void write_detector(detector_t &det, const typename detector_t::name_map &names, detector_writer_config &cfg)
Writer function for detray detectors.
Definition detector_writer.hpp:32
auto create_path(const std::string &outdir)
Check if a given file path exists and generate it if not.
Definition create_path.hpp:79
config struct for detector writing.
Definition detector_writer_config.hpp:21
bool write_material() const
Return whether material data is written.
Definition detector_writer_config.hpp:51
detray::io::format format() const
Return the selected output format.
Definition detector_writer_config.hpp:42
bool compactify_json() const
Return whether JSON output is compacted.
Definition detector_writer_config.hpp:48
bool replace_files() const
Return whether existing output files are replaced.
Definition detector_writer_config.hpp:45
const std::string & path() const
GettersReturn the output directory used for detector files.
Definition detector_writer_config.hpp:39