trennen
This commit is contained in:
54
FlippR-Driver/src/input/EventHandler.h
Normal file
54
FlippR-Driver/src/input/EventHandler.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* InputEventHandler.h
|
||||
*
|
||||
* This interface must be implemented to be informed about input events.
|
||||
*
|
||||
* Please be aware that handle must be implemented thread safe!
|
||||
*
|
||||
* Created on: Apr 5, 2018
|
||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
|
||||
*/
|
||||
|
||||
#ifndef INPUTEVENTHANDLER_H_
|
||||
#define INPUTEVENTHANDLER_H_
|
||||
|
||||
#include "IInputDriver.h"
|
||||
|
||||
#include "../utilities/IEventHandler.h"
|
||||
#include "../utilities/config.h"
|
||||
#include "Event.h"
|
||||
|
||||
namespace Input
|
||||
{
|
||||
class EventHandler;
|
||||
|
||||
class EventHandler : public IEventHandler
|
||||
{
|
||||
public:
|
||||
EventHandler(std::shared_ptr<IInputDriver> input_driver) :
|
||||
input_driver(input_driver)
|
||||
{
|
||||
this->input_driver->register_event_handler(this);
|
||||
|
||||
CLOG(INFO, INPUT_LOGGER) << "Created EventHandler";
|
||||
}
|
||||
|
||||
virtual ~EventHandler()
|
||||
{
|
||||
this->input_driver->unregister_event_handler(this);
|
||||
this->input_driver = NULL;
|
||||
}
|
||||
|
||||
// This function is intended to be non pure, if it is called when the derived class doesn't exist anymore
|
||||
virtual void handle(Event& event)
|
||||
{
|
||||
CLOG(WARNING, INPUT_LOGGER) << "Called EventHandler parent class";
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<IInputDriver> input_driver;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* INPUTEVENTHANDLER_H_ */
|
||||
Reference in New Issue
Block a user