#ifndef n_ServiceFinder_H
#define n_ServiceFinder_H

/*
 *
 * nucleo/network/rdv/ServiceFinder.H --
 *
 * Copyright (C) Nicolas Roussel
 *
 * See the file LICENSE for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 */

#include <nucleo/core/ReactiveObject.H>
#include <nucleo/network/rdv/Service.H>

#include <queue>

namespace nucleo {

  class ServiceFinder : public ReactiveObject {

  public:

    struct Event {
	 enum {FOUND, LOST} event ;
	 // ipaddr, port and textRecords are not set for LOST services
	 Service service ;

	 void debug(std::ostream& out) const ;
    } ;

    typedef std::queue<Event*> EventQueue ;

  protected:

    EventQueue *queue ;

    // Use the plugin-enabled static method "create" to create an instance
    ServiceFinder(EventQueue *queue) ;

  public:

    virtual ~ServiceFinder(void) {}

    // domain defaults to ".local"
    static ServiceFinder *create(const char *type, EventQueue *queue, const char *domain=0) ;

  } ;

  typedef ServiceFinder * (*ServiceFinderFactory) (const char *type,
										 ServiceFinder::EventQueue *queue,
										 const char *domain) ;

}

#endif
