bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
Connection.h
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., 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 Connection_h
34#define Connection_h 1
35
36#include <iostream>
37#include <string>
38#include <map>
39
40#include "BESObj.h"
41#include "Socket.h"
42
43class Connection: public BESObj {
44protected:
45 Socket *_mySock = nullptr;
46 std::ostream *_out = nullptr;
47 bool _brokenPipe = false;
48
49 Connection() = default;
50
51 virtual void send(const std::string &buffer) = 0;
52 virtual void sendChunk(const std::string &buffer, std::map<std::string, std::string> &extensions) = 0;
53
54public:
55 ~Connection() override = default;
56
57 virtual void initConnection() = 0;
58 virtual void closeConnection() = 0;
59
60 virtual std::string exit() = 0;
61
62 virtual void send(const std::string &buffer, std::map<std::string, std::string> &extensions) = 0;
63 virtual void sendExtensions(std::map<std::string, std::string> &extensions) = 0;
64 virtual void sendExit() = 0;
65 virtual bool receive(std::map<std::string, std::string> &extensions, std::ostream *strm = nullptr) = 0;
66
67 virtual Socket * getSocket()
68 {
69 return _mySock;
70 }
71
72 virtual bool isConnected()
73 {
74 if (_mySock) return _mySock->isConnected();
75 return false;
76 }
77
78 virtual void setOutputStream(std::ostream *strm)
79 {
80 _out = strm;
81 }
82 virtual std::ostream * getOutputStream()
83 {
84 return _out;
85 }
86
87 virtual void brokenPipe()
88 {
89 _brokenPipe = true;
90 }
91
92 virtual unsigned int getRecvChunkSize() = 0;
93 virtual unsigned int getSendChunkSize() = 0;
94
95 void dump(std::ostream &strm) const override;
96};
97
98#endif // Connection_h
top level BES object to house generic methods
Definition BESObj.h:54
void dump(std::ostream &strm) const override
dumps information about this object
Definition Connection.cc:44