|
PH Logo
Logo intepreter modeled after UCB Logo.
|
00001 /* 00002 * RestProcessor.h 00003 * 00004 * Author: Paul Hamilton 00005 * Date: 8 Aug 2011 00006 * 00007 */ 00008 #ifndef _RESTPROCESSOR_H 00009 #define _RESTPROCESSOR_H 00010 00011 #include "Console.h" 00012 #include "Interpreter.h" 00013 #include "World.h" 00014 #include "Turtle.h" 00015 00016 #include <boost/shared_ptr.hpp> 00017 #include <sstream> 00018 00019 namespace phlogo { 00020 00021 class RestOutput; 00022 00026 class RestProcessor : public Console { 00027 00028 public: 00029 RestProcessor() : _w(this), _itp(&_w) { _w.setTurtle(&_t); } 00030 00031 static RestProcessor *getInstance(); 00032 00033 bool process(const std::string &path, RestOutput *output); 00034 00035 // Console overrides 00036 virtual void reset(); 00037 virtual void outputLine(const std::string &s); 00038 virtual void outputError(const std::string &s); 00039 virtual bool isError(); 00040 virtual std::string getString(); 00041 00042 private: 00043 static boost::shared_ptr<RestProcessor> instance; 00044 00045 void startOutput(); 00046 std::string endOutput(const std::string &gdata); 00047 00048 World _w; 00049 Interpreter _itp; 00050 JSONTurtle _t; 00051 std::stringstream _ss; 00052 bool _error; 00053 bool _firstop; 00054 }; 00055 00056 } 00057 00058 #endif // _RESTPROCESSOR_H
1.7.4