using namespace dcpomatic;
Decoder::Decoder (weak_ptr<const Film> film)
- : _film (film)
+ : WeakConstFilm (film)
{
}
}
return text.front ();
}
-
-shared_ptr<const Film>
-Decoder::film () const
-{
- shared_ptr<const Film> f = _film.lock ();
- DCPOMATIC_ASSERT (f);
- return f;
-}
#include "types.h"
#include "film.h"
#include "dcpomatic_time.h"
+#include "weak_film.h"
#include <boost/utility.hpp>
class Decoded;
/** @class Decoder.
* @brief Parent class for decoders of content.
*/
-class Decoder : public boost::noncopyable
+class Decoder : public boost::noncopyable, public WeakConstFilm
{
public:
Decoder (boost::weak_ptr<const Film> film);
virtual void seek (dcpomatic::ContentTime time, bool accurate);
virtual dcpomatic::ContentTime position () const;
-
-protected:
- boost::shared_ptr<const Film> film () const;
-
-private:
- boost::weak_ptr<const Film> _film;
};
#endif
#endif
Hints::Hints (weak_ptr<const Film> film)
- : _film (film)
+ : WeakConstFilm (film)
, _long_ccap (false)
, _overlap_ccap (false)
, _too_many_ccap_lines (false)
}
-shared_ptr<const Film>
-Hints::film () const
-{
- shared_ptr<const Film> film = _film.lock ();
- DCPOMATIC_ASSERT (film);
- return film;
-}
-
-
void
Hints::check_ffec_and_ffmc_in_smpte_feature ()
{
#include "types.h"
#include "dcp_text_track.h"
#include "dcpomatic_time.h"
+#include "weak_film.h"
#include <boost/weak_ptr.hpp>
#include <boost/signals2.hpp>
#include <boost/atomic.hpp>
class Film;
-class Hints : public Signaller, public ExceptionStore
+class Hints : public Signaller, public ExceptionStore, public WeakConstFilm
{
public:
explicit Hints (boost::weak_ptr<const Film> film);
void text (PlayerText text, TextType type, dcpomatic::DCPTimePeriod period);
void closed_caption (PlayerText text, dcpomatic::DCPTimePeriod period);
void open_subtitle (PlayerText text, dcpomatic::DCPTimePeriod period);
- boost::shared_ptr<const Film> film () const;
void check_big_font_files ();
void check_few_audio_channels ();
void check_loudness ();
void check_ffec_and_ffmc_in_smpte_feature ();
- boost::weak_ptr<const Film> _film;
boost::thread _thread;
bool _long_ccap;
--- /dev/null
+/*
+ Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic 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.
+
+ DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#ifndef DCPOMATIC_WEAK_FILM_H
+#define DCPOMATIC_WEAK_FILM_H
+
+
+#include "dcpomatic_assert.h"
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+
+
+class Film;
+
+
+template <class T>
+class WeakFilmTemplate
+{
+public:
+ WeakFilmTemplate (boost::weak_ptr<T> f)
+ : _film(f)
+ {}
+
+protected:
+ boost::weak_ptr<T> _film;
+
+ boost::shared_ptr<T> film () const {
+ boost::shared_ptr<T> f = _film.lock();
+ DCPOMATIC_ASSERT (f);
+ return f;
+ }
+};
+
+
+typedef WeakFilmTemplate<const Film> WeakConstFilm;
+typedef WeakFilmTemplate<Film> WeakFilm;
+
+
+#endif
SMPTEMetadataDialog::SMPTEMetadataDialog (wxWindow* parent, weak_ptr<Film> weak_film)
: wxDialog (parent, wxID_ANY, _("Metadata"))
- , _film (weak_film)
+ , WeakFilm (weak_film)
{
wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
SetSizer (overall_sizer);
}
-shared_ptr<Film>
-SMPTEMetadataDialog::film () const
-{
- shared_ptr<Film> film = _film.lock ();
- DCPOMATIC_ASSERT (film);
- return film;
-}
-
-
void
SMPTEMetadataDialog::version_number_changed ()
{
#include "editable_list.h"
#include "language_tag_dialog.h"
#include "lib/film.h"
+#include "lib/weak_film.h"
#include <dcp/language_tag.h>
#include <dcp/types.h>
#include <wx/wx.h>
class LanguageTagWidget;
-class SMPTEMetadataDialog : public wxDialog
+class SMPTEMetadataDialog : public wxDialog, public WeakFilm
{
public:
SMPTEMetadataDialog (wxWindow* parent, boost::weak_ptr<Film> film);
void luminance_changed ();
void film_changed (ChangeType type, Film::Property property);
void setup_sensitivity ();
- boost::shared_ptr<Film> film () const;
- boost::weak_ptr<Film> _film;
LanguageTagWidget* _name_language;
LanguageTagWidget* _audio_language;
wxCheckBox* _enable_main_subtitle_language;