29 explicit GeneralScenariofile(std::string path_to_file) : file_path_(std::move(path_to_file)) {
31 node = YAML::Load(file_content_);
34 SERIALIZE_VAR(version);
36 SERIALIZE_VAR(random_seed);
38 SERIALIZE_NS3_TIME(stop_time);
39 SERIALIZE_NS3_TIME(default_delay);
41 SERIALIZE_VAR(output_path);
44 std::string getOutputPath()
const {
47 if (output_path.has_value() && !output_path.value().empty()) {
48 return pathWithEndingSlash(output_path.value());
51 std::string output_path_env = std::getenv(
"DAISI_OUTPUT_PATH");
52 if (!output_path_env.empty())
return pathWithEndingSlash(output_path_env);
54 throw std::runtime_error(
"No output path set!");
58 static std::string pathWithEndingSlash(std::string path) {
59 if (path.empty())
throw std::runtime_error(
"cannot modify empty path");
60 if (path.at(path.size() - 1) !=
'/') path.append(
"/");
69 uint64_t random_seed = 0;
73 ns3::Time default_delay;
75 std::optional<std::string> output_path;
79 std::string getFileContent()
const {
return file_content_; }
82 void loadFileContent() {
87 file_content_ = file_path_;
89 std::ifstream t(file_path_);
90 std::string file_as_string((std::istreambuf_iterator<char>(t)),
91 std::istreambuf_iterator<char>());
92 file_content_ = file_as_string;
96 std::string file_content_;
97 std::string file_path_;