OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
Connection.h
Go to the documentation of this file.
1 // Connection.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 Connection_h
34 #define Connection_h 1
35 
36 #include <iostream>
37 #include <string>
38 #include <map>
39 
40 using std::ostream ;
41 using std::string ;
42 using std::map ;
43 
44 #include "BESObj.h"
45 #include "Socket.h"
46 
47 class Connection : public BESObj
48 {
49 protected:
51  ostream *_out ;
52  bool _brokenPipe ;
53 
55  : _mySock( 0 ),
56  _out( 0 ),
57  _brokenPipe( false ) {}
58 
59  virtual void send( const string &buffer ) = 0 ;
60  virtual void sendChunk( const string &buffer,
61  map<string,string> &extensions ) = 0 ;
62 public:
63  virtual ~Connection() {}
64 
65  virtual void initConnection() = 0 ;
66  virtual void closeConnection() = 0 ;
67 
68  virtual string exit() = 0 ;
69 
70  virtual void send( const string &buffer,
71  map<string,string> &extensions ) = 0 ;
72  virtual void sendExtensions( map<string,string> &extensions ) = 0 ;
73  virtual void sendExit() = 0 ;
74  virtual bool receive( map<string,string> &extensions,
75  ostream *strm = 0 ) = 0 ;
76 
77  virtual Socket * getSocket()
78  {
79  return _mySock ;
80  }
81 
82  virtual bool isConnected()
83  {
84  if( _mySock )
85  return _mySock->isConnected() ;
86  return false ;
87  }
88 
89  virtual void setOutputStream( ostream *strm )
90  {
91  _out = strm ;
92  }
93  virtual ostream * getOutputStream()
94  {
95  return _out ;
96  }
97 
98  virtual void brokenPipe()
99  {
100  _brokenPipe = true ;
101  }
102 
103  virtual unsigned int getRecvChunkSize() = 0 ;
104  virtual unsigned int getSendChunkSize() = 0 ;
105 
106  virtual void dump( ostream &strm ) const ;
107 } ;
108 
109 #endif // Connection_h
110 
Definition: Socket.h:44
virtual ~Connection()
Definition: Connection.h:63
virtual unsigned int getRecvChunkSize()=0
virtual bool isConnected()
Definition: Socket.h:63
ostream * _out
Definition: Connection.h:51
virtual void sendExtensions(map< string, string > &extensions)=0
virtual void closeConnection()=0
virtual bool isConnected()
Definition: Connection.h:82
virtual void sendChunk(const string &buffer, map< string, string > &extensions)=0
virtual void sendExit()=0
Base object for bes objects.
Definition: BESObj.h:52
virtual void setOutputStream(ostream *strm)
Definition: Connection.h:89
virtual void send(const string &buffer)=0
virtual unsigned int getSendChunkSize()=0
virtual void brokenPipe()
Definition: Connection.h:98
virtual void dump(ostream &strm) const
dumps information about this object
Definition: Connection.cc:42
virtual void initConnection()=0
virtual string exit()=0
virtual ostream * getOutputStream()
Definition: Connection.h:93
bool _brokenPipe
Definition: Connection.h:52
virtual Socket * getSocket()
Definition: Connection.h:77
Socket * _mySock
Definition: Connection.h:50
virtual bool receive(map< string, string > &extensions, ostream *strm=0)=0