You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.1 KiB
75 lines
2.1 KiB
/*
|
|
* Command.cpp
|
|
*
|
|
* Created on: 12.01.2013
|
|
* Author: Christian Dehnert
|
|
*/
|
|
|
|
#include "Command.h"
|
|
|
|
#include <sstream>
|
|
#include <iostream>
|
|
|
|
namespace storm {
|
|
|
|
namespace ir {
|
|
|
|
// Initializes all members with their default constructors.
|
|
Command::Command() : actionName(), guardExpression(), updates() {
|
|
// Nothing to do here.
|
|
}
|
|
|
|
// Initializes all members according to the given values.
|
|
Command::Command(std::string actionName, std::shared_ptr<storm::ir::expressions::BaseExpression> guardExpression, std::vector<std::shared_ptr<storm::ir::Update>> updates)
|
|
: actionName(actionName), guardExpression(guardExpression), updates(updates) {
|
|
// Nothing to do here.
|
|
}
|
|
|
|
Command::Command(const Command& cmd, const std::map<std::string, std::string>& renaming, const std::map<std::string,uint_fast64_t>& bools, const std::map<std::string,uint_fast64_t>& ints)
|
|
: actionName(cmd.actionName), guardExpression(cmd.guardExpression->clone(renaming, bools, ints)) {
|
|
if (renaming.count(this->actionName) > 0) {
|
|
this->actionName = renaming.at(this->actionName);
|
|
}
|
|
this->updates.reserve(cmd.updates.size());
|
|
for (std::shared_ptr<Update> u : cmd.updates) {
|
|
this->updates.emplace_back(new Update(*u, renaming, bools, ints));
|
|
}
|
|
}
|
|
|
|
// Return the action name.
|
|
std::string const& Command::getActionName() const {
|
|
return this->actionName;
|
|
}
|
|
|
|
// Return the expression for the guard.
|
|
std::shared_ptr<storm::ir::expressions::BaseExpression> const& Command::getGuard() const {
|
|
return guardExpression;
|
|
}
|
|
|
|
// Return the number of updates.
|
|
uint_fast64_t Command::getNumberOfUpdates() const {
|
|
return this->updates.size();
|
|
}
|
|
|
|
// Return the requested update.
|
|
std::shared_ptr<storm::ir::Update> const& Command::getUpdate(uint_fast64_t index) const {
|
|
return this->updates[index];
|
|
}
|
|
|
|
// Build a string representation of the command.
|
|
std::string Command::toString() const {
|
|
std::stringstream result;
|
|
result << "[" << actionName << "] " << guardExpression->toString() << " -> ";
|
|
for (uint_fast64_t i = 0; i < updates.size(); ++i) {
|
|
result << updates[i]->toString();
|
|
if (i < updates.size() - 1) {
|
|
result << " + ";
|
|
}
|
|
}
|
|
result << ";";
|
|
return result.str();
|
|
}
|
|
|
|
} // namespace ir
|
|
|
|
} // namespace storm
|