State.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-09-05
  6. * Changed: 2020-11-26
  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. class State : public ls_std::Class {
  18. public:
  19. explicit State(ls_std::StateId _id);
  20. ~State() override = default;
  21. bool addStateConnection(const ls_std::StateConnectionId& _connectionId, const std::shared_ptr<ls_std::State>& _connectedState);
  22. bool addStateConnection(const std::shared_ptr<ls_std::StateConnection>& _connection);
  23. void clearConnections();
  24. std::unordered_map<ls_std::StateConnectionId, std::shared_ptr<ls_std::StateConnection>> getConnectedStates();
  25. ls_std::StateId getId();
  26. bool hasConnection(const ls_std::StateConnectionId& _connectionId);
  27. void setId(ls_std::StateId _id);
  28. private:
  29. std::unordered_map<ls_std::StateConnectionId, std::shared_ptr<ls_std::StateConnection>> connectedStates {};
  30. ls_std::StateId id {};
  31. void _clearConnections();
  32. bool _hasConnection(const ls_std::StateConnectionId& _connectionId);
  33. };
  34. }
  35. #endif