reworked eventhandler
This commit is contained in:
@@ -9,6 +9,9 @@
|
||||
#define SRC_IEVENTHANDLER_H_
|
||||
|
||||
#include "input/Event.h"
|
||||
#include "InputDriver.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
@@ -18,9 +21,21 @@ namespace input
|
||||
class EventHandler
|
||||
{
|
||||
public:
|
||||
virtual ~EventHandler() = default;
|
||||
explicit EventHandler(std::shared_ptr<InputDriver> input_driver) :
|
||||
input_driver(std::move(input_driver))
|
||||
{
|
||||
this->input_driver->register_event_handler(this);
|
||||
}
|
||||
|
||||
virtual ~EventHandler()
|
||||
{
|
||||
this->input_driver->unregister_event_handler(this);
|
||||
};
|
||||
|
||||
virtual void handle(flippR_driver::input::Event &event) = 0;
|
||||
|
||||
private:
|
||||
const std::shared_ptr<InputDriver> input_driver;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user