EventManager.hpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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_EVENT_MANAGER_HPP
  10. #define LS_STD_EVENT_MANAGER_HPP
  11. #include <ls_std/base/Class.hpp>
  12. #include <map>
  13. #include <ls_std/event/EventTypes.hpp>
  14. #include <memory>
  15. #include "EventHandler.hpp"
  16. namespace ls_std {
  17. class EventManager : public ls_std::Class {
  18. public:
  19. explicit EventManager();
  20. ~EventManager() override = default;
  21. void addEventHandler(const std::shared_ptr<ls_std::EventHandler>& _eventHandler);
  22. void fire(ls_std::Event _event);
  23. void removeEventHandler(const std::shared_ptr<ls_std::EventHandler>& _eventHandler);
  24. private:
  25. std::map<ls_std::event_id, std::shared_ptr<ls_std::EventHandler>> eventHandlers {};
  26. bool _hasEventHandler(const ls_std::event_id& _id);
  27. void _removeEventHandler(const std::shared_ptr<ls_std::EventHandler>& _eventHandler);
  28. };
  29. }
  30. #endif