Open Lighting Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  *
16  * DeviceManager.cpp
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/e133/MessageBuilder.h>
26 #include <ola/io/SelectServerInterface.h>
27 #include <ola/network/IPV4Address.h>
28 #include <ola/network/SocketAddress.h>
29 
30 #include <memory>
31 #include <string>
32 #include <vector>
33 
34 namespace ola {
35 namespace e133 {
36 
39 using std::auto_ptr;
40 using std::string;
41 using std::vector;
42 
49  public:
50  /*
51  * The callback used to receive RDMNet layer messages from the devices.
52  * @returns true if the data should be acknowledged, false otherwise.
53  */
54  typedef ola::Callback3<bool, const IPV4Address&, uint16_t,
55  const string&> RDMMesssageCallback;
56 
57  // Run when we acquire designated controller status for a device.
59 
60  // Run when we give up (or lose) designated controller status.
62 
64  ola::e133::MessageBuilder *message_builder);
65  ~DeviceManager();
66 
67  // Ownership of the callbacks is transferred.
68  void SetRDMMessageCallback(RDMMesssageCallback *callback);
69  void SetAcquireDeviceCallback(AcquireDeviceCallback *callback);
70  void SetReleaseDeviceCallback(ReleaseDeviceCallback *callback);
71 
72  void AddDevice(const IPV4Address &ip_address);
73  void RemoveDevice(const IPV4Address &ip_address);
74  void RemoveDeviceIfNotConnected(const IPV4Address &ip_address);
75  void ListManagedDevices(vector<IPV4Address> *devices) const;
76 
77  private:
78  class DeviceManagerImpl *m_impl;
79 };
80 } // namespace e133
81 } // namespace ola
82 #endif // INCLUDE_OLA_E133_DEVICEMANAGER_H_