State.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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-01
  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
  19. {
  20. namespace std
  21. {
  22. namespace logic
  23. {
  24. class DYNAMIC_GOAL State : public ls::std::core::Class
  25. {
  26. public:
  27. explicit State(const ls::std::core::type::state_id &_id);
  28. ~State() override = default;
  29. // additional functionality
  30. bool addStateConnection(const ls::std::core::type::state_connection_id &_connectionId, const ::std::shared_ptr<ls::std::logic::State> &_connectedState);
  31. bool addStateConnection(const ::std::shared_ptr<ls::std::logic::StateConnection> &_connection);
  32. void clearConnections();
  33. ::std::unordered_map<ls::std::core::type::state_connection_id, ::std::shared_ptr<ls::std::logic::StateConnection>> getConnectedStates();
  34. ls::std::core::type::state_id getId();
  35. bool hasConnection(const ls::std::core::type::state_connection_id &_connectionId);
  36. void setId(const ls::std::core::type::state_id &_id);
  37. private:
  38. ::std::unordered_map<ls::std::core::type::state_connection_id, ::std::shared_ptr<ls::std::logic::StateConnection>> connectedStates{};
  39. ls::std::core::type::state_id id{};
  40. void _assignStateId(const ls::std::core::type::state_id &_id);
  41. void _clearConnections();
  42. bool _hasConnection(const ls::std::core::type::state_connection_id &_connectionId);
  43. };
  44. }
  45. }
  46. }
  47. #endif