4 changed files with 133 additions and 49 deletions
-
47src/storm/storage/jani/traverser/AssignmentsFinder.cpp
-
29src/storm/storage/jani/traverser/AssignmentsFinder.h
-
70src/storm/storage/jani/traverser/JaniTraverser.cpp
-
36src/storm/storage/jani/traverser/JaniTraverser.h
@ -0,0 +1,47 @@ |
|||||
|
#include "storm/storage/jani/traverser/AssignmentsFinder.h"
|
||||
|
|
||||
|
|
||||
|
namespace storm { |
||||
|
namespace jani { |
||||
|
|
||||
|
AssignmentsFinder::ResultType AssignmentsFinder::find(Model const& model, Variable const& variable) { |
||||
|
ResultType res; |
||||
|
res.hasLocationAssignment = false; |
||||
|
res.hasEdgeAssignment = false; |
||||
|
res.hasEdgeDestinationAssignment = false; |
||||
|
JaniTraverser::traverse(model, std::make_pair(&variable, &res)); |
||||
|
return res; |
||||
|
} |
||||
|
|
||||
|
void AssignmentsFinder::traverse(Location const& location, boost::any const& data) const { |
||||
|
auto resVar = boost::any_cast<std::pair<Variable const*, ResultType*>>(data); |
||||
|
for (auto const& assignment : location.getAssignments()) { |
||||
|
if (assignment.getVariable() == *resVar.first) { |
||||
|
resVar.second->hasLocationAssignment = true; |
||||
|
} |
||||
|
} |
||||
|
JaniTraverser::traverse(location, data); |
||||
|
} |
||||
|
|
||||
|
void AssignmentsFinder::traverse(TemplateEdge const& templateEdge, boost::any const& data) const { |
||||
|
auto resVar = boost::any_cast<std::pair<Variable const*, ResultType*>>(data); |
||||
|
for (auto const& assignment : templateEdge.getAssignments()) { |
||||
|
if (assignment.getVariable() == *resVar.first) { |
||||
|
resVar.second->hasEdgeAssignment = true; |
||||
|
} |
||||
|
} |
||||
|
JaniTraverser::traverse(templateEdge, data); |
||||
|
} |
||||
|
|
||||
|
void AssignmentsFinder::traverse(TemplateEdgeDestination const& templateEdgeDestination, boost::any const& data) const { |
||||
|
auto resVar = boost::any_cast<std::pair<Variable const*, ResultType*>>(data); |
||||
|
for (auto const& assignment : templateEdgeDestination.getOrderedAssignments()) { |
||||
|
if (assignment.getVariable() == *resVar.first) { |
||||
|
resVar.second->hasEdgeDestinationAssignment = true; |
||||
|
} |
||||
|
} |
||||
|
JaniTraverser::traverse(templateEdgeDestination, data); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
@ -0,0 +1,29 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
|
||||
|
#include <boost/any.hpp> |
||||
|
|
||||
|
#include "storm/storage/jani/traverser/JaniTraverser.h" |
||||
|
|
||||
|
namespace storm { |
||||
|
namespace jani { |
||||
|
class AssignmentsFinder : public JaniTraverser { |
||||
|
public: |
||||
|
|
||||
|
struct ResultType { |
||||
|
bool hasLocationAssignment, hasEdgeAssignment, hasEdgeDestinationAssignment; |
||||
|
}; |
||||
|
|
||||
|
AssignmentsFinder() = default; |
||||
|
|
||||
|
ResultType find(Model const& model, Variable const& variable); |
||||
|
|
||||
|
virtual ~AssignmentsFinder() = default; |
||||
|
|
||||
|
virtual void traverse(Location const& location, boost::any const& data) const override; |
||||
|
virtual void traverse(TemplateEdge const& templateEdge, boost::any const& data) const override; |
||||
|
virtual void traverse(TemplateEdgeDestination const& templateEdgeDestination, boost::any const& data) const override; |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue