/usr/include/olad/Port.h is in libola-dev 0.9.1-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | /*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Port.h
* Header file for the Port classes
* Copyright (C) 2005 Simon Newton
*/
#ifndef INCLUDE_OLAD_PORT_H_
#define INCLUDE_OLAD_PORT_H_
#include <ola/DmxBuffer.h>
#include <ola/base/Macro.h>
#include <ola/rdm/RDMCommand.h>
#include <ola/rdm/RDMControllerInterface.h>
#include <ola/timecode/TimeCode.h>
#include <olad/DmxSource.h>
#include <olad/PluginAdaptor.h>
#include <olad/PortConstants.h>
#include <olad/Universe.h>
#include <string>
namespace ola {
class AbstractDevice;
/*
* The base port class, all ports inherit from this.
*/
class Port {
public:
virtual ~Port() {}
// return the id of the port within this deivce
virtual unsigned int PortId() const = 0;
// Return the device which owns this port
virtual AbstractDevice *GetDevice() const = 0;
// return a short description of this port
virtual std::string Description() const = 0;
// bind this port to a universe
virtual bool SetUniverse(Universe *universe) = 0;
// return the universe that this port is bound to or NULL
virtual Universe *GetUniverse() const = 0;
// Return a globally unique id of this port. This is used to preserve port
// universe bindings. An empty string means we don't preserve settings.
virtual std::string UniqueId() const = 0;
// this tells us what sort of priority capabilities this port has
virtual port_priority_capability PriorityCapability() const = 0;
virtual bool SetPriority(uint8_t priority) = 0;
virtual uint8_t GetPriority() const = 0;
virtual void SetPriorityMode(port_priority_mode mode) = 0;
virtual port_priority_mode GetPriorityMode() const = 0;
// If this port supports RDM or not
virtual bool SupportsRDM() const = 0;
};
/*
* The Input Port interface, for ports that provide push data into the OLA
* system.
*/
class InputPort: public Port {
public:
virtual ~InputPort() {}
// signal the port that the DMX data has changed
virtual void DmxChanged() = 0;
// Get the current data
virtual const DmxSource &SourceData() const = 0;
// Handle RDMRequests, ownership of the request object is transferred
virtual void HandleRDMRequest(const ola::rdm::RDMRequest *request,
ola::rdm::RDMCallback *callback) = 0;
};
/*
* The Output Port interface, for ports that send data from the OLA system.
*/
class OutputPort: public Port, ola::rdm::DiscoverableRDMControllerInterface {
public:
virtual ~OutputPort() {}
// Write dmx data to this port
virtual bool WriteDMX(const DmxBuffer &buffer, uint8_t priority) = 0;
// Called if the universe name changes
virtual void UniverseNameChanged(const std::string &new_name) = 0;
// Methods from DiscoverableRDMControllerInterface
// Ownership of the request object is transferred
virtual void SendRDMRequest(const ola::rdm::RDMRequest *request,
ola::rdm::RDMCallback *callback) = 0;
virtual void RunFullDiscovery(
ola::rdm::RDMDiscoveryCallback *on_complete) = 0;
virtual void RunIncrementalDiscovery(
ola::rdm::RDMDiscoveryCallback *on_complete) = 0;
// timecode support
virtual bool SupportsTimeCode() const = 0;
virtual bool SendTimeCode(const ola::timecode::TimeCode &timecode) = 0;
};
/*
* A Implementation of InputPort, provides the basic functionality which saves
* the plugin implementations from having to do it.
*/
class BasicInputPort: public InputPort {
public:
BasicInputPort(AbstractDevice *parent,
unsigned int port_id,
const PluginAdaptor *plugin_adaptor,
bool supports_rdm = false);
unsigned int PortId() const { return m_port_id; }
AbstractDevice *GetDevice() const { return m_device; }
bool SetUniverse(Universe *universe);
Universe *GetUniverse() const { return m_universe; }
virtual std::string UniqueId() const;
bool SetPriority(uint8_t priority);
uint8_t GetPriority() const { return m_priority; }
void SetPriorityMode(port_priority_mode mode) { m_priority_mode = mode; }
port_priority_mode GetPriorityMode() const { return m_priority_mode; }
void DmxChanged();
const DmxSource &SourceData() const { return m_dmx_source; }
// rdm methods, the child class provides HandleRDMResponse
void HandleRDMRequest(const ola::rdm::RDMRequest *request,
ola::rdm::RDMCallback *callback);
void TriggerRDMDiscovery(ola::rdm::RDMDiscoveryCallback *on_complete,
bool full = true);
port_priority_capability PriorityCapability() const {
return SupportsPriorities() ? CAPABILITY_FULL : CAPABILITY_STATIC;
}
// subclasses override these
// Read the dmx data.
virtual const DmxBuffer &ReadDMX() const = 0;
// Get the inherited priority
virtual uint8_t InheritedPriority() const {
return ola::dmx::SOURCE_PRIORITY_MIN;
}
// override this to cancel the SetUniverse operation.
virtual bool PreSetUniverse(Universe *, Universe *) { return true; }
virtual void PostSetUniverse(Universe *, Universe *) {}
virtual bool SupportsRDM() const { return m_supports_rdm; }
protected:
// indicates whether this port supports priorities, default to no
virtual bool SupportsPriorities() const { return false; }
private:
const unsigned int m_port_id;
uint8_t m_priority;
port_priority_mode m_priority_mode;
mutable std::string m_port_string;
Universe *m_universe; // the universe this port belongs to
AbstractDevice *m_device;
DmxSource m_dmx_source;
const PluginAdaptor *m_plugin_adaptor;
bool m_supports_rdm;
DISALLOW_COPY_AND_ASSIGN(BasicInputPort);
};
/*
* An implementation of an OutputPort.
*/
class BasicOutputPort: public OutputPort {
public:
BasicOutputPort(AbstractDevice *parent,
unsigned int port_id,
bool start_rdm_discovery_on_patch = false,
bool supports_rdm = false);
unsigned int PortId() const { return m_port_id; }
AbstractDevice *GetDevice() const { return m_device; }
bool SetUniverse(Universe *universe);
Universe *GetUniverse() const { return m_universe; }
std::string UniqueId() const;
bool SetPriority(uint8_t priority);
uint8_t GetPriority() const { return m_priority; }
void SetPriorityMode(port_priority_mode mode) { m_priority_mode = mode; }
port_priority_mode GetPriorityMode() const { return m_priority_mode; }
virtual void UniverseNameChanged(const std::string &new_name) {
(void) new_name;
}
port_priority_capability PriorityCapability() const {
return SupportsPriorities() ? CAPABILITY_FULL : CAPABILITY_NONE;
}
// DiscoverableRDMControllerInterface methods
virtual void SendRDMRequest(const ola::rdm::RDMRequest *request,
ola::rdm::RDMCallback *callback);
virtual void RunFullDiscovery(
ola::rdm::RDMDiscoveryCallback *on_complete);
virtual void RunIncrementalDiscovery(
ola::rdm::RDMDiscoveryCallback *on_complete);
// TimeCode
virtual bool SupportsTimeCode() const {
return false;
}
virtual bool SendTimeCode(const ola::timecode::TimeCode &) {
return true; // no op
}
// Subclasses can override this to cancel the SetUniverse operation.
virtual bool PreSetUniverse(Universe *, Universe *) { return true; }
virtual void PostSetUniverse(Universe *, Universe *) { }
virtual bool SupportsRDM() const { return m_supports_rdm; }
protected:
// indicates whether this port supports priorities, default to no
virtual bool SupportsPriorities() const { return false; }
void UpdateUIDs(const ola::rdm::UIDSet &uids);
private:
const unsigned int m_port_id;
const bool m_discover_on_patch;
uint8_t m_priority;
port_priority_mode m_priority_mode;
mutable std::string m_port_string;
Universe *m_universe; // the universe this port belongs to
AbstractDevice *m_device;
bool m_supports_rdm;
DISALLOW_COPY_AND_ASSIGN(BasicOutputPort);
};
/*
* This allows switching based on Port type.
*/
template<class PortClass>
bool IsInputPort();
template<>
bool IsInputPort<OutputPort>();
} // namespace ola
#endif // INCLUDE_OLAD_PORT_H_
|