20 #ifndef SERVUS_SERVUS_H 21 #define SERVUS_SERVUS_H 24 #include <servus/result.h> 25 #include <servus/types.h> 53 IF_LOCAL = (unsigned)(-1)
65 explicit Result(
const int32_t code)
70 SERVUS_API std::string getString()
const override;
73 static const int32_t PENDING = -1;
75 static const int32_t NOT_SUPPORTED = -2;
77 static const int32_t POLL_ERROR = -3;
81 SERVUS_API
static bool isAvailable();
89 SERVUS_API
explicit Servus(
const std::string& name);
92 SERVUS_API
virtual ~
Servus();
95 SERVUS_API
const std::string& getName()
const;
109 SERVUS_API
void set(
const std::string& key,
const std::string& value);
112 SERVUS_API Strings getKeys()
const;
115 SERVUS_API
const std::string&
get(
const std::string& key)
const;
125 SERVUS_API
Result announce(
const unsigned short port,
126 const std::string& instance);
129 SERVUS_API
void withdraw();
132 SERVUS_API
bool isAnnounced()
const;
144 SERVUS_API Strings discover(
const Interface addr,
145 const unsigned browseTime);
163 SERVUS_API
Result browse(int32_t timeout = -1);
166 SERVUS_API
void endBrowsing();
169 SERVUS_API
bool isBrowsing()
const;
172 SERVUS_API Strings getInstances()
const;
175 SERVUS_API Strings getKeys(
const std::string& instance)
const;
178 SERVUS_API
const std::string& getHost(
const std::string& instance)
const;
181 SERVUS_API
bool containsKey(
const std::string& instance,
182 const std::string& key)
const;
185 SERVUS_API
const std::string&
get(
const std::string& instance,
186 const std::string& key)
const;
194 SERVUS_API
void addListener(
Listener* listener);
202 SERVUS_API
void removeListener(
Listener* listener);
205 typedef std::map<std::string, std::map<std::string, std::string> > Data;
208 SERVUS_API
void getData(Data& data);
213 detail::Servus*
const _impl;
214 friend SERVUS_API std::ostream& operator<<(std::ostream&,
const Servus&);
218 SERVUS_API std::string getHostname();
221 SERVUS_API std::ostream& operator<<(std::ostream&,
const Servus&);
227 #endif // SERVUS_SERVUS_H Defines export visibility macros for library Servus.
A result returns an error code and behaves like a boolean.
virtual ~Result()
Destruct the result.
The ZeroConf operation result code.
Simple wrapper for ZeroConf key/value pairs.
A listener interface which can be implemented to listen on changes of a Servus instance.