GossipNewsAgency.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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-29
  7. *
  8. * */
  9. #include "GossipNewsAgency.hpp"
  10. ls_std_test::GossipNewsAgency::GossipNewsAgency() : ls_std_test::NewsAgency("GossipNewsAgency")
  11. {}
  12. void ls_std_test::GossipNewsAgency::clear()
  13. {
  14. this->news.clear();
  15. }
  16. std::string ls_std_test::GossipNewsAgency::getNews()
  17. {
  18. return this->news;
  19. }
  20. void ls_std_test::GossipNewsAgency::listen(const ls_std::Class &_info)
  21. {
  22. ls_std::Event event = dynamic_cast<const ls_std::Event&>(_info);
  23. if(event.getId() == "SeriousNewsEvent") {
  24. this->news = this->getName() + ": " + event.getParameterList().at("news");
  25. }
  26. if(event.getId() == "GossipNewsEvent") {
  27. this->news = this->getName() + ": " + event.getParameterList().at("news");
  28. }
  29. }
  30. void ls_std_test::GossipNewsAgency::addEventHandler(const std::shared_ptr<ls_std::EventHandler> &_eventHandler)
  31. {
  32. // TODO: check event handler existence
  33. std::pair<ls_std::event_id, std::shared_ptr<ls_std::EventHandler>> entry = std::make_pair(_eventHandler->getId(), _eventHandler);
  34. this->eventHandlers.insert(entry);
  35. }