#ifndef EVENT_BUS_HPP #define EVENT_BUS_HPP #include "Logger.hpp" #include #include #include #include #include namespace Plains { namespace Core { using std::thread; using std::string; using std::vector; using std::mutex; using std::unique_ptr; class EventSubscriber { public: virtual void callback() = 0; }; class Event { public: Event(const string _id); ~Event(); const string& getID() const; void fire(); void subscribe(EventSubscriber* es); private: const string _id; vector _subscribers; mutex _mutex; }; class EventBus { public: EventBus(Logger& logger); ~EventBus(); Event& registerEvent(const string& eventID); private: void run(); private: Logger& _logger; thread _thread; vector _events; mutex _mutex; }; }} #endif