asdf
This commit is contained in:
@@ -127,7 +127,7 @@ boost::optional<Poco::JSON::Object> OutputRequestHandler::parseSolenoid(const st
|
||||
if(item_name == "")
|
||||
{
|
||||
Poco::JSON::Object response;
|
||||
response.set("solenoids", this->output_driver->get_solenoids());
|
||||
response.set("solenoids", getItemArray(this->output_driver->get_solenoids()) );
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ boost::optional<Poco::JSON::Object> OutputRequestHandler::parseLamp(const std::s
|
||||
if(item_name == "")
|
||||
{
|
||||
Poco::JSON::Object response;
|
||||
response.set("lamps", this->output_driver->get_lamps());
|
||||
response.set("lamps", getItemArray(this->output_driver->get_lamps()) );
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ boost::optional<Poco::JSON::Object> OutputRequestHandler::parseSound(const std::
|
||||
if(item_name == "")
|
||||
{
|
||||
Poco::JSON::Object response;
|
||||
response.set("sounds", this->output_driver->get_sounds());
|
||||
response.set("sounds", getItemArray(this->output_driver->get_sounds()) );
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ boost::optional<Poco::JSON::Object> OutputRequestHandler::parseFlipper(const std
|
||||
if(item_name == "")
|
||||
{
|
||||
Poco::JSON::Object response;
|
||||
response.set("flippers", this->output_driver->get_flippers());
|
||||
response.set("flippers", getItemArray(this->output_driver->get_flippers()) );
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -297,6 +297,19 @@ std::vector<std::string> OutputRequestHandler::getPathSegments(Poco::URI uri)
|
||||
return path_segments;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Poco::JSON::Array getItemArray(const std::vector<std::shared_ptr<T>> & items)
|
||||
{
|
||||
Poco::JSON::Array array;
|
||||
for ( auto & item : items )
|
||||
{
|
||||
Poco::JSON::Object var;
|
||||
var.set("name", item->get_name());
|
||||
array.add(var);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,9 @@ private:
|
||||
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
Poco::JSON::Array getItemArray(const std::vector<std::shared_ptr<T>> & items);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user