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 * Interface to the DeviceManager class
18 * Copyright (C) 2005 Simon Newton
19 */
20
21#ifndef OLAD_PLUGIN_API_DEVICEMANAGER_H_
22#define OLAD_PLUGIN_API_DEVICEMANAGER_H_
23
24#include <map>
25#include <set>
26#include <string>
27#include <vector>
28#include "ola/base/Macro.h"
29#include "ola/timecode/TimeCode.h"
30#include "olad/Device.h"
31#include "olad/Preferences.h"
32
33namespace ola {
34
35// pair a device with it's alias
37 public:
38 unsigned int alias;
39 AbstractDevice *device;
40
41 device_alias_pair(unsigned int alias, AbstractDevice *device)
42 : alias(alias), device(device) {}
43};
44
45bool operator <(const device_alias_pair& left, const device_alias_pair &right);
46
62 public:
69 DeviceManager(PreferencesFactory *prefs_factory,
70 class PortManager *port_manager);
71
76
84 bool RegisterDevice(AbstractDevice *device);
85
91 bool UnregisterDevice(const std::string &device_id);
92
98 bool UnregisterDevice(const AbstractDevice *device);
99
104 unsigned int DeviceCount() const;
105
110 std::vector<device_alias_pair> Devices() const;
111
116 AbstractDevice *GetDevice(unsigned int alias) const;
117
124 device_alias_pair GetDevice(const std::string &unique_id) const;
125
130
131
136 void SendTimeCode(const ola::timecode::TimeCode &timecode);
137
138 static const unsigned int MISSING_DEVICE_ALIAS;
139
140 private:
141 typedef std::map<std::string, device_alias_pair> DeviceIdMap;
142 typedef std::map<unsigned int, AbstractDevice*> DeviceAliasMap;
143
144 Preferences *m_port_preferences;
145 class PortManager *m_port_manager;
146
147 DeviceIdMap m_devices;
148 DeviceAliasMap m_alias_map;
149
150 unsigned int m_next_device_alias;
151 std::set<class OutputPort*> m_timecode_ports;
152
153 void ReleaseDevice(const AbstractDevice *device);
154 void RestoreDevicePortSettings(AbstractDevice *device);
155
156 template <class PortClass>
157 void SavePortPatchings(const std::vector<PortClass*> &ports) const;
158
159 void SavePortPriority(const Port &port) const;
160 void RestorePortPriority(Port *port) const;
161
162 template <class PortClass>
163 void RestorePortSettings(const std::vector<PortClass*> &ports) const;
164
165 static const char PORT_PREFERENCES[];
166 static const unsigned int FIRST_DEVICE_ALIAS = 1;
167 static const char PRIORITY_VALUE_SUFFIX[];
168 static const char PRIORITY_MODE_SUFFIX[];
169
170 DeviceManager(const DeviceManager &) = delete;
171 const DeviceManager &operator=(const DeviceManager &) = delete;
172};
173} // namespace ola
174#endif // OLAD_PLUGIN_API_DEVICEMANAGER_H_
Helper macros.
Definition Device.h:44
Keeps track of OLA's devices.
Definition DeviceManager.h:61
AbstractDevice * GetDevice(unsigned int alias) const
Lookup a device using the device alias.
Definition DeviceManager.cpp:169
DeviceManager(PreferencesFactory *prefs_factory, class PortManager *port_manager)
Create a new DeviceManager.
Definition DeviceManager.cpp:56
std::vector< device_alias_pair > Devices() const
Return a list of all devices and their aliases.
Definition DeviceManager.cpp:158
void SendTimeCode(const ola::timecode::TimeCode &timecode)
Send timecode to all ports which support timecode.
Definition DeviceManager.cpp:191
bool RegisterDevice(AbstractDevice *device)
Register a device.
Definition DeviceManager.cpp:73
bool UnregisterDevice(const std::string &device_id)
Unregister a device by id.
Definition DeviceManager.cpp:127
void UnregisterAllDevices()
Remove all devices.
Definition DeviceManager.cpp:182
~DeviceManager()
Destructor.
Definition DeviceManager.cpp:67
unsigned int DeviceCount() const
Return the number of devices.
Definition DeviceManager.cpp:154
The base port class.
Definition Port.h:49
Responsible for performing Port operations.
Definition PortManager.h:37
Definition Preferences.h:347
Definition Preferences.h:148
Definition DeviceManager.h:36
Definition TimeCode.h:33
The namespace containing all OLA symbols.
Definition Credentials.cpp:44