Open Lighting Architecture: plugins/openpixelcontrol/OPCDevice.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
OPCDevice.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 * OPCDevice.h
17 * The Open Pixel Control Device.
18 * Copyright (C) 2014 Simon Newton
19 */
20
21#ifndef PLUGINS_OPENPIXELCONTROL_OPCDEVICE_H_
22#define PLUGINS_OPENPIXELCONTROL_OPCDEVICE_H_
23
24#include <memory>
25#include <string>
26
27#include "ola/network/Socket.h"
28#include "olad/Device.h"
29#include "plugins/openpixelcontrol/OPCClient.h"
30#include "plugins/openpixelcontrol/OPCServer.h"
31
32namespace ola {
33
34class AbstractPlugin;
35
36namespace plugin {
37namespace openpixelcontrol {
38
39 class OPCServerDevice: public ola::Device {
40 public:
48 OPCServerDevice(AbstractPlugin *owner,
49 PluginAdaptor *plugin_adaptor,
50 Preferences *preferences,
51 const ola::network::IPV4SocketAddress listen_addr);
52
53 std::string DeviceId() const;
54
55 bool AllowMultiPortPatching() const { return true; }
56
57 protected:
58 bool StartHook();
59
60 private:
61 PluginAdaptor* const m_plugin_adaptor;
62 Preferences* const m_preferences;
63 const ola::network::IPV4SocketAddress m_listen_addr;
64 std::auto_ptr<class OPCServer> m_server;
65
66 OPCServerDevice(const OPCServerDevice &) = delete;
67 const OPCServerDevice &operator=(const OPCServerDevice &) = delete;
68};
69
70 class OPCClientDevice: public ola::Device {
71 public:
79 OPCClientDevice(AbstractPlugin *owner,
80 PluginAdaptor *plugin_adaptor,
81 Preferences *preferences,
82 const ola::network::IPV4SocketAddress target);
83
84 std::string DeviceId() const;
85
86 bool AllowMultiPortPatching() const { return true; }
87
88 protected:
89 bool StartHook();
90
91 private:
92 PluginAdaptor* const m_plugin_adaptor;
93 Preferences* const m_preferences;
94 const ola::network::IPV4SocketAddress m_target;
95 std::auto_ptr<class OPCClient> m_client;
96
97 OPCClientDevice(const OPCClientDevice &) = delete;
98 const OPCClientDevice &operator=(const OPCClientDevice &) = delete;
99};
100} // namespace openpixelcontrol
101} // namespace plugin
102} // namespace ola
103#endif // PLUGINS_OPENPIXELCONTROL_OPCDEVICE_H_
ola::AbstractPlugin
Definition Plugin.h:38
ola::Device
Definition Device.h:89
ola::PluginAdaptor
Definition PluginAdaptor.h:41
ola::Preferences
Definition Preferences.h:148
ola::network::IPV4SocketAddress
An IPv4 SocketAddress.
Definition SocketAddress.h:78
ola::plugin::openpixelcontrol::OPCClientDevice::DeviceId
std::string DeviceId() const
The device ID.
Definition OPCDevice.cpp:105
ola::plugin::openpixelcontrol::OPCClientDevice::OPCClientDevice
OPCClientDevice(AbstractPlugin *owner, PluginAdaptor *plugin_adaptor, Preferences *preferences, const ola::network::IPV4SocketAddress target)
Create a new OPC client device.
Definition OPCDevice.cpp:94
ola::plugin::openpixelcontrol::OPCClientDevice::StartHook
bool StartHook()
Called during Start().
Definition OPCDevice.cpp:109
ola::plugin::openpixelcontrol::OPCServerDevice::DeviceId
std::string DeviceId() const
The device ID.
Definition OPCDevice.cpp:72
ola::plugin::openpixelcontrol::OPCServerDevice::OPCServerDevice
OPCServerDevice(AbstractPlugin *owner, PluginAdaptor *plugin_adaptor, Preferences *preferences, const ola::network::IPV4SocketAddress listen_addr)
Create a new OPC server device.
Definition OPCDevice.cpp:60
ola::plugin::openpixelcontrol::OPCServerDevice::StartHook
bool StartHook()
Called during Start().
Definition OPCDevice.cpp:76
ola::plugin::openpixelcontrol
The Open Pixel Control (OPC) plugin.
ola::plugin
Code for supported devices and protocols.
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44