Open Lighting Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OSCPlugin.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  * OSCPlugin.h
17  * Interface for the OSC plugin.
18  * Copyright (C) 2012 Simon Newton
19  */
20 
21 #ifndef PLUGINS_OSC_OSCPLUGIN_H_
22 #define PLUGINS_OSC_OSCPLUGIN_H_
23 
24 #include <string>
25 #include "olad/Plugin.h"
26 #include "ola/plugin_id.h"
27 #include "plugins/osc/OSCDevice.h"
28 #include "plugins/osc/OSCTarget.h"
29 
30 namespace ola {
31 namespace plugin {
32 namespace osc {
33 
34 using ola::Plugin;
35 using ola::PluginAdaptor;
36 
37 class OSCDevice;
38 
39 class OSCPlugin: public Plugin {
40  public:
41  explicit OSCPlugin(PluginAdaptor *plugin_adaptor):
42  Plugin(plugin_adaptor),
43  m_device(NULL) {}
44 
45  string Name() const { return PLUGIN_NAME; }
46  string Description() const;
47  ola_plugin_id Id() const { return OLA_PLUGIN_OSC; }
48  string PluginPrefix() const { return PLUGIN_PREFIX; }
49 
50  private:
51  bool StartHook();
52  bool StopHook();
53  bool SetDefaultPreferences();
54 
55  unsigned int GetPortCount(const string &key) const;
56  bool ExtractOSCTarget(const string &str, OSCTarget *target);
57  void SetDataFormat(const string &format_option,
58  OSCDevice::PortConfig *port_config);
59 
60  OSCDevice *m_device;
61  static const char DEFAULT_ADDRESS_TEMPLATE[];
62  static const char DEFAULT_PORT_COUNT[];
63  static const char DEFAULT_TARGETS_TEMPLATE[];
64  static const char DEFAULT_UDP_PORT[];
65  static const char INPUT_PORT_COUNT_KEY[];
66  static const char OUTPUT_PORT_COUNT_KEY[];
67  static const char PLUGIN_NAME[];
68  static const char PLUGIN_PREFIX[];
69  static const char PORT_ADDRESS_TEMPLATE[];
70  static const char PORT_TARGETS_TEMPLATE[];
71  static const char PORT_FORMAT_TEMPLATE[];
72  static const char UDP_PORT_KEY[];
73 
74  static const char BLOB_FORMAT[];
75  static const char FLOAT_ARRAY_FORMAT[];
76  static const char FLOAT_INDIVIDUAL_FORMAT[];
77  static const char INT_ARRAY_FORMAT[];
78  static const char INT_INDIVIDUAL_FORMAT[];
79 };
80 } // namespace osc
81 } // namespace plugin
82 } // namespace ola
83 #endif // PLUGINS_OSC_OSCPLUGIN_H_