Fawkes API  Fawkes Development Version
service.h
00001 
00002 /***************************************************************************
00003  *  service.h - Network service representation
00004  *
00005  *  Generated: Tue Nov 07 17:58:10 2006
00006  *  Copyright  2006-2008  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023 
00024 #ifndef __NETCOMM_SERVICE_DISCOVERY_SERVICE_H_
00025 #define __NETCOMM_SERVICE_DISCOVERY_SERVICE_H_
00026 
00027 #include <string>
00028 #include <list>
00029 
00030 #include <sys/types.h>
00031 #include <sys/socket.h>
00032 
00033 namespace fawkes {
00034 
00035 class NetworkNameResolver;
00036 
00037 class NetworkService
00038 {
00039  public:
00040   NetworkService(const char         *name,
00041                  const char         *type,
00042                  const char         *domain,
00043                  const char         *host,
00044                  unsigned short int  port);
00045 
00046   NetworkService(const char         *name,
00047                  const char         *type,
00048                  const char         *domain,
00049                  const char         *host,
00050                  unsigned short int  port,
00051                  const struct sockaddr *addr,
00052                  const socklen_t     addr_size,
00053                  std::list<std::string> &txt);
00054 
00055   NetworkService(const char         *name,
00056                  const char         *type,
00057                  unsigned short int  port);
00058 
00059   NetworkService(const char         *name,
00060                  const char         *type,
00061                  const char         *domain);
00062 
00063   NetworkService(NetworkNameResolver *nnresolver,
00064                  const char *name, const char *type,
00065                  unsigned short int port);
00066 
00067   NetworkService(const NetworkService *s);
00068   NetworkService(const NetworkService &s);
00069   ~NetworkService();
00070 
00071   void                add_txt(const char *format, ...);
00072   void                set_txt(std::list<std::string> &txtlist);
00073 
00074   void                set_name(const char *new_name);
00075 
00076   const char *        name() const;
00077   const char *        type() const;
00078   const char *        domain() const;
00079   const char *        host() const;
00080   std::string         addr_string() const;
00081   unsigned short int  port() const;
00082   const std::list<std::string> & txt() const;
00083 
00084   bool                operator==(const NetworkService &s) const;
00085   bool                operator==(const NetworkService *s) const;
00086   bool                operator<(const NetworkService &s) const;
00087 
00088  private:
00089   std::list<std::string> list;
00090   char *              _name;
00091   char *              _type;
00092   char *              _domain;
00093   char *              _host;
00094   unsigned short int  _port;
00095   struct sockaddr    *_addr;
00096   socklen_t           _addr_size;
00097 
00098 };
00099 
00100 } // end namespace fawkes
00101 
00102 #endif