LIBRCSC Docs
Documentation for HELIOS's BASE LIBRCSC library for RoboCup 2D Simulation League.
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
host_address.h
Go to the documentation of this file.
1// -*-c++-*-
2
8/*
9 *Copyright:
10
11 Copyright (C) Hidehisa AKIYAMA
12
13 This code is free software; you can redistribute it and/or
14 modify it under the terms of the GNU Lesser General Public
15 License as published by the Free Software Foundation; either
16 version 3 of the License, or (at your option) any later version.
17
18 This library is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
22
23 You should have received a copy of the GNU Lesser General Public
24 License along with this library; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
27 *EndCopyright:
28 */
29
31
32#ifndef RCSC_NET_HOST_ADDRESS_H
33#define RCSC_NET_HOST_ADDRESS_H
34
35#include <memory>
36#include <string>
37#include <cstdint>
38
39struct sockaddr_in;
40
41namespace rcsc {
42
44public:
45 typedef std::uint16_t PortNumber;
46 typedef std::uint32_t IPV4Address;
47 typedef struct sockaddr_in AddrType;
48
49private:
50
51 class Impl;
52
54 std::unique_ptr< Impl > M_impl;
55
56public:
57
62
67 HostAddress( const HostAddress & addr );
68
73 HostAddress( const AddrType & addr );
74
79
84 const HostAddress & operator=( const HostAddress & addr );
85
90 const HostAddress & operator=( const AddrType & addr );
91
95 void clear();
96
101 bool isNull() const;
102
107 bool equals( const HostAddress & addr ) const;
108
113 bool equals( const AddrType & addr ) const;
114
119 void setAddress( const AddrType & addr );
120
121 /*
122 \brief get port number of this address
123 \return port number
124 */
125 PortNumber portNumber() const;
126
132
137 std::string toHostName() const;
138
143 const AddrType & toAddress() const;
144};
145
146}
147
148#endif
Definition: host_address.h:43
void clear()
the host address is set to 0.0.0.0.
bool equals(const HostAddress &addr) const
check if the specified address is same as this object.
bool equals(const AddrType &addr) const
check if the specified address is same as this object.
std::uint16_t PortNumber
port number type
Definition: host_address.h:45
HostAddress(const AddrType &addr)
create a new address object with the argument.
HostAddress()
create a null address object
const HostAddress & operator=(const AddrType &addr)
copy the host address data
~HostAddress()
we need the destructor definition in order to use pimpl idiom with scoped_ptr
const AddrType & toAddress() const
get the raw address object.
HostAddress(const HostAddress &addr)
create a new address object that has same address with the argument.
struct sockaddr_in AddrType
binary ipv4 host address type
Definition: host_address.h:47
const HostAddress & operator=(const HostAddress &addr)
copy the host address data
std::string toHostName() const
get the address as a string (e.g. "127.0.0.1") that is generated by inet_ntoa.
bool isNull() const
check if the host address is 0.0.0.0
void setAddress(const AddrType &addr)
set new address
std::uint32_t IPV4Address
binary ipv4 host address type
Definition: host_address.h:46
IPV4Address toIPV4Address() const
get IPv4 address as a number