State.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-09-05
  6. * Changed: 2022-07-15
  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/core/Class.hpp>
  14. #include <ls_std/core/types/StateMachineTypes.hpp>
  15. #include "StateConnection.hpp"
  16. #include <ls_std/core/interface/ISerializable.hpp>
  17. #include <ls_std/os/dynamic_goal.hpp>
  18. namespace ls::std::logic
  19. {
  20. class [[deprecated("consider using ls_game_tool_kit dependency instead!")]] LS_STD_DYNAMIC_GOAL State : public ls::std::core::Class
  21. {
  22. public:
  23. explicit State(const ls::std::core::type::state_id &_id);
  24. ~State() override = default;
  25. // additional functionality
  26. bool addStateConnection(const ls::std::core::type::state_connection_id &_connectionId, const ::std::shared_ptr<ls::std::logic::State> &_connectedState);
  27. bool addStateConnection(const ::std::shared_ptr<ls::std::logic::StateConnection> &_connection);
  28. void clearConnections();
  29. ::std::unordered_map<ls::std::core::type::state_connection_id, ::std::shared_ptr<ls::std::logic::StateConnection>> getConnectedStates();
  30. ls::std::core::type::state_id getId();
  31. bool hasConnection(const ls::std::core::type::state_connection_id &_connectionId);
  32. void setId(const ls::std::core::type::state_id &_id);
  33. private:
  34. ::std::unordered_map<ls::std::core::type::state_connection_id, ::std::shared_ptr<ls::std::logic::StateConnection>> connectedStates{};
  35. ls::std::core::type::state_id id{};
  36. void _assignStateId(const ls::std::core::type::state_id &_id);
  37. void _clearConnections();
  38. bool _hasConnection(const ls::std::core::type::state_connection_id &_connectionId);
  39. };
  40. }
  41. #endif