EventListener.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2024-05-16
  6. * Changed: 2024-05-17
  7. *
  8. * */
  9. #ifndef LS_STD_EVENT_LISTENER_HPP
  10. #define LS_STD_EVENT_LISTENER_HPP
  11. #include "Event.hpp"
  12. #include <ls-std/core/Class.hpp>
  13. #include <ls-std/event/type/EventTypes.hpp>
  14. #include <ls-std/os/dynamic-goal.hpp>
  15. namespace ls::std::event
  16. {
  17. class LS_STD_DYNAMIC_GOAL EventListener : public ::std::enable_shared_from_this<EventListener>, public ls::std::core::Class
  18. {
  19. public:
  20. explicit EventListener();
  21. ~EventListener() noexcept override;
  22. [[nodiscard]] ls::std::event::type::listener_id getId() const;
  23. void setId(ls::std::event::type::listener_id _id);
  24. [[maybe_unused]] bool subscribe(const ls::std::event::Event &_event, const ls::std::event::type::event_action &_action);
  25. private:
  26. ls::std::event::type::listener_id id{};
  27. void _requestListenerId(const ::std::shared_ptr<ls::std::core::Class> &_manager);
  28. [[nodiscard]] bool _subscribe(const ls::std::event::Event &_event, const ls::std::event::type::event_action &_action);
  29. };
  30. }
  31. #endif