diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-07-31 23:52:02 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-07-31 23:52:02 +0100 |
| commit | 9c01623c3038b978ba732de2ad147d29fad60afe (patch) | |
| tree | 72907bc7560dcef38d43f363881e2b959d4c0d34 /src/lib/dcpomatic_time.h | |
| parent | 83a2cf5916fe7207e786b95aa5c560b6b5d11e4e (diff) | |
Allow configuration of MXF/XML filenames (part of #710).
Diffstat (limited to 'src/lib/dcpomatic_time.h')
| -rw-r--r-- | src/lib/dcpomatic_time.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/lib/dcpomatic_time.h b/src/lib/dcpomatic_time.h index e6ca493b2..a94b605d2 100644 --- a/src/lib/dcpomatic_time.h +++ b/src/lib/dcpomatic_time.h @@ -28,6 +28,7 @@ #include "frame_rate_change.h" #include "dcpomatic_assert.h" #include <locked_sstream.h> +#include <boost/optional.hpp> #include <stdint.h> #include <cmath> #include <ostream> @@ -261,8 +262,15 @@ public: return TimePeriod<T> (from + o, to + o); } - bool overlaps (TimePeriod<T> const & other) const { - return (from < other.to && to > other.from); + boost::optional<TimePeriod<T> > overlap (TimePeriod<T> const & other) { + T const max_from = std::max (from, other.from); + T const min_to = std::min (to, other.to); + + if (max_from >= min_to) { + return boost::optional<TimePeriod<T> > (); + } + + return TimePeriod<T> (max_from, min_to); } bool contains (T const & other) const { |
