20 #ifndef SERVUS_SERVUS_H 21 #define SERVUS_SERVUS_H 24 #include <servus/result.h> 25 #include <servus/types.h> 35 static const std::string TEST_DRIVER{
"_servus._test"};
66 explicit Result(
const int32_t code)
71 SERVUS_API std::string
getString()
const override;
90 SERVUS_API
explicit Servus(
const std::string& name);
96 SERVUS_API
const std::string&
getName()
const;
110 SERVUS_API
void set(
const std::string& key,
const std::string& value);
113 SERVUS_API Strings
getKeys()
const;
116 SERVUS_API
const std::string&
get(
const std::string& key)
const;
127 const std::string& instance);
146 const unsigned browseTime);
176 SERVUS_API Strings
getKeys(
const std::string& instance)
const;
179 SERVUS_API
const std::string&
getHost(
const std::string& instance)
const;
182 SERVUS_API
bool containsKey(
const std::string& instance,
183 const std::string& key)
const;
186 SERVUS_API
const std::string&
get(
const std::string& instance,
187 const std::string& key)
const;
206 typedef std::map<std::string, std::map<std::string, std::string> > Data;
209 SERVUS_API
void getData(Data& data);
217 std::unique_ptr<Impl> _impl;
223 SERVUS_API std::string getHostname();
232 #endif // SERVUS_SERVUS_H Result browse(int32_t timeout=-1)
Browse and process discovered key/value pairs.
Defines export visibility macros for library Servus.
void addListener(Listener *listener)
Add a listener which is invoked according to its supported callbacks.
A result returns an error code and behaves like a boolean.
virtual ~Result()
Destruct the result.
void removeListener(Listener *listener)
Remove a listener to stop invokation on its supported callbacks.
The ZeroConf operation result code.
virtual ~Servus()
Destruct this service.
Result beginBrowsing(const servus::Servus::Interface addr)
Begin the discovery of announced key/value pairs.
static bool isAvailable()
static const int32_t PENDING
operation did not complete.
friend std::ostream & operator<<(std::ostream &, const Servus &)
Output the servus instance in human-readable format.
Simple wrapper for ZeroConf key/value pairs.
Strings discover(const Interface addr, const unsigned browseTime)
Discover all announced key/value pairs.
static const int32_t POLL_ERROR
Error during polling for event.
void endBrowsing()
Stop a discovery process and return all results.
Result announce(const unsigned short port, const std::string &instance)
Start announcing the registered key/value pairs.
const std::string & getHost(const std::string &instance) const
Servus(const std::string &name)
Create a new service handle.
A listener interface which can be implemented to listen on changes of a Servus instance.
std::string getString() const override
void withdraw()
Stop announcing the registered key/value pairs.
Strings getInstances() const
bool containsKey(const std::string &instance, const std::string &key) const
static const int32_t NOT_SUPPORTED
Servus compiled without ZeroConf support.
const std::string & getName() const