summaryrefslogtreecommitdiff
path: root/NT/src/rotor.h
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2014-01-22 14:28:34 +0000
committerTim Redfern <tim@eclectronics.org>2014-01-22 14:28:34 +0000
commita879f37ff944cd7bf502f4e3520b7da3d8faf39b (patch)
tree630ee0e87764e5982a00524f045b51d486f3292a /NT/src/rotor.h
parentc10e756720fe30ad2ffdcb54d83737aaad77190b (diff)
variable arrays working correctly
Diffstat (limited to 'NT/src/rotor.h')
-rw-r--r--NT/src/rotor.h19
1 files changed, 14 insertions, 5 deletions
diff --git a/NT/src/rotor.h b/NT/src/rotor.h
index 96a89ef..68473af 100644
--- a/NT/src/rotor.h
+++ b/NT/src/rotor.h
@@ -126,9 +126,10 @@ namespace Rotor {
for (auto node:nodes){
if (node.first==input){
if (connect(node.second)) {
- std::cerr<<"connecting '"<<TypeName<T>::Get()<<"' input to '"<<input<<"'"<<std::endl;
+ if (connection) std::cerr<<"connected '"<<TypeName<T>::Get()<<"' input to '"<<(dynamic_cast<Node_type<T>*>(connection))->get_type()<<"' "<<input<<std::endl;
+ //else std::cerr<<"connection disappeared"<<std::endl;
}
- else std::cerr<<"could not connect '"<<TypeName<T>::Get()<<"'' input to '"<<input<<"'"<<std::endl;
+ //else std::cerr<<"could not connect '"<<TypeName<T>::Get()<<"'' input to '"<<input<<"'"<<std::endl;
}
}
}
@@ -147,9 +148,13 @@ namespace Rotor {
return false;
}
const T& get(const Frame_parameters &frame){
+ //if (connection) std::cerr<<"still connected to '"<<(dynamic_cast<Node_type<T>*>(connection))->get_type()<<"'"<<std::endl;
+ //else std::cerr<<"connection disappeared"<<std::endl;
if (connection){
+ //std::cerr<<"retreiving value from '"<<(dynamic_cast<Node_type<T>*>(connection))->get_type()<<"' node ("<<get_type()<<"):"<<(dynamic_cast<Node_type<T>*>(connection))->get_output(frame)<<std::endl;
return (dynamic_cast<Node_type<T>*>(connection))->get_output(frame);
}
+ //else std::cerr<<"variable: returning default"<<std::endl;
return value;
}
protected:
@@ -173,9 +178,10 @@ namespace Rotor {
}
}
void create_connection(std::unordered_map<std::string,Node*> &nodes){
- for (auto v:values){
- v.create_connection(nodes);
- }
+ //for (auto v:values){ //weirdly does not work even though it seems to! maybe it returns a copy of of the object?
+ // v.create_connection(nodes);
+ //}
+ for (uint32_t i=0;i<values.size();i++) values[i].create_connection(nodes);
}
Json::Value to_json();
std::string get_type(){
@@ -199,11 +205,14 @@ namespace Rotor {
}
const T& get(uint32_t which,const Frame_parameters &frame){
if (values.size()>which){
+ //std::cerr<<"array: requested value "<<which<<":"<<values[which].get(frame)<<std::endl;
return values[which].get(frame);
}
+ //else std::cerr<<"array: returning default"<<std::endl;
return value;
}
const std::vector<Variable_type<T>>& get_values(){return values;};
+ uint32_t get_number(){return values.size();};
protected:
std::vector<Variable_type<T>> values;
T value;