Updated copyright headers. Omit CVS ID.
[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)
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
54
55 void mp::Origin::set_tcpip_address(std::string addr, unsigned long s)
56 {
57     m_type = TCPIP;
58     m_address = addr;
59     m_origin_id = s;
60 }
61
62 std::ostream& std::operator<<(std::ostream& os,  mp::Origin& o)
63 {
64     if (o.m_address != "")
65         os << o.m_address;
66     else
67         os << "0";
68     os << ":" << o.m_origin_id;
69     return os;
70 }
71                 
72 /*
73  * Local variables:
74  * c-basic-offset: 4
75  * indent-tabs-mode: nil
76  * c-file-style: "stroustrup"
77  * End:
78  * vim: shiftwidth=4 tabstop=8 expandtab
79  */