Open Lighting Architecture  Latest Git
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 
32 namespace ola {
33 
34 class AbstractPlugin;
35 
36 namespace plugin {
37 namespace openpixelcontrol {
38 
40  public:
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  DISALLOW_COPY_AND_ASSIGN(OPCServerDevice);
67 };
68 
70  public:
79  PluginAdaptor *plugin_adaptor,
80  Preferences *preferences,
81  const ola::network::IPV4SocketAddress target);
82 
83  std::string DeviceId() const;
84 
85  bool AllowMultiPortPatching() const { return true; }
86 
87  protected:
88  bool StartHook();
89 
90  private:
91  PluginAdaptor* const m_plugin_adaptor;
92  Preferences* const m_preferences;
93  const ola::network::IPV4SocketAddress m_target;
94  std::auto_ptr<class OPCClient> m_client;
95 
97 };
98 } // namespace openpixelcontrol
99 } // namespace plugin
100 } // namespace ola
101 #endif // PLUGINS_OPENPIXELCONTROL_OPCDEVICE_H_
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Creates dummy copy constructor and assignment operator declarations.
Definition: Macro.h:44
std::string DeviceId() const
The device ID.
Definition: OPCDevice.cpp:72
bool AllowMultiPortPatching() const
Allow multiple ports of the same type to be patched to the same universe.
Definition: OPCDevice.h:55
OPCServerDevice(AbstractPlugin *owner, PluginAdaptor *plugin_adaptor, Preferences *preferences, const ola::network::IPV4SocketAddress listen_addr)
Create a new OPC server device.
Definition: OPCDevice.cpp:60
Definition: Device.h:95
bool StartHook()
Called during Start().
Definition: OPCDevice.cpp:76
Definition: PluginAdaptor.h:41
bool AllowMultiPortPatching() const
Allow multiple ports of the same type to be patched to the same universe.
Definition: OPCDevice.h:85
Definition: Preferences.h:147
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
An IPv4 SocketAddress.
Definition: SocketAddress.h:78
Definition: Plugin.h:38