summaryrefslogtreecommitdiff
path: root/NT/src
diff options
context:
space:
mode:
Diffstat (limited to 'NT/src')
-rw-r--r--NT/src/rotor.cpp89
-rw-r--r--NT/src/rotor.h4
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<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;
}
+
diff --git a/NT/src/rotor.h b/NT/src/rotor.h
index 9228388..ef90eb6 100644
--- a/NT/src/rotor.h
+++ b/NT/src/rotor.h
@@ -143,8 +143,8 @@ namespace Rotor {
}
return false;
}
- void add(int num=1){
- for (int i=0;i<num;i++) values.push_back(T());
+ void add(std::string _name="",bool _connectable=true,int num=1){
+ for (int i=0;i<num;i++) values.push_back(Variable_type<T>(_name,_connectable));
}
bool connect(int which,Node* target){
if (values.size()>which){