Open Lighting Architecture  0.9.0
 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 
42  public:
51  OSCInputPort(OSCDevice *parent,
52  unsigned int port_id,
53  PluginAdaptor *plugin_adaptor,
54  OSCNode *node,
55  const std::string &address);
56 
60  const DmxBuffer &ReadDMX() const { return m_buffer; }
61 
66  bool PreSetUniverse(Universe *old_universe, Universe *new_universe);
67 
71  std::string Description() const { return m_actual_address; }
72 
73  private:
74  OSCNode *m_node;
75  DmxBuffer m_buffer;
76  const std::string m_address;
77  std::string m_actual_address;
78 
82  void NewDMXData(const DmxBuffer &data);
83 };
84 
85 
90  public:
97  OSCOutputPort(OSCDevice *device,
98  unsigned int port_id,
99  OSCNode *node,
100  const std::vector<OSCTarget> &targets,
101  OSCNode::DataFormat data_format);
102  ~OSCOutputPort();
103 
108  bool PreSetUniverse(Universe *old_universe, Universe *new_universe);
109 
115  bool WriteDMX(const DmxBuffer &buffer, uint8_t) {
116  return m_node->SendData(this->PortId(), m_data_format, buffer);
117  }
118 
122  std::string Description() const { return m_description; }
123 
124  private:
125  OSCNode *m_node;
126  const std::vector<OSCTarget> m_template_targets;
127  std::vector<OSCTarget> m_registered_targets;
128  std::string m_description;
129  OSCNode::DataFormat m_data_format;
130 
131  void RemoveTargets();
132  void SetUnpatchedDescription();
133 };
134 } // namespace osc
135 } // namespace plugin
136 } // namespace ola
137 #endif // PLUGINS_OSC_OSCPORT_H_