refactored everything

This commit is contained in:
Johannes Wendel
2018-11-09 01:16:35 +01:00
parent c53b6af33e
commit 3ea37e4e53
70 changed files with 202 additions and 177 deletions

View File

@@ -12,9 +12,9 @@
#include "utility/config.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
Detector::Detector(std::unique_ptr<utility::IInputGPIOInterface> input_gpio_interface, std::vector<std::shared_ptr<DistributingEvent>> events) :

View File

@@ -25,9 +25,9 @@
#include "DistributingEvent.h"
#include "IEventNotifier.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
class Detector : public IDetector

View File

@@ -4,7 +4,7 @@
#include "DistributingEvent.h"
FlippR_Driver::Input::DistributingEvent::DistributingEvent(char address, int priority, std::string name,
flippR_driver::input::DistributingEvent::DistributingEvent(char address, int priority, std::string name,
std::chrono::milliseconds bounce_time, std::shared_ptr<IEventNotifier> event_notifier):
Event(address, priority, name),
bounce_time(bounce_time),
@@ -12,12 +12,12 @@ FlippR_Driver::Input::DistributingEvent::DistributingEvent(char address, int pri
activation_state(NOT_ACTIVATED)
{}
void FlippR_Driver::Input::DistributingEvent::distribute()
void flippR_driver::input::DistributingEvent::distribute()
{
event_notifier->distribute_event(*this);
}
void FlippR_Driver::Input::DistributingEvent::active()
void flippR_driver::input::DistributingEvent::active()
{
if(!is_bouncing())
{
@@ -35,7 +35,7 @@ void FlippR_Driver::Input::DistributingEvent::active()
}
}
bool FlippR_Driver::Input::DistributingEvent::is_bouncing()
bool flippR_driver::input::DistributingEvent::is_bouncing()
{
std::chrono::time_point<std::chrono::high_resolution_clock> now = std::chrono::high_resolution_clock::now();
std::chrono::milliseconds elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(now - last_activation);
@@ -43,7 +43,7 @@ bool FlippR_Driver::Input::DistributingEvent::is_bouncing()
return elapsed_time < bounce_time;
}
void FlippR_Driver::Input::DistributingEvent::inactive()
void flippR_driver::input::DistributingEvent::inactive()
{
if(activation_state == ACTIVATED)
{

View File

@@ -2,15 +2,15 @@
// Created by rhetenor on 21.09.18.
//
#ifndef FLIPPR_DRIVER_DISTRIBUTINGEVENT_H
#define FLIPPR_DRIVER_DISTRIBUTINGEVENT_H
#ifndef flippR_driver_DISTRIBUTINGEVENT_H
#define flippR_driver_DISTRIBUTINGEVENT_H
#include "Event.h"
#include "IEventNotifier.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
class DistributingEvent : public Event
{
@@ -45,4 +45,4 @@ private:
}
}
#endif //FLIPPR_DRIVER_DISTRIBUTINGEVENT_H
#endif //flippR_driver_DISTRIBUTINGEVENT_H

View File

@@ -10,8 +10,8 @@
#include "Event.h"
namespace FlippR_Driver {
namespace Input {
namespace flippR_driver {
namespace input {
class ErrorEvent : public Event
{

View File

@@ -8,16 +8,16 @@
#include "utility/config.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
// todo unsigned char address
Event::Event(char address, int priority, std::string name) :
address(address), priority(priority), name(name)
{
CLOG_IF(VLOG_IS_ON(HIGHEST_LOG_VERBOSITY), INFO, INPUT_LOGGER) << "Created event: " << name << ", address: " << address;
CLOG_IF(VLOG_IS_ON(0), INFO, INPUT_LOGGER) << "Created event: " << name << ", address: " << address;
}
bool operator==(const Event& left, const Event& right)

View File

@@ -7,9 +7,9 @@
#include "EventHandler.h"
#include "utility/config.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
EventHandler::EventHandler(std::shared_ptr<IInputDriver> input_driver) :

View File

@@ -11,9 +11,9 @@
#include "EventNotifier.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
EventNotifier::EventNotifier(utility::IBlockingQueue<Event>* queue) :

View File

@@ -21,9 +21,9 @@
#define HANDLER_TIMEOUT 2000
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
class EventNotifier : public IEventNotifier

View File

@@ -9,9 +9,9 @@
#define SRC_INPUT_IDETECTOR_H_
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
class IDetector

View File

@@ -12,9 +12,9 @@
#include "IEventHandler.h"
#include <memory>
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
class IEventNotifier

View File

@@ -10,9 +10,9 @@
#include <input/ErrorEvent.hpp>
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
InputDriver::InputDriver(std::shared_ptr<IEventNotifier> event_notifier, std::unique_ptr<IDetector> detector,

View File

@@ -13,9 +13,9 @@
#include "IInputDriver.h"
#include "IDetector.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
class InputDriver : public IInputDriver

View File

@@ -16,13 +16,13 @@
#include "EventNotifier.h"
using namespace nlohmann;
using namespace FlippR_Driver::utility;
using namespace flippR_driver::utility;
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
std::shared_ptr<IInputDriver> InputDriverFactory::get_InputDriver(std::istream &input_config_stream, std::istream &matrix_config_stream)
std::shared_ptr<IInputDriver> InputDriverFactory::get_InputDriver(std::istream &input_config_stream, std::istream &matrix_config_stream)
{
LoggerFactory::CreateInputLogger();
@@ -52,9 +52,9 @@ void InputDriverFactory::create_input_events(json matrix_config, std::vector<std
{
int global_bounce_time = matrix_config.at("global_bounce_time").get<json::number_integer_t>();
auto& event_array = matrix_config.at("input_matrix");
for (auto &json_event : event_array)
for (auto &json_event : event_array)
{
try
try
{
std::string name = json_event.at("name");
char address = json_event.at("address").get<json::number_integer_t>();
@@ -73,7 +73,7 @@ void InputDriverFactory::create_input_events(json matrix_config, std::vector<std
events.push_back(event_ptr);
name_event_map.emplace(name, event_ptr);
}
catch (json::exception &e)
catch (json::exception &e)
{
CLOG(ERROR, INPUT_LOGGER) << "Matrix config-file corrupted: " << e.what();
exit(EXIT_FAILURE);

View File

@@ -18,9 +18,9 @@
#include "json/json.hpp"
#include "IEventNotifier.h"
namespace FlippR_Driver
namespace flippR_driver
{
namespace Input
namespace input
{
class InputDriverFactory
{