zeroconf/Glue: move code to the ZeroconfHelper constructor
This commit is contained in:
		@@ -84,13 +84,5 @@ ZeroconfInit(const ConfigData &config, [[maybe_unused]] EventLoop &loop)
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef HAVE_AVAHI
 | 
						return std::make_unique<ZeroconfHelper>(loop, serviceName, listen_port);
 | 
				
			||||||
	return std::make_unique<ZeroconfHelper>(AvahiInit(loop, serviceName,
 | 
					 | 
				
			||||||
							  listen_port));
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef HAVE_BONJOUR
 | 
					 | 
				
			||||||
	return std::make_unique<ZeroconfHelper>(BonjourInit(loop, serviceName,
 | 
					 | 
				
			||||||
							    listen_port));
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,10 +21,16 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#ifdef HAVE_AVAHI
 | 
					#ifdef HAVE_AVAHI
 | 
				
			||||||
#include "avahi/Helper.hxx"
 | 
					#include "avahi/Helper.hxx"
 | 
				
			||||||
 | 
					#define CreateHelper AvahiInit
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef HAVE_BONJOUR
 | 
					#ifdef HAVE_BONJOUR
 | 
				
			||||||
#include "Bonjour.hxx"
 | 
					#include "Bonjour.hxx"
 | 
				
			||||||
 | 
					#define CreateHelper BonjourInit
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ZeroconfHelper::ZeroconfHelper(EventLoop &event_loop, const char *name,
 | 
				
			||||||
 | 
								       unsigned port)
 | 
				
			||||||
 | 
						:helper(CreateHelper(event_loop, name, port)) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ZeroconfHelper::~ZeroconfHelper() noexcept = default;
 | 
					ZeroconfHelper::~ZeroconfHelper() noexcept = default;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,6 +24,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <memory>
 | 
					#include <memory>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class EventLoop;
 | 
				
			||||||
class AvahiHelper;
 | 
					class AvahiHelper;
 | 
				
			||||||
class BonjourHelper;
 | 
					class BonjourHelper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -37,9 +38,8 @@ class ZeroconfHelper final {
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
	template<typename T>
 | 
						ZeroconfHelper(EventLoop &event_loop, const char *name,
 | 
				
			||||||
	ZeroconfHelper(T &&_helper) noexcept
 | 
							       unsigned port);
 | 
				
			||||||
		:helper(std::forward<T>(_helper)) {}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	~ZeroconfHelper() noexcept;
 | 
						~ZeroconfHelper() noexcept;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user