/* * Module.h * * Created on: 04.01.2013 * Author: Christian Dehnert */ #ifndef STORM_IR_MODULE_H_ #define STORM_IR_MODULE_H_ #include "BooleanVariable.h" #include "IntegerVariable.h" #include "expressions/VariableExpression.h" #include "Command.h" #include #include #include #include #include namespace storm { namespace ir { struct VariableAdder { virtual uint_fast64_t addIntegerVariable(const std::string& name, const std::shared_ptr lower, const std::shared_ptr upper) = 0; virtual uint_fast64_t addBooleanVariable(const std::string& name) = 0; virtual std::shared_ptr getVariable(const std::string& name) = 0; virtual void performRenaming(const std::map& renaming) = 0; }; /*! * A class representing a module. */ class Module { public: /*! * Default constructor. Creates an empty module. */ Module(); /*! * Creates a module with the given name, variables and commands. * @param moduleName the name of the module. * @param booleanVariables a map of boolean variables. * @param integerVariables a map of integer variables. * @param commands the vector of commands. */ Module(std::string moduleName, std::vector booleanVariables, std::vector integerVariables, std::map booleanVariableToIndexMap, std::map integerVariableToIndexMap, std::vector commands); typedef uint_fast64_t (*addIntegerVariablePtr)(const std::string& name, const std::shared_ptr lower, const std::shared_ptr upper, const std::shared_ptr init); typedef uint_fast64_t (*addBooleanVariablePtr)(const std::string& name, const std::shared_ptr init); /*! * Special copy constructor, implementing the module renaming functionality. * This will create a new module having all identifier renamed according to the given map. * @param module Module to be copied. * @param moduleName Name of the new module. * @param renaming Renaming map. */ Module(const Module& module, const std::string& moduleName, const std::map& renaming, std::shared_ptr adder); /*! * Retrieves the number of boolean variables in the module. * @returns the number of boolean variables in the module. */ uint_fast64_t getNumberOfBooleanVariables() const; /*! * Retrieves a reference to the boolean variable with the given index. * @returns a reference to the boolean variable with the given index. */ storm::ir::BooleanVariable const& getBooleanVariable(uint_fast64_t index) const; /*! * Retrieves the number of integer variables in the module. * @returns the number of integer variables in the module. */ uint_fast64_t getNumberOfIntegerVariables() const; /*! * Retrieves a reference to the integer variable with the given index. * @returns a reference to the integer variable with the given index. */ storm::ir::IntegerVariable const& getIntegerVariable(uint_fast64_t index) const; /*! * Retrieves the number of commands of this module. * @returns the number of commands of this module. */ uint_fast64_t getNumberOfCommands() const; /*! * Retrieves the index of the boolean variable with the given name. * @param variableName the name of the variable whose index to retrieve. * @returns the index of the boolean variable with the given name. */ uint_fast64_t getBooleanVariableIndex(std::string variableName) const; /*! * Retrieves the index of the integer variable with the given name. * @param variableName the name of the variable whose index to retrieve. * @returns the index of the integer variable with the given name. */ uint_fast64_t getIntegerVariableIndex(std::string variableName) const; /*! * Retrieves a reference to the command with the given index. * @returns a reference to the command with the given index. */ storm::ir::Command const getCommand(uint_fast64_t index) const; /*! * Retrieves a string representation of this variable. * @returns a string representation of this variable. */ std::string toString() const; /*! * Retrieves the set of actions present in this module. * @returns the set of actions present in this module. */ std::set const& getActions() const; /*! * Retrieves the indices of all commands within this module that are labelled * by the given action. * @param action Name of the action. * @returns Indices of all matching commands. */ std::shared_ptr> const getCommandsByAction(std::string const& action) const; private: void collectActions(); // The name of the module. std::string moduleName; // A list of boolean variables. std::vector booleanVariables; // A list of integer variables. std::vector integerVariables; // A map of boolean variable names to their index. std::map booleanVariablesToIndexMap; // A map of integer variable names to their details. std::map integerVariablesToIndexMap; // The commands associated with the module. std::vector commands; // The set of actions present in this module. std::set actions; // A map of actions to the set of commands labeled with this action. std::map>> actionsToCommandIndexMap; }; } // namespace ir } // namespace storm #endif /* STORM_IR_MODULE_H_ */