diff options
| author | Tim Redfern <tim@eclectronics.org> | 2014-01-19 19:54:38 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2014-01-19 19:54:38 +0000 |
| commit | ce528aa299501ecab63018f91b937766ffbc95be (patch) | |
| tree | 34972d49d69c5cf926a3974a020e945ff4576a8c /NT/src/rotor.h | |
| parent | 1e01ca3e89beca6870a3112c4513df66dd07dbb1 (diff) | |
variables writing json
Diffstat (limited to 'NT/src/rotor.h')
| -rw-r--r-- | NT/src/rotor.h | 43 |
1 files changed, 9 insertions, 34 deletions
diff --git a/NT/src/rotor.h b/NT/src/rotor.h index 0138191..9228388 100644 --- a/NT/src/rotor.h +++ b/NT/src/rotor.h @@ -78,9 +78,9 @@ namespace Rotor { class Variable { //pure virtual base type for variable pointers public: Variable(){connection=nullptr;}; - virtual void init(std::string s)=0; - virtual void init(Json::Value s)=0; virtual ~Variable(){}; + virtual Json::Value to_json()=0; + virtual void init(Json::Value s)=0; virtual bool connect(Node* target)=0; virtual std::string get_type()=0; Node* connection; @@ -89,16 +89,13 @@ namespace Rotor { }; template <class T> class Variable_type : public Variable { public: - Variable_type(std::string n,bool _c){name=n;connectable=_c;}; - void init(std::string s){ - std::istringstream cur(s); - cur >> value; - } + Variable_type(std::string _name,bool _connectable){name=_name;connectable=_connectable;}; void init(Json::Value s){ std::istringstream cur(s["value"].asString()); cur >> value; name=s["name"].asString(); } + Json::Value to_json(); std::string get_type(){ //need this to output node templates return TypeName<T>::Get(); } @@ -128,15 +125,12 @@ namespace Rotor { template <class T> class Variable_array_type: public Variable_array { public: Variable_array_type(std::string n){name=n;connectable=true;}; - void init(std::string s){ - std::istringstream cur(s); - cur >> value; - } void init(Json::Value s){ std::istringstream cur(s["value"].asString()); cur >> value; name=s["name"].asString(); } + Json::Value to_json(); std::string get_type(){ //need this to output node templates return TypeName<T>::Get(); } @@ -193,8 +187,8 @@ namespace Rotor { } return false; } - Json::Value list_json(); - virtual Node* clone(std::map<std::string,std::string> &_settings)=0; + Json::Value to_json(); + virtual Node* clone(Json::Value &_settings)=0; virtual std::string output_type()=0; std::string type; std::string id; @@ -207,32 +201,13 @@ namespace Rotor { template <class NT> class Node_type : public Node { public: virtual const NT& get_output(const Frame_parameters &frame)=0; - void init(std::map<std::string,std::string> settings){ - for (auto s:settings) { - 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()); - } - } - } void init(Json::Value settings){ - if (settings["vars"]){ + if (settings["vars"]!=nullptr){ 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"]; + if (settings["id"]!=nullptr) id=settings["id"].asString(); } std::string output_type(){return TypeName<NT>::Get();}; template <class IT> Variable_type<IT>* create_inlet(std::string name){ |
