Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
LabelSubstitutionVisitor.cpp
Go to the documentation of this file.
2#include <boost/any.hpp>
3
5
6namespace storm {
7namespace logic {
8
9LabelSubstitutionVisitor::LabelSubstitutionVisitor(std::map<std::string, storm::expressions::Expression> const& labelToExpressionMapping)
10 : labelToExpressionMapping(&labelToExpressionMapping), labelToLabelMapping(nullptr) {
11 // Intentionally left empty.
12}
13
14LabelSubstitutionVisitor::LabelSubstitutionVisitor(std::map<std::string, std::string> const& labelToLabelMapping)
15 : labelToExpressionMapping(nullptr), labelToLabelMapping(&labelToLabelMapping) {
16 // Intentionally left empty.
17}
18
19std::shared_ptr<Formula> LabelSubstitutionVisitor::substitute(Formula const& f) const {
20 boost::any result = f.accept(*this, boost::any());
21 return boost::any_cast<std::shared_ptr<Formula>>(result);
22}
23
24boost::any LabelSubstitutionVisitor::visit(AtomicLabelFormula const& f, boost::any const&) const {
25 if (labelToExpressionMapping) {
26 auto it = labelToExpressionMapping->find(f.getLabel());
27 if (it != labelToExpressionMapping->end()) {
28 return std::static_pointer_cast<Formula>(std::make_shared<AtomicExpressionFormula>(it->second));
29 } else {
30 return std::static_pointer_cast<Formula>(std::make_shared<AtomicLabelFormula>(f.getLabel()));
31 }
32 } else {
33 auto it = labelToLabelMapping->find(f.getLabel());
34 if (it != labelToLabelMapping->end()) {
35 return std::static_pointer_cast<Formula>(std::make_shared<AtomicLabelFormula>(it->second));
36 } else {
37 return std::static_pointer_cast<Formula>(std::make_shared<AtomicLabelFormula>(f.getLabel()));
38 }
39 }
40}
41} // namespace logic
42} // namespace storm
std::string const & getLabel() const
boost::any accept(FormulaVisitor const &visitor) const
Definition Formula.cpp:16
virtual boost::any visit(AtomicLabelFormula const &f, boost::any const &data) const override
LabelSubstitutionVisitor(std::map< std::string, storm::expressions::Expression > const &labelToExpressionMapping)
std::shared_ptr< Formula > substitute(Formula const &f) const
LabParser.cpp.
Definition cli.cpp:18