Open Lighting Architecture  Latest Git
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 class OSCDevice;
35 
36 class OSCPlugin: public ola::Plugin {
37  public:
38  explicit OSCPlugin(ola::PluginAdaptor *plugin_adaptor):
39  ola::Plugin(plugin_adaptor),
40  m_device(NULL) {}
41 
42  std::string Name() const { return PLUGIN_NAME; }
43  std::string Description() const;
44  ola_plugin_id Id() const { return OLA_PLUGIN_OSC; }
45  std::string PluginPrefix() const { return PLUGIN_PREFIX; }
46 
47  private:
48  bool StartHook();
49  bool StopHook();
50  bool SetDefaultPreferences();
51 
52  unsigned int GetPortCount(const std::string &key) const;
53  bool ExtractOSCTarget(const std::string &str, OSCTarget *target);
54  void SetDataFormat(const std::string &format_option,
55  OSCDevice::PortConfig *port_config);
56 
57  OSCDevice *m_device;
58  static const uint8_t DEFAULT_PORT_COUNT = 5;
59  static const uint16_t DEFAULT_UDP_PORT = 7770;
60 
61  static const char DEFAULT_ADDRESS_TEMPLATE[];
62  static const char DEFAULT_TARGETS_TEMPLATE[];
63  static const char INPUT_PORT_COUNT_KEY[];
64  static const char OUTPUT_PORT_COUNT_KEY[];
65  static const char PLUGIN_NAME[];
66  static const char PLUGIN_PREFIX[];
67  static const char PORT_ADDRESS_TEMPLATE[];
68  static const char PORT_TARGETS_TEMPLATE[];
69  static const char PORT_FORMAT_TEMPLATE[];
70  static const char UDP_PORT_KEY[];
71 
72  static const char BLOB_FORMAT[];
73  static const char FLOAT_ARRAY_FORMAT[];
74  static const char FLOAT_INDIVIDUAL_FORMAT[];
75  static const char INT_ARRAY_FORMAT[];
76  static const char INT_INDIVIDUAL_FORMAT[];
77 };
78 } // namespace osc
79 } // namespace plugin
80 } // namespace ola
81 #endif // PLUGINS_OSC_OSCPLUGIN_H_
Definition: OSCTarget.h:31
Definition: OSCDevice.h:40
ola_plugin_id Id() const
Get the plugin ID of this plugin.
Definition: OSCPlugin.h:44
std::string Description() const
Definition: OSCPlugin.cpp:132
std::string Name() const
Get the plugin name.
Definition: OSCPlugin.h:42
Definition: Plugin.h:118
Definition: PluginAdaptor.h:41
Definition: OSCDevice.h:42
std::string PluginPrefix() const
The prefix to use for storing configuration files.
Definition: OSCPlugin.h:45
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Definition: OSCPlugin.h:36