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 | |
| parent | 8e1d11383ed4ef2e41b11fa88b475014c8c2ba5c (diff) | |
pesky factory
| -rw-r--r-- | rotord/rotor.cpp | 8 | ||||
| -rwxr-xr-x | rotord/rotor.h | 24 |
2 files changed, 18 insertions, 14 deletions
diff --git a/rotord/rotor.cpp b/rotord/rotor.cpp index 02f4675..3e7dc2f 100644 --- a/rotord/rotor.cpp +++ b/rotord/rotor.cpp @@ -78,6 +78,7 @@ Command_response Render_context::session_command(const std::vector<std::string>& //Poco::File f=Poco::File(command[3]); std::auto_ptr<std::istream> pStr(URIStreamOpener::defaultOpener().open(command[3])); + /* if (f.exists()) { //pass to worker thread ??if engine is ready?? ??what if engine has finished but results aren't read?? audio_filename=command[3]; //for now, store session variables in memory @@ -88,6 +89,7 @@ Command_response Render_context::session_command(const std::vector<std::string>& response.status=HTTPResponse::HTTP_NOT_FOUND; response.description="<status context='"+command[1]+"'>File "+command[3]+" not found</status>\n"; } + */ } else { response.status=HTTPResponse::HTTP_BAD_REQUEST; @@ -374,7 +376,7 @@ bool Render_context::load_graph(string filename){ Node_factory::Node_factory(){ //for now, statically load prototype map in constructor - add_type("audio_analysis",Audio_analysis()); - add_type("==",Is_new_integer()); - add_type("signal_output",Signal_output()); + add_type("audio_analysis",new Audio_analysis()); + add_type("==",new Is_new_integer()); + add_type("signal_output",new Signal_output()); }
\ No newline at end of file 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; |
