/* * Author: Patrick-Christopher Mattulat * Company: Lynar Studios * E-Mail: webmaster@lynarstudios.com * Created: 2020-09-05 * Changed: 2021-05-28 * * */ #ifndef LS_STD_STATE_HPP #define LS_STD_STATE_HPP #include #include #include #include "StateMachineTypes.hpp" #include "StateConnection.hpp" #include namespace ls_std { class State : public ls_std::Class, public ls_std::ISerializable { public: explicit State(const ls_std::StateId& _id); ~State() override = default; // implementation ls_std::byte_field marshal() override; void unmarshal(const ls_std::byte_field &_data) override; // additional functionality bool addStateConnection(const ls_std::StateConnectionId &_connectionId, const std::shared_ptr &_connectedState); bool addStateConnection(const std::shared_ptr &_connection); void clearConnections(); std::unordered_map> getConnectedStates(); ls_std::StateId getId(); bool hasConnection(const ls_std::StateConnectionId &_connectionId); void setId(const ls_std::StateId& _id); void setSerializable(const std::shared_ptr& _serializable); private: std::unordered_map> connectedStates{}; ls_std::StateId id{}; std::shared_ptr serializable{}; void _assignSerializable(const std::shared_ptr& _serializable); void _assignStateId(const ls_std::StateId& _id); void _clearConnections(); bool _hasConnection(const ls_std::StateConnectionId &_connectionId); }; } #endif