Lunchbox
1.4.0
|
00001 00002 /* Copyright (c) 2012, Stefan Eilemann <eile@eyescale.ch> 00003 * 00004 * This file is part of Lunchbox <https://github.com/Eyescale/Lunchbox> 00005 * 00006 * This library is free software; you can redistribute it and/or modify it under 00007 * the terms of the GNU Lesser General Public License version 2.1 as published 00008 * by the Free Software Foundation. 00009 * 00010 * This library is distributed in the hope that it will be useful, but WITHOUT 00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00012 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00013 * details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public License 00016 * along with this library; if not, write to the Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00018 */ 00019 00020 #ifndef LUNCHBOX_SERVUS_H 00021 #define LUNCHBOX_SERVUS_H 00022 00023 #include <lunchbox/api.h> 00024 #include <lunchbox/types.h> 00025 #include <map> 00026 00027 namespace lunchbox 00028 { 00029 namespace detail { class Servus; } 00030 00040 class Servus 00041 { 00042 public: 00043 enum Interface 00044 { 00045 IF_ALL = 0, 00046 // (uint32_t) -1 == kDNSServiceInterfaceIndexLocalOnly 00047 IF_LOCAL = (unsigned)(-1) 00048 }; 00049 00056 LUNCHBOX_API Servus( const std::string& name ); 00057 00059 LUNCHBOX_API virtual ~Servus(); 00060 00073 LUNCHBOX_API void set( const std::string& key, const std::string& value ); 00074 00082 LUNCHBOX_API bool announce( const unsigned short port, 00083 const std::string& instance ); 00084 00086 LUNCHBOX_API void withdraw(); 00087 00089 LUNCHBOX_API bool isAnnounced() const; 00090 00099 LUNCHBOX_API Strings discover( const Interface interface, 00100 const unsigned browseTime ); 00101 00103 LUNCHBOX_API Strings getInstances() const; 00104 00106 LUNCHBOX_API Strings getKeys( const std::string& instance ) const; 00107 00109 LUNCHBOX_API bool containsKey( const std::string& instance, 00110 const std::string& key ) const; 00111 00113 LUNCHBOX_API const std::string& get( const std::string& instance, 00114 const std::string& key ) const; 00115 00117 typedef std::map< std::string, std::map< std::string, std::string > > Data; 00118 00120 LUNCHBOX_API void getData( Data& data ); 00121 00122 private: 00123 detail::Servus* const impl_; 00124 }; 00125 } 00126 00127 #endif // LUNCHBOX_SERVUS_H