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

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
SyncronizedWidgetObserver.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 * SyncronizedWidgetObserver.h
17 * Transfers widget add/remove events to another thread.
18 * Copyright (C) 2014 Simon Newton
19 */
20
21#ifndef PLUGINS_USBDMX_SYNCRONIZEDWIDGETOBSERVER_H_
22#define PLUGINS_USBDMX_SYNCRONIZEDWIDGETOBSERVER_H_
23
24#include "plugins/usbdmx/WidgetFactory.h"
25
26#include "ola/io/SelectServerInterface.h"
27#include "ola/thread/Future.h"
28#include "ola/thread/Thread.h"
29
30namespace ola {
31namespace plugin {
32namespace usbdmx {
33
40 class SyncronizedWidgetObserver : public WidgetObserver {
41 public:
47 SyncronizedWidgetObserver(WidgetObserver *observer,
48 ola::io::SelectServerInterface *ss);
49
50 bool NewWidget(class AnymauDMX *widget) {
51 return DispatchNewWidget(widget);
52 }
53
54 bool NewWidget(class DMXCProjectsNodleU1 *widget) {
55 return DispatchNewWidget(widget);
56 }
57
58 bool NewWidget(class EurolitePro *widget) {
59 return DispatchNewWidget(widget);
60 }
61
62 bool NewWidget(ola::usb::JaRuleWidget *widget) {
63 return DispatchNewWidget(widget);
64 }
65
66 bool NewWidget(class ScanlimeFadecandy *widget) {
67 return DispatchNewWidget(widget);
68 }
69
70 bool NewWidget(class Sunlite *widget) {
71 return DispatchNewWidget(widget);
72 }
73
74 bool NewWidget(class VellemanK8062 *widget) {
75 return DispatchNewWidget(widget);
76 }
77
78 private:
79 typedef ola::thread::Future<bool> AddFuture;
80
81 WidgetObserver* const m_observer;
82 ola::io::SelectServerInterface* const m_ss;
83 const ola::thread::ThreadId m_main_thread_id;
84
85 template<typename WidgetClass>
86 bool DispatchNewWidget(WidgetClass *widget);
87
88 template<typename WidgetClass>
89 void HandleNewWidget(WidgetClass *widget, AddFuture *f);
90
91 SyncronizedWidgetObserver(const SyncronizedWidgetObserver &) = delete;
92 const SyncronizedWidgetObserver &operator=(const SyncronizedWidgetObserver &) = delete;
93};
94} // namespace usbdmx
95} // namespace plugin
96} // namespace ola
97#endif // PLUGINS_USBDMX_SYNCRONIZEDWIDGETOBSERVER_H_
ola::io::SelectServerInterface
The interface for the SelectServer.
Definition SelectServerInterface.h:42
ola::plugin::usbdmx::AnymauDMX
The base class for Anyma Widgets.
Definition AnymauDMX.h:41
ola::plugin::usbdmx::DMXCProjectsNodleU1
The interface for the Nodle Widgets.
Definition DMXCProjectsNodleU1.h:43
ola::plugin::usbdmx::EurolitePro
The EurolitePro Widget.
Definition EurolitePro.h:42
ola::plugin::usbdmx::ScanlimeFadecandy
The interface for the Fadecandy Widgets.
Definition ScanlimeFadecandy.h:49
ola::plugin::usbdmx::Sunlite
The interface for the Sunlite Widgets.
Definition Sunlite.h:40
ola::plugin::usbdmx::SyncronizedWidgetObserver
Transfers widget add/remove events to another thread.
Definition SyncronizedWidgetObserver.h:40
ola::plugin::usbdmx::SyncronizedWidgetObserver::SyncronizedWidgetObserver
SyncronizedWidgetObserver(WidgetObserver *observer, ola::io::SelectServerInterface *ss)
Create a new SyncronizedWidgetObserver.
Definition SyncronizedWidgetObserver.cpp:31
ola::plugin::usbdmx::SyncronizedWidgetObserver::NewWidget
bool NewWidget(class DMXCProjectsNodleU1 *widget)
Called when a new DMXCProjects Nodle U1 widget is added.
Definition SyncronizedWidgetObserver.h:54
ola::plugin::usbdmx::SyncronizedWidgetObserver::NewWidget
bool NewWidget(class VellemanK8062 *widget)
Called when a new VellemanK8062 is added.
Definition SyncronizedWidgetObserver.h:74
ola::plugin::usbdmx::SyncronizedWidgetObserver::NewWidget
bool NewWidget(class ScanlimeFadecandy *widget)
Called when a new ScanlimeFadecandy is added.
Definition SyncronizedWidgetObserver.h:66
ola::plugin::usbdmx::SyncronizedWidgetObserver::NewWidget
bool NewWidget(class Sunlite *widget)
Called when a new Sunlite is added.
Definition SyncronizedWidgetObserver.h:70
ola::plugin::usbdmx::SyncronizedWidgetObserver::NewWidget
bool NewWidget(class EurolitePro *widget)
Called when a new EurolitePro is added.
Definition SyncronizedWidgetObserver.h:58
ola::plugin::usbdmx::SyncronizedWidgetObserver::NewWidget
bool NewWidget(ola::usb::JaRuleWidget *widget)
Called when a new Ja Rule widget is added.
Definition SyncronizedWidgetObserver.h:62
ola::plugin::usbdmx::SyncronizedWidgetObserver::NewWidget
bool NewWidget(class AnymauDMX *widget)
Called when a new AnymauDMX is added.
Definition SyncronizedWidgetObserver.h:50
ola::plugin::usbdmx::VellemanK8062
The interface for the Velleman Widgets.
Definition VellemanK8062.h:41
ola::plugin::usbdmx::WidgetObserver
Receives notifications when Widgets are added or removed.
Definition WidgetFactory.h:49
ola::thread::Future
Definition Future.h:33
ola::usb::JaRuleWidget
A Ja Rule hardware device (widget).
Definition JaRuleWidget.h:57
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