diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-02-20 21:55:27 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-02-20 21:55:27 (GMT) |
commit | 47956a35d11495f2ebf6988c7f9d9dffe0bd3a4b (patch) | |
tree | b991daf52ca2051d2e3f89f8143b843bf1318449 /src/uscxml/plugins/invoker | |
parent | 8c30e4f664bb8b68f965165035ec29115486b065 (diff) | |
download | uscxml-47956a35d11495f2ebf6988c7f9d9dffe0bd3a4b.zip uscxml-47956a35d11495f2ebf6988c7f9d9dffe0bd3a4b.tar.gz uscxml-47956a35d11495f2ebf6988c7f9d9dffe0bd3a4b.tar.bz2 |
Beautified source code again
Diffstat (limited to 'src/uscxml/plugins/invoker')
5 files changed, 112 insertions, 106 deletions
diff --git a/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp b/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp index 2d308ce..9486de3 100644 --- a/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp +++ b/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp @@ -158,7 +158,7 @@ void DirMonInvoker::reportExistingIn(const std::string dir, FW::WatchID watchid) if (boost::iequals(dname, ".") || boost::iequals(dname, "..")) continue; - char* filename = (char*)malloc(dir.size() + dname.size() + 2); + char* filename = (char*)malloc(dir.size() + dname.size() + 2); sprintf(filename, "%s/%s", dir.c_str(), dname.c_str()); struct stat fileStat; diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGConverter.cpp b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGConverter.cpp index eb3d810..49c9ccb 100644 --- a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGConverter.cpp +++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGConverter.cpp @@ -33,10 +33,10 @@ Data OSGConverter::getDataModelVariables() { } void OSGConverter::send(const SendRequest& req) { - std::cout << req << std::endl; - Event event; - event.name = "error"; - returnEvent(event); + std::cout << req << std::endl; + Event event; + event.name = "error"; + returnEvent(event); } void OSGConverter::cancel(const std::string sendId) { diff --git a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp index 0272ca8..f89c1b0 100644 --- a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp +++ b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp @@ -19,7 +19,7 @@ HeartbeatInvoker::HeartbeatInvoker() { } HeartbeatInvoker::~HeartbeatInvoker() { - cancel(""); + cancel(""); }; boost::shared_ptr<IOProcessorImpl> HeartbeatInvoker::create(Interpreter* interpreter) { diff --git a/src/uscxml/plugins/invoker/http/HTTPServletInvoker.cpp b/src/uscxml/plugins/invoker/http/HTTPServletInvoker.cpp index 40f8b66..78e3bea 100644 --- a/src/uscxml/plugins/invoker/http/HTTPServletInvoker.cpp +++ b/src/uscxml/plugins/invoker/http/HTTPServletInvoker.cpp @@ -16,24 +16,24 @@ bool connect(pluma::Host& host) { #endif HTTPServletInvoker::HTTPServletInvoker() { - _isInterpreterGlobal = false; + _isInterpreterGlobal = false; } HTTPServletInvoker::HTTPServletInvoker(Interpreter* interpreter) { - _isInterpreterGlobal = true; - _interpreter = interpreter; - std::stringstream path; - path << _interpreter->getName(); - int i = 2; - while(!HTTPServer::registerServlet(path.str(), this)) { - path.clear(); - path.str(); - path << _interpreter->getName() << toStr(i++); - } + _isInterpreterGlobal = true; + _interpreter = interpreter; + std::stringstream path; + path << _interpreter->getName(); + int i = 2; + while(!HTTPServer::registerServlet(path.str(), this)) { + path.clear(); + path.str(); + path << _interpreter->getName() << toStr(i++); + } } HTTPServletInvoker::~HTTPServletInvoker() { - HTTPServer::unregisterServlet(this); + HTTPServer::unregisterServlet(this); }; @@ -51,97 +51,97 @@ Data HTTPServletInvoker::getDataModelVariables() { } void HTTPServletInvoker::send(const SendRequest& req) { - assert(!_isInterpreterGlobal); - - if (req.name.find("reply.", 0, req.name.length())) { - // this is a reply - const std::string requestId = req.name.substr(6); - if (_requests.find(requestId) == _requests.end()) { - LOG(ERROR) << "Replying to non existing request " << requestId; - return; - } - - HTTPServer::Request httpRequest = _requests[requestId]; - HTTPServer::Reply httpReply(httpRequest); - httpReply.content = req.content; - - std::map<std::string, std::string>::const_iterator nameListIter = req.namelist.begin(); - while(nameListIter != req.namelist.end()) { - httpReply.headers[nameListIter->first] = nameListIter->second; - nameListIter++; - } - - std::multimap<std::string, std::string>::const_iterator paramIter = req.params.begin(); - while(paramIter != req.params.end()) { - httpReply.headers[paramIter->first] = paramIter->second; - paramIter++; - } - - HTTPServer::reply(httpReply); - return; - } + assert(!_isInterpreterGlobal); + + if (req.name.find("reply.", 0, req.name.length())) { + // this is a reply + const std::string requestId = req.name.substr(6); + if (_requests.find(requestId) == _requests.end()) { + LOG(ERROR) << "Replying to non existing request " << requestId; + return; + } + + HTTPServer::Request httpRequest = _requests[requestId]; + HTTPServer::Reply httpReply(httpRequest); + httpReply.content = req.content; + + std::map<std::string, std::string>::const_iterator nameListIter = req.namelist.begin(); + while(nameListIter != req.namelist.end()) { + httpReply.headers[nameListIter->first] = nameListIter->second; + nameListIter++; + } + + std::multimap<std::string, std::string>::const_iterator paramIter = req.params.begin(); + while(paramIter != req.params.end()) { + httpReply.headers[paramIter->first] = paramIter->second; + paramIter++; + } + + HTTPServer::reply(httpReply); + return; + } } void HTTPServletInvoker::cancel(const std::string sendId) { - assert(!_isInterpreterGlobal); + assert(!_isInterpreterGlobal); } void HTTPServletInvoker::invoke(const InvokeRequest& req) { - assert(!_isInterpreterGlobal); - - _invokeId = req.invokeid; - if (req.params.find("path") == req.params.end()) { - LOG(ERROR) << "Path parameter required with httpserver"; - } - _path = (*req.params.find("path")).second; - - if (req.params.find("callback") != req.params.end()) { - _callback = (*req.params.find("callback")).second; - } else { - _callback = _path; - std::replace(_callback.begin(), _callback.end(), '/', '.'); - } - - if (!HTTPServer::registerServlet(_path, this)) { - LOG(ERROR) << "Cannot register http servlet at " << _path << ": " << " already taken"; - } + assert(!_isInterpreterGlobal); + + _invokeId = req.invokeid; + if (req.params.find("path") == req.params.end()) { + LOG(ERROR) << "Path parameter required with httpserver"; + } + _path = (*req.params.find("path")).second; + + if (req.params.find("callback") != req.params.end()) { + _callback = (*req.params.find("callback")).second; + } else { + _callback = _path; + std::replace(_callback.begin(), _callback.end(), '/', '.'); + } + + if (!HTTPServer::registerServlet(_path, this)) { + LOG(ERROR) << "Cannot register http servlet at " << _path << ": " << " already taken"; + } } /** * Receive a request and deliver it to the interpreter */ void HTTPServletInvoker::httpRecvRequest(const HTTPServer::Request& req) { - tthread::lock_guard<tthread::recursive_mutex> lock(_mutex); - + tthread::lock_guard<tthread::recursive_mutex> lock(_mutex); + // evhttp_request_own(req.curlReq); - _requests[toStr((uintptr_t)req.curlReq)] = req; - - Event event; - - if (_isInterpreterGlobal) { - event.name = "http." + req.type; - event.origin = toStr((uintptr_t)req.curlReq); - } else { - event.name = _callback; - event.data.compound["reqId"] = Data(toStr((uintptr_t)req.curlReq), Data::VERBATIM); - } - - std::map<std::string, std::string>::const_iterator headerIter = req.headers.begin(); - while(headerIter != req.headers.end()) { - event.data.compound["headers"].compound[headerIter->first] = Data(headerIter->second, Data::VERBATIM); - headerIter++; - } - - event.data.compound["content"] = Data(req.content, Data::VERBATIM); - event.data.compound["type"] = Data(req.type, Data::VERBATIM); - - returnEvent(event); + _requests[toStr((uintptr_t)req.curlReq)] = req; + + Event event; + + if (_isInterpreterGlobal) { + event.name = "http." + req.type; + event.origin = toStr((uintptr_t)req.curlReq); + } else { + event.name = _callback; + event.data.compound["reqId"] = Data(toStr((uintptr_t)req.curlReq), Data::VERBATIM); + } + + std::map<std::string, std::string>::const_iterator headerIter = req.headers.begin(); + while(headerIter != req.headers.end()) { + event.data.compound["headers"].compound[headerIter->first] = Data(headerIter->second, Data::VERBATIM); + headerIter++; + } + + event.data.compound["content"] = Data(req.content, Data::VERBATIM); + event.data.compound["type"] = Data(req.type, Data::VERBATIM); + + returnEvent(event); } - + std::string HTTPServletInvoker::getPath() { - return _path; + return _path; } }
\ No newline at end of file diff --git a/src/uscxml/plugins/invoker/http/HTTPServletInvoker.h b/src/uscxml/plugins/invoker/http/HTTPServletInvoker.h index 1d667de..4ac87e0 100644 --- a/src/uscxml/plugins/invoker/http/HTTPServletInvoker.h +++ b/src/uscxml/plugins/invoker/http/HTTPServletInvoker.h @@ -13,7 +13,7 @@ namespace uscxml { class HTTPServletInvoker : public InvokerImpl, public HTTPServlet { public: HTTPServletInvoker(); - HTTPServletInvoker(Interpreter* interpreter); + HTTPServletInvoker(Interpreter* interpreter); virtual ~HTTPServletInvoker(); virtual boost::shared_ptr<IOProcessorImpl> create(Interpreter* interpreter); @@ -29,21 +29,27 @@ public: virtual void cancel(const std::string sendId); virtual void invoke(const InvokeRequest& req); - // HTTPServlet - virtual void httpRecvRequest(const HTTPServer::Request& req); - virtual std::string getPath(); - virtual void setURL(const std::string& url) { _url = url; } + // HTTPServlet + virtual void httpRecvRequest(const HTTPServer::Request& req); + virtual std::string getPath(); + virtual void setURL(const std::string& url) { + _url = url; + } + + tthread::recursive_mutex& getMutex() { + return _mutex; + } + std::map<std::string, HTTPServer::Request>& getRequests() { + return _requests; + } - tthread::recursive_mutex& getMutex() { return _mutex; } - std::map<std::string, HTTPServer::Request>& getRequests() { return _requests; } - protected: - tthread::recursive_mutex _mutex; - std::map<std::string, HTTPServer::Request> _requests; - std::string _path; - std::string _callback; - std::string _url; - bool _isInterpreterGlobal; + tthread::recursive_mutex _mutex; + std::map<std::string, HTTPServer::Request> _requests; + std::string _path; + std::string _callback; + std::string _url; + bool _isInterpreterGlobal; }; #ifdef BUILD_AS_PLUGINS |