refactoring

This commit is contained in:
Jonas Zeunert
2018-05-06 19:26:59 +02:00
parent 20b5be8bfa
commit c2fb59139b
5 changed files with 39 additions and 38 deletions

View File

@@ -13,12 +13,34 @@
namespace Input
{
class InputEventHandler
{
class Detector
{
public:
virtual ~InputEventHandler(){};
void register_input_event_handler(InputEventHandler* handler);
void unregister_input_event_handler(InputEventHandler* handler);
};
public:
InputEventHandler(std::shared_ptr<Detector> detector) :
detector(detector)
{
this->detector->register_input_event_handler(this);
}
virtual ~InputEventHandler()
{
this->detector->unregister_input_event_handler(this);
this->detector = NULL;
}
virtual void handle(InputEvent& event) = 0;
private:
std::shared_ptr<Detector> detector;
};
}