2016-10-20 13:12:15 +00:00
|
|
|
#ifndef EVENT_H__
|
|
|
|
#define EVENT_H__
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include <boost/asio.hpp>
|
|
|
|
|
|
|
|
typedef std::map<std::string, std::string> EventType;
|
|
|
|
|
|
|
|
namespace i2p
|
|
|
|
{
|
2016-11-01 14:26:40 +00:00
|
|
|
namespace event
|
|
|
|
{
|
|
|
|
class EventListener {
|
|
|
|
public:
|
|
|
|
virtual ~EventListener() {};
|
|
|
|
virtual void HandleEvent(const EventType & ev) = 0;
|
|
|
|
};
|
2016-10-20 13:12:15 +00:00
|
|
|
|
2016-11-01 14:26:40 +00:00
|
|
|
class EventCore
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void QueueEvent(const EventType & ev);
|
|
|
|
void SetListener(EventListener * l);
|
|
|
|
|
|
|
|
private:
|
|
|
|
EventListener * m_listener = nullptr;
|
|
|
|
};
|
2016-11-01 17:57:25 +00:00
|
|
|
#ifdef WITH_EVENTS
|
2016-11-01 14:26:40 +00:00
|
|
|
extern EventCore core;
|
2016-11-01 17:57:25 +00:00
|
|
|
#endif
|
2016-11-01 14:26:40 +00:00
|
|
|
}
|
2016-10-20 13:12:15 +00:00
|
|
|
}
|
|
|
|
void EmitEvent(const EventType & ev);
|
|
|
|
|
|
|
|
#endif
|