Allow x-max-sockets parameter for SRU
[metaproxy-moved-to-github.git] / src / origin.cpp
1 /* This file is part of Metaproxy.
2    Copyright (C) 2005-2008 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 //#include "config.hpp"
20 #include "origin.hpp"
21
22 #include <iostream>
23
24 namespace mp = metaproxy_1;
25
26 mp::Origin::Origin(std::string listen_host, 
27                    unsigned int listen_port) 
28     : m_type(API), m_address(""), m_origin_id(0),
29       m_listen_host(listen_host), m_listen_port(listen_port), m_max_sockets(0)
30 {
31 }
32
33 std::string mp::Origin::listen_host() const
34 {
35     return m_listen_host;
36 };
37
38 std::string & mp::Origin::listen_host()
39 {
40     return m_listen_host;
41 };
42
43 unsigned int mp::Origin::listen_port() const
44 {
45     return m_listen_port;
46 };
47
48 unsigned int & mp::Origin::listen_port()
49 {
50     return m_listen_port;
51 };
52
53 void mp::Origin::set_max_sockets(int max_sockets)
54 {
55     m_max_sockets = max_sockets;
56 }
57
58 int mp::Origin::get_max_sockets()
59 {
60     return m_max_sockets;
61 }
62
63 void mp::Origin::set_tcpip_address(std::string addr, unsigned long s)
64 {
65     m_type = TCPIP;
66     m_address = addr;
67     m_origin_id = s;
68 }
69
70 std::ostream& std::operator<<(std::ostream& os,  mp::Origin& o)
71 {
72     if (o.m_address != "")
73         os << o.m_address;
74     else
75         os << "0";
76     os << ":" << o.m_origin_id;
77     return os;
78 }
79                 
80 /*
81  * Local variables:
82  * c-basic-offset: 4
83  * indent-tabs-mode: nil
84  * c-file-style: "stroustrup"
85  * End:
86  * vim: shiftwidth=4 tabstop=8 expandtab
87  */