MetriVis | Overview | Download | User Manual | Development |
Reference | Overview | Design Documentation | Reference Backend | Reference Frontend |
00001 /* 00002 * MetriVis - Metrics Visualization Application 00003 * 00004 * 00005 * License notice: 00006 * 00007 * This program is free software: you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation, either version 3 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00019 * 00020 */ 00021 00022 00029 #ifndef _METRIVIS_REQUEST_DISPATHER_H 00030 #define _METRIVIS_REQUEST_DISPATHER_H 00031 00032 #include <string> 00033 #include "pattern/Thread.h" 00034 #include "BaseClass.h" 00035 #include "RequestDescription.h" 00036 00037 namespace metrivis { 00038 00039 class Pipeline; 00040 class RequestDescription; 00041 00057 class RequestDispatcher : public Thread, public BaseClass { 00058 00059 public: 00060 00066 RequestDispatcher(int clone_id); 00067 00073 virtual ~RequestDispatcher(); 00074 00075 00080 inline void set_request_description(const RequestDescription& description) { 00081 request_description_ = description; 00082 } 00083 00088 const RequestDescription& request_description() const { 00089 return request_description_; 00090 } 00091 00092 00093 protected: 00094 00100 virtual void Run(); 00101 00102 00103 protected: 00104 00112 int SendHTTPImage(const std::string& image_data); 00113 00114 00122 int SendHTTPPlainText(const std::string& plain_text); 00123 00124 00132 int SendHTTPText(const std::string& http_text); 00133 00134 00142 int SendJSONText(const std::string& json_text); 00143 00144 00145 private: 00146 00152 int SendHTTPReplyRaw(const std::string& message, const std::string& type); 00153 00154 00155 protected: 00156 00157 Pipeline* pipeline_; 00158 RequestDescription request_description_; 00159 }; 00160 00161 00162 } // namespace metrivis 00163 00164 #endif // _METRIVIS_REQUEST_DISPATHER_H