/*
 * EventHandler.h
 *
 *  Created on: Jun 13, 2018
 *      Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
 */

#ifndef SRC_IEVENTHANDLER_H_
#define SRC_IEVENTHANDLER_H_

#include "input/Event.h"
#include "InputDriver.h"

#include <memory>

namespace flippR_driver
{
namespace input
{

class EventHandler
{
public:
  explicit EventHandler(std::shared_ptr<InputDriver> input_driver) :
  input_driver(std::move(input_driver))
  {
    this->input_driver->register_event_handler(std::shared_ptr<EventHandler>(this));
  }

  virtual ~EventHandler()
  {
    this->input_driver->unregister_event_handler(std::shared_ptr<EventHandler>(this));
  };

  virtual void handle(flippR_driver::input::Event &event) = 0;

private:
  const std::shared_ptr<InputDriver> input_driver;
};

}
}
#endif /* SRC_IEVENTHANDLER_H_ */
