C++11 tidying.
authorCarl Hetherington <cth@carlh.net>
Fri, 7 Jan 2022 22:22:48 +0000 (23:22 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 7 Jan 2022 22:23:08 +0000 (23:23 +0100)
src/lib/dcp_content.cc
src/lib/decoder_factory.cc
src/lib/ffmpeg_decoder.cc
src/tools/dcpomatic.cc
src/tools/dcpomatic_playlist.cc
src/wx/job_view.cc
src/wx/playlist_controls.cc

index de71c1257c3e61046b5bedfaeaadea9f5bb29ade..d72c0c43da7606ef973134555ddb69b94d8ce0be 100644 (file)
 
 
 #include "atmos_content.h"
-#include "dcp_content.h"
-#include "video_content.h"
 #include "audio_content.h"
-#include "dcp_examiner.h"
-#include "job.h"
-#include "film.h"
-#include "config.h"
-#include "overlaps.h"
 #include "compose.hpp"
+#include "config.h"
+#include "dcp_content.h"
 #include "dcp_decoder.h"
-#include "log.h"
+#include "dcp_examiner.h"
 #include "dcpomatic_log.h"
+#include "film.h"
+#include "job.h"
+#include "log.h"
+#include "overlaps.h"
 #include "text_content.h"
+#include "video_content.h"
 #include <dcp/dcp.h>
 #include <dcp/raw_convert.h>
 #include <dcp/exceptions.h>
@@ -690,7 +690,7 @@ DCPContent::can_reference_audio (shared_ptr<const Film> film, string& why_not) c
 {
        shared_ptr<DCPDecoder> decoder;
        try {
-               decoder.reset (new DCPDecoder (film, shared_from_this(), false, film->tolerant(), shared_ptr<DCPDecoder>()));
+               decoder = make_shared<DCPDecoder>(film, shared_from_this(), false, film->tolerant(), shared_ptr<DCPDecoder>());
        } catch (dcp::ReadError &) {
                /* We couldn't read the DCP, so it's probably missing */
                return false;
@@ -725,7 +725,7 @@ DCPContent::can_reference_text (shared_ptr<const Film> film, TextType type, stri
 {
        shared_ptr<DCPDecoder> decoder;
        try {
-               decoder.reset (new DCPDecoder (film, shared_from_this(), false, film->tolerant(), shared_ptr<DCPDecoder>()));
+               decoder = make_shared<DCPDecoder>(film, shared_from_this(), false, film->tolerant(), shared_ptr<DCPDecoder>());
        } catch (dcp::ReadError &) {
                /* We couldn't read the DCP, so it's probably missing */
                return false;
index 1acef6f4fbe9326d8b50d0f59050f0489a55e6bc..cb17d27d12ace772b0ea2fa62d7f53f89490e2e2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2016-2020 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2016-2022 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
 */
 
+
 #include "atmos_mxf_content.h"
 #include "atmos_mxf_decoder.h"
-#include "ffmpeg_content.h"
-#include "ffmpeg_decoder.h"
 #include "dcp_content.h"
 #include "dcp_decoder.h"
+#include "dcp_subtitle_content.h"
+#include "dcp_subtitle_decoder.h"
+#include "ffmpeg_content.h"
+#include "ffmpeg_decoder.h"
 #include "image_content.h"
 #include "image_decoder.h"
 #include "string_text_file_content.h"
 #include "string_text_file_decoder.h"
-#include "dcp_subtitle_content.h"
-#include "dcp_subtitle_decoder.h"
+#include "timer.h"
 #include "video_mxf_content.h"
 #include "video_mxf_decoder.h"
-#include "timer.h"
 
+
+using std::dynamic_pointer_cast;
 using std::list;
+using std::make_shared;
 using std::shared_ptr;
-using std::dynamic_pointer_cast;
+
 
 template <class T>
 shared_ptr<T>
 maybe_cast (shared_ptr<Decoder> d)
 {
        if (!d) {
-               return shared_ptr<T> ();
+               return {};
        }
        return dynamic_pointer_cast<T> (d);
 }
 
-/**
-   @param tolerant true to proceed in the face of `survivable' errors, otherwise false.
-   @param old_decoder A `used' decoder that has been previously made for this piece of content, or 0
+
+/** @param tolerant true to proceed in the face of `survivable' errors, otherwise false.
*  @param old_decoder A `used' decoder that has been previously made for this piece of content, or 0
 */
 shared_ptr<Decoder>
 decoder_factory (shared_ptr<const Film> film, shared_ptr<const Content> content, bool fast, bool tolerant, shared_ptr<Decoder> old_decoder)
 {
-       shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<const FFmpegContent> (content);
+       auto fc = dynamic_pointer_cast<const FFmpegContent>(content);
        if (fc) {
-               return shared_ptr<Decoder> (new FFmpegDecoder(film, fc, fast));
+               return make_shared<FFmpegDecoder>(film, fc, fast);
        }
 
-       shared_ptr<const DCPContent> dc = dynamic_pointer_cast<const DCPContent> (content);
+       auto dc = dynamic_pointer_cast<const DCPContent>(content);
        if (dc) {
                try {
-                       return shared_ptr<Decoder> (new DCPDecoder(film, dc, fast, tolerant, maybe_cast<DCPDecoder>(old_decoder)));
+                       return make_shared<DCPDecoder>(film, dc, fast, tolerant, maybe_cast<DCPDecoder>(old_decoder));
                } catch (KDMError& e) {
                        /* This will be found and reported to the user when the content is examined */
-                       return shared_ptr<Decoder>();
+                       return {};
                }
        }
 
-       shared_ptr<const ImageContent> ic = dynamic_pointer_cast<const ImageContent> (content);
+       auto ic = dynamic_pointer_cast<const ImageContent>(content);
        if (ic) {
-               return shared_ptr<Decoder> (new ImageDecoder(film, ic));
+               return make_shared<ImageDecoder>(film, ic);
        }
 
-       shared_ptr<const StringTextFileContent> rc = dynamic_pointer_cast<const StringTextFileContent> (content);
+       auto rc = dynamic_pointer_cast<const StringTextFileContent>(content);
        if (rc) {
-               return shared_ptr<Decoder> (new StringTextFileDecoder(film, rc));
+               return make_shared<StringTextFileDecoder>(film, rc);
        }
 
-       shared_ptr<const DCPSubtitleContent> dsc = dynamic_pointer_cast<const DCPSubtitleContent> (content);
+       auto dsc = dynamic_pointer_cast<const DCPSubtitleContent> (content);
        if (dsc) {
-               return shared_ptr<Decoder> (new DCPSubtitleDecoder(film, dsc));
+               return make_shared<DCPSubtitleDecoder>(film, dsc);
        }
 
-       shared_ptr<const VideoMXFContent> vmc = dynamic_pointer_cast<const VideoMXFContent> (content);
+       auto vmc = dynamic_pointer_cast<const VideoMXFContent> (content);
        if (vmc) {
-               return shared_ptr<Decoder> (new VideoMXFDecoder(film, vmc));
+               return make_shared<VideoMXFDecoder>(film, vmc);
        }
 
-       shared_ptr<const AtmosMXFContent> amc = dynamic_pointer_cast<const AtmosMXFContent> (content);
+       auto amc = dynamic_pointer_cast<const AtmosMXFContent> (content);
        if (amc) {
-               return shared_ptr<Decoder> (new AtmosMXFDecoder(film, amc));
+               return make_shared<AtmosMXFDecoder>(film, amc);
        }
 
-       return shared_ptr<Decoder> ();
+       return {};
 }
index ea961a894d5446b5a81731ea86909a14cc918635..8e34de0953a75fa419a0ca9600c17134c37622ad 100644 (file)
@@ -144,7 +144,7 @@ FFmpegDecoder::flush ()
                auto const f = full_length.frames_round (vfr);
                auto v = video->position(film()).get_value_or(ContentTime()).frames_round(vfr) + 1;
                while (v < f) {
-                       video->emit (film(), shared_ptr<const ImageProxy> (new RawImageProxy (_black_image)), v);
+                       video->emit (film(), make_shared<const RawImageProxy>(_black_image), v);
                        ++v;
                }
        }
index 27df23ef03692ca049c46c73350ba191a5b3b91b..459832963ecebdcc9cff0c9991bb99a668353e5b 100644 (file)
@@ -615,7 +615,7 @@ private:
                int const r = d->ShowModal ();
 
                if (r == wxID_OK && d->check_path() && maybe_save_film<FilmChangedDuplicatingDialog>()) {
-                       shared_ptr<Film> film (new Film (d->path()));
+                       auto film = make_shared<Film>(d->path());
                        film->copy_from (_film);
                        film->set_name (d->path().filename().generic_string());
                        film->write_metadata ();
index 6f06c0624e91109475a6b320c4ca5e8a56ed6fa1..d80d1390371a42e6ff11a577deeb7ea6c6fe3b35 100644 (file)
@@ -206,7 +206,7 @@ private:
 
        void new_playlist ()
        {
-               shared_ptr<SignalSPL> spl (new SignalSPL(wx_to_std(_("New Playlist"))));
+               auto spl = make_shared<SignalSPL>(wx_to_std(_("New Playlist")));
                add_playlist_to_model (spl);
                add_playlist_to_view (spl);
                _list->SetItemState (_list->GetItemCount() - 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
index 06d10401f578c23a980fc92279aceea1d380930b..a8db39751915730ae95a80a750ad805de5f06b8b 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2022 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 #include "static_text.h"
 #include "check_box.h"
 #include "dcpomatic_button.h"
-#include "lib/job.h"
-#include "lib/job_manager.h"
+#include "lib/analyse_audio_job.h"
 #include "lib/compose.hpp"
 #include "lib/config.h"
+#include "lib/job.h"
+#include "lib/job_manager.h"
 #include "lib/send_notification_email_job.h"
 #include "lib/transcode_job.h"
-#include "lib/analyse_audio_job.h"
 #include <wx/wx.h>
 #include <boost/algorithm/string.hpp>
 
 
-using std::string;
+using std::make_shared;
 using std::min;
 using std::shared_ptr;
+using std::string;
 using boost::bind;
 
 
@@ -166,7 +167,7 @@ JobView::finished ()
                        string body = Config::instance()->notification_email();
                        boost::algorithm::replace_all (body, "$JOB_NAME", _job->name());
                        boost::algorithm::replace_all (body, "$JOB_STATUS", _job->status());
-                       JobManager::instance()->add_after (_job, shared_ptr<Job> (new SendNotificationEmailJob (body)));
+                       JobManager::instance()->add_after(_job, make_shared<SendNotificationEmailJob>(body));
                }
        }
 }
index 3be47ad97cd0d4ad7a264cb938bc3263e078d072..31bebdb06eda0badaaf0ac7c5ac996f5282823e5 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2018-2020 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2018-2022 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
 */
 
-#include "playlist_controls.h"
-#include "film_viewer.h"
-#include "wx_util.h"
+
 #include "content_view.h"
 #include "dcpomatic_button.h"
+#include "film_viewer.h"
+#include "playlist_controls.h"
 #include "static_text.h"
-#include "lib/player_video.h"
-#include "lib/dcp_content.h"
+#include "wx_util.h"
+#include "lib/compose.hpp"
 #include "lib/cross.h"
-#include "lib/scoped_temporary.h"
-#include "lib/internet.h"
+#include "lib/dcp_content.h"
 #include "lib/ffmpeg_content.h"
-#include "lib/compose.hpp"
-#include <dcp/raw_convert.h>
+#include "lib/internet.h"
+#include "lib/player_video.h"
+#include "lib/scoped_temporary.h"
 #include <dcp/exceptions.h>
+#include <dcp/raw_convert.h>
 #include <wx/listctrl.h>
 #include <wx/progdlg.h>
 
-using std::string;
+
 using std::cout;
+using std::dynamic_pointer_cast;
 using std::exception;
-using std::sort;
+using std::make_shared;
 using std::shared_ptr;
-using std::dynamic_pointer_cast;
+using std::sort;
+using std::string;
 using boost::optional;
 using namespace dcpomatic;
 
+
 PlaylistControls::PlaylistControls (wxWindow* parent, shared_ptr<FilmViewer> viewer)
        : Controls (parent, viewer, false)
        , _play_button (new Button(this, _("Play")))
@@ -62,13 +66,13 @@ PlaylistControls::PlaylistControls (wxWindow* parent, shared_ptr<FilmViewer> vie
        _spl_view = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_NO_HEADER);
        _spl_view->AppendColumn (wxT(""), wxLIST_FORMAT_LEFT, 740);
 
-       wxBoxSizer* left_sizer = new wxBoxSizer (wxVERTICAL);
-       wxBoxSizer* e_sizer = new wxBoxSizer (wxHORIZONTAL);
+       auto left_sizer = new wxBoxSizer (wxVERTICAL);
+       auto e_sizer = new wxBoxSizer (wxHORIZONTAL);
 
        wxFont subheading_font (*wxNORMAL_FONT);
        subheading_font.SetWeight (wxFONTWEIGHT_BOLD);
 
-       wxBoxSizer* spl_header = new wxBoxSizer (wxHORIZONTAL);
+       auto spl_header = new wxBoxSizer (wxHORIZONTAL);
        {
                wxStaticText* m = new StaticText (this, "Playlists");
                m->SetFont (subheading_font);
@@ -82,7 +86,7 @@ PlaylistControls::PlaylistControls (wxWindow* parent, shared_ptr<FilmViewer> vie
 
        _content_view = new ContentView (this);
 
-       wxBoxSizer* content_header = new wxBoxSizer (wxHORIZONTAL);
+       auto content_header = new wxBoxSizer (wxHORIZONTAL);
        {
                wxStaticText* m = new StaticText (this, "Content");
                m->SetFont (subheading_font);
@@ -142,7 +146,7 @@ PlaylistControls::deselect_playlist ()
                _selected_playlist = boost::none;
                _spl_view->SetItemState (selected, 0, wxLIST_STATE_SELECTED);
        }
-       ResetFilm (shared_ptr<Film>(new Film(optional<boost::filesystem::path>())));
+       ResetFilm (std::make_shared<Film>(optional<boost::filesystem::path>()));
 }
 
 void
@@ -293,9 +297,9 @@ optional<dcp::EncryptedKDM>
 PlaylistControls::get_kdm_from_directory (shared_ptr<DCPContent> dcp)
 {
        using namespace boost::filesystem;
-       optional<path> kdm_dir = Config::instance()->player_kdm_directory();
+       auto kdm_dir = Config::instance()->player_kdm_directory();
        if (!kdm_dir) {
-               return optional<dcp::EncryptedKDM>();
+               return {};
        }
        for (directory_iterator i = directory_iterator(*kdm_dir); i != directory_iterator(); ++i) {
                try {
@@ -343,7 +347,7 @@ PlaylistControls::select_playlist (int selected, int position)
 
        for (auto const& i: _playlists[selected].get()) {
                dialog.Pulse ();
-               shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (i.content);
+               auto dcp = dynamic_pointer_cast<DCPContent> (i.content);
                if (dcp && dcp->needs_kdm()) {
                        optional<dcp::EncryptedKDM> kdm;
                        kdm = get_kdm_from_directory (dcp);
@@ -388,7 +392,7 @@ void
 PlaylistControls::reset_film ()
 {
        DCPOMATIC_ASSERT (_selected_playlist);
-       shared_ptr<Film> film (new Film(optional<boost::filesystem::path>()));
+       auto film = std::make_shared<Film>(optional<boost::filesystem::path>());
        film->add_content (_playlists[*_selected_playlist].get()[_selected_playlist_position].content);
        ResetFilm (film);
 }