8f150b19c141408661b5bedac1e00be97e625fd8
[metaproxy-moved-to-github.git] / src / origin.cpp
1 /* This file is part of Metaproxy.
2    Copyright (C) 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 <metaproxy/origin.hpp>
21
22 #include <iostream>
23
24 namespace mp = metaproxy_1;
25
26 mp::Origin::Origin() : m_address(""), m_origin_id(0), m_max_sockets(0)
27 {
28 }
29
30 void mp::Origin::set_max_sockets(int max_sockets)
31 {
32     m_max_sockets = max_sockets;
33 }
34
35 int mp::Origin::get_max_sockets()
36 {
37     return m_max_sockets;
38 }
39
40 void mp::Origin::set_tcpip_address(std::string addr, unsigned long s)
41 {
42     m_address = addr;
43     m_origin_id = s;
44 }
45
46 void mp::Origin::set_custom_session(const std::string &s)
47 {
48     m_custom_session = s;
49 }
50
51 std::string mp::Origin::get_address()
52 {
53     return m_address;
54 }
55
56 std::ostream& std::operator<<(std::ostream& os, const mp::Origin& o)
57 {
58     if (o.m_address.length())
59         os << o.m_address;
60     else
61         os << "0";
62     os << ":" << o.m_origin_id;
63     if (o.m_custom_session.length())
64         os << ":" << o.m_custom_session;
65     return os;
66 }
67
68 /*
69  * Local variables:
70  * c-basic-offset: 4
71  * c-file-style: "Stroustrup"
72  * indent-tabs-mode: nil
73  * End:
74  * vim: shiftwidth=4 tabstop=8 expandtab
75  */
76