zeroconf/avahi/Poll: move to namespace Avahi

This commit is contained in:
Max Kellermann 2021-02-23 21:39:03 +01:00
parent 1ac16516a1
commit 07865d0707
3 changed files with 22 additions and 13 deletions

View File

@ -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,

View File

@ -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

View File

@ -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