Atlas-C++
Stream.h
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 // $Id$
00006 
00007 #ifndef ATLAS_NET_STREAM_H
00008 #define ATLAS_NET_STREAM_H
00009 
00010 #include <Atlas/Negotiate.h>
00011 
00012 #include <iosfwd>
00013 #include <string>
00014 #include <list>
00015 
00016 namespace Atlas { 
00017 
00018 class Bridge;
00019 
00023 namespace Net {
00024 
00036   class NegotiateHelper {
00037 
00038   public:
00039 
00040     NegotiateHelper(std::list<std::string> & names);
00041 
00042     bool get(std::string &buf, const std::string & header);
00043     void put(std::string &buf, const std::string & header);
00044 
00045   private:
00046 
00047     std::list<std::string> & m_names;
00048 
00049   };
00050 
00058 class StreamConnect : public Atlas::Negotiate
00059 {
00060     public:
00061 
00062     StreamConnect(const std::string& name, std::iostream&);
00063 
00064     virtual ~StreamConnect();
00065 
00066     virtual void poll(bool can_read = true);
00067 
00068     virtual State getState();
00069     virtual Atlas::Codec * getCodec(Atlas::Bridge&);
00070 
00071     private:
00072 
00073     enum
00074     {
00075         SERVER_GREETING,
00076         CLIENT_GREETING,
00077         CLIENT_CODECS,
00078         SERVER_CODECS,
00079         // CLIENT_FILTERS,
00080         // SERVER_FILTERS,
00081         DONE
00082     };
00083 
00084     int m_state;
00085 
00086     std::string m_outName;
00087     std::string m_inName;
00088     std::iostream& m_socket;
00089     std::list<std::string> m_inCodecs;
00090     std::list<std::string> m_inFilters;
00091   
00092     NegotiateHelper m_codecHelper;
00093     NegotiateHelper m_filterHelper;
00094     std::string m_buf;
00095 
00096     void processServerCodecs();
00097     void processServerFilters();
00098 
00099     //void processClientCodecs();
00100     //void processClientFilters();
00101 
00102     bool m_canPacked;
00103     bool m_canXML;
00104     bool m_canBach;
00105 
00106     bool m_canGzip;
00107     bool m_canBzip2;
00108 };
00109  
00118 class StreamAccept : public Atlas::Negotiate
00119 {
00120     public:
00121 
00122     StreamAccept(const std::string& name, std::iostream&);
00123 
00124     virtual ~StreamAccept();
00125 
00126     virtual void poll(bool can_read = true);
00127 
00128     virtual State getState();
00129     virtual Atlas::Codec * getCodec(Atlas::Bridge&);
00130 
00131     private:
00132 
00133     enum
00134     {
00135         SERVER_GREETING,
00136         CLIENT_GREETING,
00137         CLIENT_CODECS,
00138         SERVER_CODECS,
00139         CLIENT_FILTERS,
00140         SERVER_FILTERS,
00141         DONE
00142     };
00143 
00144     int m_state;
00145 
00146     std::string m_outName;
00147     std::string m_inName;
00148     std::iostream& m_socket;
00149     std::list<std::string> m_inCodecs;
00150     std::list<std::string> m_inFilters;
00151   
00152     NegotiateHelper m_codecHelper;
00153     NegotiateHelper m_filterHelper;
00154     std::string m_buf;
00155 
00156     //void processServerCodecs();
00157     //void processServerFilters();
00158 
00159     void processClientCodecs();
00160     void processClientFilters();
00161 
00162     bool m_canPacked;
00163     bool m_canXML;
00164     bool m_canBach;
00165 
00166     bool m_canGzip;
00167     bool m_canBzip2;
00168 };
00169 
00170 } } // namespace Atlas::Net
00171 
00172 #endif
00173 

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.