diff options
| author | Comment <tim@gray.(none)> | 2013-11-06 01:09:39 +0000 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-11-06 01:09:39 +0000 |
| commit | 94921caf9ca327d35adcb941f51ba4b1a776f768 (patch) | |
| tree | 5c7cf44fe1ccde53b380ee2346ce3535943ca016 | |
| parent | 18a77356a424511e7ae1865d1554d20b4b5c51fb (diff) | |
json loader issue
| -rw-r--r-- | rotord/Makefile | 2 | ||||
| -rw-r--r-- | rotord/src/graph.cpp | 20 | ||||
| -rw-r--r-- | rotord/src/rotor.h | 1 |
3 files changed, 13 insertions, 10 deletions
diff --git a/rotord/Makefile b/rotord/Makefile index 55d2970..70c6acb 100644 --- a/rotord/Makefile +++ b/rotord/Makefile @@ -44,7 +44,7 @@ HDREXTS = .h .H .hh .hpp .HPP .h++ .hxx .hp # The pre-processor and compiler options. # Users can override those variables from the command line. -CFLAGS = -g -O2 +CFLAGS = -g -O3 CXXFLAGS= CXX = colorgcc diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp index e34ddec..9544446 100644 --- a/rotord/src/graph.cpp +++ b/rotord/src/graph.cpp @@ -324,13 +324,18 @@ bool Graph::parseJson(string &data,string &media_path){ Node* node=factory.create(settings); for (uint32_t m=0;m<jnodes[i]["attributes"].size();m++){ string attribute=jnodes[i]["attributes"][m]["name"].asString(); + string 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); + val=jnodes[i]["attributes"][m]["value"].asString(); + attr->init(val); } - else if (attr->type=="array"){ + if (attr->type=="string") { + val=jnodes[i]["attributes"][m]["value"].asString(); + attr->value=val; + } + if (attr->type=="array"){ std::vector<std::string> vals; for (uint32_t i5 = 0; i5 < jnodes[i]["attributes"][m]["value"].size(); i5++ ) @@ -338,15 +343,12 @@ bool Graph::parseJson(string &data,string &media_path){ 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; } + //cerr << "Rotor: setting attribute '"<<attribute<<"' of "<<nodeID<<" type "<<attr->type<<" to "<<val<<endl; + cerr << "Rotor: setting attribute '"<<attribute<<"' of "<<nodeID<<" type "<<attr->type<<" to "<<val<<endl; + } //settings[attribute]=val; - //cerr << "Rotor: setting attribute '"<<attribute<<"' of "<<nodeID<<" to "<<val<<endl; } if (node) { if (nodes.find(nodeID)==nodes.end()){ diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index aa76491..a8e6fca 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -249,6 +249,7 @@ namespace Rotor { 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={},std::string _type="string") { + if (_vals.size()&&_type!="array") _type="enum"; //hack for incomplete attribute types attributes[_attr]=new Attribute(_desc,_title,_value,_vals,_type); }; 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") { |
