summaryrefslogtreecommitdiff
path: root/NT/src/rotor.h
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2014-01-19 09:33:14 +0000
committerTim Redfern <tim@eclectronics.org>2014-01-19 09:33:14 +0000
commit1e01ca3e89beca6870a3112c4513df66dd07dbb1 (patch)
treeff3128a93b0d7de9416eaf701267a315c0f8c0fb /NT/src/rotor.h
parent4f840c4ffee84df757bb593e8f3efe631235e521 (diff)
json spreadiing
Diffstat (limited to 'NT/src/rotor.h')
-rw-r--r--NT/src/rotor.h25
1 files changed, 15 insertions, 10 deletions
diff --git a/NT/src/rotor.h b/NT/src/rotor.h
index 6fed8df..0138191 100644
--- a/NT/src/rotor.h
+++ b/NT/src/rotor.h
@@ -33,6 +33,13 @@ struct TypeName<double> {
return "number";
}
};
+template <>
+struct TypeName<std::string> {
+ static const char* Get() {
+ return "string";
+ }
+};
+
namespace Rotor {
@@ -71,7 +78,7 @@ namespace Rotor {
class Variable { //pure virtual base type for variable pointers
public:
Variable(){connection=nullptr;};
- virtual void init(std::string n,std::string s)=0;
+ virtual void init(std::string s)=0;
virtual void init(Json::Value s)=0;
virtual ~Variable(){};
virtual bool connect(Node* target)=0;
@@ -82,11 +89,10 @@ namespace Rotor {
};
template <class T> class Variable_type : public Variable {
public:
- Variable_type(bool _c){connectable=_c;};
- void init(std::string n,std::string s){
+ Variable_type(std::string n,bool _c){name=n;connectable=_c;};
+ void init(std::string s){
std::istringstream cur(s);
cur >> value;
- name=n;
}
void init(Json::Value s){
std::istringstream cur(s["value"].asString());
@@ -121,11 +127,10 @@ namespace Rotor {
};
template <class T> class Variable_array_type: public Variable_array {
public:
- Variable_array_type(){connectable=true;};
- void init(std::string n,std::string s){
+ Variable_array_type(std::string n){name=n;connectable=true;};
+ void init(std::string s){
std::istringstream cur(s);
cur >> value;
- name=n;
}
void init(Json::Value s){
std::istringstream cur(s["value"].asString());
@@ -231,15 +236,15 @@ namespace Rotor {
}
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);
+ vars[name]=new Variable_type<IT>(name,true);
return (dynamic_cast<Variable_type<IT>*>(vars[name]));
}
template <class IT> Variable_type<IT>* create_attribute(std::string name){
- vars[name]=new Variable_type<IT>(false);
+ vars[name]=new Variable_type<IT>(name,false);
return (dynamic_cast<Variable_type<IT>*>(vars[name]));
}
template <class IT> Variable_array_type<IT>* create_array(std::string name){
- vars[name]=new Variable_array_type<IT>();
+ vars[name]=new Variable_array_type<IT>(name);
return (dynamic_cast<Variable_array_type<IT>*>(vars[name]));
}
};