From 28e7bf7a13656620452e19d017ea5eedf14a8bc5 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 1 Aug 2011 15:17:45 +0300 Subject: [PATCH] Style update: reorder class members --- source/inet.h | 3 ++- source/inet6.h | 4 ++-- source/sockaddr.cpp | 10 +++++----- source/sockaddr.h | 18 +++++++++--------- source/streamlistensocket.h | 6 ++++-- source/streamsocket.h | 2 +- 6 files changed, 23 insertions(+), 20 deletions(-) diff --git a/source/inet.h b/source/inet.h index a65813b..75735a7 100644 --- a/source/inet.h +++ b/source/inet.h @@ -30,12 +30,13 @@ public: InetAddr(const sockaddr_in &); InetAddr(in_addr_t, in_port_t); + virtual InetAddr *copy() const { return new InetAddr(*this); } + Family get_family() const { return INET; } in_addr_t get_addr() const { return ntohl(addr); } in_port_t get_port() const { return ntohs(port); } std::string str() const; virtual unsigned fill_sockaddr(sockaddr &) const; - virtual InetAddr *copy() const { return new InetAddr(*this); } }; } // namespace Net diff --git a/source/inet6.h b/source/inet6.h index 44a5180..f5a7079 100644 --- a/source/inet6.h +++ b/source/inet6.h @@ -27,13 +27,13 @@ public: Inet6Addr(const sockaddr_in6 &); Inet6Addr(unsigned char [16], in_port_t); + virtual Inet6Addr *copy() const { return new Inet6Addr(*this); } + virtual Family get_family() const { return INET6; } virtual std::string str() const; virtual unsigned fill_sockaddr(sockaddr &) const; virtual unsigned fill_sockaddr(sockaddr_storage &) const; - - virtual Inet6Addr *copy() const { return new Inet6Addr(*this); } }; } // namespace Net diff --git a/source/sockaddr.cpp b/source/sockaddr.cpp index f95edd3..08babb1 100644 --- a/source/sockaddr.cpp +++ b/source/sockaddr.cpp @@ -5,11 +5,6 @@ namespace Msp { namespace Net { -unsigned SockAddr::fill_sockaddr(sockaddr_storage &sa) const -{ - return fill_sockaddr(reinterpret_cast(sa)); -} - SockAddr *SockAddr::create(const sockaddr_storage &sa) { switch(sa.ss_family) @@ -23,5 +18,10 @@ SockAddr *SockAddr::create(const sockaddr_storage &sa) } } +unsigned SockAddr::fill_sockaddr(sockaddr_storage &sa) const +{ + return fill_sockaddr(reinterpret_cast(sa)); +} + } // namespace Net } // namespace Msp diff --git a/source/sockaddr.h b/source/sockaddr.h index 745e6d4..6e4025d 100644 --- a/source/sockaddr.h +++ b/source/sockaddr.h @@ -12,7 +12,16 @@ namespace Net { class SockAddr { +protected: + SockAddr() { } public: + virtual ~SockAddr() { } + + static SockAddr *create(const sockaddr &sa) { return create(reinterpret_cast(sa)); } + static SockAddr *create(const sockaddr_storage &); + + virtual SockAddr *copy() const = 0; + virtual Family get_family() const = 0; virtual std::string str() const = 0; @@ -23,15 +32,6 @@ public: */ virtual unsigned fill_sockaddr(sockaddr &) const = 0; virtual unsigned fill_sockaddr(sockaddr_storage &) const; - - virtual SockAddr *copy() const =0; - - virtual ~SockAddr() { } - - static SockAddr *create(const sockaddr &sa) { return create(reinterpret_cast(sa)); } - static SockAddr *create(const sockaddr_storage &); -protected: - SockAddr() { } }; } // namespace Net diff --git a/source/streamlistensocket.h b/source/streamlistensocket.h index 8b96a98..a24e731 100644 --- a/source/streamlistensocket.h +++ b/source/streamlistensocket.h @@ -10,13 +10,15 @@ class StreamSocket; class StreamListenSocket: public Socket { +private: + bool listening; + public: StreamListenSocket(Family, int = 0); + int connect(const SockAddr &); void listen(const SockAddr &, unsigned = 4); StreamSocket *accept(); -private: - bool listening; }; } // namespace Net diff --git a/source/streamsocket.h b/source/streamsocket.h index 66841de..37c5b8e 100644 --- a/source/streamsocket.h +++ b/source/streamsocket.h @@ -24,9 +24,9 @@ private: public: StreamSocket(Family, int = 0); + virtual int connect(const SockAddr &); bool is_connecting() const { return connecting; } int poll_connect(const Time::TimeDelta &); - int connect(const SockAddr &); private: void on_event(IO::PollEvent); }; -- 2.45.2