diff options
| author | Comment <tim@gray.(none)> | 2013-03-08 10:11:50 +0000 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-03-08 10:11:50 +0000 |
| commit | 20eaa8e39617cc22147b82d678b72ded2dd5fe27 (patch) | |
| tree | f2097ee7fa81296bba1467643393976b0be83c41 /rotord/rotor.h | |
| parent | 8e1d11383ed4ef2e41b11fa88b475014c8c2ba5c (diff) | |
pesky factory
Diffstat (limited to 'rotord/rotor.h')
| -rwxr-xr-x | rotord/rotor.h | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/rotord/rotor.h b/rotord/rotor.h index d79c9e2..346158e 100755 --- a/rotord/rotor.h +++ b/rotord/rotor.h @@ -121,7 +121,7 @@ namespace Rotor { }; class Node{ public: - Node(){}; + Node(){type="node";}; virtual ~Node() {}; Node(map<string,string> &settings){ cerr << "Node:"; @@ -129,7 +129,7 @@ namespace Rotor { cerr << it->first << "," << it->second << " "; } cerr << endl; - description=settings["description"];type=settings["type"];output_type=settings["output"];ID=settings["ID"]; + description=settings["description"];output_type=settings["output"];ID=settings["ID"]; }; UUID uid; //every usable node has a UUID int id; @@ -179,7 +179,7 @@ namespace Rotor { //actual nodes------------------------------------------------- class Audio_analysis: public Node { public: - Audio_analysis(){}; + Audio_analysis(){type="audio_analysis";}; Audio_analysis(map<string,string> &settings) { cerr << "Audio analysis:"; for (map<string,string>::iterator it=settings.begin();it!=settings.end();++it) { @@ -198,7 +198,7 @@ namespace Rotor { //for now, assume 25 //what to cache? for now, don't cache public: - Is_new_integer(){}; + Is_new_integer(){type="is_new_integer";}; Is_new_integer(map<string,string> &settings) { cerr << "Is new integer:"; for (map<string,string>::iterator it=settings.begin();it!=settings.end();++it) { @@ -214,14 +214,14 @@ namespace Rotor { }; class Signal_output: public Node { public: - Signal_output(){}; + Signal_output(){type="signal_output";}; Signal_output(map<string,string> &settings) { cerr << "Signal output:"; for (map<string,string>::iterator it=settings.begin();it!=settings.end();++it) { cerr << it->first << "," << it->second << " "; } cerr << endl; - description=settings["description"];type=settings["type"];output_type=settings["output"];ID=settings["ID"]; + }; bool render(const float duration, const float framerate,string &xml_out); @@ -231,15 +231,16 @@ namespace Rotor { public: Node_factory(); template <typename T> - T* clone(T proto,map<string,string> &settings) { - cerr << "Factory settings: "; + Node* clone(T *proto,map<string,string> &settings) { + cerr << "Factory creating a " << proto->type << ", settings: "; for (map<string,string>::iterator it=settings.begin();it!=settings.end();++it) { cerr << it->first << "," << it->second << " "; } cerr << endl; return new T(settings); - } - void add_type(string type,Node proto){ + }; + template <typename T> + void add_type(string type,T *proto){ type_map[type]=proto; }; Node* create(map<string,string> &settings){ @@ -249,7 +250,7 @@ namespace Rotor { else return NULL; }; private: - map<string,Node> type_map; + map<string,Node*> type_map; }; class Graph{ public: @@ -261,6 +262,7 @@ namespace Rotor { std::unordered_map<string,Node*> nodes; Node* find(const string &type){ for (std::unordered_map<string,Node*>::iterator it=nodes.begin();it!=nodes.end();++it) { + cerr << "checking a " << it->second->type << " looking for a " << type << endl; if (it->second->type==type) return it->second; } return NULL; |
