Open Lighting Architecture  0.9.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ClientTypes.h
Go to the documentation of this file.
1 /*
2  * This library is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU Lesser General Public
4  * License as published by the Free Software Foundation; either
5  * version 2.1 of the License, or (at your option) any later version.
6  *
7  * This library 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 GNU
10  * Lesser General Public License for more details.
11  *
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with this library; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15  *
16  * ClientTypes.h
17  * Types used as return values from the OLA Client.
18  * Copyright (C) 2013 Simon Newton
19  */
20 
21 #ifndef INCLUDE_OLA_CLIENT_CLIENTTYPES_H_
22 #define INCLUDE_OLA_CLIENT_CLIENTTYPES_H_
23 
25 #include <ola/rdm/RDMResponseCodes.h>
26 
27 #include <olad/PortConstants.h>
28 
29 #include <string>
30 #include <vector>
31 
37 namespace ola {
38 namespace client {
39 
43 class OlaPlugin {
44  public:
45  OlaPlugin(unsigned int id, const std::string &name, bool active)
46  : m_id(id),
47  m_name(name),
48  m_active(active) {}
49  ~OlaPlugin() {}
50 
54  unsigned int Id() const { return m_id; }
55 
59  const std::string& Name() const { return m_name; }
60 
65  bool IsActive() const { return m_active; }
66 
67  bool operator<(const OlaPlugin &other) const {
68  return m_id < other.m_id;
69  }
70 
71  private:
72  unsigned int m_id; // id of this plugin
73  std::string m_name; // plugin name
74  bool m_active;
75 };
76 
81 struct PluginState {
85  std::string name;
89  bool enabled;
93  bool active;
97  std::string preferences_source;
101  std::vector<OlaPlugin> conflicting_plugins;
102 };
103 
107 class OlaPort {
108  public:
109  OlaPort(unsigned int port_id,
110  unsigned int universe,
111  bool active,
112  const std::string &description,
113  port_priority_capability capability,
114  port_priority_mode mode,
115  uint8_t priority,
116  bool supports_rdm):
117  m_id(port_id),
118  m_universe(universe),
119  m_active(active),
120  m_description(description),
121  m_priority_capability(capability),
122  m_priority_mode(mode),
123  m_priority(priority),
124  m_supports_rdm(supports_rdm) {}
125  virtual ~OlaPort() {}
126 
127  unsigned int Id() const { return m_id; }
128 
132  unsigned int Universe() const { return m_universe; }
133 
134  bool IsActive() const { return m_active; }
135 
139  const std::string& Description() const { return m_description; }
140 
141  port_priority_capability PriorityCapability() const {
142  return m_priority_capability;
143  }
144  port_priority_mode PriorityMode() const {
145  return m_priority_mode;
146  }
147 
148  uint8_t Priority() const { return m_priority; }
149 
154  bool SupportsRDM() const { return m_supports_rdm; }
155 
156  private:
157  unsigned int m_id; // id of this port
158  unsigned int m_universe; // universe
159  bool m_active; // active
160  std::string m_description;
161  port_priority_capability m_priority_capability;
162  port_priority_mode m_priority_mode;
163  uint8_t m_priority;
164  bool m_supports_rdm;
165 };
166 
170 class OlaInputPort: public OlaPort {
171  public:
172  OlaInputPort(unsigned int port_id,
173  unsigned int universe,
174  bool active,
175  const std::string &description,
176  port_priority_capability capability,
177  port_priority_mode mode,
178  uint8_t priority,
179  bool supports_rdm):
180  OlaPort(port_id, universe, active, description,
181  capability, mode, priority, supports_rdm) {
182  }
183 };
184 
188 class OlaOutputPort: public OlaPort {
189  public:
190  OlaOutputPort(unsigned int port_id,
191  unsigned int universe,
192  bool active,
193  const std::string &description,
194  port_priority_capability capability,
195  port_priority_mode mode,
196  uint8_t priority,
197  bool supports_rdm):
198  OlaPort(port_id, universe, active, description,
199  capability, mode, priority, supports_rdm) {
200  }
201 };
202 
203 
207 class OlaDevice {
208  public:
209  OlaDevice(const std::string &id,
210  unsigned int alias,
211  const std::string &name,
212  int plugin_id,
213  const std::vector<OlaInputPort> &input_ports,
214  const std::vector<OlaOutputPort> &output_ports):
215  m_id(id),
216  m_alias(alias),
217  m_name(name),
218  m_plugin_id(plugin_id),
219  m_input_ports(input_ports),
220  m_output_ports(output_ports) {}
221  ~OlaDevice() {}
222 
223  std::string Id() const { return m_id; }
224  unsigned int Alias() const { return m_alias; }
225  const std::string& Name() const { return m_name; }
226  int PluginId() const { return m_plugin_id; }
227 
228  const std::vector<OlaInputPort> &InputPorts() const {
229  return m_input_ports;
230  }
231  const std::vector<OlaOutputPort> &OutputPorts() const {
232  return m_output_ports;
233  }
234 
235  bool operator<(const OlaDevice &other) const {
236  return m_alias < other.m_alias;
237  }
238 
239  private:
240  std::string m_id; // device id
241  unsigned int m_alias; // device alias
242  std::string m_name; // device name
243  int m_plugin_id; // parent plugin id
244  std::vector<OlaInputPort> m_input_ports;
245  std::vector<OlaOutputPort> m_output_ports;
246 };
247 
248 
252 class OlaUniverse {
253  public:
254  enum merge_mode {
255  MERGE_HTP,
256  MERGE_LTP,
257  };
258 
259  OlaUniverse(unsigned int id,
260  merge_mode m,
261  const std::string &name,
262  unsigned int input_port_count,
263  unsigned int output_port_count,
264  unsigned int rdm_device_count):
265  m_id(id),
266  m_merge_mode(m),
267  m_name(name),
268  m_input_port_count(input_port_count),
269  m_output_port_count(output_port_count),
270  m_rdm_device_count(rdm_device_count) {}
271  ~OlaUniverse() {}
272 
273  unsigned int Id() const { return m_id;}
274  merge_mode MergeMode() const { return m_merge_mode; }
275  const std::string& Name() const { return m_name;}
276  unsigned int InputPortCount() const { return m_input_port_count; }
277  unsigned int OutputPortCount() const { return m_output_port_count; }
278  unsigned int RDMDeviceCount() const { return m_rdm_device_count; }
279 
280  private:
281  unsigned int m_id;
282  merge_mode m_merge_mode;
283  std::string m_name;
284  unsigned int m_input_port_count;
285  unsigned int m_output_port_count;
286  unsigned int m_rdm_device_count;
287 };
288 
292 struct DMXMetadata {
296  unsigned int universe;
300  uint8_t priority;
301 
302  explicit DMXMetadata(unsigned int universe,
304  : universe(universe),
305  priority(priority) {
306  }
307 };
308 
309 
313 struct RDMMetadata {
317  ola::rdm::rdm_response_code response_code;
318 
323  RDMMetadata() : response_code(ola::rdm::RDM_FAILED_TO_SEND) {}
324 
325  explicit RDMMetadata(ola::rdm::rdm_response_code response_code)
326  : response_code(response_code) {
327  }
328 };
329 } // namespace client
330 } // namespace ola
331 #endif // INCLUDE_OLA_CLIENT_CLIENTTYPES_H_