Atlas-C++
Stream.h
1 // This file may be redistributed and modified only under the terms of
2 // the GNU Lesser General Public License (See COPYING for details).
3 // Copyright (C) 2000-2001 Michael Day, Dmitry Derevyanko, Stefanus Du Toit
4 
5 // $Id$
6 
7 #ifndef ATLAS_NET_STREAM_H
8 #define ATLAS_NET_STREAM_H
9 
10 #include <Atlas/Negotiate.h>
11 
12 #include <iosfwd>
13 #include <string>
14 #include <list>
15 
16 namespace Atlas {
17 
18 class Bridge;
19 
23 namespace Net {
24 
37 
38  public:
39 
40  explicit NegotiateHelper(std::list<std::string> & names);
41 
42  bool get(std::string &buf, const std::string & header);
43  void put(std::string &buf, const std::string & header);
44 
45  private:
46 
47  std::list<std::string> & m_names;
48 
49  };
50 
59 {
60  public:
61 
62  StreamConnect(const std::string& name, std::istream& inStream, std::ostream& outStream);
63 
64  ~StreamConnect() override = default;
65 
66  void poll(bool can_read) override;
67 
68  State getState() override;
69 
70  Atlas::Codec * getCodec(Atlas::Bridge&) override;
71 
72  private:
73 
74  enum
75  {
76  SERVER_GREETING,
77  CLIENT_GREETING,
78  CLIENT_CODECS,
79  SERVER_CODECS,
80  // CLIENT_FILTERS,
81  // SERVER_FILTERS,
82  DONE
83  };
84 
85  int m_state;
86 
87  std::string m_outName;
88  std::string m_inName;
89  std::istream& m_inStream;
90  std::ostream& m_outStream;
91  std::list<std::string> m_inCodecs;
92  std::list<std::string> m_inFilters;
93 
94  NegotiateHelper m_codecHelper;
95  NegotiateHelper m_filterHelper;
96  std::string m_buf;
97 
98  void processServerCodecs();
99  void processServerFilters();
100 
101  //void processClientCodecs();
102  //void processClientFilters();
103 
104  bool m_canPacked;
105  bool m_canXML;
106  bool m_canBach;
107 
108  bool m_canGzip;
109  bool m_canBzip2;
110 };
111 
121 {
122  public:
123 
124  StreamAccept(const std::string& name, std::istream& inStream, std::ostream& outStream);
125 
126  ~StreamAccept() override = default;
127 
128  void poll(bool can_read) override;
129 
130  State getState() override;
131 
132  Atlas::Codec * getCodec(Atlas::Bridge&) override;
133 
134  private:
135 
136  enum
137  {
138  SERVER_GREETING,
139  CLIENT_GREETING,
140  CLIENT_CODECS,
141  SERVER_CODECS,
142  CLIENT_FILTERS,
143  SERVER_FILTERS,
144  DONE
145  };
146 
147  int m_state;
148 
149  std::string m_outName;
150  std::string m_inName;
151  std::istream& m_inStream;
152  std::ostream& m_outStream;
153  std::list<std::string> m_inCodecs;
154  std::list<std::string> m_inFilters;
155 
156  NegotiateHelper m_codecHelper;
157  NegotiateHelper m_filterHelper;
158  std::string m_buf;
159 
160  //void processServerCodecs();
161  //void processServerFilters();
162 
163  void processClientCodecs();
164  void processClientFilters();
165 
166  bool m_canPacked;
167  bool m_canXML;
168  bool m_canBach;
169 
170  bool m_canGzip;
171  bool m_canBzip2;
172 };
173 
174 } } // namespace Atlas::Net
175 
176 #endif
177 
Atlas stream bridge.
Definition: Bridge.h:35
Negotiation of codecs and filters for an Atlas connection.
Definition: Stream.h:36
Negotiation of codecs and filters for an Atlas connection.
Definition: Negotiate.h:26
The Atlas namespace.
Definition: Bridge.h:20
Atlas stream codec.
Definition: Codec.h:27
Negotiation of servers accepting a connection from a remote system.
Definition: Stream.h:120
Negotiation of clients building a connection to a remote system.
Definition: Stream.h:58

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.