diff options
Diffstat (limited to 'NT')
| -rw-r--r-- | NT/src/graph.cpp | 5 | ||||
| -rw-r--r-- | NT/src/rendercontext.h | 28 | ||||
| -rw-r--r-- | NT/src/rotor.cpp | 7 | ||||
| -rw-r--r-- | NT/src/rotor.h | 22 |
4 files changed, 54 insertions, 8 deletions
diff --git a/NT/src/graph.cpp b/NT/src/graph.cpp index ef638cc..e671238 100644 --- a/NT/src/graph.cpp +++ b/NT/src/graph.cpp @@ -4,16 +4,17 @@ using namespace Rotor; using namespace std; bool Graph::check_audio(string audio,string path){ + Logger& logger = Logger::get(id); if (audio!="") { audio_filename=path+audio; Poco::File f=Poco::File(audio_filename); if (f.exists()) { //here we should check the audio is actually valid audio_loaded=true; - cerr<<"Rotor: loading "<<audio_filename<<" from graph"<<endl; + logger.information("Loading "+audio_filename+" from graph"); return true; } - cerr<<"Rotor: audio file "<<audio_filename<<" not found"<<endl; + logger.error("Audio file "+audio_filename+" not found"); } return false; } diff --git a/NT/src/rendercontext.h b/NT/src/rendercontext.h index ea7a8c1..10332df 100644 --- a/NT/src/rendercontext.h +++ b/NT/src/rendercontext.h @@ -15,15 +15,37 @@ TJR Jan 2014 #include "rotor.h" #include "graph.h" - namespace Rotor { class Render_context: public Poco::Task { public: - Render_context(const std::string& id): Task(id) { + Render_context(const std::string& _id): Task(_id) { + id=_id; graph.init(id); + //set up log + AutoPtr<SplitterChannel> splitterChannel(new SplitterChannel()); + AutoPtr<Channel> consoleChannel(new ConsoleChannel()); + AutoPtr<Channel> fileChannel(new FileChannel("Rotord_"+id+".log")); + splitterChannel->addChannel(consoleChannel); + splitterChannel->addChannel(fileChannel); + AutoPtr<Formatter> formatter(new PatternFormatter("%d-%m-%Y %H:%M:%S %s: %t")); + AutoPtr<Channel> formattingChannel(new FormattingChannel(formatter, splitterChannel)); + Logger& logger = Logger::create(id, formattingChannel, Message::PRIO_TRACE); + logger.information("started thread"); + } + ~Render_context(){ + Logger& logger = Logger::get(id); + cancel(); + logger.information("stopped thread"); + } + void runTask() { + Logger& logger = Logger::get(id); + while (!isCancelled()) { + sleep(100); + } } - private: Graph graph; + private: + std::string id; }; }; diff --git a/NT/src/rotor.cpp b/NT/src/rotor.cpp index bf0c26a..f600c7f 100644 --- a/NT/src/rotor.cpp +++ b/NT/src/rotor.cpp @@ -4,6 +4,7 @@ #include "factory.h" #include "nodes.h" #include "graph.h" +#include "rendercontext.h" using namespace std; using namespace Rotor; @@ -82,8 +83,8 @@ int main(){ delete m; delete p; */ - Rotor::Graph g; - cerr<<(g.load_file("testgraph.json","./")?"loaded ":"could not load ")<<"testgraph.json"<<endl; + Rotor::Render_context r("dbbbb4ba-8430-11e3-9774-74d02b29f6a6"); + cerr<<(r.graph.load_file("testgraph.json","./")?"loaded ":"could not load ")<<"testgraph.json"<<endl; /* Json::Value js; f.list_node("time",js); @@ -97,7 +98,7 @@ int main(){ //now need a way to grab output - Node* p=g.find_node("print"); + Node* p=r.graph.find_node("print"); if (p){ for (double t=0;t<10.0;t+=0.765){ diff --git a/NT/src/rotor.h b/NT/src/rotor.h index 68473af..5023a95 100644 --- a/NT/src/rotor.h +++ b/NT/src/rotor.h @@ -20,6 +20,28 @@ NB when plugging in to framework - convert all cerr messages to logged #include <json/json.h> #include <typeinfo> +#include "Poco/Logger.h" +#include "Poco/Channel.h" +#include "Poco/SplitterChannel.h" +#include "Poco/ConsoleChannel.h" +#include "Poco/FormattingChannel.h" +#include "Poco/FileChannel.h" +#include "Poco/Message.h" +#include "Poco/Formatter.h" +#include "Poco/PatternFormatter.h" +#include "Poco/AutoPtr.h" + +using Poco::Logger; +using Poco::Channel; +using Poco::SplitterChannel; +using Poco::ConsoleChannel; +using Poco::FormattingChannel; +using Poco::Formatter; +using Poco::PatternFormatter; +using Poco::FileChannel; +using Poco::Message; +using Poco::AutoPtr; + template <typename T> struct TypeName { |
