Open Lighting Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OpenSLPThread.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  *
16  * OpenSLPThread.h
17  * Copyright (C) 2011 Simon Newton
18  *
19  * An implementation of BaseSLPThread that uses openslp.
20  */
21 
22 #ifndef INCLUDE_OLA_E133_OPENSLPTHREAD_H_
23 #define INCLUDE_OLA_E133_OPENSLPTHREAD_H_
24 
25 #include <slp.h>
26 #include <ola/e133/SLPThread.h>
27 #include <ola/network/Socket.h>
28 #include <ola/thread/ExecutorInterface.h>
29 #include <ola/thread/Thread.h>
30 
31 #include <memory>
32 #include <string>
33 
34 namespace ola {
35 namespace e133 {
36 
37 using std::string;
38 using std::auto_ptr;
39 
41  public:
42  // Ownership of the discovery_callback is transferred.
45  unsigned int discovery_interval = DEFAULT_DISCOVERY_INTERVAL_SECONDS);
46  ~OpenSLPThread();
47 
48  bool Init();
49  void Cleanup();
50 
51  protected:
52  void RunDiscovery(InternalDiscoveryCallback *callback,
53  const string &service);
54  void RegisterSLPService(RegistrationCallback *callback,
55  const string& url,
56  uint16_t lifetime);
57  void DeRegisterSLPService(RegistrationCallback *callback,
58  const string& url);
59  void SLPServerInfo(ServerInfoCallback *callback);
60 
61  private:
62  bool m_init_ok;
63  SLPHandle m_slp_handle;
64 };
65 } // namespace e133
66 } // namespace ola
67 #endif // INCLUDE_OLA_E133_OPENSLPTHREAD_H_