State.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-09-05
  6. * Changed: 2022-05-12
  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. namespace ls
  18. {
  19. namespace std
  20. {
  21. namespace logic
  22. {
  23. class State : public ls::std::core::Class
  24. {
  25. public:
  26. explicit State(const ls::std::core::type::state_id &_id);
  27. ~State() override = default;
  28. // additional functionality
  29. bool addStateConnection(const ls::std::core::type::state_connection_id &_connectionId, const ::std::shared_ptr<ls::std::logic::State> &_connectedState);
  30. bool addStateConnection(const ::std::shared_ptr<ls::std::logic::StateConnection> &_connection);
  31. void clearConnections();
  32. ::std::unordered_map<ls::std::core::type::state_connection_id, ::std::shared_ptr<ls::std::logic::StateConnection>> getConnectedStates();
  33. ls::std::core::type::state_id getId();
  34. bool hasConnection(const ls::std::core::type::state_connection_id &_connectionId);
  35. void setId(const ls::std::core::type::state_id &_id);
  36. private:
  37. ::std::unordered_map<ls::std::core::type::state_connection_id, ::std::shared_ptr<ls::std::logic::StateConnection>> connectedStates{};
  38. ls::std::core::type::state_id id{};
  39. void _assignStateId(const ls::std::core::type::state_id &_id);
  40. void _clearConnections();
  41. bool _hasConnection(const ls::std::core::type::state_connection_id &_connectionId);
  42. };
  43. }
  44. }
  45. }
  46. #endif