implemented output driver

This commit is contained in:
Jonas Zeunert
2018-10-10 11:58:31 +02:00
parent 46dd4ba6c5
commit 10a55412fe
3 changed files with 47 additions and 8 deletions

View File

@@ -7,20 +7,58 @@
#include "OutputDriver.h"
#include <boost/range/adaptor/map.hpp>
#include <boost/range/algorithm/copy.hpp>
namespace FlippR_Driver
{
namespace output
{
OutputDriver::OutputDriver()
{
// TODO Auto-generated constructor stub
OutputDriver::OutputDriver(std::map<std::string, std::shared_ptr<ICabinetItem>> cabinet_items, std::map<char, std::shared_ptr<IDisplay>> displays, std::map<std::string, std::shared_ptr<ISound>> sounds)
: cabinet_items(cabinet_items), displays(displays), sounds(sounds)
{}
std::vector<std::shared_ptr<ICabinetItem>> OutputDriver::get_cabinet_items()
{
std::vector<std::shared_ptr<ICabinetItem>> cabinet_items;
boost::copy(this->cabinet_items | boost::adaptors::map_values, std::back_inserter(cabinet_items));
return cabinet_items;
}
OutputDriver::~OutputDriver()
std::vector<std::shared_ptr<ISound>> OutputDriver::get_sounds()
{
// TODO Auto-generated destructor stub
std::vector<std::shared_ptr<ISound>> sounds;
boost::copy(this->sounds | boost::adaptors::map_values, std::back_inserter(sounds));
return sounds;
}
std::vector<std::shared_ptr<IDisplay>> OutputDriver::get_displays()
{
std::vector<std::shared_ptr<IDisplay>> displays;
boost::copy(this->displays | boost::adaptors::map_values, std::back_inserter(displays));
return displays;
}
std::shared_ptr<ICabinetItem> OutputDriver::get_cabinet_item(std::string name)
{
return this->cabinet_items.find(name)->second;
}
std::shared_ptr<ISound> OutputDriver::get_sound(std::string name)
{
return this->sounds.find(name)->second;
}
std::shared_ptr<IDisplay> OutputDriver::get_display(char number)
{
return this->displays.find(number)->second;
}
} /* namespace output */

View File

@@ -25,8 +25,9 @@ namespace output
class OutputDriver : public IOutputDriver
{
public:
OutputDriver();
virtual ~OutputDriver();
OutputDriver(std::map<std::string, std::shared_ptr<ICabinetItem>> cabinet_items, std::map<char, std::shared_ptr<IDisplay>> displays, std::map<std::string, std::shared_ptr<ISound>> sounds);
virtual ~OutputDriver() = default;
std::vector<std::shared_ptr<ICabinetItem>> get_cabinet_items();
std::vector<std::shared_ptr<ISound>> get_sounds();

View File

@@ -16,7 +16,7 @@ namespace output
class OutputDriverFactory
{
public:
std::shared_ptr <OutputDriver> getOutputDriver(std::ifstream &output_gpio_config, std::ifstream &output_config);
static std::shared_ptr <OutputDriver> getOutputDriver(std::ifstream &output_gpio_config, std::ifstream &output_config);
};
}
}