diff options
Diffstat (limited to 'NT/src/rotor.h')
| -rw-r--r-- | NT/src/rotor.h | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/NT/src/rotor.h b/NT/src/rotor.h index f2e19b5..038334b 100644 --- a/NT/src/rotor.h +++ b/NT/src/rotor.h @@ -90,14 +90,21 @@ namespace Rotor { public: Enum(std::initializer_list<std::string> init={},int def=0) : labels(init), value(def){}; int get_value(){return value;}; - operator int () const { + operator int () const { //overload C style cast to int return value; } + friend istream& operator>> (istream &in, Enum &en); private: std::vector<std::string> labels; int value; }; - + + istream& operator>> (istream &in, Enum &en) + { + in >> en.value; + return in; + } + class Audio_frame{ public: Audio_frame(uint16_t *_samples,int _channels,int _numsamples){ @@ -212,9 +219,7 @@ namespace Rotor { void init(Json::Value s){ name=s["name"].asString(); if (!s["input"].empty()){ - for (uint32_t i=0;i<s["input"].size();i++){ - add("",s["input"][i].asString()); - } + add(s["input"].size()); } } bool create_connection(std::unordered_map<std::string,Node*> &nodes){ @@ -229,17 +234,17 @@ namespace Rotor { } Json::Value to_json(); std::string get_type(){ - return TypeName<T>::Get(); + return TypeName<T>::Get(); } bool connect(Node* target){ //array does not connect this way return false; } - void add(std::string _name,std::string _input,bool _connectable=true){ - values.push_back(Variable_type<T>(_name,_input,_connectable)); + void add(std::string _name="",std::string _description="",std::string _title="",bool _connectable=true){ + values.push_back(Variable_type<T>(_name,_description,_title,_connectable)); } - void add(std::string _name="",bool _connectable=true,int num=1){ - for (int i=0;i<num;i++) values.push_back(Variable_type<T>(_name,"",_connectable)); + void add(int num,std::string _name="",std::string _description="",std::string _title="",bool _connectable=true){ + for (int i=0;i<num;i++) values.push_back(Variable_type<T>(_name,_description,_title,_connectable)); } bool connect(uint32_t which,Node* target){ if (values.size()>which){ @@ -261,16 +266,7 @@ namespace Rotor { 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: - //std::unordered_map<std::string,std::pair<bool,std::vector<Variable*>>> - //?? - //or could it be that a var has properties - //var needs to be a class? - //or multi var could be a subclass of var? - //with an extra accessor const T& get(int which,const Frame_parameters &frame) - //in Node we could have create_multi_inlet() and add_multi_inlet() + //could specialise a variable type operator double() etc to allow direct cast class Node { //base type for node pointers public: Node(){type="";type_id="";id="";description="";}; |
