]> git.stg.codes - stg.git/blob - stglibs/sgcp.lib/transport.h
Reduced public interface.
[stg.git] / stglibs / sgcp.lib / transport.h
1 #ifndef __STG_SGCP_TRANSPORT_H__
2 #define __STG_SGCP_TRANSPORT_H__
3
4 /*
5  *    This program is free software; you can redistribute it and/or modify
6  *    it under the terms of the GNU General Public License as published by
7  *    the Free Software Foundation; either version 2 of the License, or
8  *    (at your option) any later version.
9  *
10  *    This program is distributed in the hope that it will be useful,
11  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *    GNU General Public License for more details.
14  *
15  *    You should have received a copy of the GNU General Public License
16  *    along with this program; if not, write to the Free Software
17  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 /*
21  *    Author : Maxim Mamontov <faust@stargazer.dp.ua>
22  */
23
24 #include "stg/sgcp_types.h"
25
26 #include "stg/os_int.h"
27
28 #include <string>
29 #include <stdexcept>
30
31 #include <unistd.h> // ssize_t
32
33 namespace STG
34 {
35 namespace SGCP
36 {
37
38 class TransportProto
39 {
40     public:
41         struct Error : public std::runtime_error {
42             Error(const std::string& message) : runtime_error(message) {}
43         };
44
45         static TransportProto* create(TransportType transport, const std::string& key);
46
47         virtual ~TransportProto() {}
48
49         virtual ConnectionPtr connect(const std::string& address, uint16_t port) = 0;
50         virtual void bind(const std::string& address, uint16_t port, Proto::AcceptHandler handler) = 0;
51 };
52
53 } // namespace SGCP
54 } // namespace STG
55
56 #endif