#ifndef n_ServiceAnnouncer_H
#define n_ServiceAnnouncer_H

/*
 *
 * nucleo/network/rdv/ServiceAnnouncer.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/network/rdv/Service.H>

#include <string>

namespace nucleo {

  class ServiceAnnouncer {

  public:

    virtual ~ServiceAnnouncer(void) {}

    typedef enum {UNKNOWN, NAME_COLLISION, ANNOUNCED} state ;

    virtual state getState(void) = 0 ;

    // Use this method when state is NAME_COLLISION to specify a new
    // name. 0 means "find a new name for me".
    virtual bool changeName(const char *newname=0) = 0 ;

    virtual std::string getName(void) = 0 ;

    // domain defaults to ".local", host to the machine running the application
    static ServiceAnnouncer *create(const char *name, const char *type, int port,
							 TextRecords *textRecords=0,
							 bool autorename=true,
							 const char *domain=0, const char *host=0) ;
  
  } ;

  typedef ServiceAnnouncer * (*ServiceAnnouncerFactory) (const char *name, const char *type, int port,
											  TextRecords *textRecords,
											  bool autorename,
											  const char *domain, const char *host) ;

}

#endif
