bes  Updated for version 3.20.6
PPTConnection.h
1 // PPTConnection.h
2 
3 // This file is part of bes, A C++ back-end server implementation framework
4 // for the OPeNDAP Data Access Protocol.
5 
6 // Copyright (c) 2004-2009 University Corporation for Atmospheric Research
7 // Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 //
23 // You can contact University Corporation for Atmospheric Research at
24 // 3080 Center Green Drive, Boulder, CO 80301
25 
26 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
27 // Please read the full copyright statement in the file COPYRIGHT_UCAR.
28 //
29 // Authors:
30 // pwest Patrick West <pwest@ucar.edu>
31 // jgarcia Jose Garcia <jgarcia@ucar.edu>
32 
33 #ifndef PPTConnection_h
34 #define PPTConnection_h 1
35 
36 #include "Connection.h"
37 #include "PPTProtocol.h"
38 
39 class Socket;
40 
41 #define PPT_CHUNK_HEADER_SPACE 15
42 
43 class PPTConnection: public Connection {
44 private:
45  int _timeout;
46  char * _inBuff;
47  int _inBuff_len;
48 #if 0
49  int _bytesRead;
50 #endif
51 
52  PPTConnection() : _timeout(0), _inBuff(0), _inBuff_len(0) //, _bytesRead(0)
53  {
54  }
55 
56  virtual int readChunkHeader(char *inBuff,
57  /*unsigned*/int buff_size);
58  virtual void sendChunk(const std::string &buffer, std::map<std::string, std::string> &extensions);
59  virtual void receive(std::ostream &strm, const /*unsigned*/int len);
60 
61 protected:
62  PPTConnection(int timeout) : _timeout(timeout), _inBuff(0), _inBuff_len(0) //, _bytesRead(0)
63  {
64  }
65 
66  virtual int readBuffer(char *inBuff, const unsigned int buff_size);
67  virtual int readBufferNonBlocking(char *inBuff, const /*unsigned*/int buff_size);
68 
69  virtual void send(const std::string &buffer);
70  virtual void read_extensions(std::map<std::string, std::string> &extensions, const std::string &xstr);
71 
72 public:
73  virtual ~PPTConnection();
74 
75  virtual void initConnection() = 0;
76  virtual void closeConnection() = 0;
77 
78  virtual std::string exit()
79  {
80  return PPTProtocol::PPT_EXIT_NOW;
81  }
82 
83  virtual void send(const std::string &buffer, std::map<std::string, std::string> &extensions);
84  virtual void sendExtensions(std::map<std::string, std::string> &extensions);
85  virtual void sendExit();
86  virtual bool receive(std::map<std::string, std::string> &extensions, std::ostream *strm = 0);
87 
88  virtual unsigned int getRecvChunkSize();
89  virtual unsigned int getSendChunkSize();
90 
91  virtual void dump(std::ostream &strm) const;
92 };
93 
94 #endif // PPTConnection_h
PPTConnection::read_extensions
virtual void read_extensions(std::map< std::string, std::string > &extensions, const std::string &xstr)
the string passed are extensions, read them and store the name/value pairs into the passed map
Definition: PPTConnection.cc:370
Socket
Definition: Socket.h:42
Connection
Definition: Connection.h:43
PPTConnection::readBufferNonBlocking
virtual int readBufferNonBlocking(char *inBuff, const int buff_size)
read a buffer of data from the socket without blocking
Definition: PPTConnection.cc:418
PPTConnection::sendExit
virtual void sendExit()
Send the exit token as an extension.
Definition: PPTConnection.cc:119
PPTConnection::send
virtual void send(const std::string &buffer)
sends the buffer to the socket
Definition: PPTConnection.cc:184
PPTConnection::sendExtensions
virtual void sendExtensions(std::map< std::string, std::string > &extensions)
send the specified extensions
Definition: PPTConnection.cc:156
PPTConnection
Definition: PPTConnection.h:43
PPTConnection::readBuffer
virtual int readBuffer(char *inBuff, const unsigned int buff_size)
read a buffer of data from the socket
Definition: PPTConnection.cc:204
PPTConnection::dump
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition: PPTConnection.cc:469