summaryrefslogtreecommitdiff
path: root/src/lib/overlaps.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-10-13 11:30:30 +0100
committerCarl Hetherington <cth@carlh.net>2015-10-13 11:30:30 +0100
commit6f23b55a7783f93549115a133ca2e6e938bd0cd1 (patch)
tree6c674d088eb37dd9d91992366cfa6ddb3e0e69e5 /src/lib/overlaps.h
parentf9068dcbfbb09082e29e2a779ef1a7a2f6ee849e (diff)
Some attempts to block referencing of DCPs when it is not possible.
Diffstat (limited to 'src/lib/overlaps.h')
-rw-r--r--src/lib/overlaps.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/lib/overlaps.h b/src/lib/overlaps.h
new file mode 100644
index 000000000..6018af15f
--- /dev/null
+++ b/src/lib/overlaps.h
@@ -0,0 +1,39 @@
+/*
+ Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+
+ 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 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+/** @return Pieces of content type C that overlap a specified time range in the given ContentList */
+template<class C>
+std::list<boost::shared_ptr<C> >
+overlaps (ContentList cl, DCPTime from, DCPTime to)
+{
+ std::list<boost::shared_ptr<C> > overlaps;
+ DCPTimePeriod period (from, to);
+ for (typename ContentList::const_iterator i = cl.begin(); i != cl.end(); ++i) {
+ boost::shared_ptr<C> c = boost::dynamic_pointer_cast<C> (*i);
+ if (!c) {
+ continue;
+ }
+
+ if (DCPTimePeriod(c->position(), c->end()).overlaps (period)) {
+ overlaps.push_back (c);
+ }
+ }
+
+ return overlaps;
+}