Open Lighting Architecture  Latest Git
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 
29 namespace ola {
30 
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;
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 
103  public:
105 
113 
114  private:
116 };
117 } // namespace ola
118 #endif // OLAD_DISCOVERYAGENT_H_
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Creates dummy copy constructor and assignment operator declarations.
Definition: Macro.h:44
static const int ALL_INTERFACES
A constant which represents all Interfaces.
Definition: DiscoveryAgent.h:59
A Factory which produces implementations of DiscoveryAgentInterface.
Definition: DiscoveryAgent.h:102
int if_index
Definition: DiscoveryAgent.h:61
std::map< std::string, std::string > TxtData
Definition: DiscoveryAgent.h:54
std::string domain
The domain to use.
Definition: DiscoveryAgent.h:67
Options for the RegisterService method.
Definition: DiscoveryAgent.h:49
virtual void RegisterService(const std::string &service_name, const std::string &type, uint16_t port, const RegisterOptions &options)=0
Register a service.
Helper macros.
The interface to DNS-SD operations like register, browse etc.
Definition: DiscoveryAgent.h:34
TxtData txt_data
Definition: DiscoveryAgent.h:68
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
virtual bool Init()=0
Initialize the DiscoveryAgent.