DailyNewsAgency.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-11-27
  6. * Changed: 2020-11-27
  7. *
  8. * */
  9. #ifndef LS_STD_DAILY_NEWS_AGENCY_HPP
  10. #define LS_STD_DAILY_NEWS_AGENCY_HPP
  11. #include <string>
  12. #include <memory>
  13. #include <map>
  14. #include <ls_std/ls_std.hpp>
  15. #include "NewsAgency.hpp"
  16. namespace ls_std_test {
  17. class DailyNewsAgency : public ls_std_test::NewsAgency, public ls_std::IEventSubscriber, public ls_std::IListener, public std::enable_shared_from_this<ls_std_test::DailyNewsAgency> {
  18. public:
  19. DailyNewsAgency();
  20. ~DailyNewsAgency() override = default;
  21. // implementation
  22. void clear();
  23. std::string getNews();
  24. void listen(const ls_std::Class& _info) override;
  25. void subscribe(const ls_std::event_id& _id) override;
  26. void unsubscribe(const ls_std::event_id& _id) override;
  27. // additional functionality
  28. void addEventHandler(const std::shared_ptr<ls_std::EventHandler>& _eventHandler);
  29. private:
  30. std::map<ls_std::event_id, std::shared_ptr<ls_std::EventHandler>> eventHandlers {};
  31. std::string news {};
  32. };
  33. }
  34. #endif