X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fbundle.cc;h=f409e0beee4eb1493e9696a3f772a4564213539f;hb=8f59346592b8232e910ce0bbdc247cf8cecde4dd;hp=98d056a8f175be1e97664fa89a9556c70f412f79;hpb=e0aaed6d65f160c328cb8b56d7c6552ee15d65e2;p=ardour.git diff --git a/libs/ardour/bundle.cc b/libs/ardour/bundle.cc index 98d056a8f1..f409e0beee 100644 --- a/libs/ardour/bundle.cc +++ b/libs/ardour/bundle.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2002 Paul Davis + Copyright (C) 2002 Paul Davis 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 @@ -28,6 +28,7 @@ #include "i18n.h" +using namespace std; using namespace ARDOUR; using namespace PBD; @@ -83,7 +84,7 @@ Bundle::Bundle (boost::shared_ptr other) _signals_suspended (other->_signals_suspended), _pending_change (other->_pending_change) { - + } uint32_t @@ -135,7 +136,7 @@ Bundle::remove_port_from_channel (uint32_t ch, string portname) Glib::Mutex::Lock lm (_channel_mutex); PortList& pl = _channel[ch].ports; PortList::iterator i = find (pl.begin(), pl.end(), portname); - + if (i != pl.end()) { pl.erase (i); changed = true; @@ -182,7 +183,7 @@ bool Bundle::port_attached_to_channel (uint32_t ch, std::string portname) { assert (ch < nchannels()); - + Glib::Mutex::Lock lm (_channel_mutex); return (std::find (_channel[ch].ports.begin (), _channel[ch].ports.end (), portname) != _channel[ch].ports.end ()); } @@ -282,7 +283,7 @@ void Bundle::add_channels_from_bundle (boost::shared_ptr other) { uint32_t const ch = nchannels (); - + for (uint32_t i = 0; i < other->nchannels(); ++i) { std::stringstream s; @@ -360,7 +361,7 @@ void Bundle::remove_ports_from_channel (uint32_t ch) { assert (ch < nchannels ()); - + { Glib::Mutex::Lock lm (_channel_mutex); _channel[ch].ports.clear (); @@ -395,7 +396,7 @@ Bundle::emit_changed (Change c) Changed (c); } } - + bool Bundle::connected_to (boost::shared_ptr other, AudioEngine & engine) { @@ -409,7 +410,7 @@ Bundle::connected_to (boost::shared_ptr other, AudioEngine & engine) for (uint32_t i = 0; i < nchannels(); ++i) { Bundle::PortList const & A = channel_ports (i); Bundle::PortList const & B = other->channel_ports (i); - + for (uint32_t j = 0; j < A.size(); ++j) { for (uint32_t k = 0; k < B.size(); ++k) { @@ -431,3 +432,60 @@ Bundle::connected_to (boost::shared_ptr other, AudioEngine & engine) return true; } + +/** Set the type of the ports in this Bundle. + * @param t New type. + */ +void +Bundle::set_type (DataType t) +{ + _type = t; + emit_changed (TypeChanged); +} + +void +Bundle::set_ports_are_inputs () +{ + _ports_are_inputs = true; + emit_changed (DirectionChanged); +} + +void +Bundle::set_ports_are_outputs () +{ + _ports_are_inputs = false; + emit_changed (DirectionChanged); +} + +/** Set the name. + * @param n New name. + */ +void +Bundle::set_name (string const & n) +{ + _name = n; + emit_changed (NameChanged); +} + +/** @param b Other bundle. + * @return true if b has the same number of channels as this bundle, and those channels have corresponding ports. + */ +bool +Bundle::has_same_ports (boost::shared_ptr b) const +{ + uint32_t const N = nchannels (); + + if (b->nchannels() != N) { + return false; + } + + /* XXX: probably should sort channel port lists before comparing them */ + + for (uint32_t i = 0; i < N; ++i) { + if (channel_ports (i) != b->channel_ports (i)) { + return false; + } + } + + return true; +}