summaryrefslogtreecommitdiff
path: root/rotord/src/rotor.h
diff options
context:
space:
mode:
Diffstat (limited to 'rotord/src/rotor.h')
-rwxr-xr-xrotord/src/rotor.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h
index 069e908..9427d83 100755
--- a/rotord/src/rotor.h
+++ b/rotord/src/rotor.h
@@ -10,6 +10,8 @@
#include <sys/time.h>
#include <iostream>
+#include <json/json.h>
+
#include "Poco/Net/HTTPResponse.h"
#include "Poco/Logger.h"
#include "Poco/Path.h"
@@ -955,6 +957,74 @@ namespace Rotor {
}
}
}
+ void 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;
+ 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))->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;
+ 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["attribute"]=Json::arrayValue;
+ for (auto val: attr.second->vals){
+ attribute["attribute"].append(val);
+ }
+ }
+ else attribute["type"]="string";
+ node["attributes"].append(attribute);
+ }
+ }
+ JSON["nodeslist"].append(node);
+ }
+ }
+ }
private:
unordered_map<string,Node*> type_map;
};