Open Lighting Architecture: include/ola/e133/DeviceManager.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
DeviceManager.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 * DeviceManager.h
17 * Copyright (C) 2013 Simon Newton
18 * The DeviceManager attempts to maintain a TCP connection to each E1.33 device.
19 */
20
21#ifndef INCLUDE_OLA_E133_DEVICEMANAGER_H_
22#define INCLUDE_OLA_E133_DEVICEMANAGER_H_
23
24#include <ola/Callback.h>
25#include <ola/base/Macro.h>
26#include <ola/e133/MessageBuilder.h>
27#include <ola/io/SelectServerInterface.h>
28#include <ola/network/IPV4Address.h>
29#include <ola/network/SocketAddress.h>
30
31#include <memory>
32#include <string>
33#include <vector>
34
35namespace ola {
36namespace e133 {
37
38using ola::network::IPV4Address;
39using ola::network::IPV4SocketAddress;
40using std::auto_ptr;
41using std::string;
42using std::vector;
43
49 class DeviceManager {
50 public:
51 /*
52 * The callback used to receive RDMNet layer messages from the devices.
53 * @returns true if the data should be acknowledged, false otherwise.
54 */
55 typedef ola::Callback3<bool, const IPV4Address&, uint16_t,
56 const string&> RDMMesssageCallback;
57
58 // Run when we acquire designated controller status for a device.
59 typedef ola::Callback1<void, const IPV4Address&> AcquireDeviceCallback;
60
61 // Run when we give up (or lose) designated controller status.
62 typedef ola::Callback1<void, const IPV4Address&> ReleaseDeviceCallback;
63
64 DeviceManager(ola::io::SelectServerInterface *ss,
65 ola::e133::MessageBuilder *message_builder);
66 ~DeviceManager();
67
68 // Ownership of the callbacks is transferred.
69 void SetRDMMessageCallback(RDMMesssageCallback *callback);
70 void SetAcquireDeviceCallback(AcquireDeviceCallback *callback);
71 void SetReleaseDeviceCallback(ReleaseDeviceCallback *callback);
72
73 void AddDevice(const IPV4Address &ip_address);
74 void RemoveDevice(const IPV4Address &ip_address);
75 void RemoveDeviceIfNotConnected(const IPV4Address &ip_address);
76 void ListManagedDevices(vector<IPV4Address> *devices) const;
77
78 private:
79 class DeviceManagerImpl *m_impl;
80
81 DeviceManager(const DeviceManager &) = delete;
82 const DeviceManager &operator=(const DeviceManager &) = delete;
83};
84} // namespace e133
85} // namespace ola
86#endif // INCLUDE_OLA_E133_DEVICEMANAGER_H_
Callback.h
IPV4Address.h
Represents an IPv4 Address.
Macro.h
Helper macros.
SocketAddress.h
Represents Socket Addresses.
ola::Callback1
A 1 argument callback which can be called multiple times.
Definition Callback.h:992
ola::Callback3
A 3 argument callback which can be called multiple times.
Definition Callback.h:2838
ola::e133::MessageBuilder
Definition MessageBuilder.h:42
ola::io::SelectServerInterface
The interface for the SelectServer.
Definition SelectServerInterface.h:42
ola::network::IPV4Address
Represents a IPv4 Address.
Definition IPV4Address.h:55
ola::e133
E1.33 (RDMNet).
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44