* This allows access to all the ports as a list, ignoring type, or accessing
* the nth port of a given type. Note that port(n) and nth_audio_port(n) may
* NOT return the same port.
+ *
+ * Each port is held twice; once in a per-type vector of vectors (_ports)
+ * and once in a vector of all port (_all_ports). This is to speed up the
+ * fairly common case of iterating over all ports.
*/
-class PortSet : public boost::noncopyable {
+class LIBARDOUR_API PortSet : public boost::noncopyable {
public:
PortSet();
void add (boost::shared_ptr<Port> port);
bool remove (boost::shared_ptr<Port> port);
- /** nth port */
+ /** nth port
+ * @param index port index
+ */
boost::shared_ptr<Port> port(size_t index) const;
- /** nth port of type @a t, or nth port if t = NIL */
+ /** nth port of type @a t, or nth port if t = NIL
+ * @param t data type
+ * @param index port index
+ */
boost::shared_ptr<Port> port(DataType t, size_t index) const;
boost::shared_ptr<AudioPort> nth_audio_port(size_t n) const;
/** Remove all ports from the PortSet. Ports are not deregistered with
* the engine, it's the caller's responsibility to not leak here!
*/
- void clear() { _ports.clear(); }
+ void clear();
const ChanCount& count() const { return _count; }
// Vector of vectors, indexed by DataType::to_index()
std::vector<PortVec> _ports;
+ // All ports in _ports in one vector, to speed some operations
+ PortVec _all_ports;
ChanCount _count;
};