diff options
| -rw-r--r-- | NT/src/rotor.cpp | 4 | ||||
| -rw-r--r-- | NT/src/rotor.h | 24 |
2 files changed, 25 insertions, 3 deletions
diff --git a/NT/src/rotor.cpp b/NT/src/rotor.cpp index 96e4250..faea5f0 100644 --- a/NT/src/rotor.cpp +++ b/NT/src/rotor.cpp @@ -22,8 +22,8 @@ Json::Value Node::list_json(){ for (auto& var: vars) { string type=var.second->get_type(); Json::Value newvar; - newvar["type"]=type; - newvar["name"]=name; + 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; diff --git a/NT/src/rotor.h b/NT/src/rotor.h index 30b4ba1..6fed8df 100644 --- a/NT/src/rotor.h +++ b/NT/src/rotor.h @@ -72,6 +72,7 @@ namespace Rotor { public: Variable(){connection=nullptr;}; virtual void init(std::string n,std::string s)=0; + virtual void init(Json::Value s)=0; virtual ~Variable(){}; virtual bool connect(Node* target)=0; virtual std::string get_type()=0; @@ -87,6 +88,11 @@ namespace Rotor { cur >> value; name=n; } + void init(Json::Value s){ + std::istringstream cur(s["value"].asString()); + cur >> value; + name=s["name"].asString(); + } std::string get_type(){ //need this to output node templates return TypeName<T>::Get(); } @@ -121,6 +127,11 @@ namespace Rotor { cur >> value; name=n; } + void init(Json::Value s){ + std::istringstream cur(s["value"].asString()); + cur >> value; + name=s["name"].asString(); + } std::string get_type(){ //need this to output node templates return TypeName<T>::Get(); } @@ -199,13 +210,24 @@ namespace Rotor { } } } - void init(Json::Value settings){ + void init(Json::Value settings){ + if (settings["vars"]){ + for ( uint32_t i = 0; i < settings["vars"].size(); ++i ) { + vars[settings["vars"][i]["name"].asString()]->init(settings["vars"][i]); + } + } + + /* + + for (auto s:settings["input"].Members) { if (vars.find(s.first)!=vars.end()){ vars[s.first]->init(s.second); //printf("set %s to %s\n",s.first.c_str(),s.second.c_str()); } } + */ + if (settings["id"]) id=settings["id"]; } std::string output_type(){return TypeName<NT>::Get();}; template <class IT> Variable_type<IT>* create_inlet(std::string name){ |
