diff options
Diffstat (limited to 'NT/src/rotor.h')
| -rw-r--r-- | NT/src/rotor.h | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/NT/src/rotor.h b/NT/src/rotor.h index c83fe63..e64095c 100644 --- a/NT/src/rotor.h +++ b/NT/src/rotor.h @@ -50,6 +50,7 @@ namespace Rotor { virtual void init(std::string s)=0; virtual ~Variable(){}; virtual bool connect(Node* target)=0; + virtual std::string get_type()=0; Node* connection; bool connectable; }; @@ -60,6 +61,9 @@ namespace Rotor { std::istringstream cur(s); cur >> value; } + std::string get_type(){ //need this to output node templates + return "unknown"; + } bool connect(Node* target){ if (connectable){ if (dynamic_cast<Node_type<T>*>(target)){ @@ -77,6 +81,27 @@ namespace Rotor { } T value; }; + template <class T> class Variable_array: public Variable_type<T> { + public: + Variable_array(){}; + void add(int num=1){ + for (int i=0;i<num;i++) values.push_back(T()); + } + bool connect(int which,Node* target){ + if (values.size()>which){ + return values[which].connect(target); + } + return false; + } + const T& get(int which,const Frame_parameters &frame){ + if (values.size()>which){ + return values[which].get(frame); + } + return value; + } + std::vector<Variable_type<T>> values; + T value; + }; //don't forget the dupliicate inlets //it needs to be a property of a var //vars need to be: @@ -104,11 +129,13 @@ namespace Rotor { return false; } virtual Node* clone(std::map<std::string,std::string> &_settings)=0; - std::string type; - std::string type; - std::string type; - std::string type; - protected: + std::string node_type; + std::string node_id; + std::string id; + std::string description; + std::string title; + std::string ui_type; + std::string output_type; std::unordered_map<std::string,Variable*> vars; }; template <class NT> class Node_type : public Node { @@ -130,6 +157,10 @@ 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])); + } }; } |
