summaryrefslogtreecommitdiff
path: root/NT/src/rotor.h
diff options
context:
space:
mode:
Diffstat (limited to 'NT/src/rotor.h')
-rw-r--r--NT/src/rotor.h30
1 files changed, 19 insertions, 11 deletions
diff --git a/NT/src/rotor.h b/NT/src/rotor.h
index 040435b..4d73050 100644
--- a/NT/src/rotor.h
+++ b/NT/src/rotor.h
@@ -1,6 +1,14 @@
#ifndef ROTOR_H
#define ROTOR_H
+/*
+ROTORD rewrite
+
+TJR-Jan-2014
+
+NB when plugging in to framework - convert all cerr messages to logged
+*/
+
#define ENABLE_TYPENAME(A) template<> struct TypeName<A> { static const char *Get() { return #A; }};
#include <string>
@@ -22,19 +30,19 @@ struct TypeName
};
template <>
-struct TypeName<int> {
+struct TypeName<int> {
static const char* Get() {
return "int";
}
};
template <>
-struct TypeName<double> {
+struct TypeName<double> {
static const char* Get() {
return "number";
}
};
template <>
-struct TypeName<std::string> {
+struct TypeName<std::string> {
static const char* Get() {
return "string";
}
@@ -154,16 +162,16 @@ namespace Rotor {
}
return false;
}
- void add(std::string _name="",bool _connectable=true,int num=1){
+ 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));
}
- bool connect(int which,Node* target){
+ bool connect(uint32_t which,Node* target){
if (values.size()>which){
return values[which].connect(target);
}
return false;
}
- const T& get(int which,const Frame_parameters &frame){
+ const T& get(uint32_t which,const Frame_parameters &frame){
if (values.size()>which){
return values[which].get(frame);
}
@@ -205,6 +213,7 @@ namespace Rotor {
Json::Value to_json();
virtual Node* clone(Json::Value &_settings)=0;
virtual std::string get_output_type()=0;
+ std::unordered_map<std::string,Variable*> vars;
protected:
std::string type;
std::string id;
@@ -212,18 +221,17 @@ namespace Rotor {
std::string description;
std::string title;
std::string ui_type;
- std::unordered_map<std::string,Variable*> vars;
};
template <class NT> class Node_type : public Node {
public:
virtual const NT& get_output(const Frame_parameters &frame)=0;
- void init(Json::Value settings){
- if (settings["vars"]!=nullptr){
+ void init(Json::Value settings){
+ if (!settings["vars"].empty()){
for ( uint32_t i = 0; i < settings["vars"].size(); ++i ) {
vars[settings["vars"][i]["name"].asString()]->init(settings["vars"][i]);
}
}
- if (settings["id"]!=nullptr) id=settings["id"].asString();
+ if (!settings["id"].empty()) id=settings["id"].asString();
}
std::string get_output_type(){return TypeName<NT>::Get();};
template <class IT> Variable_type<IT>* create_inlet(std::string name){
@@ -239,7 +247,7 @@ namespace Rotor {
return (dynamic_cast<Variable_array_type<IT>*>(vars[name]));
}
};
-
+
}
#endif //ROTOR_H