State.hpp 1.2 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-06
  7. *
  8. * */
  9. #ifndef LS_STD_STATE_HPP
  10. #define LS_STD_STATE_HPP
  11. #include <memory>
  12. #include <unordered_map>
  13. #include "../../../include/base/Class.hpp"
  14. #include "StateMachineTypes.hpp"
  15. #include "StateConnection.hpp"
  16. namespace ls_std {
  17. class State : public Class {
  18. public:
  19. explicit State(StateId _id);
  20. ~State() = default;
  21. bool addStateConnection(const StateConnectionId& _connectionId, const std::shared_ptr<State>& _connectedState);
  22. bool addStateConnection(const std::shared_ptr<StateConnection>& _connection);
  23. void clearConnections();
  24. std::unordered_map<StateConnectionId, std::shared_ptr<StateConnection>> getConnectedStates();
  25. StateId getId();
  26. bool hasConnection(const StateConnectionId& _connectionId);
  27. void setId(StateId _id);
  28. private:
  29. std::unordered_map<StateConnectionId, std::shared_ptr<StateConnection>> connectedStates {};
  30. StateId id {};
  31. void _clearConnections();
  32. bool _hasConnection(const StateConnectionId& _connectionId);
  33. };
  34. }
  35. #endif