11namespace expressions {
14 std::unordered_map<storm::expressions::Variable, std::string>
const& names,
ToCppTranslationMode mode)
15 : prefixes(prefixes), names(names), mode(mode) {
20 return prefixes.get();
32 expression.
accept(*
this, options);
33 std::string result = stream.str();
44 expression.
getCondition()->accept(*
this, conditionOptions);
127 stream <<
"std::min(";
134 stream <<
"std::max(";
141 stream <<
"std::pow(";
155 STORM_LOG_THROW(
false, storm::exceptions::NotSupportedException,
"Log expressions not implemented for C++ translation.");
211 std::unordered_map<storm::expressions::Variable, std::string>
const& names) {
212 auto prefixIt = prefixes.find(variable);
213 if (prefixIt != prefixes.end()) {
214 auto nameIt = names.find(variable);
215 if (nameIt != names.end()) {
216 return prefixIt->second + nameIt->second;
218 return prefixIt->second + variable.
getName();
221 auto nameIt = names.find(variable);
222 if (nameIt != names.end()) {
223 return nameIt->second;
236 stream << variableName;
240 stream << variableName;
243 stream <<
"static_cast<double>(" << variableName <<
")";
246 stream <<
"carl::rationalize<storm::RationalNumber>(" << variableName <<
")";
250 stream << variableName;
263 expression.
getOperand()->accept(*
this, newOptions);
280 "Floor is not supported by rational functions.");
282 stream <<
"std::floor";
284 stream <<
"carl::floor";
292 "Ceil is not supported by rational functions.");
294 stream <<
"std::ceil";
296 stream <<
"carl::ceil";
307 stream << std::boolalpha << expression.
getValue();
318 stream <<
"static_cast<double>(" << expression.
getValue() <<
")";
321 stream <<
"carl::rationalize<storm::RationalNumber>(\"" << expression.
getValue() <<
"\")";
324 stream <<
"storm::RationalFunction(carl::rationalize<storm::RationalNumber>(\"" << expression.
getValue() <<
"\"))";
334 stream <<
"(static_cast<double>(" << carl::getNum(expression.
getValue()) <<
")/" << carl::getDenom(expression.
getValue()) <<
")";
340 stream <<
"carl::rationalize<storm::RationalNumber>(\"" << expression.
getValue() <<
"\")";
343 stream <<
"storm::RationalFunction(carl::rationalize<storm::RationalNumber>(\"" << expression.
getValue() <<
"\"))";
OperatorType getOperatorType() const
Retrieves the operator associated with the expression.
std::shared_ptr< BaseExpression const > const & getSecondOperand() const
Retrieves the second operand of the expression.
std::shared_ptr< BaseExpression const > const & getFirstOperand() const
Retrieves the first operand of the expression.
OperatorType getOperatorType() const
Retrieves the operator associated with the expression.
RelationType getRelationType() const
Retrieves the relation associated with the expression.
bool getValue() const
Retrieves the value of the boolean literal.
boost::any accept(ExpressionVisitor &visitor, boost::any const &data) const
Accepts the given visitor.
std::shared_ptr< BaseExpression const > getElseExpression() const
Retrieves the else expression of the if-then-else expression.
std::shared_ptr< BaseExpression const > getCondition() const
Retrieves the condition expression of the if-then-else expression.
std::shared_ptr< BaseExpression const > getThenExpression() const
Retrieves the then expression of the if-then-else expression.
int_fast64_t getValue() const
Retrieves the value of the integer literal.
double getValueAsDouble() const
Retrieves the value of the double literal.
storm::RationalNumber getValue() const
Retrieves the value of the double literal.
ToCppTranslationOptions(std::unordered_map< storm::expressions::Variable, std::string > const &prefixes, std::unordered_map< storm::expressions::Variable, std::string > const &names, ToCppTranslationMode mode=ToCppTranslationMode::KeepType)
std::unordered_map< storm::expressions::Variable, std::string > const & getNames() const
std::unordered_map< storm::expressions::Variable, std::string > const & getPrefixes() const
ToCppTranslationMode const & getMode() const
virtual boost::any visit(IfThenElseExpression const &expression, boost::any const &data) override
std::string translate(storm::expressions::Expression const &expression, ToCppTranslationOptions const &options)
OperatorType getOperatorType() const
Retrieves the operator associated with this expression.
virtual std::shared_ptr< BaseExpression const > getOperand(uint_fast64_t operandIndex) const override
Retrieves the given operand from the expression.
OperatorType getOperatorType() const
Retrieves the operator associated with this expression.
Variable const & getVariable() const
Retrieves the variable associated with this expression.
bool hasBooleanType() const
Checks whether the variable is of boolean type.
std::string const & getName() const
Retrieves the name of the variable.
#define STORM_LOG_THROW(cond, exception, message)
std::string getVariableName(storm::expressions::Variable const &variable, std::unordered_map< storm::expressions::Variable, std::string > const &prefixes, std::unordered_map< storm::expressions::Variable, std::string > const &names)