summaryrefslogtreecommitdiff
path: root/rotord/src/rotor.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-11-01 16:56:52 +0000
committerTim Redfern <tim@eclectronics.org>2013-11-01 16:56:52 +0000
commit2c74f2bf6cba53e17b5b36beacc895a121de3b4d (patch)
tree8ac67bb64835019f5d93c2a27f7c2153165c849c /rotord/src/rotor.cpp
parente67e0a69e8f168646076d26e7317eaec4e02058a (diff)
listnode/json
Diffstat (limited to 'rotord/src/rotor.cpp')
-rw-r--r--rotord/src/rotor.cpp144
1 files changed, 80 insertions, 64 deletions
diff --git a/rotord/src/rotor.cpp b/rotord/src/rotor.cpp
index a4ef055..6ceab91 100644
--- a/rotord/src/rotor.cpp
+++ b/rotord/src/rotor.cpp
@@ -45,6 +45,7 @@ Node_factory::Node_factory(){
add_type("waves",new Waves(),category["Source"]);
add_type("still_image",new Still_image(),category["Source"]);
add_type("video_loader",new Video_loader(),category["Source"]);
+ add_type("video_bank",new Video_bank(),category["Source"]);
add_type("svg",new Svg(),category["Source"]);
category["Distort"]=vector<Node*>();
@@ -112,7 +113,83 @@ bool Node_factory::list_node(const string &t,xmlIO XML){
}
}
XML.addValue("error","Node /"+t+"/ not found");
+ return false;
};
+bool Node_factory::list_node(const string &t,Json::Value &JSON){
+ for (auto& type: type_map) {
+ if (type.first==t) {
+ JSON["node"]=list_node(type.second);
+ return true;
+ }
+ }
+ JSON["error"]="Node /"+t+"/ not found";
+ return false;
+};
+Json::Value Node_factory::list_node(Rotor::Node* _node){
+ Json::Value node;
+ node["type"]=_node->type;
+ node["title"]=_node->title;
+ node["inputs"]=_node->duplicate_inputs?"expandable":"fixed";
+ if (dynamic_cast<Signal_node*> (_node)!=nullptr) node["output"]="signal";
+ if (dynamic_cast<Image_node*> (_node)!=nullptr) node["output"]="image";
+ node["description"]=_node->description;
+ node["UID"]=_node->UID;
+ 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;
+ 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);
+ }
+ }
+ return node;
+}
void Node_factory::list_node(Rotor::Node* type,xmlIO XML,int i=0){
XML.addTag("node");
XML.addAttribute("node","type",type->type,i);
@@ -210,70 +287,9 @@ void Node_factory::list_categories(Json::Value &JSON){
category["name"]=_category.first;
category["nodes"]=Json::arrayValue;
for (auto& _node: _category.second){
- cerr<<"Adding "<<_category.first<<":"<<_node->type<<endl;
- Json::Value node;
- node["type"]=_node->type;
- node["title"]=_node->title;
- node["inputs"]=_node->duplicate_inputs?"expandable":"fixed";
- if (dynamic_cast<Signal_node*> (_node)!=nullptr) node["output"]="signal";
- if (dynamic_cast<Image_node*> (_node)!=nullptr) node["output"]="image";
- node["description"]=_node->description;
- node["UID"]=_node->UID;
- 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;
- 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);
- }
- }
- category["nodes"].append(node);
+ //cerr<<"Adding "<<_category.first<<":"<<_node->type<<endl;
+
+ category["nodes"].append(list_node(_node));
}
JSON["category"].append(category);
}