State.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-09-05
  6. * Changed: 2021-04-23
  7. *
  8. * */
  9. #ifndef LS_STD_STATE_HPP
  10. #define LS_STD_STATE_HPP
  11. #include <memory>
  12. #include <unordered_map>
  13. #include <ls_std/base/Class.hpp>
  14. #include "StateMachineTypes.hpp"
  15. #include "StateConnection.hpp"
  16. namespace ls_std
  17. {
  18. class State : public ls_std::Class
  19. {
  20. public:
  21. explicit State(ls_std::StateId _id);
  22. ~State() override = default;
  23. bool addStateConnection(const ls_std::StateConnectionId &_connectionId, const std::shared_ptr<ls_std::State> &_connectedState);
  24. bool addStateConnection(const std::shared_ptr<ls_std::StateConnection> &_connection);
  25. void clearConnections();
  26. std::unordered_map<ls_std::StateConnectionId, std::shared_ptr<ls_std::StateConnection>> getConnectedStates();
  27. ls_std::StateId getId();
  28. bool hasConnection(const ls_std::StateConnectionId &_connectionId);
  29. void setId(ls_std::StateId _id);
  30. private:
  31. std::unordered_map<ls_std::StateConnectionId, std::shared_ptr<ls_std::StateConnection>> connectedStates{};
  32. ls_std::StateId id{};
  33. void _clearConnections();
  34. bool _hasConnection(const ls_std::StateConnectionId &_connectionId);
  35. };
  36. }
  37. #endif