State.hpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-09-05
  6. * Changed: 2020-09-15
  7. *
  8. * */
  9. #ifndef LS_STD_STATE_HPP
  10. #define LS_STD_STATE_HPP
  11. #include <memory>
  12. #include <unordered_map>
  13. #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. std::unordered_map<StateConnectionId, std::shared_ptr<StateConnection>> getConnectedStates();
  24. StateId getId();
  25. bool hasConnection(const StateConnectionId& _connectionId);
  26. void setId(StateId _id);
  27. private:
  28. std::unordered_map<StateConnectionId, std::shared_ptr<StateConnection>> connectedStates {};
  29. StateId id {};
  30. bool _hasConnection(const StateConnectionId& _connectionId);
  31. };
  32. }
  33. #endif