Open Lighting Architecture  0.9.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OSCPort.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  * OSCPort.h
17  * The OSCInputPort and OSCOutputPort classes.
18  * Copyright (C) 2012 Simon Newton
19  */
20 
21 #ifndef PLUGINS_OSC_OSCPORT_H_
22 #define PLUGINS_OSC_OSCPORT_H_
23 
24 #include <string>
25 #include <vector>
26 #include "olad/Port.h"
27 #include "plugins/osc/OSCAddressTemplate.h"
28 #include "plugins/osc/OSCDevice.h"
29 #include "plugins/osc/OSCNode.h"
30 
31 namespace ola {
32 namespace plugin {
33 namespace osc {
34 
43  public:
52  OSCInputPort(OSCDevice *parent,
53  unsigned int port_id,
54  PluginAdaptor *plugin_adaptor,
55  OSCNode *node,
56  const std::string &address);
57 
61  const DmxBuffer &ReadDMX() const { return m_buffer; }
62 
67  bool PreSetUniverse(Universe *old_universe, Universe *new_universe);
68 
72  std::string Description() const { return m_actual_address; }
73 
74  private:
75  OSCNode *m_node;
76  DmxBuffer m_buffer;
77  const std::string m_address;
78  std::string m_actual_address;
79 
83  void NewDMXData(const DmxBuffer &data);
84 };
85 
86 
91  public:
100  OSCOutputPort(OSCDevice *device,
101  unsigned int port_id,
102  OSCNode *node,
103  const std::vector<OSCTarget> &targets,
104  OSCNode::DataFormat data_format);
105  ~OSCOutputPort();
106 
111  bool PreSetUniverse(Universe *old_universe, Universe *new_universe);
112 
118  bool WriteDMX(const DmxBuffer &buffer, uint8_t) {
119  return m_node->SendData(this->PortId(), m_data_format, buffer);
120  }
121 
125  std::string Description() const { return m_description; }
126 
127  private:
128  OSCNode *m_node;
129  const std::vector<OSCTarget> m_template_targets;
130  std::vector<OSCTarget> m_registered_targets;
131  std::string m_description;
132  OSCNode::DataFormat m_data_format;
133 
134  void RemoveTargets();
135  void SetUnpatchedDescription();
136 };
137 } // namespace osc
138 } // namespace plugin
139 } // namespace ola
140 #endif // PLUGINS_OSC_OSCPORT_H_