00001 // This file may be redistributed and modified only under the terms of 00002 // the GNU Lesser General Public License (See COPYING for details). 00003 // Copyright (C) 2000-2001 Michael Day, Dmitry Derevyanko, Stefanus Du Toit 00004 00005 #ifndef ATLAS_NET_STREAM_H 00006 #define ATLAS_NET_STREAM_H 00007 00008 #include <Atlas/Negotiate.h> 00009 00010 #include <iosfwd> 00011 #include <string> 00012 #include <list> 00013 00014 namespace Atlas { 00015 00016 class Bridge; 00017 00021 namespace Net { 00022 00034 class NegotiateHelper { 00035 00036 public: 00037 00038 NegotiateHelper(std::list<std::string> & names); 00039 00040 bool get(std::string &buf, const std::string & header); 00041 void put(std::string &buf, const std::string & header); 00042 00043 private: 00044 00045 std::list<std::string> & m_names; 00046 00047 }; 00048 00056 class StreamConnect : public Atlas::Negotiate 00057 { 00058 public: 00059 00060 StreamConnect(const std::string& name, std::iostream&); 00061 00062 virtual ~StreamConnect(); 00063 00064 virtual void poll(bool can_read = true); 00065 00066 virtual State getState(); 00067 virtual Atlas::Codec * getCodec(Atlas::Bridge&); 00068 00069 private: 00070 00071 enum 00072 { 00073 SERVER_GREETING, 00074 CLIENT_GREETING, 00075 CLIENT_CODECS, 00076 SERVER_CODECS, 00077 // CLIENT_FILTERS, 00078 // SERVER_FILTERS, 00079 DONE 00080 }; 00081 00082 int m_state; 00083 00084 std::string m_outName; 00085 std::string m_inName; 00086 std::iostream& m_socket; 00087 std::list<std::string> m_inCodecs; 00088 std::list<std::string> m_inFilters; 00089 00090 NegotiateHelper m_codecHelper; 00091 NegotiateHelper m_filterHelper; 00092 std::string m_buf; 00093 00094 void processServerCodecs(); 00095 void processServerFilters(); 00096 00097 //void processClientCodecs(); 00098 //void processClientFilters(); 00099 00100 bool m_canPacked; 00101 bool m_canXML; 00102 bool m_canBach; 00103 00104 bool m_canGzip; 00105 bool m_canBzip2; 00106 }; 00107 00116 class StreamAccept : public Atlas::Negotiate 00117 { 00118 public: 00119 00120 StreamAccept(const std::string& name, std::iostream&); 00121 00122 virtual ~StreamAccept(); 00123 00124 virtual void poll(bool can_read = true); 00125 00126 virtual State getState(); 00127 virtual Atlas::Codec * getCodec(Atlas::Bridge&); 00128 00129 private: 00130 00131 enum 00132 { 00133 SERVER_GREETING, 00134 CLIENT_GREETING, 00135 CLIENT_CODECS, 00136 SERVER_CODECS, 00137 CLIENT_FILTERS, 00138 SERVER_FILTERS, 00139 DONE 00140 }; 00141 00142 int m_state; 00143 00144 std::string m_outName; 00145 std::string m_inName; 00146 std::iostream& m_socket; 00147 std::list<std::string> m_inCodecs; 00148 std::list<std::string> m_inFilters; 00149 00150 NegotiateHelper m_codecHelper; 00151 NegotiateHelper m_filterHelper; 00152 std::string m_buf; 00153 00154 //void processServerCodecs(); 00155 //void processServerFilters(); 00156 00157 void processClientCodecs(); 00158 void processClientFilters(); 00159 00160 bool m_canPacked; 00161 bool m_canXML; 00162 bool m_canBach; 00163 00164 bool m_canGzip; 00165 bool m_canBzip2; 00166 }; 00167 00168 } } // namespace Atlas::Net 00169 00170 #endif 00171
Copyright 2000-2004 the respective authors.
This document can be licensed under the terms of the GNU Free Documentation License or the GNU General Public License and may be freely distributed under the terms given by one of these licenses.