Open Lighting Architecture 0.10.9
Loading...
Searching...
No Matches
PortBroker.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 * PortBroker.h
17 * The port broker exists to handle the case where a port may be removed
18 * while a RDM call is in flight. When the call completes, the port broker
19 * will detect that the port has disconnected and not run the callback (which
20 * would now point to an invalid memory location).
21 * Copyright (C) 2010 Simon Newton
22 */
23
24#ifndef INCLUDE_OLAD_PORTBROKER_H_
25#define INCLUDE_OLAD_PORTBROKER_H_
26
27#include <ola/base/Macro.h>
28#include <ola/rdm/RDMCommand.h>
30#include <ola/Callback.h>
31#include <olad/Universe.h>
32#include <olad/Port.h>
33#include <set>
34#include <string>
35#include <utility>
36#include <vector>
37
38namespace ola {
39
41 public:
43 virtual ~PortBrokerInterface() {}
44
45 virtual void SendRDMRequest(
46 const Port *port,
47 Universe *universe,
48 ola::rdm::RDMRequest *request,
49 ola::rdm::RDMCallback *callback) = 0;
50};
51
52
54 public:
55 PortBroker() {}
56 ~PortBroker() {}
57
58 void AddPort(const Port *port);
59 void RemovePort(const Port *port);
60
61 void SendRDMRequest(const Port *port,
62 Universe *universe,
63 ola::rdm::RDMRequest *request,
64 ola::rdm::RDMCallback *callback);
65
66 private:
67 typedef std::pair<std::string, const Port*> port_key;
68
69 void RequestComplete(port_key key,
70 ola::rdm::RDMCallback *callback,
71 ola::rdm::RDMReply *reply);
72
73 std::set<port_key> m_ports;
74
75 PortBroker(const PortBroker &) = delete;
76 const PortBroker &operator=(const PortBroker &) = delete;
77};
78} // namespace ola
79#endif // INCLUDE_OLAD_PORTBROKER_H_
Helper macros.
Classes that represent RDM commands.
Definitions and Interfaces to implement an RDMController that sends a single message at a time.
The base class for all 1 argument callbacks.
Definition Callback.h:982
Definition PortBroker.h:53
void RemovePort(const Port *port)
Definition PortBroker.cpp:47
void AddPort(const Port *port)
Definition PortBroker.cpp:38
void SendRDMRequest(const Port *port, Universe *universe, ola::rdm::RDMRequest *request, ola::rdm::RDMCallback *callback)
Definition PortBroker.cpp:60
Definition PortBroker.h:40
The base port class.
Definition Port.h:49
Definition Universe.h:46
RDM Commands that represent requests (GET, SET or DISCOVER).
Definition RDMCommand.h:234
The namespace containing all OLA symbols.
Definition Credentials.cpp:44
Holds the final state of an RDM request.
Definition RDMReply.h:43