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.

124 lines
4.4 KiB

  1. #pragma once
  2. #include <cstdint>
  3. #include <string>
  4. #include <boost/optional.hpp>
  5. #include "storm/storage/expressions/Variable.h"
  6. #include "storm/storage/expressions/Expression.h"
  7. namespace storm {
  8. namespace jani {
  9. class BooleanVariable;
  10. class BoundedIntegerVariable;
  11. class UnboundedIntegerVariable;
  12. class RealVariable;
  13. class ArrayVariable;
  14. class ClockVariable;
  15. class Variable {
  16. public:
  17. /*!
  18. * Creates a new variable with initial value construct
  19. */
  20. Variable(std::string const& name, storm::expressions::Variable const& variable, storm::expressions::Expression const& init, bool transient = false);
  21. /*!
  22. * Creates a new variable without initial value construct.
  23. */
  24. Variable(std::string const& name, storm::expressions::Variable const& variable);
  25. virtual ~Variable();
  26. /*!
  27. * Clones the variable.
  28. */
  29. virtual std::unique_ptr<Variable> clone() const = 0;
  30. /*!
  31. * Retrieves the associated expression variable
  32. */
  33. storm::expressions::Variable const& getExpressionVariable() const;
  34. /*!
  35. * Sets the associated expression variable.
  36. */
  37. void setExpressionVariable(storm::expressions::Variable const& newVariable);
  38. /*!
  39. * Retrieves the name of the variable.
  40. */
  41. std::string const& getName() const;
  42. /*!
  43. * Sets the name of the variable.
  44. */
  45. void setName(std::string const& newName);
  46. /*!
  47. * Retrieves whether an initial expression is set.
  48. */
  49. bool hasInitExpression() const;
  50. /*!
  51. * Retrieves the initial expression
  52. * Should only be called if an initial expression is set for this variable.
  53. *
  54. * @see hasInitExpression()
  55. */
  56. storm::expressions::Expression const& getInitExpression() const;
  57. /*!
  58. * Sets the initial expression for this variable.
  59. */
  60. void setInitExpression(storm::expressions::Expression const& initialExpression);
  61. // Methods to determine the type of the variable.
  62. virtual bool isBooleanVariable() const;
  63. virtual bool isBoundedIntegerVariable() const;
  64. virtual bool isUnboundedIntegerVariable() const;
  65. virtual bool isRealVariable() const;
  66. virtual bool isArrayVariable() const;
  67. virtual bool isClockVariable() const;
  68. virtual bool isTransient() const;
  69. // Methods to get the variable as a different type.
  70. BooleanVariable& asBooleanVariable();
  71. BooleanVariable const& asBooleanVariable() const;
  72. BoundedIntegerVariable& asBoundedIntegerVariable();
  73. BoundedIntegerVariable const& asBoundedIntegerVariable() const;
  74. UnboundedIntegerVariable& asUnboundedIntegerVariable();
  75. UnboundedIntegerVariable const& asUnboundedIntegerVariable() const;
  76. RealVariable& asRealVariable();
  77. RealVariable const& asRealVariable() const;
  78. ArrayVariable& asArrayVariable();
  79. ArrayVariable const& asArrayVariable() const;
  80. ClockVariable& asClockVariable();
  81. ClockVariable const& asClockVariable() const;
  82. /*!
  83. * Substitutes all variables in all expressions according to the given substitution.
  84. */
  85. virtual void substitute(std::map<storm::expressions::Variable, storm::expressions::Expression> const& substitution);
  86. private:
  87. // The name of the variable.
  88. std::string name;
  89. // The expression variable associated with this variable.
  90. storm::expressions::Variable variable;
  91. /// Whether this is a transient variable.
  92. bool transient;
  93. /// Expression for initial values
  94. boost::optional<storm::expressions::Expression> init;
  95. };
  96. bool operator==(Variable const& lhs, Variable const& rhs);
  97. bool operator!=(Variable const& lhs, Variable const& rhs);
  98. }
  99. }