/* * Copyright (c) 2012 Tobias Markmann * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ #pragma once #include #include #include #include namespace Swift { class EventLoop; class TimerFactory; class UnboundDomainNameResolver; class UnboundQuery { public: UnboundQuery(UnboundDomainNameResolver* resolver, ub_ctx* context) : resolver(resolver), ubContext(context) {} virtual ~UnboundQuery() {} virtual void handleResult(int err, ub_result* result) = 0; protected: UnboundDomainNameResolver* resolver; ub_ctx* ubContext; }; class UnboundDomainNameResolver : public DomainNameResolver { public: UnboundDomainNameResolver(EventLoop* eventLoop, TimerFactory* timerFactory); virtual ~UnboundDomainNameResolver(); virtual boost::shared_ptr createServiceQuery(const std::string& name); virtual boost::shared_ptr createAddressQuery(const std::string& name); static void unbound_callback_wrapper(void* data, int err, ub_result* result); private: void unbound_callback(boost::shared_ptr query, int err, ub_result* result); void processData(); private: EventLoop* eventLoop; TimerFactory* timerFactory; ub_ctx* ubContext; Timer::ref timer; }; }