From 87b2dabd9dd692aa505ea1327893d719f56fa162 Mon Sep 17 00:00:00 2001 From: Comment Date: Sun, 3 Mar 2013 20:21:46 +0000 Subject: xml transfusion --- rotord/rotor.cpp | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'rotord/rotor.cpp') diff --git a/rotord/rotor.cpp b/rotord/rotor.cpp index 8af1f0b..8360824 100644 --- a/rotord/rotor.cpp +++ b/rotord/rotor.cpp @@ -48,22 +48,22 @@ Command_response Render_context::session_command(const std::vector& //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 add_queue(ANALYSE_AUDIO); - response.description="Starting audio analysis: "+command[3]+"\n"; + response.description="Starting audio analysis: "+command[3]+"\n"; } else { response.status=HTTPResponse::HTTP_NOT_FOUND; - response.description="File "+command[3]+" not found\n"; + response.description="File "+command[3]+" not found\n"; } } else { response.status=HTTPResponse::HTTP_BAD_REQUEST; - response.description="Rotor: session busy\n"; + response.description="Rotor: session busy\n"; } } } if (command[0]=="GET") { if (state==ANALYSING_AUDIO) { - response.description="Rotor: analysing audio\n"; + response.description="Rotor: analysing audio\n"; char c[20]; sprintf(c,"%02f",audio_analyser.get_progress()); response.description+=""+string(c)+"\n"; @@ -72,7 +72,7 @@ Command_response Render_context::session_command(const std::vector& //not sure about this-- should this state be retained? //can the data only be read once? //for now - response.description="Rotor: audio ready\n"; + response.description="Rotor: audio ready\n"; response.description+=""; for (auto& i: audio_analyser.beats) { //is actually giving no data? char c[20]; @@ -88,9 +88,30 @@ Command_response Render_context::session_command(const std::vector& if (command[0]=="PUT") { //get new graph from file if (command.size()>2) { //should interrupt whatever is happening? - //before beggining to load from xml + //before begining to load from xml + if (state==IDLE) { //eventually not like this + Poco::File f=Poco::File(command[3]); + if (f.exists()) { + string graph_filename=command[3]; + if (load_graph(graph_filename)) { + response.description="Rotor: loaded graph "+command[3]+"\n"; + } + else { + response.status=HTTPResponse::HTTP_INTERNAL_SERVER_ERROR; //~/sources/poco-1.4.6-all/Net/include/Poco/Net/HTTPResponse.h + response.description="Rotor: could not load graph "+command[3]+"\n"; + } + } + else { + response.status=HTTPResponse::HTTP_NOT_FOUND; + response.description="File "+command[3]+" not found\n"; + } + } } } } return response; +} + +bool Render_context::load_graph(string graph_filename){ + return true; } \ No newline at end of file -- cgit v1.2.3