fix crash when copy'ing latent plugins
[ardour.git] / libs / ardour / ardour / io_vector.h
1 /*
2  * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
3  * Copyright (C) 2006 Paul Davis
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19
20 #ifndef __ardour_io_vector_h__
21 #define __ardour_io_vector_h__
22
23 #include <vector>
24 #include <boost/shared_ptr.hpp>
25 #include "ardour/io.h"
26
27 namespace ARDOUR {
28
29 class IOVector : public std::vector<boost::weak_ptr<ARDOUR::IO> >
30 {
31 public:
32 #if 0 // unused -- for future reference
33         bool connected_to (const IOVector& other) const {
34                 for (IOVector::const_iterator i = other.begin(); i != other.end(); ++i) {
35                         boost::shared_ptr<const IO> io = i->lock();
36                         if (!io) continue;
37                         if (connected_to (io)) {
38                                 return true;
39                         }
40                 }
41                 return false;
42         }
43
44         bool connected_to (boost::shared_ptr<const IO> other) const {
45                 for (IOVector::const_iterator i = begin(); i != end(); ++i) {
46                         boost::shared_ptr<const IO> io = i->lock();
47                         if (!io) continue;
48                         if (io->connected_to (other)) {
49                                 return true;
50                         }
51                 }
52                 return false;
53         }
54 #endif
55
56         bool fed_by (boost::shared_ptr<const IO> other) const {
57                 for (IOVector::const_iterator i = begin(); i != end(); ++i) {
58                         boost::shared_ptr<const IO> io = i->lock();
59                         if (!io) continue;
60                         if (other->connected_to (io)) {
61                                 return true;
62                         }
63                 }
64                 return false;
65         }
66 };
67
68 } // namespace ARDOUR
69
70
71 #endif