Main Page | Modules | Class Hierarchy | Class List | File List | Class Members | Related Pages

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 #ifndef ATLAS_NET_STREAM_H
00006 #define ATLAS_NET_STREAM_H
00007 
00008 #include <iosfwd>
00009 #include <string>
00010 #include <list>
00011 
00012 #include <Atlas/Negotiate.h>
00013 
00014 namespace Atlas {
00015 
00016 class Bridge;
00017 
00018 namespace Net {
00019 
00030   class NegotiateHelper {
00031 
00032   public:
00033 
00034     NegotiateHelper(std::list<std::string> *names);
00035 
00036     bool get(std::string &buf, const std::string & header);
00037     void put(std::string &buf, const std::string & header);
00038 
00039   private:
00040 
00041     std::list<std::string> *names;
00042 
00043   };
00044 
00045 class StreamConnect : public Atlas::Negotiate<std::iostream>
00046 {
00047     public:
00048 
00049     StreamConnect(const std::string& name, std::iostream&, Atlas::Bridge*);
00050 
00051     virtual ~StreamConnect() {}
00052 
00053     virtual void Poll(bool can_read = true);
00054 
00055     virtual State GetState();
00056     virtual Atlas::Codec<std::iostream>* GetCodec();
00057 
00058     private:
00059 
00060     enum
00061     {
00062         SERVER_GREETING,
00063         CLIENT_GREETING,
00064         CLIENT_CODECS,
00065         SERVER_CODECS,
00066         DONE
00067     };
00068 
00069     int state;
00070 
00071     std::string outName;
00072     std::string inName;
00073     std::iostream& socket;
00074     Atlas::Bridge* bridge;
00075     std::list<std::string> inCodecs;
00076   
00077     NegotiateHelper codecHelper;
00078     std::string buf;
00079 
00080     void processServerCodecs();
00081 
00082     bool m_canPacked;
00083     bool m_canXml;
00084 };
00085  
00086 class StreamAccept : public Atlas::Negotiate<std::iostream>
00087 {
00088     public:
00089 
00090     StreamAccept(const std::string& name, std::iostream&, Atlas::Bridge*);
00091 
00092     virtual ~StreamAccept() {}
00093 
00094     virtual void Poll(bool can_read = true);
00095 
00096     virtual State GetState();
00097     virtual Atlas::Codec<std::iostream>* GetCodec();
00098 
00099     private:
00100 
00101     enum
00102     {
00103         SERVER_GREETING,
00104         CLIENT_GREETING,
00105         CLIENT_CODECS,
00106         SERVER_CODECS,
00107         DONE
00108     };
00109 
00110     int state;
00111 
00112     std::string outName;
00113     std::string inName;
00114     std::iostream& socket;
00115     Atlas::Bridge* bridge;
00116     std::list<std::string> inCodecs;
00117   
00118     NegotiateHelper codecHelper;
00119     std::string buf;
00120 
00121     void processClientCodecs();
00122 
00123     bool m_canPacked;
00124     bool m_canXml;
00125 };
00126 
00127 } } // Atlas::Net
00128 
00129 #endif
00130 

Copyright 2000 the respective authors.

This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.