eeb4af580c3a5684612beb8c6c93e6c6a9c59df7
[metaproxy-moved-to-github.git] / src / origin.hpp
1 /* This file is part of Metaproxy.
2    Copyright (C) 2005-2009 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     private:
60         friend std::ostream& 
61         std::operator<<(std::ostream& os,  metaproxy_1::Origin& o);
62         
63         enum origin_t {
64             API,
65             UNIX,
66             TCPIP
67         } m_type;
68         std::string m_address; // UNIX+TCPIP
69         unsigned int m_origin_id;
70         std::string m_listen_host;
71         unsigned int m_listen_port;
72         int m_max_sockets;
73     };
74
75 }
76
77
78
79 #endif
80 /*
81  * Local variables:
82  * c-basic-offset: 4
83  * c-file-style: "Stroustrup"
84  * indent-tabs-mode: nil
85  * End:
86  * vim: shiftwidth=4 tabstop=8 expandtab
87  */
88