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.h48
1 files changed, 10 insertions, 38 deletions
diff --git a/NT/src/rotor.h b/NT/src/rotor.h
index 26f7fb0..49e978f 100644
--- a/NT/src/rotor.h
+++ b/NT/src/rotor.h
@@ -9,7 +9,7 @@
#include <unordered_map>
#include <json/json.h>
-#include "xmlIO.h"
+
namespace Rotor {
@@ -68,7 +68,8 @@ namespace Rotor {
delete v.second;
}
}
- virtual Node* clone(map<string,string> &_settings)=0;
+ bool connect(std::string v,Node *t);
+ virtual Node* clone(std::map<std::string,std::string> &_settings)=0;
std::string type;
protected:
std::unordered_map<std::string,Variable*> vars;
@@ -77,43 +78,14 @@ namespace Rotor {
public:
virtual const NT& get_output(const Frame_parameters &frame)=0;
void init(std::map<std::string,std::string> settings);
- bool connect(std::string v,Node *t);
- template <class IT> Variable_type<IT>* create_inlet(std::string name);
- template <class IT> Variable_type<IT>* create_attribute(std::string name);
- };
- class Node_factory{
- public:
- Node_factory();
- ~Node_factory(){
- for (auto t:type_map) delete t.second;
+ template <class IT> Variable_type<IT>* create_inlet(std::string name){
+ vars[name]=new Variable_type<IT>(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);
+ return (dynamic_cast<Variable_type<IT>*>(vars[name]));
}
- void add_type(std::string type,Node* proto){
- type_map[type]=proto;
- type_map[type]->type=type;
- };
- void add_type(std::string type,Node* proto,std::vector<Rotor::Node*> &category){
- add_type(type,proto);
- category.push_back(proto);
- };
- Node *create(std::map<std::string,std::string> &settings){
- if (settings.find("type")!=settings.end()) {
- if (type_map.find(settings["type"])!=type_map.end()) {
- return type_map[settings["type"]]->clone(settings);
- }
- }
- return NULL;
- };
- bool list_node(const std::string &t,xmlIO XML);
- bool list_node(const std::string &t,Json::Value &JSON);
- void list_node(Rotor::Node* type,xmlIO XML,int i=0);
- Json::Value list_node(Rotor::Node* type);
- void list_nodes(xmlIO XML);
- void list_nodes(Json::Value &JSON);
- void list_categories(xmlIO XML);
- void list_categories(Json::Value &JSON);
- private:
- std::map<std::string,Node*> type_map;
- std::map<std::string,std::vector<Rotor::Node*> > category;
};
}