Open Lighting Architecture: plugins/usbdmx/Widget.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
Widget.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 * Widget.h
17 * A generic USB Widget.
18 * Copyright (C) 2014 Simon Newton
19 */
20
21#ifndef PLUGINS_USBDMX_WIDGET_H_
22#define PLUGINS_USBDMX_WIDGET_H_
23
24#include "libs/usb/LibUsbAdaptor.h"
25#include "libs/usb/Types.h"
26#include "ola/DmxBuffer.h"
27
28namespace ola {
29namespace plugin {
30namespace usbdmx {
31
36 class WidgetInterface {
37 public:
38 virtual ~WidgetInterface() {}
39
44 virtual bool Init() = 0;
45
50 virtual ola::usb::USBDeviceID GetDeviceId() const = 0;
51
57 virtual bool SendDMX(const DmxBuffer &buffer) = 0;
58};
59
66 class SimpleWidget : public WidgetInterface {
67 public:
73 explicit SimpleWidget(ola::usb::LibUsbAdaptor *adaptor,
74 libusb_device *usb_device)
75 : m_adaptor(adaptor),
76 m_usb_device(usb_device) {
77 }
78
79 ola::usb::USBDeviceID GetDeviceId() const {
80 return m_adaptor->GetDeviceId(m_usb_device);
81 }
82
83 protected:
84 ola::usb::LibUsbAdaptor* const m_adaptor;
85 libusb_device* const m_usb_device;
86};
87} // namespace usbdmx
88} // namespace plugin
89} // namespace ola
90#endif // PLUGINS_USBDMX_WIDGET_H_
DmxBuffer.h
A class used to hold a single universe of DMX data.
ola::DmxBuffer
Used to hold a single universe of DMX data.
Definition DmxBuffer.h:49
ola::plugin::usbdmx::SimpleWidget::SimpleWidget
SimpleWidget(ola::usb::LibUsbAdaptor *adaptor, libusb_device *usb_device)
Create a new SimpleWidget.
Definition Widget.h:73
ola::plugin::usbdmx::SimpleWidget::GetDeviceId
ola::usb::USBDeviceID GetDeviceId() const
The device ID of this widget.
Definition Widget.h:79
ola::plugin::usbdmx::WidgetInterface
The interface for a simple widget that supports a single universe of DMX.
Definition Widget.h:36
ola::plugin::usbdmx::WidgetInterface::Init
virtual bool Init()=0
Initialize the widget.
ola::plugin::usbdmx::WidgetInterface::GetDeviceId
virtual ola::usb::USBDeviceID GetDeviceId() const =0
The device ID of this widget.
ola::plugin::usbdmx::WidgetInterface::SendDMX
virtual bool SendDMX(const DmxBuffer &buffer)=0
Send DMX data from this widget.
ola::usb::LibUsbAdaptor
Wraps calls to libusb so we can test the code.
Definition LibUsbAdaptor.h:36
ola::usb::USBDeviceID
Definition Types.h:30
ola::plugin::usbdmx
The plugin for hardware using libusb.
ola::plugin
Code for supported devices and protocols.
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44