Open Lighting Architecture  0.9.1
 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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/base/Macro.h>
27 #include <ola/e133/SLPThread.h>
28 #include <ola/network/Socket.h>
29 #include <ola/thread/ExecutorInterface.h>
30 #include <ola/thread/Thread.h>
31 
32 #include <memory>
33 #include <string>
34 
35 namespace ola {
36 namespace e133 {
37 
38 using std::string;
39 using std::auto_ptr;
40 
42  public:
43  // Ownership of the discovery_callback is transferred.
46  unsigned int discovery_interval = DEFAULT_DISCOVERY_INTERVAL_SECONDS);
47  ~OpenSLPThread();
48 
49  bool Init();
50  void Cleanup();
51 
52  protected:
53  void RunDiscovery(InternalDiscoveryCallback *callback,
54  const string &service);
55  void RegisterSLPService(RegistrationCallback *callback,
56  const string& url,
57  uint16_t lifetime);
58  void DeRegisterSLPService(RegistrationCallback *callback,
59  const string& url);
60  void SLPServerInfo(ServerInfoCallback *callback);
61 
62  private:
63  bool m_init_ok;
64  SLPHandle m_slp_handle;
65 
66  DISALLOW_COPY_AND_ASSIGN(OpenSLPThread);
67 };
68 } // namespace e133
69 } // namespace ola
70 #endif // INCLUDE_OLA_E133_OPENSLPTHREAD_H_