Open Lighting Architecture  Latest Git
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/RDMFrame.h>
27 
28 #include <olad/PortConstants.h>
29 
30 #include <string>
31 #include <vector>
32 
38 namespace ola {
39 namespace client {
40 
44 class OlaPlugin {
45  public:
46  OlaPlugin(unsigned int id,
47  const std::string &name,
48  bool active,
49  bool enabled)
50  : m_id(id),
51  m_name(name),
52  m_active(active),
53  m_enabled(enabled) {}
54  ~OlaPlugin() {}
55 
59  unsigned int Id() const { return m_id; }
60 
64  const std::string& Name() const { return m_name; }
65 
70  bool IsActive() const { return m_active; }
71 
76  bool IsEnabled() const { return m_enabled; }
77 
78  bool operator<(const OlaPlugin &other) const {
79  return m_id < other.m_id;
80  }
81 
82  private:
83  unsigned int m_id; // id of this plugin
84  std::string m_name; // plugin name
85  bool m_active;
86  bool m_enabled;
87 };
88 
93 struct PluginState {
97  std::string name;
101  bool enabled;
105  bool active;
109  std::string preferences_source;
113  std::vector<OlaPlugin> conflicting_plugins;
114 };
115 
119 class OlaPort {
120  public:
121  OlaPort(unsigned int port_id,
122  unsigned int universe,
123  bool active,
124  const std::string &description,
125  port_priority_capability capability,
126  port_priority_mode mode,
127  uint8_t priority,
128  bool supports_rdm):
129  m_id(port_id),
130  m_universe(universe),
131  m_active(active),
132  m_description(description),
133  m_priority_capability(capability),
134  m_priority_mode(mode),
135  m_priority(priority),
136  m_supports_rdm(supports_rdm) {}
137  virtual ~OlaPort() {}
138 
139  unsigned int Id() const { return m_id; }
140 
144  unsigned int Universe() const { return m_universe; }
145 
146  bool IsActive() const { return m_active; }
147 
151  const std::string& Description() const { return m_description; }
152 
153  port_priority_capability PriorityCapability() const {
154  return m_priority_capability;
155  }
156  port_priority_mode PriorityMode() const {
157  return m_priority_mode;
158  }
159 
160  uint8_t Priority() const { return m_priority; }
161 
166  bool SupportsRDM() const { return m_supports_rdm; }
167 
168  private:
169  unsigned int m_id; // id of this port
170  unsigned int m_universe; // universe
171  bool m_active; // active
172  std::string m_description;
173  port_priority_capability m_priority_capability;
174  port_priority_mode m_priority_mode;
175  uint8_t m_priority;
176  bool m_supports_rdm;
177 };
178 
182 class OlaInputPort: public OlaPort {
183  public:
184  OlaInputPort(unsigned int port_id,
185  unsigned int universe,
186  bool active,
187  const std::string &description,
188  port_priority_capability capability,
189  port_priority_mode mode,
190  uint8_t priority,
191  bool supports_rdm):
192  OlaPort(port_id, universe, active, description,
193  capability, mode, priority, supports_rdm) {
194  }
195 };
196 
200 class OlaOutputPort: public OlaPort {
201  public:
202  OlaOutputPort(unsigned int port_id,
203  unsigned int universe,
204  bool active,
205  const std::string &description,
206  port_priority_capability capability,
207  port_priority_mode mode,
208  uint8_t priority,
209  bool supports_rdm):
210  OlaPort(port_id, universe, active, description,
211  capability, mode, priority, supports_rdm) {
212  }
213 };
214 
215 
219 class OlaDevice {
220  public:
221  OlaDevice(const std::string &id,
222  unsigned int alias,
223  const std::string &name,
224  int plugin_id,
225  const std::vector<OlaInputPort> &input_ports,
226  const std::vector<OlaOutputPort> &output_ports):
227  m_id(id),
228  m_alias(alias),
229  m_name(name),
230  m_plugin_id(plugin_id),
231  m_input_ports(input_ports),
232  m_output_ports(output_ports) {}
233  ~OlaDevice() {}
234 
235  std::string Id() const { return m_id; }
236  unsigned int Alias() const { return m_alias; }
237  const std::string& Name() const { return m_name; }
238  int PluginId() const { return m_plugin_id; }
239 
240  const std::vector<OlaInputPort> &InputPorts() const {
241  return m_input_ports;
242  }
243  const std::vector<OlaOutputPort> &OutputPorts() const {
244  return m_output_ports;
245  }
246 
247  bool operator<(const OlaDevice &other) const {
248  return m_alias < other.m_alias;
249  }
250 
251  private:
252  std::string m_id; // device id
253  unsigned int m_alias; // device alias
254  std::string m_name; // device name
255  int m_plugin_id; // parent plugin id
256  std::vector<OlaInputPort> m_input_ports;
257  std::vector<OlaOutputPort> m_output_ports;
258 };
259 
260 
264 class OlaUniverse {
265  public:
266  enum merge_mode {
267  MERGE_HTP,
268  MERGE_LTP,
269  };
270 
271  OlaUniverse(unsigned int id,
272  merge_mode m,
273  const std::string &name,
274  const std::vector<OlaInputPort> &input_ports,
275  const std::vector<OlaOutputPort> &output_ports,
276  unsigned int rdm_device_count):
277  m_id(id),
278  m_merge_mode(m),
279  m_name(name),
280  m_input_ports(input_ports),
281  m_output_ports(output_ports),
282  m_rdm_device_count(rdm_device_count) {}
283  ~OlaUniverse() {}
284 
285  unsigned int Id() const { return m_id;}
286  merge_mode MergeMode() const { return m_merge_mode; }
287  const std::string& Name() const { return m_name;}
288  unsigned int InputPortCount() const { return m_input_ports.size(); }
289  unsigned int OutputPortCount() const { return m_output_ports.size(); }
290  unsigned int RDMDeviceCount() const { return m_rdm_device_count; }
291 
292  const std::vector<OlaInputPort> &InputPorts() const {
293  return m_input_ports;
294  }
295  const std::vector<OlaOutputPort> &OutputPorts() const {
296  return m_output_ports;
297  }
298 
299  private:
300  unsigned int m_id;
301  merge_mode m_merge_mode;
302  std::string m_name;
303  std::vector<OlaInputPort> m_input_ports;
304  std::vector<OlaOutputPort> m_output_ports;
305  unsigned int m_rdm_device_count;
306 };
307 
311 struct DMXMetadata {
315  unsigned int universe;
319  uint8_t priority;
320 
321  explicit DMXMetadata(unsigned int _universe,
322  uint8_t _priority = ola::dmx::SOURCE_PRIORITY_DEFAULT)
323  : universe(_universe),
324  priority(_priority) {
325  }
326 };
327 
328 
332 struct RDMMetadata {
337 
341  std::vector<ola::rdm::RDMFrame> frames;
342 
347  RDMMetadata() : response_code(ola::rdm::RDM_FAILED_TO_SEND) {}
348 
349  explicit RDMMetadata(ola::rdm::rdm_response_code _response_code)
350  : response_code(_response_code) {
351  }
352 };
353 } // namespace client
354 } // namespace ola
355 #endif // INCLUDE_OLA_CLIENT_CLIENTTYPES_H_
unsigned int universe
The universe the DMX frame is for.
Definition: ClientTypes.h:315
ola::rdm::rdm_response_code response_code
The internal (OLA) response code.
Definition: ClientTypes.h:336
static const uint8_t SOURCE_PRIORITY_DEFAULT
The default priority for a source.
Definition: SourcePriorities.h:41
The constants for DMX source priorities.
bool enabled
true if the plugin is enabled.
Definition: ClientTypes.h:101
RDMStatusCode
RDM Status Codes.
Definition: RDMResponseCodes.h:45
Metadata that accompanies RDM Responses.
Definition: ClientTypes.h:332
unsigned int Universe() const
The universe this port is patched to.
Definition: ClientTypes.h:144
Represents a device.
Definition: ClientTypes.h:219
const std::string & Description() const
The description of this port.
Definition: ClientTypes.h:151
port_priority_mode
Defines the different priority modes that OLA supports.
Definition: PortConstants.h:44
unsigned int Id() const
The plugin id.
Definition: ClientTypes.h:59
port_priority_capability
Defines the priority capability of a Port.
Definition: PortConstants.h:58
The state of a plugin. This information can be used to detect conflicts between plugins.
Definition: ClientTypes.h:93
bool IsEnabled() const
Indicates if the plugin is enabled or not.
Definition: ClientTypes.h:76
Enums representing the states of a response. This is generated from the proto file.
std::string preferences_source
The source of preferences for this plugin.
Definition: ClientTypes.h:109
bool IsActive() const
Indicates if the plugin is active or not.
Definition: ClientTypes.h:70
const std::string & Name() const
The name of the plugin.
Definition: ClientTypes.h:64
Different priority modes and priority capabilities. Please make sure to visit Merging Algorithms for ...
Represents a universe.
Definition: ClientTypes.h:264
bool active
true if the plugin is active.
Definition: ClientTypes.h:105
std::string name
The name of the plugin.
Definition: ClientTypes.h:97
std::vector< ola::rdm::RDMFrame > frames
The RDMFrames that made up this response.
Definition: ClientTypes.h:341
An Output Port (sends DMX).
Definition: ClientTypes.h:200
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Metadata that accompanies DMX packets.
Definition: ClientTypes.h:311
Represents a Plugin.
Definition: ClientTypes.h:44
bool SupportsRDM() const
Indicates if this port supports RDM.
Definition: ClientTypes.h:166
An input port (receives DMX).
Definition: ClientTypes.h:182
The base class that represents a port.
Definition: ClientTypes.h:119
RDMMetadata()
Construct a new RDMMetadata object. The default response code is RDM_FAILED_TO_SEND.
Definition: ClientTypes.h:347
std::vector< OlaPlugin > conflicting_plugins
A list on plugins which conflict with this one.
Definition: ClientTypes.h:113
uint8_t priority
The priority of the DMX frame.
Definition: ClientTypes.h:319