From 20eaac69187c662c21501a6a5ebf9871e5d39131 Mon Sep 17 00:00:00 2001 From: sjunges Date: Tue, 13 Sep 2016 23:59:32 +0200 Subject: [PATCH] Convenience function in model and automaton, building explicit mappings (independent of implementation) Former-commit-id: e183ae7ea82262724f8051d19fb521333012b249 [formerly 62b52cb78b3fe1551fa8970063d3f0063d759901] Former-commit-id: 8204f5b6553d2580d630889d82a9a758f9e4bcc1 --- src/storage/jani/Automaton.cpp | 11 +++++++++++ src/storage/jani/Automaton.h | 5 +++++ src/storage/jani/Model.cpp | 10 ++++++++++ src/storage/jani/Model.h | 5 +++++ 4 files changed, 31 insertions(+) diff --git a/src/storage/jani/Automaton.cpp b/src/storage/jani/Automaton.cpp index 9c618a838..6b11d29a0 100644 --- a/src/storage/jani/Automaton.cpp +++ b/src/storage/jani/Automaton.cpp @@ -148,6 +148,16 @@ namespace storm { std::set const& Automaton::getInitialLocationIndices() const { return initialLocationIndices; } + + std::map Automaton::buildIdToLocationNameMap() const { + std::map mapping; + uint64_t i = 0; + for(auto const& loc : locations) { + mapping[i] = loc.getName(); + ++i; + } + return mapping; + } Automaton::Edges Automaton::getEdgesFromLocation(std::string const& name) { auto it = locationToIndex.find(name); @@ -299,6 +309,7 @@ namespace storm { actionIndices.insert(edge.getActionIndex()); } + std::vector& Automaton::getEdges() { return edges; } diff --git a/src/storage/jani/Automaton.h b/src/storage/jani/Automaton.h index c6219aa1e..539e7df5e 100644 --- a/src/storage/jani/Automaton.h +++ b/src/storage/jani/Automaton.h @@ -193,6 +193,11 @@ namespace storm { */ std::set const& getInitialLocationIndices() const; + /*! + * Builds a map from ID to Location Name. + */ + std::map buildIdToLocationNameMap() const; + /*! * Retrieves the edges of the location with the given name. */ diff --git a/src/storage/jani/Model.cpp b/src/storage/jani/Model.cpp index fc170ac58..619324ae7 100644 --- a/src/storage/jani/Model.cpp +++ b/src/storage/jani/Model.cpp @@ -260,6 +260,16 @@ namespace storm { return result; } + std::map Model::buildActionToNameMap() const { + std::map mapping; + uint64_t i = 0; + for(auto const& act : actions) { + mapping[i] = act.getName(); + ++i; + } + return mapping; + } + std::string const& Model::getSilentActionName() const { return actions[silentActionIndex].getName(); } diff --git a/src/storage/jani/Model.h b/src/storage/jani/Model.h index 2fc06b18f..bade96875 100644 --- a/src/storage/jani/Model.h +++ b/src/storage/jani/Model.h @@ -81,6 +81,11 @@ namespace storm { * Retrieves the actions of the model. */ std::vector const& getActions() const; + + /*! + * Builds a map with action indices mapped to their names + */ + std::map buildActionToNameMap() const; /*! * Retrieves all non-silent action indices of the model.