extended interface

This commit is contained in:
Jonas Zeunert
2018-12-07 14:47:28 +01:00
parent dc0dfd732a
commit d25c030152
4 changed files with 34 additions and 23 deletions

View File

@@ -8,6 +8,15 @@
#ifndef _SRC_OUTPUT_IOUTPUTDRIVER_H_
#define _SRC_OUTPUT_IOUTPUTDRIVER_H_
#include "output/items/ILamp.h"
#include "output/items/ISolenoid.h"
#include "output/items/IDisplay.h"
#include "output/items/ISound.h"
#include <vector>
#include <memory>
#include <boost/optional.hpp>
namespace flippR_driver
{
namespace output
@@ -16,8 +25,17 @@ namespace output
class IOutputDriver
{
public:
IOutputDriver();
virtual ~IOutputDriver();
virtual ~IOutputDriver() = default;
virtual std::vector<std::shared_ptr<items::ILamp>> get_lamps() = 0;
virtual std::vector<std::shared_ptr<items::ISolenoid>> get_solenoids() = 0;
virtual std::vector<std::shared_ptr<items::ISound>> get_sounds() = 0;
virtual std::vector<std::shared_ptr<items::IDisplay>> get_displays() = 0;
virtual boost::optional<std::shared_ptr<items::ILamp>> get_lamp(std::string name) = 0;
virtual boost::optional<std::shared_ptr<items::ISolenoid>> get_solenoid(std::string name) = 0;
virtual boost::optional<std::shared_ptr<items::ISound>> get_sound(std::string name) = 0;
virtual boost::optional<std::shared_ptr<items::IDisplay>> get_display(char number) = 0;
};
} /* namespace output */

View File

@@ -31,7 +31,7 @@ public:
void handle(Event& event) override;
private:
std::shared_ptr<IInputDriver> input_driver;
const std::shared_ptr<IInputDriver> input_driver;
};
}

View File

@@ -42,7 +42,7 @@ private:
void notify();
private:
utility::IBlockingQueue<Event>* event_queue;
const utility::IBlockingQueue<Event>* event_queue;
std::set<IEventHandler*> event_handlers;
bool is_running;

View File

@@ -10,14 +10,7 @@
#include "output/IOutputDriver.h"
#include "output/items/ILamp.h"
#include "output/items/ISolenoid.h"
#include "output/items/IDisplay.h"
#include "output/items/ISound.h"
#include <vector>
#include <map>
#include <memory>
namespace flippR_driver
{
@@ -31,21 +24,21 @@ public:
virtual ~OutputDriver() = default;
// todo what is flipper_relay ?
std::vector<std::shared_ptr<items::ILamp>> get_lamps();
std::vector<std::shared_ptr<items::ISolenoid>> get_solenoids();
std::vector<std::shared_ptr<items::ISound>> get_sounds();
std::vector<std::shared_ptr<items::IDisplay>> get_displays();
std::vector<std::shared_ptr<items::ILamp>> get_lamps() override;
std::vector<std::shared_ptr<items::ISolenoid>> get_solenoids() override;
std::vector<std::shared_ptr<items::ISound>> get_sounds() override;
std::vector<std::shared_ptr<items::IDisplay>> get_displays() override;
std::shared_ptr<items::ILamp> get_lamp(std::string name);
std::shared_ptr<items::ISolenoid> get_solenoid(std::string name);
std::shared_ptr<items::ISound> get_sound(std::string name);
std::shared_ptr<items::IDisplay> get_display(char number);
boost::optional<std::shared_ptr<items::ILamp>> get_lamp(std::string name) override;
boost::optional<std::shared_ptr<items::ISolenoid>> get_solenoid(std::string name) override;
boost::optional<std::shared_ptr<items::ISound>> get_sound(std::string name) override;
boost::optional<std::shared_ptr<items::IDisplay>> get_display(char number) override;
private:
std::map<std::string, std::shared_ptr<items::ILamp>> lamps;
std::map<std::string, std::shared_ptr<items::ISolenoid>> solenoids;
std::map<char, std::shared_ptr<items::IDisplay>> displays;
std::map<std::string, std::shared_ptr<items::ISound>> sounds;
const std::map<std::string, std::shared_ptr<items::ILamp>> lamps;
const std::map<std::string, std::shared_ptr<items::ISolenoid>> solenoids;
const std::map<char, std::shared_ptr<items::IDisplay>> displays;
const std::map<std::string, std::shared_ptr<items::ISound>> sounds;
};
} /* namespace output */