Open Lighting Architecture: olad/BonjourDiscoveryAgent.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
BonjourDiscoveryAgent.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 * BonjourDiscoveryAgent.h
17 * The Bonjour implementation of DiscoveryAgentInterface.
18 * Copyright (C) 2013 Simon Newton
19 */
20
21#ifndef OLAD_BONJOURDISCOVERYAGENT_H_
22#define OLAD_BONJOURDISCOVERYAGENT_H_
23
24#include <dns_sd.h>
25
26#include <ola/base/Macro.h>
27#include <ola/io/Descriptor.h>
28#include <ola/io/SelectServer.h>
29#include <memory>
30#include <string>
31#include <vector>
32
33#include "olad/DiscoveryAgent.h"
34
35namespace ola {
36namespace thread {
37class CallbackThread;
38}
39
44 class BonjourDiscoveryAgent : public DiscoveryAgentInterface {
45 public:
46 BonjourDiscoveryAgent();
47 ~BonjourDiscoveryAgent();
48
49 bool Init();
50
51 void RegisterService(const std::string &service_name,
52 const std::string &type,
53 uint16_t port,
54 const RegisterOptions &options);
55
56 private:
57 struct RegisterArgs : public RegisterOptions {
58 std::string service_name;
59 std::string type;
60 uint16_t port;
61
62 RegisterArgs(const std::string &service_name,
63 const std::string &type,
64 uint16_t port,
65 const RegisterOptions &options);
66 };
67
68 struct ServiceRef {
69 // DNSServiceRef is just a pointer.
70 DNSServiceRef service_ref;
71 class DNSSDDescriptor *descriptor;
72 };
73
74 typedef std::vector<ServiceRef> ServiceRefs;
75
76 ola::io::SelectServer m_ss;
77 std::auto_ptr<thread::CallbackThread> m_thread;
78 ServiceRefs m_refs;
79
80 void InternalRegisterService(RegisterArgs *args);
81 std::string BuildTxtRecord(const RegisterOptions::TxtData &txt_data);
82 void RunThread();
83 BonjourDiscoveryAgent(const BonjourDiscoveryAgent &) = delete;
84 const BonjourDiscoveryAgent &operator=(const BonjourDiscoveryAgent &) = delete;
85};
86} // namespace ola
87#endif // OLAD_BONJOURDISCOVERYAGENT_H_
Macro.h
Helper macros.
ola::BonjourDiscoveryAgent::RegisterService
void RegisterService(const std::string &service_name, const std::string &type, uint16_t port, const RegisterOptions &options)
Register a service.
Definition BonjourDiscoveryAgent.cpp:115
ola::BonjourDiscoveryAgent::Init
bool Init()
Initialize the DiscoveryAgent.
Definition BonjourDiscoveryAgent.cpp:110
ola::DNSSDDescriptor
Definition BonjourDiscoveryAgent.cpp:56
ola::DiscoveryAgentInterface
The interface to DNS-SD operations like register, browse etc.
Definition DiscoveryAgent.h:34
ola::io::SelectServer
A single threaded I/O event management system.
Definition SelectServer.h:63
ola::thread::CallbackThread
A thread which executes a Callback.
Definition CallbackThread.h:36
Descriptor.h
ola::thread
Threads and synchronization mechanisms.
Definition ConsumerThread.cpp:25
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44
ola::DiscoveryAgentInterface::RegisterOptions
Options for the RegisterService method.
Definition DiscoveryAgent.h:49