From ce528aa299501ecab63018f91b937766ffbc95be Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Sun, 19 Jan 2014 19:54:38 +0000 Subject: variables writing json --- NT/src/factory.cpp | 99 +++--------------------------------------------------- 1 file changed, 4 insertions(+), 95 deletions(-) (limited to 'NT/src/factory.cpp') diff --git a/NT/src/factory.cpp b/NT/src/factory.cpp index c02bcee..73a96f4 100644 --- a/NT/src/factory.cpp +++ b/NT/src/factory.cpp @@ -4,109 +4,18 @@ using namespace Rotor; Node_factory::Node_factory(){ //for now, statically load prototype map in constructor - add_type(new Time(),"nodes"); add_type(new Multiply(),"nodes"); add_type(new Print(),"nodes"); } -/* -bool Node_factory::list_node(const string &t,xmlIO XML){ - for (auto& type: type_map) { - if (type.first==t) { - list_node(type.second,XML); - return true; - } - } - XML.addValue("error","Node /"+t+"/ not found"); - return false; -}; -*/ -bool Node_factory::list_node(const string &t,Json::Value &JSON){ +bool Node_factory::list_node(const string &_type,Json::Value &json){ for (auto& type: type_map) { - if (type.first==t) { - JSON["node"]=type.second->list_json(); + if (type.first==_type) { + json["node"]=type.second->to_json(); return true; } } - JSON["error"]="Node /"+t+"/ not found"; + json["error"]="Node '"+_type+"' not found"; return false; }; -/* -void Node_factory::list_node(Rotor::Node* type,xmlIO XML,int i){ - XML.addTag("node"); - XML.addAttribute("node","output_type",type->output_type(),i); - XML.addAttribute("node","node_type",type->node_type,i); - XML.addAttribute("node","title",type->title,i); - XML.addAttribute("node","description",type->description,i); - XML.addAttribute("node","node_id",type->node_id,i); - XML.addAttribute("node","ui_type",type->ui_type,i); - XML.pushTag("node",i); - - //if (type->description!="") { - // XML.addTag("description"); - // XML.setValue("description",type->description,0); - //} - int j=0; - for (auto& input: type->inputs) { - XML.addTag("signal_input"); - XML.addAttribute("signal_input","title",input->title,j); - XML.addAttribute("signal_input","description",input->description,j); - j++; - } - j=0; - if (dynamic_cast (type)!=nullptr) { - for (auto& input: (dynamic_cast(type))->image_inputs) { - XML.addTag("image_input"); - XML.addAttribute("image_input","title",input->title,j); - XML.addAttribute("image_input","description",input->description,j); - j++; - } - } - j=0; - for (auto& parameter: type->parameters) { - XML.addTag("parameter"); - XML.addAttribute("parameter","name",parameter.first,j); - XML.addAttribute("parameter","type",parameter.second->type,j); - XML.addAttribute("parameter","title",parameter.second->title,j); - XML.addAttribute("parameter","description",parameter.second->description,j); - XML.addAttribute("parameter","value",parameter.second->value,j); - XML.addAttribute("parameter","min",parameter.second->min,j); - XML.addAttribute("parameter","max",parameter.second->max,j); - XML.addAttribute("parameter","step",parameter.second->step,j); - j++; - } - j=0; - for (auto& attribute: type->attributes) { - XML.addTag("attribute"); - XML.addAttribute("attribute","name",attribute.first,j); - XML.addAttribute("attribute","title",attribute.second->title,j); - XML.addAttribute("attribute","description",attribute.second->description,j); - if (attribute.second->vals.size()){ //document attribute enumeration - XML.addAttribute("attribute","value",attribute.second->value,j); - XML.addAttribute("attribute","type","enum",j); - XML.pushTag("attribute",j); - int k=0; - for (auto val: attribute.second->vals){ - XML.addTag("option"); - XML.addAttribute("option","value",val,k); - k++; - } - XML.popTag(); - } - else { - XML.addAttribute("attribute","type",attribute.second->type,j); - if (attribute.second->type=="array"){ - XML.pushTag("attribute",j); - XML.addTag("value"); - XML.popTag(); - } - else XML.addAttribute("attribute","value",attribute.second->value,j); - } - j++; - } - - XML.popTag(); -} - -*/ -- cgit v1.2.3