finished detector

This commit is contained in:
Jonas Zeunert
2018-04-27 00:50:48 +02:00
parent 18c43c1edd
commit a181f12d20
6 changed files with 0 additions and 203 deletions

View File

@@ -1,54 +0,0 @@
/*
* Detector.cpp
*
* Created on: Apr 5, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
*/
#include "Detector.h"
#include <iostream>
namespace Input
{
Detector::Detector(std::vector<InputEvent*> events) :
input_events(events), is_running(true)
{
detect_thread = std::thread(&Detector::detect, this);
}
Detector::~Detector()
{
is_running = false;
detect_thread.join();
}
void Detector::register_input_event_handler(InputEventHandler* handler)
{
event_handler.insert(handler);
}
void Detector::unregister_input_event_handler(InputEventHandler* handler)
{
event_handler.erase(handler);
}
void Detector::detect()
{
while(is_running)
{
std::cout << "hallo_thread\n";
}
}
void Detector::notify_handlers(InputEvent& event)
{
for(auto* handler : event_handler)
{
handler->handle(event);
}
}
}

View File

@@ -1,45 +0,0 @@
/*
* Detector.h
*
* Created on: Apr 5, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
*/
#ifndef DETECTOR_H_
#define DETECTOR_H_
#include <vector>
#include <thread>
#include "InputEvent.h"
namespace Input
{
class Detector
{
public:
Detector(std::vector<InputEvent*> events);
~Detector();
void register_input_event_handler(InputEventHandler* handler);
void unregister_input_event_handler(InputEventHandler* handler);
private:
void detect();
void notify_handlers(InputEvent& event);
private:
std::vector<InputEvent*> input_events;
std::set<InputEventHandler*> event_handler;
std::thread detect_thread;
bool is_running;
};
}
#endif /* DETECTOR_H_ */

View File

@@ -1,33 +0,0 @@
/*
* InputEvent.h
*
* Created on: Apr 5, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
*/
#ifndef INPUTEVENT_H_
#define INPUTEVENT_H_
#include <set>
#include <string>
#include "InputEventHandler.h"
namespace Input
{
class InputEvent
{
public:
InputEvent();
~InputEvent();
private:
char address;
std::string name;
};
}
#endif /* INPUTEVENT_H_ */

View File

@@ -1,26 +0,0 @@
/*
* InputEventHandler.h
*
* Created on: Apr 5, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
*/
#ifndef INPUTEVENTHANDLER_H_
#define INPUTEVENTHANDLER_H_
#include "InputEvent.h"
namespace Input
{
class InputEventHandler
{
public:
virtual ~InputEventHandler(){};
virtual void handle(InputEvent& event) = 0;
};
}
#endif /* INPUTEVENTHANDLER_H_ */

View File

@@ -1,33 +0,0 @@
/*
* InputFactory.h
*
* Created on: Apr 5, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
*/
#ifndef INPUTFACTORY_H_
#define INPUTFACTORY_H_
#include <vector>
#include "InputEvent.h"
namespace Input
{
class InputFactory
{
public:
InputFactory();
~InputFactory();
std::vector<InputEvent*> get_input_events();
private:
std::vector<InputEvent*> input_events;
};
}
#endif /* INPUTFACTORY_H_ */

View File

@@ -1,12 +0,0 @@
#include <vector>
#include "InputEvent.h"
#include "Detector.h"
#include <iostream>
int main()
{
Input::Detector(std::vector<Input::InputEvent*>());
std::printf("hallo");
return 0;
}