Open Lighting Architecture  0.9.1
 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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"
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 class OSCDevice: public Device {
41  public:
42  struct PortConfig {
43  PortConfig() : data_format(OSCNode::FORMAT_BLOB) {}
44 
45  std::vector<OSCTarget> targets;
46  OSCNode::DataFormat data_format;
47  };
48 
49  typedef std::vector<PortConfig> PortConfigs;
50 
52  PluginAdaptor *plugin_adaptor,
53  uint16_t udp_port,
54  const std::vector<std::string> &addresses,
55  const PortConfigs &port_configs);
56  std::string DeviceId() const { return "1"; }
57 
58  bool AllowLooping() const { return true; }
59  bool AllowMultiPortPatching() const { return true; }
60 
61  protected:
62  PluginAdaptor *m_plugin_adaptor;
63  const std::vector<std::string> m_port_addresses;
64  const PortConfigs m_port_configs;
65  std::auto_ptr<class OSCNode> m_osc_node;
66 
67  bool StartHook();
68 
69  static const char DEVICE_NAME[];
70 };
71 } // namespace osc
72 } // namespace plugin
73 } // namespace ola
74 #endif // PLUGINS_OSC_OSCDEVICE_H_