diff --git a/FlippR-Driver/cli/main.cpp b/FlippR-Driver/cli/main.cpp index 4d172fa..552140d 100644 --- a/FlippR-Driver/cli/main.cpp +++ b/FlippR-Driver/cli/main.cpp @@ -4,7 +4,7 @@ #include #include -#include "IInputDriverFactory.h" +#include "DriverFactory.h" #include "IInputDriver.h" int main (int argc, char *argv[]) @@ -28,5 +28,4 @@ int main (int argc, char *argv[]) - } diff --git a/FlippR-Driver/include/DriverFactory.h b/FlippR-Driver/include/DriverFactory.h new file mode 100644 index 0000000..29a00e8 --- /dev/null +++ b/FlippR-Driver/include/DriverFactory.h @@ -0,0 +1,18 @@ +// +// Created by rhetenor on 13.09.18. +// + +#ifndef FLIPPR_DRIVER_DRIVERFACTORY_H +#define FLIPPR_DRIVER_DRIVERFACTORY_H + +#include +#include + +#include "IInputDriver.h" + +namespace FlippR_Driver +{ + static std::shared_ptr get_InputDriver(std::istream& input_config_stream, std::istream& matrix_config_stream); +} + +#endif //FLIPPR_DRIVER_DRIVERFACTORY_H diff --git a/FlippR-Driver/include/Event.h b/FlippR-Driver/include/Event.h index 6e7a6a9..b2f4959 100644 --- a/FlippR-Driver/include/Event.h +++ b/FlippR-Driver/include/Event.h @@ -12,7 +12,7 @@ #include -namespace Input +namespace FlippR_Driver::Input { class Event diff --git a/FlippR-Driver/include/IEventHandler.h b/FlippR-Driver/include/IEventHandler.h index 594e0ca..18b9041 100644 --- a/FlippR-Driver/include/IEventHandler.h +++ b/FlippR-Driver/include/IEventHandler.h @@ -15,7 +15,7 @@ class IEventHandler public: virtual ~IEventHandler(){}; - virtual void handle(Input::Event& event) = 0; + virtual void handle(FlippR_Driver::Input::Event& event) = 0; }; #endif /* SRC_IEVENTHANDLER_H_ */ diff --git a/FlippR-Driver/include/IInputDriver.h b/FlippR-Driver/include/IInputDriver.h index 3cd4f84..6376ff5 100644 --- a/FlippR-Driver/include/IInputDriver.h +++ b/FlippR-Driver/include/IInputDriver.h @@ -11,7 +11,7 @@ #include "IEventHandler.h" #include -namespace Input { +namespace FlippR_Driver::Input { class IInputDriver { diff --git a/FlippR-Driver/include/IInputDriverFactory.h b/FlippR-Driver/include/IInputDriverFactory.h deleted file mode 100644 index 49ee81d..0000000 --- a/FlippR-Driver/include/IInputDriverFactory.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * IInputDriverFactory.h - * - * Created on: Jun 13, 2018 - * Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht - */ - -#ifndef SRC_INPUT_IINPUTDRIVERFACTORY_H_ -#define SRC_INPUT_IINPUTDRIVERFACTORY_H_ - -namespace Input { - -class IInputDriverFactory -{ - -}; -} - -#endif /* SRC_INPUT_IINPUTDRIVERFACTORY_H_ */ diff --git a/FlippR-Driver/src/DriverFactory.cpp b/FlippR-Driver/src/DriverFactory.cpp new file mode 100644 index 0000000..53c16c4 --- /dev/null +++ b/FlippR-Driver/src/DriverFactory.cpp @@ -0,0 +1,14 @@ +// +// Created by rhetenor on 13.09.18. +// + +#include "DriverFactory.h" +#include "input/InputDriverFactory.h" + +namespace FlippR_Driver +{ + static std::shared_ptr get_InputDriver(std::istream& input_config_stream, std::istream& matrix_config_stream) + { + return FlippR_Driver::Input::InputDriverFactory::get_InputDriver(input_config_stream, matrix_config_stream); + } +} \ No newline at end of file diff --git a/FlippR-Driver/src/input/Detector.cpp b/FlippR-Driver/src/input/Detector.cpp index 4aa99a5..c89f01b 100644 --- a/FlippR-Driver/src/input/Detector.cpp +++ b/FlippR-Driver/src/input/Detector.cpp @@ -12,7 +12,7 @@ #include "utilities/config.h" -namespace Input +namespace FlippR_Driver::Input { Detector::Detector(std::unique_ptr input_gpio_interface, std::map> events, std::shared_ptr event_notifier) : diff --git a/FlippR-Driver/src/input/Detector.h b/FlippR-Driver/src/input/Detector.h index 79d9d9b..3619724 100644 --- a/FlippR-Driver/src/input/Detector.h +++ b/FlippR-Driver/src/input/Detector.h @@ -24,7 +24,7 @@ #include "Event.h" #include "IEventNotifier.h" -namespace Input +namespace FlippR_Driver::Input { class Detector : public IDetector diff --git a/FlippR-Driver/src/input/ErrorEvent.hpp b/FlippR-Driver/src/input/ErrorEvent.hpp index 660746f..2918c65 100644 --- a/FlippR-Driver/src/input/ErrorEvent.hpp +++ b/FlippR-Driver/src/input/ErrorEvent.hpp @@ -10,7 +10,7 @@ #include "Event.h" -namespace Input +namespace FlippR_Driver::Input { class ErrorEvent : public Event diff --git a/FlippR-Driver/src/input/Event.cpp b/FlippR-Driver/src/input/Event.cpp index 825afda..c7df27b 100644 --- a/FlippR-Driver/src/input/Event.cpp +++ b/FlippR-Driver/src/input/Event.cpp @@ -8,7 +8,7 @@ #include "utilities/config.h" -namespace Input +namespace FlippR_Driver::Input { Event::Event(char address, int priority, std::string name) : diff --git a/FlippR-Driver/src/input/EventHandler.cpp b/FlippR-Driver/src/input/EventHandler.cpp index e9706d6..67ec5e1 100644 --- a/FlippR-Driver/src/input/EventHandler.cpp +++ b/FlippR-Driver/src/input/EventHandler.cpp @@ -6,7 +6,7 @@ */ #include "EventHandler.h" -namespace Input +namespace FlippR_Driver::Input { EventHandler::EventHandler(std::shared_ptr input_driver) : diff --git a/FlippR-Driver/src/input/EventHandler.h b/FlippR-Driver/src/input/EventHandler.h index b1d4328..e0d382f 100644 --- a/FlippR-Driver/src/input/EventHandler.h +++ b/FlippR-Driver/src/input/EventHandler.h @@ -18,7 +18,7 @@ #include "utilities/config.h" #include "Event.h" -namespace Input +namespace FlippR_Driver::Input { class EventHandler; diff --git a/FlippR-Driver/src/input/EventNotifier.cpp b/FlippR-Driver/src/input/EventNotifier.cpp index 1ce50b4..7db6cb7 100644 --- a/FlippR-Driver/src/input/EventNotifier.cpp +++ b/FlippR-Driver/src/input/EventNotifier.cpp @@ -11,7 +11,7 @@ #include "EventNotifier.h" -namespace Input +namespace FlippR_Driver::Input { EventNotifier::EventNotifier(IBlockingQueue* queue) : diff --git a/FlippR-Driver/src/input/EventNotifier.h b/FlippR-Driver/src/input/EventNotifier.h index eb11532..a9b2282 100644 --- a/FlippR-Driver/src/input/EventNotifier.h +++ b/FlippR-Driver/src/input/EventNotifier.h @@ -21,7 +21,7 @@ #define HANDLER_TIMEOUT 2000 -namespace Input +namespace FlippR_Driver::Input { class EventNotifier : public IEventNotifier diff --git a/FlippR-Driver/src/input/IDetector.h b/FlippR-Driver/src/input/IDetector.h index e0635c0..b31b310 100644 --- a/FlippR-Driver/src/input/IDetector.h +++ b/FlippR-Driver/src/input/IDetector.h @@ -9,7 +9,7 @@ #define SRC_INPUT_IDETECTOR_H_ -namespace Input +namespace FlippR_Driver::Input { class IDetector diff --git a/FlippR-Driver/src/input/IEventNotifier.h b/FlippR-Driver/src/input/IEventNotifier.h index c88c9cc..6d6ad3f 100644 --- a/FlippR-Driver/src/input/IEventNotifier.h +++ b/FlippR-Driver/src/input/IEventNotifier.h @@ -12,7 +12,7 @@ #include "IEventHandler.h" #include -namespace Input +namespace FlippR_Driver::Input { class IEventNotifier diff --git a/FlippR-Driver/src/input/InputDriver.cpp b/FlippR-Driver/src/input/InputDriver.cpp index 1e66546..411b8ec 100644 --- a/FlippR-Driver/src/input/InputDriver.cpp +++ b/FlippR-Driver/src/input/InputDriver.cpp @@ -7,7 +7,7 @@ #include #include "InputDriver.h" -namespace Input +namespace FlippR_Driver::Input { InputDriver::InputDriver(std::shared_ptr event_notifier, std::unique_ptr detector, std::map> events) : diff --git a/FlippR-Driver/src/input/InputDriver.h b/FlippR-Driver/src/input/InputDriver.h index 47d520e..a762e37 100644 --- a/FlippR-Driver/src/input/InputDriver.h +++ b/FlippR-Driver/src/input/InputDriver.h @@ -13,7 +13,7 @@ #include "IInputDriver.h" #include "IDetector.h" -namespace Input +namespace FlippR_Driver::Input { class InputDriver : public IInputDriver diff --git a/FlippR-Driver/src/input/InputDriverFactory.cpp b/FlippR-Driver/src/input/InputDriverFactory.cpp index 48aa6c1..d8612ae 100644 --- a/FlippR-Driver/src/input/InputDriverFactory.cpp +++ b/FlippR-Driver/src/input/InputDriverFactory.cpp @@ -7,16 +7,17 @@ #include "InputDriverFactory.h" +#include "InputDriver.h" #include "utilities/LoggerFactory.hpp" #include "EventNotifier.h" using namespace nlohmann; -namespace Input +namespace FlippR_Driver::Input { -std::shared_ptr InputDriverFactory::get_InputDriver(std::istream& input_config_stream, std::istream& matrix_config_stream) +std::shared_ptr InputDriverFactory::get_InputDriver(std::istream& input_config_stream, std::istream& matrix_config_stream) { LoggerFactory::CreateInputLogger(); diff --git a/FlippR-Driver/src/input/InputDriverFactory.h b/FlippR-Driver/src/input/InputDriverFactory.h index d8f670d..bb083dd 100644 --- a/FlippR-Driver/src/input/InputDriverFactory.h +++ b/FlippR-Driver/src/input/InputDriverFactory.h @@ -12,7 +12,7 @@ #include #include "Detector.h" -#include "InputDriver.h" +#include "IInputDriver.h" #include "utilities/InputGPIOInterface.h" #include "utilities/config.h" @@ -24,13 +24,13 @@ INITIALIZE_EASYLOGGINGPP -namespace Input +namespace FlippR_Driver::Input { class InputDriverFactory { public: - static std::shared_ptr get_InputDriver(std::istream& input_config_stream, std::istream& matrix_config_stream); + static std::shared_ptr get_InputDriver(std::istream& input_config_stream, std::istream& matrix_config_stream); private: static void create_input_events(nlohmann::json matrix_config, std::map> address_event_map, std::map> name_event_map); diff --git a/FlippR-Driver/tests/input/TestDetector.cpp b/FlippR-Driver/tests/input/TestDetector.cpp index 41298ab..651c78c 100644 --- a/FlippR-Driver/tests/input/TestDetector.cpp +++ b/FlippR-Driver/tests/input/TestDetector.cpp @@ -23,7 +23,7 @@ using namespace fakeit; -using namespace Input; +using namespace FlippR_Driver::Input; SCENARIO("Creating a Detector object", "") diff --git a/FlippR-Driver/tests/input/TestEventHandler.cpp b/FlippR-Driver/tests/input/TestEventHandler.cpp index 60062f1..6ceddbf 100644 --- a/FlippR-Driver/tests/input/TestEventHandler.cpp +++ b/FlippR-Driver/tests/input/TestEventHandler.cpp @@ -25,15 +25,15 @@ SCENARIO("An EventHandler gets created", "[construction}") { LoggerFactory::CreateInputTestLogger(); - Mock input_driver_mock; + Mock input_driver_mock; Fake(Dtor(input_driver_mock)); When(Method(input_driver_mock, register_event_handler)).AlwaysReturn(); When(Method(input_driver_mock, unregister_event_handler)).AlwaysReturn(); WHEN("the event handler gets created") { - std::shared_ptr driver_ptr(&input_driver_mock.get()); - Input::EventHandler handler(driver_ptr); + std::shared_ptr driver_ptr(&input_driver_mock.get()); + FlippR_Driver::Input::EventHandler handler(driver_ptr); THEN("It should register itself at the input_driver") { diff --git a/FlippR-Driver/tests/input/TestEventNotifier.cpp b/FlippR-Driver/tests/input/TestEventNotifier.cpp index 9e33784..b8717d0 100644 --- a/FlippR-Driver/tests/input/TestEventNotifier.cpp +++ b/FlippR-Driver/tests/input/TestEventNotifier.cpp @@ -20,7 +20,7 @@ #include "input/EventNotifier.h" -using namespace Input; +using namespace FlippR_Driver::Input; using namespace fakeit; SCENARIO("An EventNotifier gets created", "[construction]") diff --git a/FlippR-Driver/tests/input/TestInputDriver.cpp b/FlippR-Driver/tests/input/TestInputDriver.cpp index 8240d66..4f3a8b6 100644 --- a/FlippR-Driver/tests/input/TestInputDriver.cpp +++ b/FlippR-Driver/tests/input/TestInputDriver.cpp @@ -19,7 +19,7 @@ using namespace fakeit; -using namespace Input; +using namespace FlippR_Driver::Input; SCENARIO("An InputDriver gets created", "[construction}") { @@ -56,14 +56,14 @@ SCENARIO("An EventHandler [un]registers at the driver", "[un-register]") { LoggerFactory::CreateInputTestLogger(); - Mock detector_mock; + Mock detector_mock; Fake(Dtor(detector_mock)); Mock event_handler_mock; Fake(Method(event_handler_mock, handle)); Fake(Dtor(event_handler_mock)); - Mock event_notifier_mock; + Mock event_notifier_mock; Fake(Method(event_notifier_mock, register_event_handler)); Fake(Method(event_notifier_mock, unregister_event_handler)); Fake(Dtor(event_notifier_mock)); @@ -103,13 +103,13 @@ SCENARIO("An Input Driver is created normally", "") { LoggerFactory::CreateInputTestLogger(); - Mock detector_mock; + Mock detector_mock; Fake(Dtor(detector_mock)); Mock event_handler_mock; Fake(Dtor(event_handler_mock)); - Mock event_notifier_mock; + Mock event_notifier_mock; Fake(Dtor(event_notifier_mock)); std::shared_ptr event_notifier_ptr(&event_notifier_mock.get()); diff --git a/FlippR-Driver/tests/input/TestInputDriverFactory.cpp b/FlippR-Driver/tests/input/TestInputDriverFactory.cpp index 54f3042..820dd51 100644 --- a/FlippR-Driver/tests/input/TestInputDriverFactory.cpp +++ b/FlippR-Driver/tests/input/TestInputDriverFactory.cpp @@ -16,7 +16,7 @@ #include "input/EventNotifier.h" -using namespace Input; +using namespace FlippR_Driver::Input; using namespace fakeit; SCENARIO("The factory creates a InputDriver") diff --git a/FlippR-Driver/tests/input/mocks/EventHandlerMock.hpp b/FlippR-Driver/tests/input/mocks/EventHandlerMock.hpp index d9d1684..728ebf5 100644 --- a/FlippR-Driver/tests/input/mocks/EventHandlerMock.hpp +++ b/FlippR-Driver/tests/input/mocks/EventHandlerMock.hpp @@ -8,7 +8,7 @@ #ifndef SRC_TESTS_INPUT_MOCKS_EVENTHANDLERMOCK_HPP_ #define SRC_TESTS_INPUT_MOCKS_EVENTHANDLERMOCK_HPP_ -namespace Input +namespace FlippR_Driver::Input { class EventHandler; class Event; diff --git a/FlippR-Driver/tests/input/mocks/EventNotifierMock.hpp b/FlippR-Driver/tests/input/mocks/EventNotifierMock.hpp index b00af63..3ae9d32 100644 --- a/FlippR-Driver/tests/input/mocks/EventNotifierMock.hpp +++ b/FlippR-Driver/tests/input/mocks/EventNotifierMock.hpp @@ -8,7 +8,7 @@ #ifndef SRC_TESTS_INPUT_MOCKS_EVENTNOTIFIERMOCK_HPP_ #define SRC_TESTS_INPUT_MOCKS_EVENTNOTIFIERMOCK_HPP_ -namespace Input +namespace FlippR_Driver::Input { class EventNotifier; class EventHandler; diff --git a/FlippR-Driver/tests/input/mocks/InputDriverMock.hpp b/FlippR-Driver/tests/input/mocks/InputDriverMock.hpp index 6e63a91..3ceab79 100644 --- a/FlippR-Driver/tests/input/mocks/InputDriverMock.hpp +++ b/FlippR-Driver/tests/input/mocks/InputDriverMock.hpp @@ -8,7 +8,7 @@ #ifndef SRC_TESTS_INPUT_MOCKS_INPUTDRIVERMOCK_HPP_ #define SRC_TESTS_INPUT_MOCKS_INPUTDRIVERMOCK_HPP_ -namespace Input +namespace FlippR_Driver::Input { class InputDriver; class EventHandler;