diff options
Diffstat (limited to 'rotord/src/rotor.cpp')
| -rw-r--r-- | rotord/src/rotor.cpp | 86 |
1 files changed, 19 insertions, 67 deletions
diff --git a/rotord/src/rotor.cpp b/rotord/src/rotor.cpp index 6ceab91..840298e 100644 --- a/rotord/src/rotor.cpp +++ b/rotord/src/rotor.cpp @@ -176,15 +176,21 @@ Json::Value Node_factory::list_node(Rotor::Node* _node){ attribute["name"]=attr.first; attribute["title"]=attr.second->title; attribute["description"]=attr.second->description; - attribute["value"]=attr.second->value; if (attr.second->vals.size()){ //document attribute enumeration + attribute["value"]=attr.second->value; attribute["type"]="enum"; attribute["options"]=Json::arrayValue; for (auto val: attr.second->vals){ attribute["options"].append(val); } } - else attribute["type"]="string"; + else { + attribute["type"]=attr.second->type; + if (attr.second->type=="array"){ + attribute["value"]=Json::arrayValue; + } + else attribute["value"]=attr.second->value; + } node["attributes"].append(attribute); } } @@ -239,8 +245,8 @@ void Node_factory::list_node(Rotor::Node* type,xmlIO XML,int i=0){ XML.addAttribute("attribute","name",attribute.first,j); XML.addAttribute("attribute","title",attribute.second->title,j); XML.addAttribute("attribute","description",attribute.second->description,j); - XML.addAttribute("attribute","value",attribute.second->value,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; @@ -251,7 +257,15 @@ void Node_factory::list_node(Rotor::Node* type,xmlIO XML,int i=0){ } XML.popTag(); } - else XML.addAttribute("attribute","type","string",j); + 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(); @@ -298,69 +312,7 @@ void Node_factory::list_nodes(Json::Value &JSON){ JSON["nodeslist"]=Json::arrayValue; for (auto& type: type_map) { if (type.second->description!="") { //blank description = internal/ testing node - Json::Value node; - node["type"]=type.first; - node["title"]=type.second->title; - node["inputs"]=type.second->duplicate_inputs?"expandable":"fixed"; - if (dynamic_cast<Signal_node*> (type.second)!=nullptr) node["output"]="signal"; - if (dynamic_cast<Image_node*> (type.second)!=nullptr) node["output"]="image"; - node["description"]=type.second->description; - node["UID"]=type.second->UID; - if (type.second->inputs.size()){ - node["signal_inputs"]=Json::arrayValue; - for (auto& input: type.second->inputs) { - Json::Value signal_input; - signal_input["title"]=input->title; - signal_input["description"]=input->description; - node["signal_inputs"].append(signal_input); - } - } - if (dynamic_cast<Image_node*> (type.second)!=nullptr) { - if ((dynamic_cast<Image_node*>(type.second))->image_inputs.size()){ - node["image_inputs"]=Json::arrayValue; - for (auto& input: (dynamic_cast<Image_node*>(type.second))->image_inputs) { - Json::Value image_input; - image_input["title"]=input->title; - image_input["description"]=input->description; - node["image_inputs"].append(image_input); - } - } - } - if (type.second->parameters.size()){ - node["parameters"]=Json::arrayValue; - for (auto& param: type.second->parameters) { - Json::Value parameter; - parameter["name"]=param.first; - parameter["type"]=param.second->type; - parameter["title"]=param.second->title; - parameter["description"]=param.second->description; - parameter["value"]=param.second->value; - parameter["min"]=param.second->min; - parameter["max"]=param.second->max; - parameter["step"]=param.second->step; - node["parameters"].append(parameter); - } - } - if (type.second->attributes.size()){ - node["attributes"]=Json::arrayValue; - for (auto& attr: type.second->attributes) { - Json::Value attribute; - attribute["name"]=attr.first; - attribute["title"]=attr.second->title; - attribute["description"]=attr.second->description; - attribute["value"]=attr.second->value; - if (attr.second->vals.size()){ //document attribute enumeration - attribute["type"]="enum"; - attribute["options"]=Json::arrayValue; - for (auto val: attr.second->vals){ - attribute["options"].append(val); - } - } - else attribute["type"]="string"; - node["attributes"].append(attribute); - } - } - JSON["nodeslist"].append(node); + JSON["nodeslist"].append(list_node(type.second)); } } }
\ No newline at end of file |
