diff options
| author | Comment <tim@gray.(none)> | 2013-11-03 16:00:34 +0000 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-11-03 16:00:34 +0000 |
| commit | 7d78e568bcef0356fa2d4873b2ba6d19b65c4689 (patch) | |
| tree | 37597ee4e74513f54ddfa72511803faba43bdfe7 /rotord/src/graph.cpp | |
| parent | 510a5218d5e981db3dde9ed31ddc6f732ed6a22a (diff) | |
making video bank loader
Diffstat (limited to 'rotord/src/graph.cpp')
| -rw-r--r-- | rotord/src/graph.cpp | 56 |
1 files changed, 47 insertions, 9 deletions
diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp index 3f1d02b..e323b87 100644 --- a/rotord/src/graph.cpp +++ b/rotord/src/graph.cpp @@ -322,19 +322,35 @@ bool Graph::parseJson(string &data,string &media_path){ map<string,string> settings; vector<string> attrs; settings["type"]=jnodes[i]["type"].asString(); - if (settings["type"]=="video_cycler"){ - //breakpoint - cerr<<"making video cycler"<<endl; - } - //attributes + //attributes settings["media_path"]=media_path; - for (int m=0;m<jnodes[i]["attributes"].size();m++){ + Node* node=factory.create(settings); + for (int m=0;m<jnodes[i]["attributes"].size();m++){ string attribute=jnodes[i]["attributes"][m]["name"].asString(); - string val=jnodes[i]["attributes"][m]["value"].asString(); - settings[attribute]=val; + if (node->attributes.find(attribute)!=node->attributes.end()){ + Attribute *attr=node->attributes.find(attribute)->second; + if (attr->type=="enum"){ + string val=jnodes[i]["attributes"][m]["value"].asString(); + attr->init(val); + } + else if (attr->type=="array"){ + std::vector<std::string> vals; + + for (int i5 = 0; i5 < jnodes[i]["attributes"][m]["value"].size(); i5++ ) + { + vals.push_back(jnodes[i]["attributes"][m]["value"][i5].asString()); + } + attr->init(vals); + + } + else { + string val=jnodes[i]["attributes"][m]["value"].asString(); + attr->value=val; + } + } + //settings[attribute]=val; //cerr << "Rotor: setting attribute '"<<attribute<<"' of "<<nodeID<<" to "<<val<<endl; } - Node* node=factory.create(settings); if (node) { if (nodes.find(nodeID)==nodes.end()){ cerr << "Rotor: creating node '"<<nodeID<<"': '"<< settings["type"] << "'" << endl; @@ -545,6 +561,28 @@ bool Graph::parseXml(string media_path){ // nodes[nodeID]->set_parameter(xml.getAttribute("parameter","name","",i5),xml.getAttribute("parameter","value","",i5)); //} //if (n5>0) cerr << "Rotor: found " << n5 << " extra parameters for node '" << nodeID << "'" << endl; + //support attributes in tags + n4=xml.getNumTags("attribute"); + for (int i4=0;i4<n4;i4++){ + string attribute=xml.getAttribute("attribute","name","",i4); + if (nodes[nodeID]->attributes.find(attribute)!=nodes[nodeID]->attributes.end()) { + string val=xml.getAttribute("attribute","value","",i4); + if (val!="") nodes[nodeID]->attributes.find(attribute)->second->value=val; + string type=xml.getAttribute("attribute","type","",i4); + if (nodes[nodeID]->attributes.find(attribute)->second->type=="array"){ + if(xml.pushTag("attribute",i4)) { + int n5=xml.getNumTags("value"); + std::vector<std::string> vals; + for (int i5=0;i5<n5;i5++){ + vals.push_back(xml.getValue("value","",i5)); + } + nodes[nodeID]->attributes.find(attribute)->second->init(vals); + xml.popTag(); + } + } + } + else cerr << "Rotor: cannot find attribute '" << attribute << "' of "<<nodetype<<" "<< nodeID << endl; + } xml.popTag(); } |
