From ebc9d15f13cbf96d1ec093405657fe201b830ce4 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Thu, 8 Aug 2013 14:45:47 +0100 Subject: basic list_nodes --- rotord/src/rotor.h | 10 ++++++++++ rotord/src/rotord.cpp | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index 8e37b51..e4207b3 100755 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -1138,6 +1138,16 @@ namespace Rotor { } return NULL; }; + void list_nodes(xmlIO XML){ + int i=0; + for (auto& type: type_map) { //c++11 + XML.addTag("node"); + XML.addAttribute("node","name",type.first,i); + if (dynamic_cast (type.second)!=nullptr) XML.addAttribute("node","type","signal",i); + if (dynamic_cast (type.second)!=nullptr) XML.addAttribute("node","type","image",i); + i++; + } + } private: unordered_map type_map; }; diff --git a/rotord/src/rotord.cpp b/rotord/src/rotord.cpp index 6f2d765..fefca8e 100755 --- a/rotord/src/rotord.cpp +++ b/rotord/src/rotord.cpp @@ -1,5 +1,7 @@ #include "rotord.h" +using namespace Rotor; + RenderContextHandler::RenderContextHandler(const std::string _content,const HTTPServerResponse::HTTPStatus _status){ content=_content; status=_status; @@ -98,6 +100,14 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS status=HTTPResponse::HTTP_OK; } } + else if (command[0]=="listnodes") { + XML.pushTag("rotor"); + if (request.getMethod()=="GET") { + Node_factory factory; + factory.list_nodes(XML); + status=HTTPResponse::HTTP_OK; + } + } else if (command[0]=="exit") { logger.information("exiting"); exit(0); -- cgit v1.2.3