refactored namespaaaces suckz

This commit is contained in:
Jonas Zeunert
2018-09-14 00:57:39 +02:00
parent 530893c404
commit 25da106bea
80 changed files with 149 additions and 255 deletions

View File

@@ -25,3 +25,4 @@
},
"data" : 13
}
}

View File

@@ -189,3 +189,4 @@
},
}
}
}

View File

@@ -12,32 +12,29 @@
#include <string>
namespace FlippR_Driver
{
namespace Input
{
namespace FlippR_Driver {
namespace Input {
class Event
{
public:
class Event {
public:
Event(char address, int priority, std::string name);
friend bool operator==(const Event& left, const Event& right);
friend bool operator<(const Event& left, const Event& right)
{
friend bool operator==(const Event &left, const Event &right);
friend bool operator<(const Event &left, const Event &right) {
return left.priority < right.priority;
}
public:
public:
std::string name;
char address;
int priority;
};
};
bool operator==(const Event& left, const Event& right);
bool operator==(const Event &left, const Event &right);
}
}
#endif /* INPUTEVENT_H_ */

View File

@@ -11,19 +11,19 @@
#include "IEventHandler.h"
#include <memory>
namespace FlippR_Driver
{
namespace Input {
namespace FlippR_Driver {
namespace Input {
class IInputDriver
{
public:
virtual ~IInputDriver(){};
virtual void register_event_handler(IEventHandler* handler) = 0;
virtual void unregister_event_handler(IEventHandler* handler) = 0;
class IInputDriver {
public:
virtual ~IInputDriver() {};
virtual void register_event_handler(IEventHandler *handler) = 0;
virtual void unregister_event_handler(IEventHandler *handler) = 0;
virtual std::shared_ptr<Event> get_event(std::string name) = 0;
};
};
}
}
#endif /* SRC_INPUT_IINPUTDRIVER_H_ */

View File

@@ -291,3 +291,4 @@ int ads1115Setup (const int pinBase, int i2cAddr)
return TRUE ;
}
}

View File

@@ -235,3 +235,4 @@ int bmp180Setup (const int pinBase)
return TRUE ;
}
}

View File

@@ -403,3 +403,4 @@ int drcSetupNet (const int pinBase, const int numPins, const char *ipAddress, co
return TRUE ;
}
}

View File

@@ -194,3 +194,4 @@ int drcSetupSerial (const int pinBase, const int numPins, const char *device, co
return TRUE ;
}
}

View File

@@ -144,3 +144,4 @@ int ds18b20Setup (const int pinBase, const char *deviceId)
return TRUE ;
}
}

View File

@@ -148,3 +148,4 @@ int htu21dSetup (const int pinBase)
return (status == 0x02) ? TRUE : FALSE ;
}
}

View File

@@ -97,3 +97,4 @@ int max31855Setup (const int pinBase, int spiChannel)
return TRUE ;
}
}

View File

@@ -82,3 +82,4 @@ int max5322Setup (const int pinBase, int spiChannel)
return TRUE ;
}
}

View File

@@ -147,3 +147,4 @@ int mcp23008Setup (const int pinBase, const int i2cAddress)
return TRUE ;
}
}

View File

@@ -162,3 +162,4 @@ int mcp23016Setup (const int pinBase, const int i2cAddress)
return TRUE ;
}
}

View File

@@ -193,3 +193,4 @@ int mcp23017Setup (const int pinBase, const int i2cAddress)
return TRUE ;
}
}

View File

@@ -186,3 +186,4 @@ int mcp23s08Setup (const int pinBase, const int spiPort, const int devId)
return TRUE ;
}
}

View File

@@ -233,3 +233,4 @@ int mcp23s17Setup (const int pinBase, const int spiPort, const int devId)
return TRUE ;
}
}

View File

@@ -74,3 +74,4 @@ int mcp3002Setup (const int pinBase, int spiChannel)
return TRUE ;
}
}

View File

@@ -74,3 +74,4 @@ int mcp3004Setup (const int pinBase, int spiChannel)
return TRUE ;
}
}

View File

@@ -123,3 +123,4 @@ int mcp3422Setup (int pinBase, int i2cAddress, int sampleRate, int gain)
return TRUE ;
}
}

View File

@@ -74,3 +74,4 @@ int mcp4802Setup (const int pinBase, int spiChannel)
return TRUE ;
}
}

View File

@@ -124,3 +124,4 @@ int pcf8574Setup (const int pinBase, const int i2cAddress)
return TRUE ;
}
}

View File

@@ -88,3 +88,4 @@ int pcf8591Setup (const int pinBase, const int i2cAddress)
return TRUE ;
}
}

View File

@@ -49,3 +49,4 @@ int piHiPri (const int pri)
return sched_setscheduler (0, SCHED_RR, &sched) ;
}
}

View File

@@ -93,3 +93,4 @@ int pseudoPinsSetup (const int pinBase)
return TRUE ;
}
}

View File

@@ -250,3 +250,4 @@ int rht03Setup (const int pinBase, const int piPin)
return TRUE ;
}
}

View File

@@ -73,3 +73,4 @@ int sn3218Setup (const int pinBase)
return TRUE ;
}
}

View File

@@ -181,3 +181,4 @@ void softPwmStop (int pin)
}
}
}
}

View File

@@ -209,3 +209,4 @@ int softServoSetup (int p0, int p1, int p2, int p3, int p4, int p5, int p6, int
return piThreadCreate (softServoThread) ;
}
}

View File

@@ -148,3 +148,4 @@ void softToneStop (int pin)
digitalWrite (pin, LOW) ;
}
}
}

View File

@@ -107,3 +107,4 @@ int sr595Setup (const int pinBase, const int numPins,
return TRUE ;
}
}

View File

@@ -2371,3 +2371,4 @@ int wiringPiSetupSys (void)
return 0 ;
}
}

View File

@@ -231,3 +231,4 @@ int wiringPiI2CSetup (const int devId)
return wiringPiI2CSetupInterface (device, devId) ;
}
}

View File

@@ -135,3 +135,4 @@ int wiringPiSPISetup (int channel, int speed)
{
return wiringPiSPISetupMode (channel, speed, 0) ;
}
}

View File

@@ -223,3 +223,4 @@ int serialGetchar (const int fd)
return ((int)x) & 0xFF ;
}
}

View File

@@ -81,3 +81,4 @@ void shiftOut (uint8_t dPin, uint8_t cPin, uint8_t order, uint8_t val)
digitalWrite (cPin, LOW) ;
}
}
}

View File

@@ -926,3 +926,4 @@ int loadWPiExtension (char *progName, char *extensionData, int printErrors)
fprintf (stderr, "%s: extension %s not found", progName, extension) ;
return FALSE ;
}
}

View File

@@ -67,3 +67,4 @@ bool Detector::check_inputs(char& address)
}
}
}

View File

@@ -52,7 +52,5 @@ private:
};
}
#endif /* DETECTOR_H_ */
}
#endif

View File

@@ -10,18 +10,15 @@
#include "Event.h"
namespace FlippR_Driver
{
namespace Input
{
namespace FlippR_Driver {
namespace Input {
class ErrorEvent : public Event
{
public:
class ErrorEvent : public Event {
public:
ErrorEvent() :
Event(0, 0, "ERROR")
{}
};
Event(0, 0, "ERROR") {}
};
}
}
#endif /* SRC_INPUT_ERROREVENT_HPP_ */
#endif

View File

@@ -25,3 +25,4 @@ bool operator==(const Event& left, const Event& right)
}
}
}

View File

@@ -33,3 +33,4 @@ namespace Input
}
}
}

View File

@@ -36,4 +36,5 @@ private:
}
#endif /* INPUTEVENTHANDLER_H_ */
}
#endif

View File

@@ -82,3 +82,4 @@ void EventNotifier::notify()
}
}
}

View File

@@ -53,4 +53,5 @@ private:
#endif /* SRC_INPUT_EVENTNOTIFIER_H_ */
}
#endif

View File

@@ -23,4 +23,5 @@ public:
}
#endif /* SRC_INPUT_IDETECTOR_H_ */
}
#endif

View File

@@ -29,4 +29,5 @@ public:
};
}
#endif /* SRC_INPUT_IEVENTNOTIFIER_H_ */
}
#endif

View File

@@ -10,42 +10,36 @@
#include <input/ErrorEvent.hpp>
namespace FlippR_Driver
{
namespace Input
{
namespace FlippR_Driver {
namespace Input {
InputDriver::InputDriver(std::shared_ptr<IEventNotifier> event_notifier, std::unique_ptr<IDetector> detector, std::map<std::string, std::shared_ptr<Event>> events) :
InputDriver::InputDriver(std::shared_ptr<IEventNotifier> event_notifier, std::unique_ptr<IDetector> detector,
std::map<std::string, std::shared_ptr<Event>> events) :
event_notifier(event_notifier),
detector(std::move(detector)),
events(events)
{
events(events) {
CLOG(INFO, INPUT_LOGGER) << "Created InputDriver";
}
}
void InputDriver::register_event_handler(IEventHandler* handler)
{
void InputDriver::register_event_handler(IEventHandler *handler) {
this->event_notifier->register_event_handler(handler);
}
}
void InputDriver::unregister_event_handler(IEventHandler* handler)
{
void InputDriver::unregister_event_handler(IEventHandler *handler) {
this->event_notifier->unregister_event_handler(handler);
}
}
std::shared_ptr<Event> InputDriver::get_event(std::string name)
{
std::shared_ptr<Event> InputDriver::get_event(std::string name) {
std::shared_ptr<Event> event(new ErrorEvent());
try
{
try {
event = this->events.at(name);
}
catch(std::out_of_range& e)
{
catch (std::out_of_range &e) {
CLOG_N_TIMES(1, WARNING, OUTPUT_LOGGER) << "Did not found event " << name << " please check config file!";
}
return event;
}
}
}
}

View File

@@ -38,4 +38,5 @@ private:
}
#endif /* SRC_INPUT_INPUTDRIVER_H_ */
}
#endif

View File

@@ -66,3 +66,4 @@ namespace Input {
}
}
}
}

View File

@@ -32,4 +32,5 @@ private:
static void create_input_events(nlohmann::json matrix_config, std::map<char, std::shared_ptr<Event>> address_event_map, std::map<std::string, std::shared_ptr<Event>> name_event_map);
};
}
#endif /* INPUTFACTORY_H_ */
}
#endif

View File

@@ -30,4 +30,4 @@ protected:
} /* namespace output */
#endif /* _SRC_OUTPUT_CABINETITEM_H_ */
#endif

View File

@@ -30,4 +30,4 @@ private:
} /* namespace output */
#endif /* _SRC_OUTPUT_DISPLAY_H_ */
#endif

View File

@@ -20,3 +20,4 @@ DisplayController::~DisplayController() {
}
}

View File

@@ -27,4 +27,4 @@ private:
};
}
#endif /* _SRC_OUTPUT_DISPLAYCONTROLLER_H_ */
#endif

View File

@@ -18,4 +18,4 @@ class ICabinetItem
};
#endif /* _SRC_OUTPUT_ICABINETITEM_H_ */
#endif

View File

@@ -22,4 +22,4 @@ public:
} /* namespace output */
#endif /* _SRC_OUTPUT_IDISPLAY_H_ */
#endif

View File

@@ -18,4 +18,4 @@ public:
} /* namespace output */
#endif /* _SRC_OUTPUT_IDISPLAYCONTROLLER_H_ */
#endif

View File

@@ -14,4 +14,4 @@ class ILamp
};
#endif /* _SRC_OUTPUT_ILAMP_H_ */
#endif

View File

@@ -18,4 +18,4 @@ public:
} /* namespace output */
#endif /* _SRC_OUTPUT_IOUTPUTDRIVER_H_ */
#endif

View File

@@ -15,4 +15,4 @@ class ISolenoid
#endif /* _SRC_OUTPUT_ISOLENOID_H_ */
#endif

View File

@@ -20,4 +20,4 @@ public:
} /* namespace output */
#endif /* _SRC_OUTPUT_ISOUND_H_ */
#endif

View File

@@ -20,4 +20,4 @@ public:
} /* namespace output */
#endif /* _SRC_OUTPUT_LAMP_H_ */
#endif

View File

@@ -20,4 +20,4 @@ public:
} /* namespace output */
#endif /* _SRC_OUTPUT_OUTPUTDRIVER_H_ */
#endif

View File

@@ -20,4 +20,4 @@ public:
} /* namespace output */
#endif /* _SRC_OUTPUT_SOLENOID_H_ */
#endif

View File

@@ -27,4 +27,4 @@ private:
} /* namespace output */
#endif /* _SRC_OUTPUT_SOUND_H_ */
#endif

View File

@@ -46,4 +46,4 @@ public:
#endif /* SRC_UTILITIES_BLOCKINGQUEUE_HPP_ */
#endif

View File

@@ -15,7 +15,6 @@
#include <mutex>
#include <fstream>
//#include "config.h"
class GPIOInterface
{
@@ -39,4 +38,4 @@ public:
#endif /* SRC_UTILITIES_GPIOINTERFACE_H_ */
#endif

View File

@@ -19,4 +19,4 @@ public:
};
#endif /* SRC_UTILITIES_IBLOCKINGQUEUE_H_ */
#endif

View File

@@ -17,6 +17,4 @@ public:
virtual bool read_data(char pin) = 0;
};
#endif /* SRC_UTILITIES_INPUTGPIOINTERFACE_H_ */
#endif

View File

@@ -34,4 +34,4 @@ private:
char data_address;
};
#endif /* SRC_UTILITIES_INPUTGPIOINTERFACE_H_ */
#endif

View File

@@ -15,4 +15,4 @@ namespace LoggerFactory
void CreateInputLogger();
};
#endif /* SRC_UTILITIES_LOGGERFACTORY_HPP_ */
#endif

View File

@@ -16,4 +16,4 @@ class OutputGPIOInterface : GPIOInterface
};
#endif /* SRC_UTILITIES_OUTPUTGPIOINTERFACE_H_ */
#endif

View File

@@ -23,9 +23,8 @@
using namespace fakeit;
using namespace FlippR_Driver
{
namespace Input;
using namespace FlippR_Driver;
using namespace Input;
SCENARIO("Creating a Detector object", "")

View File

@@ -20,9 +20,8 @@
#include "input/EventNotifier.h"
using namespace FlippR_Driver
{
namespace Input;
using namespace FlippR_Driver;
using namespace Input;
using namespace fakeit;
SCENARIO("An EventNotifier gets created", "[construction]")

View File

@@ -19,9 +19,8 @@
using namespace fakeit;
using namespace FlippR_Driver
{
namespace Input;
using namespace FlippR_Driver;
using namespace Input;
SCENARIO("An InputDriver gets created", "[construction}")
{

View File

@@ -1,27 +0,0 @@
/*
* TestInputDriverFactory.cpp
*
* Created on: Jul 11, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Oliver Martin, Dr. Franca Rupprecht
*/
#include "catch.hpp"
#include "fakeit.hpp"
#include "utilities/LoggerFactory.h"
// testing purposes
#define private public
#include "input/EventNotifier.h"
using namespace FlippR_Driver
{
namespace Input;
using namespace fakeit;
SCENARIO("The factory creates a InputDriver")
{
}

View File

@@ -1,29 +0,0 @@
/*
* EventHandlerMock.hpp
*
* Created on: May 31, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
*/
#ifndef SRC_TESTS_INPUT_MOCKS_EVENTHANDLERMOCK_HPP_
#define SRC_TESTS_INPUT_MOCKS_EVENTHANDLERMOCK_HPP_
namespace FlippR_Driver
{
namespace Input
{
class EventHandler;
class Event;
class EventHandlerMock : EventHandler
{
public:
void handle(Event& event) override
{
}
};
}
#endif /* SRC_TESTS_INPUT_MOCKS_EVENTHANDLERMOCK_HPP_ */

View File

@@ -1,41 +0,0 @@
/*
* EventNotfierMock.hpp
*
* Created on: May 31, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
*/
#ifndef SRC_TESTS_INPUT_MOCKS_EVENTNOTIFIERMOCK_HPP_
#define SRC_TESTS_INPUT_MOCKS_EVENTNOTIFIERMOCK_HPP_
namespace FlippR_Driver
{
namespace Input
{
class EventNotifier;
class EventHandler;
class EventNotifierMock : EventNotifier
{
public:
EventNotifierMock() :
registered(false)
{}
void register_event_handler(EventHandler* handler) override
{
registered = true;
}
void unregister_event_handler(EventHandler* handler) override
{
registered = false;
}
public:
bool registered;
};
}
#endif /* SRC_TESTS_INPUT_MOCKS_EVENTNOTIFIERMOCK_HPP_ */

View File

@@ -1,36 +0,0 @@
/*
* InputDriverMock.hpp
*
* Created on: May 31, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
*/
#ifndef SRC_TESTS_INPUT_MOCKS_INPUTDRIVERMOCK_HPP_
#define SRC_TESTS_INPUT_MOCKS_INPUTDRIVERMOCK_HPP_
namespace FlippR_Driver
{
namespace Input
{
class InputDriver;
class EventHandler;
class InputDriverMock : InputDriver
{
public:
InputDriverMock() :
registered(false)
{}
void register_event_handler(EventHandler* handler)
{
registered = true;
}
public:
bool registered;
};
}
#endif /* SRC_TESTS_INPUT_MOCKS_INPUTDRIVERMOCK_HPP_ */