WIP: Work done on EventBus
This commit is contained in:
1 parent
1dd457d2d2
commit
3be9e64f7e
6 files changed
+67
-22
No files matched your search
@@ -2,23 +2,45 @@
|
||||
#define EVENT_BUS_HPP
|
||||
#include "Logger.hpp"
|
||||
#include <thread>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Plains {
|
||||
namespace Core {
|
||||
|
||||
using std::thread;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
class EventSubscriber {
|
||||
public:
|
||||
virtual void callback() = 0;
|
||||
};
|
||||
|
||||
class Event {
|
||||
public:
|
||||
Event(const string _id);
|
||||
string& getID() const;
|
||||
void fire();
|
||||
void subscribe(EventSubscriber* es);
|
||||
|
||||
private:
|
||||
const string _id;
|
||||
vector<EventSubscriber*> _subscribers;
|
||||
};
|
||||
|
||||
class EventBus {
|
||||
private:
|
||||
Logger& _logger;
|
||||
//thread* _thread
|
||||
thread _thread;
|
||||
|
||||
public:
|
||||
EventBus(Logger& logger);
|
||||
~EventBus();
|
||||
void test();
|
||||
Event* registerEvent(string eventID);
|
||||
Event* getEvent(const string& eventID);
|
||||
|
||||
private:
|
||||
Logger& _logger;
|
||||
thread _thread;
|
||||
vector<Event*> _events;
|
||||
|
||||
void run();
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user