From 61dc090fa81b6fdd46f2e1465d853743b32494ef Mon Sep 17 00:00:00 2001 From: sjunges Date: Wed, 12 Oct 2016 19:41:07 +0200 Subject: [PATCH] gspn export settings (currently only dot output) and better gspn to jani support Former-commit-id: 38f41a581feabfb03b534afe9c227ffb779d4226 [formerly e1909eca6ddcee25ca50a6bc54b53278af3cb94f] Former-commit-id: 88b71b0f0aa6ff1d941dd6f1218c0ad284f7df5b --- src/settings/modules/GSPNExportSettings.cpp | 43 +++++++++++++++++++++ src/settings/modules/GSPNExportSettings.h | 40 +++++++++++++++++++ src/settings/modules/GSPNSettings.cpp | 4 +- src/storm-gspn.cpp | 23 ++++++----- 4 files changed, 99 insertions(+), 11 deletions(-) create mode 100644 src/settings/modules/GSPNExportSettings.cpp create mode 100644 src/settings/modules/GSPNExportSettings.h diff --git a/src/settings/modules/GSPNExportSettings.cpp b/src/settings/modules/GSPNExportSettings.cpp new file mode 100644 index 000000000..17bdb1f1e --- /dev/null +++ b/src/settings/modules/GSPNExportSettings.cpp @@ -0,0 +1,43 @@ +#include "GSPNExportSettings.h" +#include "JaniExportSettings.h" + +#include "src/settings/SettingsManager.h" +#include "src/settings/SettingMemento.h" +#include "src/settings/Option.h" +#include "src/settings/OptionBuilder.h" +#include "src/settings/ArgumentBuilder.h" +#include "src/settings/Argument.h" + +#include "src/exceptions/InvalidSettingsException.h" + +namespace storm { + namespace settings { + namespace modules { + const std::string GSPNExportSettings::moduleName = "exportGspn"; + + const std::string GSPNExportSettings::writeToDotOptionName = "gspn-dot-output"; + //const std::string GSPNExportSettings::janiFileOptionShortName = "dotoutput"; + + + GSPNExportSettings::GSPNExportSettings() : ModuleSettings(moduleName) { + this->addOption(storm::settings::OptionBuilder(moduleName, writeToDotOptionName, false, "Destination for the dot output.").addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "path to file").build()).build()); + } + + bool GSPNExportSettings::isWriteToDotSet() const { + return this->getOption(writeToDotOptionName).getHasOptionBeenSet(); + } + + std::string GSPNExportSettings::getWriteToDotFilename() const { + return this->getOption(writeToDotOptionName).getArgumentByName("filename").getValueAsString(); + } + + void GSPNExportSettings::finalize() { + + } + + bool GSPNExportSettings::check() const { + return true; + } + } + } +} \ No newline at end of file diff --git a/src/settings/modules/GSPNExportSettings.h b/src/settings/modules/GSPNExportSettings.h new file mode 100644 index 000000000..e3c84b291 --- /dev/null +++ b/src/settings/modules/GSPNExportSettings.h @@ -0,0 +1,40 @@ +#pragma once + +#include "storm-config.h" +#include "src/settings/modules/ModuleSettings.h" + + +namespace storm { + namespace settings { + namespace modules { + class GSPNExportSettings : public ModuleSettings { + public: + /*! + * Creates a new JaniExport setting + */ + GSPNExportSettings(); + + /** + * Retrievew whether the pgcl file option was set + */ + bool isWriteToDotSet() const; + + /** + * Retrieves the pgcl file name + */ + std::string getWriteToDotFilename() const; + + + bool check() const override; + void finalize() override; + + static const std::string moduleName; + + private: + static const std::string writeToDotOptionName; + //static const std::string writeToDotOptionShortName; + + }; + } + } +} \ No newline at end of file diff --git a/src/settings/modules/GSPNSettings.cpp b/src/settings/modules/GSPNSettings.cpp index b48597eaf..3dc09e08d 100644 --- a/src/settings/modules/GSPNSettings.cpp +++ b/src/settings/modules/GSPNSettings.cpp @@ -23,9 +23,9 @@ namespace storm { GSPNSettings::GSPNSettings() : ModuleSettings(moduleName) { - this->addOption(storm::settings::OptionBuilder(moduleName, gspnFileOptionName, false, "Parses the pgcl program.").setShortName(gspnFileOptionShortName).addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "path to file").addValidationFunctionString(storm::settings::ArgumentValidators::existingReadableFileValidator()).build()).build()); + this->addOption(storm::settings::OptionBuilder(moduleName, gspnFileOptionName, false, "Parses the GSPN.").setShortName(gspnFileOptionShortName).addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "path to file").addValidationFunctionString(storm::settings::ArgumentValidators::existingReadableFileValidator()).build()).build()); this->addOption(storm::settings::OptionBuilder(moduleName, gspnToJaniOptionName, false, "Transform to JANI.").setShortName(gspnToJaniOptionShortName).build()); - this->addOption(storm::settings::OptionBuilder(moduleName, capacitiesFileOptionName, false, "Restrictions of program variables").setShortName(capacitiesFileOptionShortName).addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "path to file").addValidationFunctionString(storm::settings::ArgumentValidators::existingReadableFileValidator()).build()).build()); + this->addOption(storm::settings::OptionBuilder(moduleName, capacitiesFileOptionName, false, "Capacaties as invariants for places.").setShortName(capacitiesFileOptionShortName).addArgument(storm::settings::ArgumentBuilder::createStringArgument("filename", "path to file").addValidationFunctionString(storm::settings::ArgumentValidators::existingReadableFileValidator()).build()).build()); } bool GSPNSettings::isGspnFileSet() const { diff --git a/src/storm-gspn.cpp b/src/storm-gspn.cpp index 861e68cf7..bb48d150a 100644 --- a/src/storm-gspn.cpp +++ b/src/storm-gspn.cpp @@ -23,7 +23,8 @@ #include "src/exceptions/FileIoException.h" #include "src/settings/modules/GeneralSettings.h" -#include "src/settings/modules/GspnSettings.h" +#include "src/settings/modules/GSPNSettings.h" +#include "src/settings/modules/GSPNExportSettings.h" #include "src/settings/modules/CoreSettings.h" #include "src/settings/modules/DebugSettings.h" #include "src/settings/modules/JaniExportSettings.h" @@ -37,6 +38,7 @@ void initializeSettings() { // Register all known settings modules. storm::settings::addModule(); storm::settings::addModule(); + storm::settings::addModule(); storm::settings::addModule(); storm::settings::addModule(); storm::settings::addModule(); @@ -65,7 +67,7 @@ void handleJani(storm::gspn::GSPN const& gspn) { std::shared_ptr exprManager(new storm::expressions::ExpressionManager()); storm::builder::JaniGSPNBuilder builder(gspn, exprManager); storm::jani::Model* model = builder.build(); - storm::jani::JsonExporter::toFile(*model, "gspn.jani"); + storm::jani::JsonExporter::toFile(*model, storm::settings::getModule().getJaniFilename()); delete model; } @@ -98,13 +100,16 @@ int main(const int argc, const char **argv) { } - std::ofstream file; - file.open("gspn.dot"); - - gspn.writeDotToStream(file); - - handleJani(gspn); - + if(storm::settings::getModule().isWriteToDotSet()) { + std::ofstream file; + file.open(storm::settings::getModule().getWriteToDotFilename()); + gspn.writeDotToStream(file); + } + + if(storm::settings::getModule().isJaniFileSet()) { + handleJani(gspn); + } + return 0;