GPL v2.
[metaproxy-moved-to-github.git] / src / origin.cpp
1 /* $Id: origin.cpp,v 1.6 2007-05-09 21:23:09 adam Exp $
2    Copyright (c) 2005-2007, Index Data.
3
4 This file is part of Metaproxy.
5
6 Metaproxy is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
9 version.
10
11 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Metaproxy; see the file LICENSE.  If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA.
20  */
21
22 //#include "config.hpp"
23 #include "origin.hpp"
24
25 #include <iostream>
26
27 namespace mp = metaproxy_1;
28
29 mp::Origin::Origin(std::string listen_host, 
30                    unsigned int listen_port) 
31     : m_type(API), m_address(""), m_origin_id(0),
32       m_listen_host(listen_host), m_listen_port(listen_port)
33 {
34 }
35
36 std::string mp::Origin::listen_host() const
37 {
38     return m_listen_host;
39 };
40
41 std::string & mp::Origin::listen_host()
42 {
43     return m_listen_host;
44 };
45
46 unsigned int mp::Origin::listen_port() const
47 {
48     return m_listen_port;
49 };
50
51 unsigned int & mp::Origin::listen_port()
52 {
53     return m_listen_port;
54 };
55
56
57
58 void mp::Origin::set_tcpip_address(std::string addr, unsigned long s)
59 {
60     m_type = TCPIP;
61     m_address = addr;
62     m_origin_id = s;
63 }
64
65 std::ostream& std::operator<<(std::ostream& os,  mp::Origin& o)
66 {
67     if (o.m_address != "")
68         os << o.m_address;
69     else
70         os << "0";
71     os << ":" << o.m_origin_id;
72     return os;
73 }
74                 
75 /*
76  * Local variables:
77  * c-basic-offset: 4
78  * indent-tabs-mode: nil
79  * c-file-style: "stroustrup"
80  * End:
81  * vim: shiftwidth=4 tabstop=8 expandtab
82  */