From 07865d070772d90e6cd88070a905c16abcfde091 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 23 Feb 2021 21:39:03 +0100 Subject: [PATCH] zeroconf/avahi/Poll: move to namespace Avahi --- src/zeroconf/ZeroconfAvahi.cxx | 4 ++-- src/zeroconf/avahi/Poll.cxx | 19 ++++++++++++------- src/zeroconf/avahi/Poll.hxx | 12 ++++++++---- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/zeroconf/ZeroconfAvahi.cxx b/src/zeroconf/ZeroconfAvahi.cxx index 46517d80f..186599fb7 100644 --- a/src/zeroconf/ZeroconfAvahi.cxx +++ b/src/zeroconf/ZeroconfAvahi.cxx @@ -36,7 +36,7 @@ static constexpr Domain avahi_domain("avahi"); static char *avahi_name; -static MyAvahiPoll *avahi_poll; +static Avahi::Poll *avahi_poll; static AvahiClient *avahi_client; static AvahiEntryGroup *avahi_group; @@ -241,7 +241,7 @@ AvahiInit(EventLoop &loop, const char *serviceName) avahi_name = avahi_strdup(serviceName); - avahi_poll = new MyAvahiPoll(loop); + avahi_poll = new Avahi::Poll(loop); int error; avahi_client = avahi_client_new(avahi_poll, AVAHI_CLIENT_NO_FAIL, diff --git a/src/zeroconf/avahi/Poll.cxx b/src/zeroconf/avahi/Poll.cxx index 073019c28..0cec88f17 100644 --- a/src/zeroconf/avahi/Poll.cxx +++ b/src/zeroconf/avahi/Poll.cxx @@ -39,6 +39,7 @@ ToAvahiWatchEvent(unsigned e) noexcept } struct AvahiWatch final { +private: SocketEvent event; const AvahiWatchCallback callback; @@ -109,7 +110,9 @@ private: } }; -MyAvahiPoll::MyAvahiPoll(EventLoop &_loop) noexcept +namespace Avahi { + +Poll::Poll(EventLoop &_loop) noexcept :event_loop(_loop) { watch_new = WatchNew; @@ -122,20 +125,22 @@ MyAvahiPoll::MyAvahiPoll(EventLoop &_loop) noexcept } AvahiWatch * -MyAvahiPoll::WatchNew(const AvahiPoll *api, int fd, AvahiWatchEvent event, - AvahiWatchCallback callback, void *userdata) noexcept +Poll::WatchNew(const AvahiPoll *api, int fd, AvahiWatchEvent event, + AvahiWatchCallback callback, void *userdata) noexcept { - const MyAvahiPoll &poll = *(const MyAvahiPoll *)api; + const Poll &poll = *(const Poll *)api; return new AvahiWatch(poll.event_loop, SocketDescriptor(fd), event, callback, userdata); } AvahiTimeout * -MyAvahiPoll::TimeoutNew(const AvahiPoll *api, const struct timeval *tv, - AvahiTimeoutCallback callback, void *userdata) noexcept +Poll::TimeoutNew(const AvahiPoll *api, const struct timeval *tv, + AvahiTimeoutCallback callback, void *userdata) noexcept { - const MyAvahiPoll &poll = *(const MyAvahiPoll *)api; + const Poll &poll = *(const Poll *)api; return new AvahiTimeout(poll.event_loop, tv, callback, userdata); } + +} // namespace Avahi diff --git a/src/zeroconf/avahi/Poll.hxx b/src/zeroconf/avahi/Poll.hxx index 9dcbd4a27..4837c85e7 100644 --- a/src/zeroconf/avahi/Poll.hxx +++ b/src/zeroconf/avahi/Poll.hxx @@ -24,14 +24,16 @@ class EventLoop; -class MyAvahiPoll final : public AvahiPoll { +namespace Avahi { + +class Poll final : public AvahiPoll { EventLoop &event_loop; public: - explicit MyAvahiPoll(EventLoop &_loop) noexcept; + explicit Poll(EventLoop &_loop) noexcept; - MyAvahiPoll(const MyAvahiPoll &) = delete; - MyAvahiPoll &operator=(const MyAvahiPoll &) = delete; + Poll(const Poll &) = delete; + Poll &operator=(const Poll &) = delete; EventLoop &GetEventLoop() const noexcept { return event_loop; @@ -49,4 +51,6 @@ private: void *userdata) noexcept; }; +} // namespace Avahi + #endif