OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
PPTConnection.h
Go to the documentation of this file.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 {
45 private:
46  int _timeout ;
47  char * _inBuff ;
48  /*unsigned*/ int _inBuff_len ;
49  /*unsigned*/ int _bytesRead ;
50 
52  : _timeout( 0 ),
53  _inBuff( 0 ),
54  _inBuff_len( 0 ),
55  _bytesRead( 0 ) {}
56 
57  virtual int readBuffer( char *inBuff,
58  const unsigned int buff_size ) ;
59  virtual int readChunkHeader( char *inBuff,
60  /*unsigned*/ int buff_size ) ;
61  virtual void sendChunk( const string &buffer,
62  map<string,string> &extensions ) ;
63  virtual void receive( ostream &strm,
64  const /*unsigned*/ int len ) ;
65 
66 protected:
67  PPTConnection( int timeout )
68  : _timeout( timeout ),
69  _inBuff( 0 ),
70  _inBuff_len( 0 ),
71  _bytesRead( 0 ) {}
72 
73  virtual int readBufferNonBlocking( char *inBuff,
74  const /*unsigned*/ int buff_size );
75 
76  virtual void send( const string &buffer ) ;
77  virtual void read_extensions( map<string,string> &extensions,
78  const string &xstr ) ;
79 public:
80  virtual ~PPTConnection() ;
81 
82  virtual void initConnection() = 0 ;
83  virtual void closeConnection() = 0 ;
84 
85  virtual string exit() { return PPTProtocol::PPT_EXIT_NOW ; }
86 
87  virtual void send( const string &buffer,
88  map<string,string> &extensions ) ;
89  virtual void sendExtensions( map<string,string> &extensions ) ;
90  virtual void sendExit() ;
91  virtual bool receive( map<string,string> &extensions,
92  ostream *strm = 0 ) ;
93 
94  virtual unsigned int getRecvChunkSize() ;
95  virtual unsigned int getSendChunkSize() ;
96 
97  virtual void dump( ostream &strm ) const ;
98 } ;
99 
100 #endif // PPTConnection_h
101 
Definition: Socket.h:44
virtual ~PPTConnection()
virtual void closeConnection()=0
virtual string exit()
Definition: PPTConnection.h:85
virtual void initConnection()=0
virtual void sendExit()
Send the exit token as an extension.
PPTConnection(int timeout)
Definition: PPTConnection.h:67
virtual void read_extensions(map< string, string > &extensions, const string &xstr)
the string passed are extensions, read them and store the name/value pairs into the passed map ...
virtual void sendExtensions(map< string, string > &extensions)
send the specified extensions
virtual unsigned int getSendChunkSize()
virtual int readBufferNonBlocking(char *inBuff, const int buff_size)
read a buffer of data from the socket without blocking
static string PPT_EXIT_NOW
Definition: PPTProtocol.h:47
virtual unsigned int getRecvChunkSize()
virtual void dump(ostream &strm) const
dumps information about this object
virtual void send(const string &buffer)
sends the buffer to the socket