Cholla 3.0.1-dev
Cholla - Massively parallel hydro on GPUs
Loading...
Searching...
No Matches
FnameTemplate.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <optional>
9#include <string>
10#include <string_view>
11
12#include "../io/ParameterMap.h"
13#include "../utils/error_handling.h"
14
43{
44 public:
45 FnameTemplate() = delete;
46
47 FnameTemplate(bool separate_cycle_dirs, std::string outdir)
48 : separate_cycle_dirs_(separate_cycle_dirs), outdir_(std::move(outdir))
49 {
50 }
51
52 static FnameTemplate from_pmap(ParameterMap& pmap)
53 {
54 bool legacy_flat_outdir;
55 int uncoerced = pmap.value_or("legacy_flat_outdir", 0);
56 if (uncoerced == 0) {
57 legacy_flat_outdir = false;
58 } else if (uncoerced == 1) {
59 legacy_flat_outdir = true;
60 } else {
61 CHOLLA_ERROR("legacy_flat_outdir parameter must be 1 or 0.");
62 }
63 return {not legacy_flat_outdir, pmap.value_or("outdir", "")};
64 }
65
67 bool separate_cycle_dirs() const noexcept { return separate_cycle_dirs_; }
68
70 std::string nominal_output_dir_path() const noexcept { return outdir_; }
71
73 std::string effective_output_dir_path(int nfile) const noexcept;
74
// <- the functions inside this doxygen group share a docstring
77 std::string format_fname(int nfile, std::string_view pre_extension_suffix,
78 std::optional<std::string_view> post_extension_suffix = std::nullopt) const noexcept;
79
80 std::string format_fname(int nfile, int file_proc_id, std::string_view pre_extension_suffix,
81 std::optional<std::string_view> post_extension_suffix = std::nullopt) const noexcept;
84 private:
85 bool separate_cycle_dirs_;
86 std::string outdir_;
87};
Definition FnameTemplate.h:43
std::string effective_output_dir_path(int nfile) const noexcept
Definition FnameTemplate.cpp:11
std::string format_fname(int nfile, std::string_view pre_extension_suffix, std::optional< std::string_view > post_extension_suffix=std::nullopt) const noexcept
Definition FnameTemplate.cpp:29
std::string nominal_output_dir_path() const noexcept
Definition FnameTemplate.h:70
bool separate_cycle_dirs() const noexcept
Definition FnameTemplate.h:67
A class that provides map-like access to parameter files.
Definition ParameterMap.h:74