Open Lighting Architecture: olad/DiscoveryAgent.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
DiscoveryAgent.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 * DiscoveryAgent.h
17 * The Interface for DNS-SD Registration & Discovery
18 * Copyright (C) 2013 Simon Newton
19 */
20
21#ifndef OLAD_DISCOVERYAGENT_H_
22#define OLAD_DISCOVERYAGENT_H_
23
24#include <stdint.h>
25#include <ola/base/Macro.h>
26#include <string>
27#include <map>
28
29namespace ola {
30
34 class DiscoveryAgentInterface {
35 public:
36 virtual ~DiscoveryAgentInterface() {}
37
41 virtual bool Init() = 0;
42
49 struct RegisterOptions {
54 typedef std::map<std::string, std::string> TxtData;
55
59 static const int ALL_INTERFACES = 0;
60
61 int if_index;
67 std::string domain;
68 TxtData txt_data;
69
70 RegisterOptions()
71 : if_index(ALL_INTERFACES),
72 domain("") {
73 }
74
75 RegisterOptions(const RegisterOptions &options)
76 : if_index(options.if_index),
77 domain(options.domain),
78 txt_data(options.txt_data) {
79 }
80 };
81
89 // TODO(simon): Think about what sort of error handling we want here
90 virtual void RegisterService(const std::string &service_name,
91 const std::string &type,
92 uint16_t port,
93 const RegisterOptions &options) = 0;
94};
95
102 class DiscoveryAgentFactory {
103 public:
104 DiscoveryAgentFactory() {}
105
112 DiscoveryAgentInterface* New();
113
114 private:
115 DiscoveryAgentFactory(const DiscoveryAgentFactory &) = delete;
116 const DiscoveryAgentFactory &operator=(const DiscoveryAgentFactory &) = delete;
117};
118} // namespace ola
119#endif // OLAD_DISCOVERYAGENT_H_
Macro.h
Helper macros.
ola::DiscoveryAgentFactory::New
DiscoveryAgentInterface * New()
Create a new DiscoveryAgent.
Definition DiscoveryAgent.cpp:36
ola::DiscoveryAgentInterface
The interface to DNS-SD operations like register, browse etc.
Definition DiscoveryAgent.h:34
ola::DiscoveryAgentInterface::Init
virtual bool Init()=0
Initialize the DiscoveryAgent.
ola::DiscoveryAgentInterface::RegisterService
virtual void RegisterService(const std::string &service_name, const std::string &type, uint16_t port, const RegisterOptions &options)=0
Register a service.
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44
ola::DiscoveryAgentInterface::RegisterOptions
Options for the RegisterService method.
Definition DiscoveryAgent.h:49
ola::DiscoveryAgentInterface::RegisterOptions::domain
std::string domain
The domain to use.
Definition DiscoveryAgent.h:67
ola::DiscoveryAgentInterface::RegisterOptions::txt_data
TxtData txt_data
Definition DiscoveryAgent.h:68
ola::DiscoveryAgentInterface::RegisterOptions::ALL_INTERFACES
static const int ALL_INTERFACES
A constant which represents all Interfaces.
Definition DiscoveryAgent.h:59
ola::DiscoveryAgentInterface::RegisterOptions::if_index
int if_index
Definition DiscoveryAgent.h:61
ola::DiscoveryAgentInterface::RegisterOptions::TxtData
std::map< std::string, std::string > TxtData
Definition DiscoveryAgent.h:54