added ItemVarHolder
This commit is contained in:
@@ -11,6 +11,7 @@ set(LIB_DIR lib)
|
||||
set(DEFAULT_BUILD_TYPE DEBUG)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
SET(DBoost_NO_BOOST_CMAKE=ON)
|
||||
|
||||
IF(NOT_PI)
|
||||
add_definitions(-DNOT_PI)
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
std::map<std::string, std::shared_ptr<items::Lamp>> lamps, std::map<std::string, std::shared_ptr<items::Sound>> sounds,
|
||||
std::map<std::string, std::shared_ptr<items::Flipper>> flippers, std::map<uint8_t, std::shared_ptr<output::items::Display>> displays);
|
||||
|
||||
~OutputDriver() = default;
|
||||
~OutputDriver() = default;//TODO aufräumen
|
||||
|
||||
void activate_displays() const;
|
||||
void deactivate_displays() const;
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#define _SRC_OUTPUT_ICABINETITEM_H_
|
||||
|
||||
#include <string>
|
||||
#include <Poco/RefCountedObject.h>
|
||||
#include <Poco/JSON/Object.h>
|
||||
|
||||
namespace flippR_driver
|
||||
{
|
||||
|
||||
@@ -7,7 +7,8 @@ set(SOURCES
|
||||
output/OutputRequestHandler.cpp
|
||||
output/OutputRequestHandlerFactory.cpp
|
||||
FlippRServer.cpp
|
||||
input/InputSocketHandlerFactory.cpp)
|
||||
input/InputSocketHandlerFactory.cpp
|
||||
output/ItemVarHolder.h)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||
|
||||
|
||||
48
FlippR-Driver/networking/output/ItemVarHolder.h
Normal file
48
FlippR-Driver/networking/output/ItemVarHolder.h
Normal file
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// Created by johannes on 29.08.19.
|
||||
//
|
||||
|
||||
#ifndef FLIPPR_DRIVER_ITEMVARHOLDER_H
|
||||
#define FLIPPR_DRIVER_ITEMVARHOLDER_H
|
||||
|
||||
#include <Poco/Dynamic/VarHolder.h>
|
||||
#include <memory>
|
||||
|
||||
#include "output/items/Item.h"
|
||||
|
||||
|
||||
template <>
|
||||
class Poco::Dynamic::VarHolderImpl<std::shared_ptr<flippR_driver::output::items::Item>> : public Poco::Dynamic::VarHolder
|
||||
{
|
||||
public:
|
||||
VarHolderImpl(const std::shared_ptr<flippR_driver::output::items::Item> & item) :
|
||||
item(item)
|
||||
{}
|
||||
|
||||
void convert(std::string & val) const override
|
||||
{
|
||||
val = this->item->get_name();
|
||||
}
|
||||
|
||||
VarHolder * clone(Placeholder < VarHolder > * pHolder = 0) const override
|
||||
{
|
||||
return cloneHolder(pHolder, item);
|
||||
}
|
||||
|
||||
const std::type_info & type() const override
|
||||
{
|
||||
return typeid(item);
|
||||
}
|
||||
|
||||
const std::shared_ptr<flippR_driver::output::items::Item> & value() const
|
||||
{
|
||||
return item;
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<flippR_driver::output::items::Item> item;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //FLIPPR_DRIVER_ITEMVARHOLDER_H
|
||||
@@ -29,7 +29,6 @@ public:
|
||||
~Item() override = default;
|
||||
|
||||
std::string get_name() const override;
|
||||
|
||||
protected:
|
||||
const std::string name;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user