EventListener.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. [[maybe_unused]] bool unsubscribe(const ls::std::event::Event &_event);
  26. private:
  27. ls::std::event::type::listener_id id{};
  28. void _requestListenerId(const ::std::shared_ptr<ls::std::core::Class> &_manager);
  29. [[nodiscard]] bool _subscribe(const ls::std::event::Event &_event, const ls::std::event::type::event_action &_action);
  30. [[nodiscard]] bool _unsubscribe(const ls::std::event::Event &_event);
  31. };
  32. }
  33. #endif