00001 /* 00002 webEngine is the HTML processing library 00003 Copyright (C) 2009 Andrew Abramov aabramov@ptsecurity.ru 00004 00005 This file is part of webEngine 00006 00007 webEngineis 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 webEngineis 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 webEngine. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 #ifndef __WEITRANSPORT_H__ 00021 #define __WEITRANSPORT_H__ 00022 00023 #include <vector> 00024 #include "weUrl.h" 00025 #include "weBlob.h" 00026 #include "weOptions.h" 00027 #include <boost/shared_ptr.hpp> 00028 00029 using namespace boost; 00030 class iweTransport; 00031 00032 class iweOperation; 00033 typedef shared_ptr<iweOperation> iweOperationPtr; 00034 00046 class iweOperation 00047 { 00048 public: 00049 iweOperation() { usageCount = 0; }; 00050 virtual ~iweOperation(); 00051 00052 virtual iweOperationPtr& GetRef() { return (* new iweOperationPtr(this)); }; 00053 00054 virtual void AddChild(iweOperationPtr* chld); 00055 virtual void RemoveChild(iweOperationPtr* chld); 00057 00058 00059 00060 WeURL &BaseUrl(void) { return(baseUrl); }; 00061 void BaseUrl(const string &url) { baseUrl = url; }; 00062 void BaseUrl(const WeURL &url) { baseUrl = url; }; 00064 00066 00067 00068 00069 void ID(const string &id) { identifier = id; }; 00070 const string & ID() { return identifier;}; 00072 00073 #ifndef __DOXYGEN__ 00074 protected: 00075 int usageCount; 00076 WeURL baseUrl; 00077 iweOperation* previous; 00078 vector<iweOperationPtr*> children; 00079 string identifier; 00080 private: 00081 iweOperation(iweOperation&) {}; 00082 iweOperation& operator=(iweOperation&) { return *this; }; 00083 #endif //__DOXYGEN__ 00084 }; 00085 00094 class iweRequest : virtual public iweOperation 00095 { 00096 public: 00097 iweRequest() {}; 00098 iweRequest(string url) {}; 00099 virtual ~iweRequest() {}; 00100 00102 00103 00104 00105 virtual WeURL &RequestUrl(void) { return(baseUrl); }; 00106 virtual void RequestUrl(const string &ReqUrl, iweOperation* resp = NULL) = 0; 00107 virtual void RequestUrl(const WeURL &ReqUrl, iweOperation* resp = NULL) = 0; 00109 }; 00110 00119 class iweResponse : virtual public iweOperation 00120 { 00121 public: 00122 iweResponse() {}; 00123 virtual ~iweResponse() {}; 00124 00126 00127 00128 00129 00130 00131 WeURL &RealUrl(void) { return(realUrl); }; 00132 void RealUrl(const string &url) { realUrl = url; }; 00133 void RealUrl(const WeURL &url) { realUrl = url; }; 00135 00137 00138 00139 00140 int RelocCount(void) { return(relocCount); }; 00141 void RelocCount(int count) { relocCount = count; }; 00143 00145 00146 00147 00148 bool Processed(void) { return(processed); }; 00149 void Processed(bool proc) { processed = proc; }; 00151 00155 WeBlob& Data() { return data; }; 00156 00157 virtual void Process(iweTransport* proc) = 0; 00158 00159 #ifndef __DOXYGEN__ 00160 protected: 00161 WeURL realUrl; 00162 unsigned int relocCount; 00163 WeBlob data; 00164 bool processed; 00165 #endif //__DOXYGEN__ 00166 }; 00167 00168 typedef vector<iweResponse*> WeResponseList; 00169 00178 class iweTransport : virtual public iweOptionsProvider 00179 { 00180 public: 00181 iweTransport(); 00182 virtual ~iweTransport() {}; 00183 00184 virtual iweResponse* Request(string url, iweResponse *resp = NULL) = 0; 00185 00186 virtual WeOption& Option(const string& name); 00187 virtual bool IsSet(const string& name); 00188 virtual void Option(const string& name, WeOptionVal val); 00189 00191 00192 00193 00194 00195 00196 00197 00198 const WeURL &BaseUrl(void) const { return(baseUrl); }; 00199 void BaseUrl(const WeURL &bUrl); 00200 void BaseUrl(const string &bUrl); 00202 00204 00205 00206 00207 00208 const unsigned int &RelocationCount(void) const { return(relocCount); }; 00209 void RelocationCount(const unsigned int& relCount) { relocCount = relCount; }; 00211 00213 00214 00215 00216 00217 const unsigned int& SiteDepth(void) const { return(siteDepth); }; 00218 void SiteDepth(const unsigned int& sDepth) { siteDepth = sDepth; }; 00220 00221 void SetOptionProvider(iweOptionsProvider* prov) { parent = prov; }; 00222 virtual string& GetName() = 0; 00223 virtual bool IsOwnProtocol(string& proto) = 0; 00224 00225 #ifndef __DOXYGEN__ 00226 protected: 00227 WeURL baseUrl; 00228 unsigned int relocCount; 00229 unsigned int siteDepth; 00230 WeResponseList responces; 00231 iweOptionsProvider* parent; 00232 00233 private: 00235 00236 iweTransport(iweTransport & source) {}; 00237 iweTransport & operator=(iweTransport & source) { return *this; }; 00239 #endif //__DOXYGEN__ 00240 }; 00241 00242 iweTransport* WeCreateNamedTransport(string name); 00243 00244 #endif // __WEITRANSPORT_H__
©2009 Positive Technologies |
Generated on Tue Jul 14 18:27:30 2009 for WebEngine by |
|
1.5.7 |
|