diff options
| -rw-r--r-- | NT/src/factory.cpp | 14 | ||||
| -rw-r--r-- | NT/src/nodes.h | 6 | ||||
| -rw-r--r-- | NT/src/rotor.h | 13 |
3 files changed, 20 insertions, 13 deletions
diff --git a/NT/src/factory.cpp b/NT/src/factory.cpp index 6c1c825..3567f83 100644 --- a/NT/src/factory.cpp +++ b/NT/src/factory.cpp @@ -44,16 +44,18 @@ Json::Value Node_factory::list_node(Rotor::Node* _node){ string type=var.second->get_type(); Json::Value newvar; newvar["type"]=type; - if (type=="array"){ - newvar["array"]=Json::arrayValue; - for (auto& element: var.second->values) { - newvar["array"].append(newvalue); + newvar["connectable"]=var.second->connectable?"yes":"no"; + if (dynamic_cast<Variable_array*>(var.second)){ + newvar["input"]=Json::arrayValue; + for (auto& element: dynamic_cast<Variable_array*>(var.second)->values) { + Json::Value newvalue; + newvar["input"].append(newvalue); } } else { - newvar["connectable"]=var.second->connectable?"yes":"no"; - node["vars"].append(newvar); + newvar["input"]=Json::Value(); } + node["vars"].append(newvar); } } /* diff --git a/NT/src/nodes.h b/NT/src/nodes.h index da24292..f294756 100644 --- a/NT/src/nodes.h +++ b/NT/src/nodes.h @@ -27,7 +27,7 @@ namespace Rotor{ class Multiply: public Double_node { public: Multiply(){ - inlet=create_inlet<double>("inlet"); + inlets=create_array<double>("inlet"); value=create_inlet<double>("value"); node_type="multiply"; } @@ -35,12 +35,12 @@ namespace Rotor{ init(settings); }; const double &get_output(const Frame_parameters &frame){ - result=inlet->get(frame)*value->get(frame); + result=inlets->get(0,frame)*value->get(frame); return result; } Multiply* clone(map<string,string> &_settings) { return new Multiply(_settings);}; private: - Variable_type<double> *inlet; + Variable_array_type<double> *inlets; Variable_type<double> *value; double result; }; diff --git a/NT/src/rotor.h b/NT/src/rotor.h index e64095c..0b728ac 100644 --- a/NT/src/rotor.h +++ b/NT/src/rotor.h @@ -81,9 +81,14 @@ namespace Rotor { } T value; }; - template <class T> class Variable_array: public Variable_type<T> { + class Variable_array: public Variable { public: Variable_array(){}; + std::vector<Variable> values; + }; + template <class T> class Variable_array_type: public Variable_array { + public: + Variable_array_type(){}; void add(int num=1){ for (int i=0;i<num;i++) values.push_back(T()); } @@ -157,9 +162,9 @@ namespace Rotor { vars[name]=new Variable_type<IT>(false); return (dynamic_cast<Variable_type<IT>*>(vars[name])); } - template <class IT> Variable_array<IT>* create_array(std::string name){ - vars[name]=new Variable_array<IT>(); - return (dynamic_cast<Variable_array<IT>*>(vars[name])); + template <class IT> Variable_array_type<IT>* create_array(std::string name){ + vars[name]=new Variable_array_type<IT>(); + return (dynamic_cast<Variable_array_type<IT>*>(vars[name])); } }; |
