Narrator.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-11-14
  6. * Changed: 2024-05-24
  7. *
  8. * */
  9. #ifndef LS_STD_NARRATOR_HPP
  10. #define LS_STD_NARRATOR_HPP
  11. #include <list>
  12. #include <ls-std/core/Class.hpp>
  13. #include <ls-std/core/interface/IListener.hpp>
  14. #include <ls-std/os/dynamic-goal.hpp>
  15. #include <memory>
  16. /*
  17. * @class(name: 'Narrator', package: 'event')
  18. * */
  19. namespace ls::std::event
  20. {
  21. class LS_STD_DYNAMIC_GOAL Narrator : public ls::std::core::Class
  22. {
  23. public:
  24. Narrator();
  25. ~Narrator() noexcept override;
  26. bool addListener(const ::std::shared_ptr<ls::std::core::interface_type::IListener> &_listener); // nodiscard is optional here
  27. void clear();
  28. [[nodiscard]] ::std::list<::std::shared_ptr<ls::std::core::interface_type::IListener>> getListeners() const;
  29. bool removeListener(const ::std::shared_ptr<ls::std::core::interface_type::IListener> &_listener); // nodiscard is optional here
  30. void tell(const ls::std::core::Class &_info) const;
  31. private:
  32. ::std::list<::std::shared_ptr<ls::std::core::interface_type::IListener>> listeners{};
  33. [[nodiscard]] bool _hasListener(const ::std::shared_ptr<ls::std::core::interface_type::IListener> &_listener);
  34. };
  35. }
  36. #endif