Custom session ID may be specified for SRU filter
[metaproxy-moved-to-github.git] / include / metaproxy / origin.hpp
1 /* This file is part of Metaproxy.
2    Copyright (C) 2005-2011 Index Data
3
4 Metaproxy is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18
19 #ifndef YP2_ORIGIN_HPP
20 #define YP2_ORIGIN_HPP
21
22 #include <iosfwd>
23 #include <string>
24
25 namespace metaproxy_1 {
26     class Origin;
27 }
28
29 namespace std {
30     std::ostream& operator<<(std::ostream& os, metaproxy_1::Origin& o);
31 }
32
33 namespace metaproxy_1 {
34     
35     class Origin {
36     public:
37         Origin(std::string listen_host = "", unsigned int listen_port = 0);
38         
39         /// get function - right val in assignment
40         std::string listen_host() const;
41
42         /// set function - left val in assignment
43         std::string & listen_host();
44  
45         /// get function - right val in assignment
46         unsigned int listen_port() const;
47         
48         /// set function - left val in assignment
49         unsigned int & listen_port();
50  
51         /// set client IP info - left val in assignment
52         void set_tcpip_address(std::string addr, unsigned long id);
53
54         /// set max sockets (for outgoing connections to a given target)
55         void set_max_sockets(int max_sockets);
56
57         /// set max sockets (for outgoing connections to a given target)
58         int get_max_sockets();
59         
60         /// get tcpip address
61         std::string get_address();
62
63         void set_custom_session(const std::string &s);
64     private:
65         friend std::ostream& 
66         std::operator<<(std::ostream& os,  metaproxy_1::Origin& o);
67         
68         enum origin_t {
69             API,
70             UNIX,
71             TCPIP
72         } m_type;
73         std::string m_address; // UNIX+TCPIP
74         unsigned int m_origin_id;
75         std::string m_listen_host;
76         unsigned int m_listen_port;
77         int m_max_sockets;
78         std::string m_custom_session;
79     };
80
81 }
82
83
84
85 #endif
86 /*
87  * Local variables:
88  * c-basic-offset: 4
89  * c-file-style: "Stroustrup"
90  * indent-tabs-mode: nil
91  * End:
92  * vim: shiftwidth=4 tabstop=8 expandtab
93  */
94