GossipNewsAgency.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-11-27
  6. * Changed: 2023-05-16
  7. *
  8. * */
  9. #include "GossipNewsAgency.hpp"
  10. #include <ls-std/ls-std-event.hpp>
  11. using ls::std::core::Class;
  12. using ls::std::event::Event;
  13. using std::string;
  14. using test::event::GossipNewsAgency;
  15. using test::event::NewsAgency;
  16. GossipNewsAgency::GossipNewsAgency() : NewsAgency("GossipNewsAgency")
  17. {}
  18. GossipNewsAgency::~GossipNewsAgency() noexcept = default;
  19. void GossipNewsAgency::listen(const Class &_info)
  20. {
  21. Event event = dynamic_cast<const Event &>(_info);
  22. if (event.getId() == "SeriousNewsEvent")
  23. {
  24. this->news = this->getName() + ": " + event.getParameterList().at("news");
  25. }
  26. if (event.getId() == "GossipNewsEvent")
  27. {
  28. this->news = this->getName() + ": " + event.getParameterList().at("news");
  29. }
  30. }
  31. void GossipNewsAgency::clear()
  32. {
  33. this->news.clear();
  34. }
  35. string GossipNewsAgency::getNews() const
  36. {
  37. return this->news;
  38. }