From 4f840c4ffee84df757bb593e8f3efe631235e521 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Wed, 15 Jan 2014 16:38:45 +0000 Subject: json loading --- NT/src/rotor.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'NT/src/rotor.h') 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::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::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::Get();}; template Variable_type* create_inlet(std::string name){ -- cgit v1.2.3