From 52710ced0e723117afa2d40f3b21e1fa2d1ad2ad Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Mon, 13 Jan 2014 16:49:20 +0000 Subject: TypeNames --- NT/src/rotor.cpp | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) (limited to 'NT/src/rotor.cpp') diff --git a/NT/src/rotor.cpp b/NT/src/rotor.cpp index c08734c..33d52ad 100644 --- a/NT/src/rotor.cpp +++ b/NT/src/rotor.cpp @@ -7,6 +7,100 @@ using namespace std; using namespace Rotor; +Json::Value Node::list_json(){ + Json::Value node; + node["node_type"]=node_type; + node["title"]=title; + node["output_type"]=output_type(); + node["description"]=description; + node["node_id"]=node_id; + node["ui_type"]=ui_type; + + if (vars.size()){ + node["vars"]=Json::arrayValue; + for (auto& var: vars) { + string type=var.second->get_type(); + Json::Value newvar; + newvar["type"]=type; + newvar["connectable"]=var.second->connectable?"yes":"no"; + if (dynamic_cast(var.second)){ + newvar["input"]=Json::arrayValue; + for (auto& element: dynamic_cast(var.second)->values) { + Json::Value newvalue; + newvar["input"].append(newvalue); + } + } + else { + newvar["input"]=Json::Value(); + } + node["vars"].append(newvar); + } + } +/* + if (_node->inputs.size()){ + node["signal_inputs"]=Json::arrayValue; + for (auto& input: _node->inputs) { + Json::Value signal_input; + signal_input["title"]=input->title; + signal_input["description"]=input->description; + node["signal_inputs"].append(signal_input); + } + } + if (dynamic_cast (_node)!=nullptr) { + if ((dynamic_cast(_node))->image_inputs.size()){ + node["image_inputs"]=Json::arrayValue; + for (auto& input: (dynamic_cast(_node))->image_inputs) { + Json::Value image_input; + image_input["title"]=input->title; + image_input["description"]=input->description; + node["image_inputs"].append(image_input); + } + } + } + if (_node->parameters.size()){ + node["parameters"]=Json::arrayValue; + for (auto& param: _node->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 (_node->attributes.size()){ + node["attributes"]=Json::arrayValue; + for (auto& attr: _node->attributes) { + Json::Value attribute; + attribute["name"]=attr.first; + attribute["title"]=attr.second->title; + attribute["description"]=attr.second->description; + 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"]=attr.second->type; + if (attr.second->type=="array"){ + attribute["value"]=Json::arrayValue; + } + else attribute["value"]=attr.second->value; + } + node["attributes"].append(attribute); + } + } +*/ + return node; +} + //factory generates linker errors if rotor.h implementation is seperated: why? int main(){ -- cgit v1.2.3