From 0d8b5bc0c2d8fd2c9765206ef267522bb639cbfe Mon Sep 17 00:00:00 2001 From: Thomas Knoll Date: Fri, 1 Sep 2023 14:38:37 +0200 Subject: [PATCH] added module config added overwrite some fixes --- main.cpp | 7 ++++- util/ConfigYaml.cpp | 58 ++++++++++++++++++++++++++---------- util/ConfigYaml.h | 30 ++++++++++++------- util/Grid.cpp | 26 +++++++++++++++- util/Grid.h | 1 + util/PrismModulesPrinter.cpp | 36 ++++++++++++++-------- util/PrismModulesPrinter.h | 4 ++- 7 files changed, 121 insertions(+), 41 deletions(-) diff --git a/main.cpp b/main.cpp index 1eaa0c7..31e1b32 100644 --- a/main.cpp +++ b/main.cpp @@ -169,7 +169,12 @@ int main(int argc, char* argv[]) { if(ok) { Grid grid(contentCells, backgroundCells, gridOptions, stateRewards); //grid.printToPrism(std::cout, prism::ModelType::MDP); - grid.printToPrism(file, configurations ,prism::ModelType::MDP); + std::stringstream ss; + // grid.printToPrism(file, configurations ,prism::ModelType::MDP); + grid.printToPrism(ss, configurations ,prism::ModelType::MDP); + std::string str = ss.str(); + grid.applyOverwrites(str, configurations); + file << str; } } catch(qi::expectation_failure const& e) { std::cout << "expected: "; print_info(e.what_); diff --git a/util/ConfigYaml.cpp b/util/ConfigYaml.cpp index 4e5d6ef..014099e 100644 --- a/util/ConfigYaml.cpp +++ b/util/ConfigYaml.cpp @@ -24,6 +24,30 @@ std::ostream& operator << (std::ostream& os, const Module& module) { return os; } +std::string Label::createExpression() const { + if (overwrite_) { + return "label \"" + label_ + "\" = " + text_ + "; // Overwrite"; + } + + return "label \"" + label_ + "\" = " + text_ + ";"; +} + +std::string Formula::createExpression() const { + if (overwrite_) { + return "formula " + formula_ + " = " + content_ + "; // Overwrite"; + } + + return "formula " + formula_ + " = " + content_ + ";"; +} + +std::string Action::createExpression() const { + if (overwrite_) { + return action_ + "\t" + guard_ + "-> " + update_ + "; // Overwrite"; + } + + return "\t" + action_ + "\t" + guard_ + "-> " + update_ + ";"; +} + YAML::Node YAML::convert::encode(const Module& rhs) { YAML::Node node; @@ -122,28 +146,30 @@ bool YAML::convert::decode(const YAML::Node& node, Formula& rhs) { std::vector configuration; try { - YAML::Node config = YAML::LoadFile(file_); + YAML::Node config = YAML::LoadFile(file_); - const std::vector