20 #ifndef SERVUS_SERVUS_H
21 #define SERVUS_SERVUS_H
24 #include <servus/result.h>
25 #include <servus/types.h>
31 namespace detail {
class Servus; }
64 SERVUS_API std::string
getString()
const override;
83 SERVUS_API
explicit Servus(
const std::string& name );
89 SERVUS_API
const std::string&
getName()
const;
103 SERVUS_API
void set(
const std::string& key,
const std::string& value );
106 SERVUS_API Strings
getKeys()
const;
109 SERVUS_API
const std::string&
get(
const std::string& key )
const;
120 const std::string& instance );
139 const unsigned browseTime );
169 SERVUS_API Strings
getKeys(
const std::string& instance )
const;
172 SERVUS_API
bool containsKey(
const std::string& instance,
173 const std::string& key )
const;
176 SERVUS_API
const std::string&
get(
const std::string& instance,
177 const std::string& key )
const;
196 typedef std::map< std::string, std::map< std::string, std::string > > Data;
199 SERVUS_API
void getData( Data& data );
204 detail::Servus*
const _impl;
205 friend SERVUS_API std::ostream&
operator << ( std::ostream&,
210 SERVUS_API std::string getHostname();
213 SERVUS_API std::ostream& operator << ( std::ostream&,
const Servus& );
219 #endif // SERVUS_SERVUS_H
SERVUS_API void withdraw()
Stop announcing the registered key/value pairs.
Defines export visibility macros for library Servus.
A result returns an error code and behaves like a boolean.
virtual ~Result()
Destruct the result.
friend SERVUS_API std::ostream & operator<<(std::ostream &, const Servus &)
Output the servus instance in human-readable format.
SERVUS_API Servus(const std::string &name)
Create a new service handle.
The ZeroConf operation result code.
SERVUS_API Strings getInstances() const
SERVUS_API bool isBrowsing() const
SERVUS_API void removeListener(Listener *listener)
Remove a listener to stop invokation on its supported callbacks.
static const int32_t PENDING
operation did not complete.
SERVUS_API void endBrowsing()
Stop a discovery process and return all results.
virtual SERVUS_API ~Servus()
Destruct this service.
SERVUS_API const std::string & getName() const
SERVUS_API void addListener(Listener *listener)
Add a listener which is invoked according to its supported callbacks.
Simple wrapper for ZeroConf key/value pairs.
SERVUS_API Strings getKeys() const
static const int32_t POLL_ERROR
Error during polling for event.
SERVUS_API void set(const std::string &key, const std::string &value)
Set a key/value pair to be announced.
SERVUS_API bool isAnnounced() const
SERVUS_API std::string getString() const override
A listener interface which can be implemented to listen on changes of a Servus instance.
SERVUS_API Strings discover(const Interface addr, const unsigned browseTime)
Discover all announced key/value pairs.
SERVUS_API Result browse(int32_t timeout=-1)
Browse and process discovered key/value pairs.
SERVUS_API Result beginBrowsing(const servus::Servus::Interface addr)
Begin the discovery of announced key/value pairs.
SERVUS_API Result announce(const unsigned short port, const std::string &instance)
Start announcing the registered key/value pairs.
static SERVUS_API bool isAvailable()
static const int32_t NOT_SUPPORTED
Servus compiled without ZeroConf support.
SERVUS_API bool containsKey(const std::string &instance, const std::string &key) const