This file is indexed.

/usr/include/olad/Port.h is in libola-dev 0.10.3.nojsmin-2+deb9u1.

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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
/*
 * 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;

/**
 * @brief The base port class.
 *
 * Ports represent a single universe of DMX512. They are either input (receive
 * DMX) or output (send DMX) but not both.
 *
 * Every port is part of a Device. Ports can be associated (patched) to a
 * universe.
 */
class Port {
 public:
  virtual ~Port() {}

  /**
   * @brief Get the Port ID. This is the index within the device.
   * @return the id of the Port.
   */
  virtual unsigned int PortId() const = 0;

  /**
   * @brief Get the device which owns this Port.
   * @returns the Device which owns this Port.
   */
  virtual AbstractDevice *GetDevice() const = 0;

  /**
   * @brief Fetch the string description for a Port.
   * @returns a short text description of this port.
   */
  virtual std::string Description() const = 0;

  /**
   * @brief Bind this port to a universe.
   * @param universe the Universe to bind to.
   * @returns true if the patch succeeded, false otherwise.
   *
   * This shouldn't be called directly. Instead use PortManager::PatchPort()
   * which takes care of everything for you.
   */
  virtual bool SetUniverse(Universe *universe) = 0;

  /**
   * @brief Fetch the universe this Port is bound to.
   * @returns the Universe that this Port is bound to or NULL if the Port isn't
   *   patched.
   */
  virtual Universe *GetUniverse() const = 0;

  /**
   * @brief Return the globally unique id for a Port.
   *
   * This is used to preserve port universe bindings. An empty string means
   * we don't preserve settings.
   */
  virtual std::string UniqueId() const = 0;

  /**
   * @brief Get the priority capabilities for this port.
   * @returns a port_priority_capability.
   */
  virtual port_priority_capability PriorityCapability() const = 0;

  /**
   * @brief Set the Priority for this Port.
   * @param priority the priority to use.
   */
  virtual bool SetPriority(uint8_t priority) = 0;

  /**
   * @brief Get the numeric priority for this Port.
   * @returns the priority, higher numbers take precedence.
   */
  virtual uint8_t GetPriority() const = 0;

  /**
   * @brief Set the Priority Mode for this Port.
   * @param mode the Priority Mode to use.
   */
  virtual void SetPriorityMode(port_priority_mode mode) = 0;

  /**
   * @brief Get the Priority Mode for this Port.
   * @returns the Priority Mode.
   */
  virtual port_priority_mode GetPriorityMode() const = 0;

  /**
   * @brief Check if this Port supports RDM or not
   * @returns true if RDM is supported for this Port, false otherwise.
   */
  virtual bool SupportsRDM() const = 0;
};


/**
 * @brief A port that receives DMX512 data.
 */
class InputPort: public Port {
 public:
  virtual ~InputPort() {}

  /**
   * @brief Signal to the port that the DMX data has changed
   */
  virtual void DmxChanged() = 0;

  /**
   * @brief Get the current DMX data
   */
  virtual const DmxSource &SourceData() const = 0;

  /**
   * @brief Handle RDMRequests, ownership of the RDMRequest object is
   *   transferred
   */
  virtual void HandleRDMRequest(ola::rdm::RDMRequest *request,
                                ola::rdm::RDMCallback *callback) = 0;
};


/**
 * @brief A port that sends DMX512 data.
 */
class OutputPort: public Port, ola::rdm::DiscoverableRDMControllerInterface {
 public:
  virtual ~OutputPort() {}

  /**
   * @brief Write DMX data to this port
   * @param buffer the DmxBuffer to write
   * @param priority the priority of the DMX data
   * @return true on success, false on failure
   */
  virtual bool WriteDMX(const DmxBuffer &buffer, uint8_t priority) = 0;

  /**
   * @brief 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(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;
};


/**
 * An implementation of InputPort, provides the basic functionality which saves
 * the plugin implementations from having to do it.
 */
class BasicInputPort: public InputPort {
 public:
  /**
   * @brief Create a new basic input port
   */
  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; }

  /**
   * @brief Called when there is new data for this port
   */
  void DmxChanged();
  const DmxSource &SourceData() const { return m_dmx_source; }

  // RDM methods, the child class provides HandleRDMResponse
  /**
   * @brief Handle an RDM Request on this port.
   * @param request the RDMRequest object, ownership is transferred to us
   * @param callback the callback to run
   */
  void HandleRDMRequest(ola::rdm::RDMRequest *request,
                        ola::rdm::RDMCallback *callback);

  /**
   * @brief Trigger the RDM Discovery procedure for this universe
   */
  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:
  /**
   * @brief Create a new BasicOutputPort
   */
  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
  /**
   * @brief Handle an RDMRequest, subclasses can implement this to support RDM
   */
  virtual void SendRDMRequest(ola::rdm::RDMRequest *request,
                              ola::rdm::RDMCallback *callback);
  /**
   * @brief This is a noop for ports that don't support RDM
   */
  virtual void RunFullDiscovery(ola::rdm::RDMDiscoveryCallback *on_complete);

  /**
   * @brief This is a noop for ports that don't support RDM
   */
  virtual void RunIncrementalDiscovery(
      ola::rdm::RDMDiscoveryCallback *on_complete);

  // TimeCode
  virtual bool SupportsTimeCode() const { return false; }

  /**
   * @brief This is a noop for ports that don't support TimeCode
   */
  virtual bool SendTimeCode(const ola::timecode::TimeCode &) {
    return true;
  }

  // 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; }

  /**
   * @brief Called when the discovery triggered by patching completes
   */
  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);
};


/**
 * @brief This allows switching based on Port type.
 */
template<class PortClass>
bool IsInputPort();

template<>
bool IsInputPort<OutputPort>();
}  // namespace ola
#endif  // INCLUDE_OLAD_PORT_H_