diff options
Diffstat (limited to 'NT/src/rotor.h')
| -rw-r--r-- | NT/src/rotor.h | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/NT/src/rotor.h b/NT/src/rotor.h index d261954..30b4ba1 100644 --- a/NT/src/rotor.h +++ b/NT/src/rotor.h @@ -30,7 +30,7 @@ struct TypeName<int> { template <> struct TypeName<double> { static const char* Get() { - return "double"; + return "number"; } }; @@ -71,23 +71,26 @@ 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(std::string n,std::string s)=0; virtual ~Variable(){}; virtual bool connect(Node* target)=0; virtual std::string get_type()=0; Node* connection; bool connectable; + std::string name; }; template <class T> class Variable_type : public Variable { public: Variable_type(bool _c){connectable=_c;}; - void init(std::string s){ + void init(std::string n,std::string s){ std::istringstream cur(s); cur >> value; + name=n; } std::string get_type(){ //need this to output node templates return TypeName<T>::Get(); } +//have to cast connect and get_output to use templated return types bool connect(Node* target){ if (connectable){ if (dynamic_cast<Node_type<T>*>(target)){ @@ -112,10 +115,11 @@ namespace Rotor { }; template <class T> class Variable_array_type: public Variable_array { public: - Variable_array_type(){}; - void init(std::string s){ + Variable_array_type(){connectable=true;}; + void init(std::string n,std::string s){ std::istringstream cur(s); cur >> value; + name=n; } std::string get_type(){ //need this to output node templates return TypeName<T>::Get(); @@ -176,9 +180,9 @@ namespace Rotor { Json::Value list_json(); virtual Node* clone(std::map<std::string,std::string> &_settings)=0; virtual std::string output_type()=0; - std::string node_type; - std::string node_id; + std::string type; std::string id; + std::string type_id; std::string description; std::string title; std::string ui_type; @@ -195,6 +199,14 @@ namespace Rotor { } } } + void init(Json::Value settings){ + 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()); + } + } + } std::string output_type(){return TypeName<NT>::Get();}; template <class IT> Variable_type<IT>* create_inlet(std::string name){ vars[name]=new Variable_type<IT>(true); |
