reworked eventhandler

This commit is contained in:
Jonas Zeunert
2019-05-07 15:04:53 +02:00
parent 13815cc714
commit c32ce18841
7 changed files with 24 additions and 89 deletions

View File

@@ -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;
};
}

View File

@@ -8,17 +8,19 @@
#ifndef SRC_INPUT_IINPUTDRIVER_H_
#define SRC_INPUT_IINPUTDRIVER_H_
#include "Event.h"
#include <memory>
#include <boost/optional/optional_io.hpp>
#include "input/EventHandler.h"
namespace flippR_driver
{
namespace input
{
class EventHandler;
class InputDriver {
public:
virtual ~InputDriver() = default;