Narrator.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-11-14
  6. * Changed: 2023-02-22
  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. namespace ls::std::event
  17. {
  18. class LS_STD_DYNAMIC_GOAL Narrator : public ls::std::core::Class
  19. {
  20. public:
  21. Narrator();
  22. ~Narrator() noexcept override;
  23. bool addListener(const ::std::shared_ptr<ls::std::core::interface_type::IListener> &_listener); // nodiscard is optional here
  24. void clear();
  25. [[nodiscard]] ::std::list<::std::shared_ptr<ls::std::core::interface_type::IListener>> getListeners();
  26. bool removeListener(const ::std::shared_ptr<ls::std::core::interface_type::IListener> &_listener); // nodiscard is optional here
  27. void tell(const ls::std::core::Class &_info);
  28. private:
  29. ::std::list<::std::shared_ptr<ls::std::core::interface_type::IListener>> listeners{};
  30. [[nodiscard]] bool _hasListener(const ::std::shared_ptr<ls::std::core::interface_type::IListener> &_listener);
  31. };
  32. }
  33. #endif