#pragma once #include #include #include #include #include #include "src/storage/jani/Composition.h" namespace storm { namespace jani { class SynchronizationVector { public: SynchronizationVector(std::vector const& input, std::string const& output); SynchronizationVector(std::vector const& input); std::size_t size() const; std::vector const& getInput() const; std::string const& getInput(uint64_t index) const; std::string const& getOutput() const; static bool isNoActionInput(std::string const& action); /*! * Retrieves the action name that is the last participating action before the given input index. If there is * no such action none is returned. */ boost::optional getPrecedingParticipatingAction(uint64_t index) const; /*! * Retrieves the position of the last participating action before the given input index. If there is * no such action none is returned. */ boost::optional getPositionOfPrecedingParticipatingAction(uint64_t index) const; /*! * Retrieves the position of the first participating action. */ uint64_t getPositionOfFirstParticipatingAction() const; /*! * Retrieves the number of action inputs, i.e. participating subcompositions. */ uint64_t getNumberOfActionInputs() const; // A marker that can be used as one of the inputs. The semantics is that no action of the corresponding // automaton takes part in the synchronization. static const std::string NO_ACTION_INPUT; private: /// The input to the synchronization. std::vector input; /// The output of the synchronization. std::string output; }; bool operator==(SynchronizationVector const& vector1, SynchronizationVector const& vector2); bool operator!=(SynchronizationVector const& vector1, SynchronizationVector const& vector2); struct SynchronizationVectorLexicographicalLess { bool operator()(SynchronizationVector const& vector1, SynchronizationVector const& vector2); }; std::ostream& operator<<(std::ostream& stream, SynchronizationVector const& synchronizationVector); class ParallelComposition : public Composition { public: /*! * Creates a parallel composition of the subcomposition and the provided synchronization vectors. */ ParallelComposition(std::shared_ptr const& subcomposition, std::vector const& synchronizationVectors); /*! * Creates a parallel composition of the subcompositions and the provided synchronization vectors. */ ParallelComposition(std::vector> const& subcompositions, std::vector const& synchronizationVectors); /*! * Creates a parallel composition of the subcompositions over the provided synchronization alphabet. */ ParallelComposition(std::vector> const& subcompositions, std::set const& synchronizationAlphabet); /*! * Creates a parallel composition of the subcompositions over the provided synchronization alphabet. */ ParallelComposition(std::shared_ptr const& leftSubcomposition, std::shared_ptr const& rightSubcomposition, std::set const& synchronizationAlphabet); virtual bool isParallelComposition() const override; /*! * Retrieves the subcomposition with the given index. */ Composition const& getSubcomposition(uint64_t index) const; /*! * Retrieves the subcompositions of the parallel composition. */ std::vector> const& getSubcompositions() const; /*! * Retrieves the number of subcompositions of this parallel composition. */ uint64_t getNumberOfSubcompositions() const; /*! * Retrieves the synchronization vector with the given index. */ SynchronizationVector const& getSynchronizationVector(uint64_t index) const; /*! * Retrieves the synchronization vectors of the parallel composition. */ std::vector const& getSynchronizationVectors() const; /*! * Retrieves the number of synchronization vectors. */ std::size_t getNumberOfSynchronizationVectors() const; virtual boost::any accept(CompositionVisitor& visitor, boost::any const& data) const override; virtual void write(std::ostream& stream) const override; private: /*! * Checks the synchronization vectors for validity. */ void checkSynchronizationVectors() const; /// The subcompositions. std::vector> subcompositions; /// The synchronization vectors of the parallel composition. std::vector synchronizationVectors; }; } }