Open Lighting Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OSCDevice.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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  *
16  * OSCDevice.h
17  * The OSC Device.
18  * Copyright (C) 2012 Simon Newton
19  */
20 
21 #ifndef PLUGINS_OSC_OSCDEVICE_H_
22 #define PLUGINS_OSC_OSCDEVICE_H_
23 
24 #include <memory>
25 #include <string>
26 #include <vector>
27 #include "ola/io/SelectServerInterface.h"
28 #include "ola/network/SocketAddress.h"
29 #include "olad/Device.h"
30 #include "plugins/osc/OSCTarget.h"
31 #include "plugins/osc/OSCNode.h"
32 
33 namespace ola {
34 
35 class AbstractPlugin;
36 
37 namespace plugin {
38 namespace osc {
39 
40 using std::string;
42 
43 class OSCDevice: public Device {
44  public:
45  struct PortConfig {
46  PortConfig() : data_format(OSCNode::FORMAT_BLOB) {}
47 
48  vector<OSCTarget> targets;
49  OSCNode::DataFormat data_format;
50  };
51 
52  typedef vector<PortConfig> PortConfigs;
53 
55  PluginAdaptor *plugin_adaptor,
56  uint16_t udp_port,
57  const vector<string> &addresses,
58  const PortConfigs &port_configs);
59  string DeviceId() const { return "1"; }
60 
61  bool AllowMultiPortPatching() const { return true; }
62 
63  protected:
64  PluginAdaptor *m_plugin_adaptor;
65  const vector<string> m_port_addresses;
66  const PortConfigs m_port_configs;
67  std::auto_ptr<class OSCNode> m_osc_node;
68 
69  bool StartHook();
70 
71  static const char DEVICE_NAME[];
72 };
73 } // namespace osc
74 } // namespace plugin
75 } // namespace ola
76 #endif // PLUGINS_OSC_OSCDEVICE_H_