service_discovery
ServiceDescription.hpp
Go to the documentation of this file.
1 #ifndef _SERVICE_DISCOVERY_SERVICEDESCRIPTION_H_
2 #define _SERVICE_DISCOVERY_SERVICEDESCRIPTION_H_
3 
4 #include <stdint.h>
5 #include <list>
6 #include <algorithm>
7 #include <string>
8 #include <vector>
9 #include <avahi-core/lookup.h>
10 
11 namespace servicediscovery {
12 namespace avahi {
13 
14 class ServiceEvent;
15 
22 {
23  friend class ServiceEvent;
24 
25  protected:
26  /* Name of service */
27  std::string name_;
28  /* Type of service such as _service._tcp */
29  std::string type_;
30  /* network protocol connected with this service. either ipv4 or ipv6 or both */
31  AvahiProtocol protocol_;
32  /* Name of domain such as .local */
33  std::string domain_;
34 
35  /*Index of network interface connected with this service */
36  AvahiIfIndex interfaceIndex_;
37 
38  std::list<std::string> descriptions_;
39  std::vector<std::string> labels_;
40 
41  static const uint32_t mDNSMaxRecordSize;
42  static const uint32_t mDNSMaxPayloadSize;
43 
44  int getDescriptionSize() const;
45 
46  public:
48 
49  ServiceDescription(const std::string& servicename);
50 
51  virtual ~ServiceDescription();
52 
53  bool operator==(const ServiceDescription& other) const;
54 
55  bool operator!=(const ServiceDescription& other) const;
56 
57  std::string getName() const;
58 
59  void setName(const std::string& name);
60 
64  bool compareWithoutTXT(const ServiceDescription& other) const;
65 
71  std::string getDescription(const std::string& label) const;
72 
85  void setDescription(const std::string& label, const std::string& description);
86 
90  void setRawDescriptions(const std::list<std::string>& descriptions);
91 
96  std::list<std::string> getRawDescriptions() const;
97 
103  std::vector<std::string> getLabels() const;
104 
108  void setType(const std::string& type);
109 
114  std::string getType() const;
115 
119  void setProtocol(int protocol);
120 
121  int getProtocol() const;
122 
123  std::string getProtocolString() const;
124 
128  void setDomain(const std::string& domain);
129 
133  std::string getDomain() const;
134 
138  void setInterfaceIndex(int interfaceIndex);
139 
143  int getInterfaceIndex() const;
144 };
145 
146 
147 } // end namespace avahi
148 } // end namespace servicediscovery
149 #endif // _SERVICE_DISCOVERY_SERVICEDESCRIPTION_H_
void setInterfaceIndex(int interfaceIndex)
Definition: ServiceDescription.cpp:260
std::string domain_
Definition: ServiceDescription.hpp:33
void setRawDescriptions(const std::list< std::string > &descriptions)
Definition: ServiceDescription.cpp:196
void setType(const std::string &type)
Definition: ServiceDescription.cpp:223
std::string getDomain() const
Definition: ServiceDescription.cpp:255
std::list< std::string > descriptions_
Definition: ServiceDescription.hpp:38
Definition: Client.cpp:7
std::string getName() const
Definition: ServiceDescription.cpp:43
virtual ~ServiceDescription()
Definition: ServiceDescription.cpp:38
Description and parameterization of a service instance.
Definition: ServiceDescription.hpp:21
void setName(const std::string &name)
Definition: ServiceDescription.cpp:48
AvahiProtocol protocol_
Definition: ServiceDescription.hpp:31
bool operator==(const ServiceDescription &other) const
Definition: ServiceDescription.cpp:77
ServiceDescription()
Definition: ServiceDescription.cpp:16
std::string type_
Definition: ServiceDescription.hpp:29
std::string getDescription(const std::string &label) const
Definition: ServiceDescription.cpp:102
int getProtocol() const
Definition: ServiceDescription.cpp:239
Event associated with appearance or disappearance of a service.
Definition: ServiceEvent.hpp:13
std::list< std::string > getRawDescriptions() const
Definition: ServiceDescription.cpp:191
bool operator!=(const ServiceDescription &other) const
Definition: ServiceDescription.cpp:96
std::string getType() const
Definition: ServiceDescription.cpp:229
std::vector< std::string > labels_
Definition: ServiceDescription.hpp:39
bool compareWithoutTXT(const ServiceDescription &other) const
Definition: ServiceDescription.cpp:53
static const uint32_t mDNSMaxPayloadSize
Definition: ServiceDescription.hpp:42
void setProtocol(int protocol)
Definition: ServiceDescription.cpp:234
std::vector< std::string > getLabels() const
Definition: ServiceDescription.cpp:218
std::string getProtocolString() const
Definition: ServiceDescription.cpp:244
void setDomain(const std::string &domain)
Definition: ServiceDescription.cpp:249
AvahiIfIndex interfaceIndex_
Definition: ServiceDescription.hpp:36
int getDescriptionSize() const
Definition: ServiceDescription.cpp:270
std::string name_
Definition: ServiceDescription.hpp:27
void setDescription(const std::string &label, const std::string &description)
Definition: ServiceDescription.cpp:120
static const uint32_t mDNSMaxRecordSize
Definition: ServiceDescription.hpp:41
int getInterfaceIndex() const
Definition: ServiceDescription.cpp:265