summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-11-01 18:11:09 +0000
committerTim Redfern <tim@eclectronics.org>2013-11-01 18:11:09 +0000
commiteaccb1437465c6aa49e1d5511876852543e3b0fa (patch)
treeb9d09c4dbdefed1ec693e0492841cde426ef6643
parent2c74f2bf6cba53e17b5b36beacc895a121de3b4d (diff)
array attribute
-rw-r--r--rotord/src/rotor.cpp86
-rw-r--r--rotord/src/rotor.h28
2 files changed, 35 insertions, 79 deletions
diff --git a/rotord/src/rotor.cpp b/rotord/src/rotor.cpp
index 6ceab91..840298e 100644
--- a/rotord/src/rotor.cpp
+++ b/rotord/src/rotor.cpp
@@ -176,15 +176,21 @@ Json::Value Node_factory::list_node(Rotor::Node* _node){
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["value"]=attr.second->value;
attribute["type"]="enum";
attribute["options"]=Json::arrayValue;
for (auto val: attr.second->vals){
attribute["options"].append(val);
}
}
- else attribute["type"]="string";
+ 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);
}
}
@@ -239,8 +245,8 @@ void Node_factory::list_node(Rotor::Node* type,xmlIO XML,int i=0){
XML.addAttribute("attribute","name",attribute.first,j);
XML.addAttribute("attribute","title",attribute.second->title,j);
XML.addAttribute("attribute","description",attribute.second->description,j);
- XML.addAttribute("attribute","value",attribute.second->value,j);
if (attribute.second->vals.size()){ //document attribute enumeration
+ XML.addAttribute("attribute","value",attribute.second->value,j);
XML.addAttribute("attribute","type","enum",j);
XML.pushTag("attribute",j);
int k=0;
@@ -251,7 +257,15 @@ void Node_factory::list_node(Rotor::Node* type,xmlIO XML,int i=0){
}
XML.popTag();
}
- else XML.addAttribute("attribute","type","string",j);
+ else {
+ XML.addAttribute("attribute","type",attribute.second->type,j);
+ if (attribute.second->type=="array"){
+ XML.pushTag("attribute",j);
+ XML.addTag("value");
+ XML.popTag();
+ }
+ else XML.addAttribute("attribute","value",attribute.second->value,j);
+ }
j++;
}
XML.popTag();
@@ -298,69 +312,7 @@ void Node_factory::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;
- node["UID"]=type.second->UID;
- 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))->image_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;
- parameter["step"]=param.second->step;
- 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["options"]=Json::arrayValue;
- for (auto val: attr.second->vals){
- attribute["options"].append(val);
- }
- }
- else attribute["type"]="string";
- node["attributes"].append(attribute);
- }
- }
- JSON["nodeslist"].append(node);
+ JSON["nodeslist"].append(list_node(type.second));
}
}
} \ No newline at end of file
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h
index fcee9d9..94ec643 100644
--- a/rotord/src/rotor.h
+++ b/rotord/src/rotor.h
@@ -206,7 +206,7 @@ namespace Rotor {
class Attribute{ //description of a static attribute which can be an enumerated string array
public:
virtual ~Attribute(){};
- Attribute(const string &_desc,const string &_title,const string &_value,std::vector<std::string> _vals={}): description(_desc),title(_title),value(_value),intVal(0){
+ Attribute(const string &_desc,const string &_title,const string &_value,std::vector<std::string> _vals={},std::string _type="string"): description(_desc),title(_title),value(_value),intVal(0),type(_type){
vals=_vals;
init(_value);
};
@@ -218,7 +218,7 @@ namespace Rotor {
}
else intVal=0;
}
- string value,description,title;
+ string value,description,title,type;
std::vector<std::string> vals;
int intVal;
};
@@ -240,18 +240,15 @@ namespace Rotor {
void create_parameter(const string &_name,const string &_type,const string &_desc,const string &_title,float _value=1.0f,float _min=0.0f,float _max=0.0f,float _step=0.0f,Node* _connect=nullptr) {
parameters[_name]=new Parameter(_type,_desc,_title,_value,_min,_max,_step,_connect);
};
- void create_attribute(const string &_attr,const string &_desc,const string &_title,const string &_value,std::vector<std::string> _vals={}) {
- attributes[_attr]=new Attribute(_desc,_title,_value,_vals);
+ void create_attribute(const string &_attr,const string &_desc,const string &_title,const string &_value,std::vector<std::string> _vals={},std::string _type="string") {
+ attributes[_attr]=new Attribute(_desc,_title,_value,_vals,_type);
};
- //void create_attribute(const string &_attr,const string &_desc,const string &_title,const string &_value,std::vector<std::string> _vals={}) {
- // attributes[_attr]=new Attribute(_desc,_title,_value,_vals);
- //};
- void create_attribute(string *alias,const string &_attr,const string &_desc,const string &_title,const string &_value,std::vector<std::string> _vals={}) {
- create_attribute(_attr,_desc,_title,_value,_vals);
+ void create_attribute(string *alias,const string &_attr,const string &_desc,const string &_title,const string &_value,std::vector<std::string> _vals={},std::string _type="string") {
+ create_attribute(_attr,_desc,_title,_value,_vals,_type);
alias=&(attributes[_attr]->value);
};
- void create_attribute(int *alias,const string &_attr,const string &_desc,const string &_title,const string &_value,std::vector<std::string> _vals={}) {
- create_attribute(_attr,_desc,_title,_value,_vals);
+ void create_attribute(int *alias,const string &_attr,const string &_desc,const string &_title,const string &_value,std::vector<std::string> _vals={},std::string _type="string") {
+ create_attribute(_attr,_desc,_title,_value,_vals,_type);
alias=&(attributes[_attr]->intVal);
};
virtual void init_attribute(const string &attr){};
@@ -571,14 +568,21 @@ namespace Rotor {
Image in1,in2,in2t,temp; //for blend frames;
string *filename;
};
- class Video_bank: public Video_loader {
+ class Video_bank: public Image_node {
public:
Video_bank(){
+ create_attribute("filenames","names of video files to load","File names","",{},"array");
UID="73616e66-4306-11e3-981e-74d02b29f6a6";
+ title="Video bank";
+ description="Loads a banks of video files";
};
Video_bank(map<string,string> &settings): Video_bank() {
base_settings(settings);
};
+ Image *output(const Frame_spec &frame){
+ return nullptr;
+ }
+ Video_bank* clone(map<string,string> &_settings) { return new Video_bank(_settings);};
~Video_bank(){};
private:
};