From 3606861884c15b8f6bfe37b804f6195ddf13d1a1 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Sun, 19 Jan 2014 22:56:26 +0000 Subject: json initialisers all done --- NT/src/rotor.cpp | 89 ++++++-------------------------------------------------- NT/src/rotor.h | 4 +-- 2 files changed, 11 insertions(+), 82 deletions(-) diff --git a/NT/src/rotor.cpp b/NT/src/rotor.cpp index eeffab9..5225c02 100644 --- a/NT/src/rotor.cpp +++ b/NT/src/rotor.cpp @@ -29,6 +29,14 @@ Json::Value Variable_array_type::to_json(){ } return json; } + +//explicit template instantiation +template class Variable_type; +template class Variable_type; + +template class Variable_array_type; + + Json::Value Node::to_json(){ Json::Value node; node["type"]=type; @@ -38,92 +46,12 @@ Json::Value Node::to_json(){ node["description"]=description; node["id"]=id; node["ui_type"]=ui_type; - if (vars.size()){ node["vars"]=Json::arrayValue; for (auto& var: vars) { node["vars"].append(var.second->to_json()); -/* - string type=var.second->get_type(); - Json::Value newvar; - newvar["type"]=var.second->get_type(); - newvar["name"]=var.second->name; - newvar["connectable"]=var.second->connectable?"yes":"no"; - if (dynamic_cast(var.second)){ - newvar["input"]=Json::arrayValue; - for (auto& input: dynamic_cast(var.second)->values) { - newvar["input"].append(input.to_json()); - } - } - else { - newvar["input"]=var.second->to_json(); - } - 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; } @@ -155,3 +83,4 @@ cerr<(_name,_connectable)); } bool connect(int which,Node* target){ if (values.size()>which){ -- cgit v1.2.3