diff options
| author | Tim Redfern <tim@eclectronics.org> | 2014-01-19 22:56:26 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2014-01-19 22:56:26 +0000 |
| commit | 3606861884c15b8f6bfe37b804f6195ddf13d1a1 (patch) | |
| tree | 045f70132e8782fac4c5448e661d7f9ae6a4043c /NT/src/rotor.cpp | |
| parent | ce528aa299501ecab63018f91b937766ffbc95be (diff) | |
json initialisers all done
Diffstat (limited to 'NT/src/rotor.cpp')
| -rw-r--r-- | NT/src/rotor.cpp | 89 |
1 files changed, 9 insertions, 80 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<T>::to_json(){ } return json; } + +//explicit template instantiation +template class Variable_type<double>; +template class Variable_type<string>; + +template class Variable_array_type<double>; + + 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<Variable_array*>(var.second)){ - newvar["input"]=Json::arrayValue; - for (auto& input: dynamic_cast<Variable_array*>(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<Image_node*> (_node)!=nullptr) { - if ((dynamic_cast<Image_node*>(_node))->image_inputs.size()){ - node["image_inputs"]=Json::arrayValue; - for (auto& input: (dynamic_cast<Image_node*>(_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<<writer.write(js)<<endl; f.list_node("print",js); cerr<<writer.write(js)<<endl; } + |
