15#include <fmt/format.h>
16#include <fmt/ranges.h>
23 if (
auto iter = parameter_defaults_.find(par_num); iter != parameter_defaults_.end())
25 throw std::logic_error(fmt::format(
26 "Default value of parameter {} has been already set to {}!", iter->second.first, iter->second.second));
28 parameter_defaults_.emplace(par_num, values);
33 if (
auto iter = methods_.find(method); iter != methods_.end())
35 throw std::logic_error(fmt::format(
"Method {} has been already set to {}!", iter->first, iter->second));
37 methods_.emplace(method, values);
42 other_options_.push_back(std::move(options));
47 auto ofile = std::ofstream{ filepath_, std::ios_base::out | std::ios_base::trunc };
49 if (not ofile.is_open())
51 throw std::runtime_error(fmt::format(
"Failed to open file {}", filepath_));
54 write_parameter_defaults();
55 write_data_file(ofile);
61 void SteerWriter::write_data_file(std::ofstream& ofile)
64 ofile << data_filepath_ <<
"\n";
65 ofile << parameter_file_ <<
"\n";
69 void SteerWriter::write_parameter_defaults()
71 auto ofile = std::ofstream{ parameter_file_, std::ios_base::out | std::ios_base::trunc };
73 if (not ofile.is_open())
75 throw std::runtime_error(fmt::format(
"Can't open file {}", parameter_file_));
78 ofile <<
"Parameter\n";
79 for (
const auto& [par_id, values] : parameter_defaults_)
81 ofile << fmt::format(
"{} {:.1f} {:.1f}\n", par_id, values.first, values.second);
85 void SteerWriter::write_methods(std::ofstream& ofile)
87 for (
const auto& [method, values] : methods_)
89 ofile << fmt::format(
"method {} {} {}\n", method, values.first, values.second);
94 void SteerWriter::write_others(std::ofstream& ofile)
96 for (
const auto& other : other_options_)
98 ofile << fmt::format(
"{}\n", fmt::join(other,
" "));
void add_method(Method method, const std::pair< float, float > &values)
void add_other_options(std::vector< std::string > options)
void add_parameter_default(int par_num, const std::pair< float, float > &values)