Open Lighting Architecture: olad/ClientBroker.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
ClientBroker.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 * ClientBroker.h
17 * The client broker exists to handle the case where a client may disconnect
18 * while a RDM call is in flight. When the call completes, the client broker
19 * will detect that the client 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 OLAD_CLIENTBROKER_H_
25#define OLAD_CLIENTBROKER_H_
26
27#include <set>
28#include <string>
29#include <vector>
30#include "ola/base/Macro.h"
31#include "ola/rdm/RDMCommand.h"
32#include "ola/rdm/RDMControllerInterface.h"
33#include "ola/Callback.h"
34#include "olad/Universe.h"
35#include "olad/plugin_api/Client.h"
36
37namespace ola {
38
52 class ClientBroker {
53 public:
54 ClientBroker() {}
55 ~ClientBroker() {}
56
61 void AddClient(const Client *client);
62
67 void RemoveClient(const Client *client);
68
77 void SendRDMRequest(const Client *client,
78 Universe *universe,
79 ola::rdm::RDMRequest *request,
80 ola::rdm::RDMCallback *callback);
81
90 void RunRDMDiscovery(const Client *client,
91 Universe *universe,
92 bool full_discovery,
93 ola::rdm::RDMDiscoveryCallback *callback);
94
95 private:
96 typedef std::set<const Client*> client_set;
97
98 client_set m_clients;
99
100 void RequestComplete(const Client *key,
101 ola::rdm::RDMCallback *callback,
102 ola::rdm::RDMReply *reply);
103
104 void DiscoveryComplete(const Client *key,
105 ola::rdm::RDMDiscoveryCallback *on_complete,
106 const ola::rdm::UIDSet &uids);
107
108 ClientBroker(const ClientBroker &) = delete;
109 const ClientBroker &operator=(const ClientBroker &) = delete;
110};
111} // namespace ola
112#endif // OLAD_CLIENTBROKER_H_
Callback.h
Macro.h
Helper macros.
RDMCommand.h
Classes that represent RDM commands.
RDMControllerInterface.h
Definitions and Interfaces to implement an RDMController that sends a single message at a time.
ola::ClientBroker::RunRDMDiscovery
void RunRDMDiscovery(const Client *client, Universe *universe, bool full_discovery, ola::rdm::RDMDiscoveryCallback *callback)
Make an RDM call.
Definition ClientBroker.cpp:57
ola::ClientBroker::AddClient
void AddClient(const Client *client)
Add a client to the broker.
Definition ClientBroker.cpp:34
ola::ClientBroker::RemoveClient
void RemoveClient(const Client *client)
Remove a client from the broker.
Definition ClientBroker.cpp:38
ola::ClientBroker::SendRDMRequest
void SendRDMRequest(const Client *client, Universe *universe, ola::rdm::RDMRequest *request, ola::rdm::RDMCallback *callback)
Make an RDM call.
Definition ClientBroker.cpp:42
ola::Client
Represents a connected OLA client on the OLA server side.
Definition Client.h:46
ola::Universe
Definition Universe.h:46
ola::rdm::RDMRequest
RDM Commands that represent requests (GET, SET or DISCOVER).
Definition RDMCommand.h:234
ola::rdm::UIDSet
Represents a set of RDM UIDs.
Definition UIDSet.h:48
ola::client
OLA C++ API.
ola::rdm::RDMCallback
ola::BaseCallback1< void, RDMReply * > RDMCallback
The callback run when a RDM request completes.
Definition RDMControllerInterface.h:52
ola::rdm::RDMDiscoveryCallback
ola::BaseCallback1< void, const ola::rdm::UIDSet & > RDMDiscoveryCallback
The callback run when a discovery operation completes.
Definition RDMControllerInterface.h:68
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44
ola::rdm::RDMReply
Holds the final state of an RDM request.
Definition RDMReply.h:43