From ef08ddd2f7412ee799579a9b91094a9226c55d52 Mon Sep 17 00:00:00 2001 From: Matthias Volk Date: Wed, 17 Apr 2019 17:29:33 +0200 Subject: [PATCH] Small refactoring for ElementState --- src/storm-dft/storage/dft/DFT.cpp | 6 ++---- src/storm-dft/storage/dft/DFTState.cpp | 14 ++++++++++++-- src/storm-dft/storage/dft/DFTState.h | 12 ++++++++---- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/storm-dft/storage/dft/DFT.cpp b/src/storm-dft/storage/dft/DFT.cpp index 4a3a5eb30..7538c4abc 100644 --- a/src/storm-dft/storage/dft/DFT.cpp +++ b/src/storm-dft/storage/dft/DFT.cpp @@ -540,12 +540,10 @@ namespace storm { std::stringstream stream; stream << "(" << id << ") "; for (auto const& elem : mElements) { - size_t elemIndex = stateGenerationInfo.getStateIndex(elem->id()); - int elementState = DFTState::getElementStateInt(status, elemIndex); if (elem->isDependency()) { - stream << storm::storage::toChar(static_cast(elementState)) << "[dep]"; + stream << storm::storage::toChar(DFTState::getDependencyState(status, stateGenerationInfo, elem->id())) << "[dep]"; } else { - stream << storm::storage::toChar(static_cast(elementState)); + stream << storm::storage::toChar(DFTState::getElementState(status, stateGenerationInfo, elem->id())); if(elem->isSpareGate()) { stream << "["; size_t nrUsedChild = status.getAsInt(stateGenerationInfo.getSpareUsageIndex(elem->id()), stateGenerationInfo.usageInfoBits()); diff --git a/src/storm-dft/storage/dft/DFTState.cpp b/src/storm-dft/storage/dft/DFTState.cpp index 778c571b8..689787b70 100644 --- a/src/storm-dft/storage/dft/DFTState.cpp +++ b/src/storm-dft/storage/dft/DFTState.cpp @@ -98,20 +98,30 @@ namespace storm { DFTElementState DFTState::getElementState(size_t id) const { return static_cast(getElementStateInt(id)); } + + template + DFTElementState DFTState::getElementState(storm::storage::BitVector const& state, DFTStateGenerationInfo const& stateGenerationInfo, size_t id) { + return static_cast(DFTState::getElementStateInt(state, stateGenerationInfo, id)); + } template DFTDependencyState DFTState::getDependencyState(size_t id) const { return static_cast(getElementStateInt(id)); } + template + DFTDependencyState DFTState::getDependencyState(storm::storage::BitVector const& state, DFTStateGenerationInfo const& stateGenerationInfo, size_t id) { + return static_cast(DFTState::getElementStateInt(state, stateGenerationInfo, id)); + } + template int DFTState::getElementStateInt(size_t id) const { return mStatus.getAsInt(mStateGenerationInfo.getStateIndex(id), 2); } template - int DFTState::getElementStateInt(storm::storage::BitVector const& state, size_t indexId) { - return state.getAsInt(indexId, 2); + int DFTState::getElementStateInt(storm::storage::BitVector const& state, DFTStateGenerationInfo const& stateGenerationInfo, size_t id) { + return state.getAsInt(stateGenerationInfo.getStateIndex(id), 2); } template diff --git a/src/storm-dft/storage/dft/DFTState.h b/src/storm-dft/storage/dft/DFTState.h index 97048fd2d..3718e7627 100644 --- a/src/storm-dft/storage/dft/DFTState.h +++ b/src/storm-dft/storage/dft/DFTState.h @@ -152,13 +152,13 @@ namespace storm { std::shared_ptr> copy() const; DFTElementState getElementState(size_t id) const; - + + static DFTElementState getElementState(storm::storage::BitVector const& state, DFTStateGenerationInfo const& stateGenerationInfo, size_t id); + DFTDependencyState getDependencyState(size_t id) const; - int getElementStateInt(size_t id) const; + static DFTDependencyState getDependencyState(storm::storage::BitVector const& state, DFTStateGenerationInfo const& stateGenerationInfo, size_t id); - static int getElementStateInt(storm::storage::BitVector const& state, size_t indexId); - size_t getId() const; void setId(size_t id); @@ -372,6 +372,10 @@ namespace storm { private: void propagateActivation(size_t representativeId); + int getElementStateInt(size_t id) const; + + static int getElementStateInt(storm::storage::BitVector const& state, DFTStateGenerationInfo const& stateGenerationInfo, size_t id); + }; }