From 49493f16a9bab200e50954ae69f0c7bca869a139 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 8 Jan 2022 12:56:05 +0100 Subject: [PATCH] C++11 tidying. --- src/lib/atmos_metadata.cc | 3 +- src/lib/audio_delay.cc | 2 +- src/lib/audio_filter_graph.cc | 10 +++++-- src/lib/config.cc | 44 +++++++++++++++------------- src/lib/image_content.cc | 28 ++++++++++-------- src/lib/json_server.cc | 19 ++++++------ src/lib/writer.cc | 5 ++-- src/lib/zipper.cc | 11 +++---- src/tools/dcpomatic.cc | 2 +- src/wx/job_manager_view.cc | 12 ++++---- src/wx/subtitle_appearance_dialog.cc | 7 +++-- 11 files changed, 79 insertions(+), 64 deletions(-) diff --git a/src/lib/atmos_metadata.cc b/src/lib/atmos_metadata.cc index 0fe23f3b0..0ab04a825 100644 --- a/src/lib/atmos_metadata.cc +++ b/src/lib/atmos_metadata.cc @@ -23,6 +23,7 @@ #include +using std::make_shared; using std::shared_ptr; @@ -39,5 +40,5 @@ AtmosMetadata::AtmosMetadata (shared_ptr asset) shared_ptr AtmosMetadata::create (dcp::Fraction edit_rate) const { - return shared_ptr (new dcp::AtmosAsset(edit_rate, _first_frame, _max_channel_count, _max_object_count, _atmos_version)); + return make_shared(edit_rate, _first_frame, _max_channel_count, _max_object_count, _atmos_version); } diff --git a/src/lib/audio_delay.cc b/src/lib/audio_delay.cc index 90214470c..d06d9e730 100644 --- a/src/lib/audio_delay.cc +++ b/src/lib/audio_delay.cc @@ -43,7 +43,7 @@ AudioDelay::run (shared_ptr in) /* You can't call this with varying channel counts */ DCPOMATIC_ASSERT (!_tail || in->channels() == _tail->channels()); - shared_ptr out (new AudioBuffers (in->channels(), in->frames())); + auto out = make_shared(in->channels(), in->frames()); if (in->frames() > _samples) { diff --git a/src/lib/audio_filter_graph.cc b/src/lib/audio_filter_graph.cc index fc43b5a34..95f6730cf 100644 --- a/src/lib/audio_filter_graph.cc +++ b/src/lib/audio_filter_graph.cc @@ -18,8 +18,9 @@ */ -#include "audio_filter_graph.h" + #include "audio_buffers.h" +#include "audio_filter_graph.h" #include "compose.hpp" extern "C" { #include @@ -31,9 +32,12 @@ extern "C" { #include "i18n.h" -using std::string; + using std::cout; +using std::make_shared; using std::shared_ptr; +using std::string; + AudioFilterGraph::AudioFilterGraph (int sample_rate, int channels) : _sample_rate (sample_rate) @@ -113,7 +117,7 @@ AudioFilterGraph::process (shared_ptr buffers) the constructor) so we need to create new buffers with some extra silent channels. */ - shared_ptr extended_buffers (new AudioBuffers (process_channels, buffers->frames())); + auto extended_buffers = make_shared(process_channels, buffers->frames()); for (int i = 0; i < buffers->channels(); ++i) { extended_buffers->copy_channel_from (buffers.get(), i, i); } diff --git a/src/lib/config.cc b/src/lib/config.cc index fdab2bb16..bf294aec9 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -18,24 +18,25 @@ */ + +#include "cinema.h" +#include "colour_conversion.h" +#include "compose.hpp" #include "config.h" +#include "cross.h" +#include "crypto.h" +#include "dcp_content_type.h" +#include "dkdm_recipient.h" +#include "dkdm_wrapper.h" +#include "film.h" #include "filter.h" +#include "log.h" #include "ratio.h" #include "types.h" -#include "log.h" -#include "dcp_content_type.h" -#include "colour_conversion.h" -#include "cinema.h" #include "util.h" -#include "cross.h" -#include "film.h" -#include "dkdm_wrapper.h" -#include "compose.hpp" -#include "crypto.h" -#include "dkdm_recipient.h" -#include -#include #include +#include +#include #include #include #include @@ -48,27 +49,30 @@ #include "i18n.h" -using std::vector; + using std::cout; +using std::dynamic_pointer_cast; using std::ifstream; -using std::string; using std::list; -using std::min; +using std::make_shared; using std::max; +using std::min; using std::remove; using std::shared_ptr; -using std::make_shared; -using boost::optional; -using std::dynamic_pointer_cast; +using std::string; +using std::vector; using boost::algorithm::trim; +using boost::optional; using dcp::raw_convert; + Config* Config::_instance = 0; int const Config::_current_version = 3; boost::signals2::signal Config::FailedToLoad; boost::signals2::signal Config::Warning; boost::signals2::signal Config::Bad; + /** Construct default configuration */ Config::Config () /* DKDMs are not considered a thing to reset on set_defaults() */ @@ -487,7 +491,7 @@ try _dkdms = dynamic_pointer_cast (DKDMBase::read (f.node_child("DKDMGroup"))); } else { /* Old-style: one or more DKDM nodes */ - _dkdms.reset (new DKDMGroup ("root")); + _dkdms = make_shared("root"); for (auto i: f.node_children("DKDM")) { _dkdms->add (DKDMBase::read (i)); } @@ -1269,7 +1273,7 @@ Config::read_dkdm_recipients (cxml::Document const & f) { _dkdm_recipients.clear (); for (auto i: f.node_children("DKDMRecipient")) { - _dkdm_recipients.push_back (shared_ptr(new DKDMRecipient(i))); + _dkdm_recipients.push_back (make_shared(i)); } } diff --git a/src/lib/image_content.cc b/src/lib/image_content.cc index 517d6792f..6a6be2716 100644 --- a/src/lib/image_content.cc +++ b/src/lib/image_content.cc @@ -16,33 +16,37 @@ You should have received a copy of the GNU General Public License along with DCP-o-matic. If not, see . + */ -#include "image_content.h" -#include "video_content.h" -#include "image_examiner.h" #include "compose.hpp" +#include "exceptions.h" #include "film.h" -#include "job.h" #include "frame_rate_change.h" -#include "exceptions.h" +#include "image_content.h" +#include "image_examiner.h" #include "image_filename_sorter.h" +#include "job.h" +#include "video_content.h" #include #include #include #include "i18n.h" -using std::string; + using std::cout; using std::list; -using std::vector; +using std::make_shared; using std::shared_ptr; +using std::string; +using std::vector; using namespace dcpomatic; + ImageContent::ImageContent (boost::filesystem::path p) { - video.reset (new VideoContent (this)); + video = make_shared(this); if (boost::filesystem::is_regular_file (p) && valid_image_file (p)) { add_path (p); @@ -107,9 +111,9 @@ ImageContent::examine (shared_ptr film, shared_ptr job) job->sub (_("Scanning image files")); vector paths; int n = 0; - for (boost::filesystem::directory_iterator i(*_path_to_scan); i != boost::filesystem::directory_iterator(); ++i) { - if (boost::filesystem::is_regular_file (i->path()) && valid_image_file (i->path())) { - paths.push_back (i->path()); + for (auto i: boost::filesystem::directory_iterator(*_path_to_scan)) { + if (boost::filesystem::is_regular_file(i.path()) && valid_image_file(i.path())) { + paths.push_back (i.path()); } ++n; if ((n % 1000) == 0) { @@ -127,7 +131,7 @@ ImageContent::examine (shared_ptr film, shared_ptr job) Content::examine (film, job); - shared_ptr examiner (new ImageExaminer (film, shared_from_this(), job)); + auto examiner = make_shared(film, shared_from_this(), job); video->take_from_examiner (examiner); set_default_colour_conversion (); } diff --git a/src/lib/json_server.cc b/src/lib/json_server.cc index dd56b3124..8c626ad1f 100644 --- a/src/lib/json_server.cc +++ b/src/lib/json_server.cc @@ -19,12 +19,12 @@ */ -#include "json_server.h" -#include "job_manager.h" -#include "job.h" -#include "util.h" #include "film.h" +#include "job.h" +#include "job_manager.h" +#include "json_server.h" #include "transcode_job.h" +#include "util.h" #include #include #include @@ -32,14 +32,15 @@ #include -using std::string; using std::cout; -using std::map; +using std::dynamic_pointer_cast; using std::list; -using boost::thread; +using std::make_shared; +using std::map; using std::shared_ptr; -using std::dynamic_pointer_cast; +using std::string; using boost::asio::ip::tcp; +using boost::thread; using dcp::raw_convert; @@ -74,7 +75,7 @@ try tcp::acceptor a (io_service, tcp::endpoint (tcp::v4 (), port)); while (true) { try { - shared_ptr s (new tcp::socket (io_service)); + auto s = make_shared(io_service); a.accept (*s); handle (s); } diff --git a/src/lib/writer.cc b/src/lib/writer.cc index d85be9eff..4596fde05 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -303,12 +303,11 @@ Writer::write (shared_ptr audio, DCPTime const time) DCPOMATIC_ASSERT ((part_frames[0] + part_frames[1]) <= audio->frames()); if (part_frames[0]) { - shared_ptr part (new AudioBuffers(audio, part_frames[0], 0)); - _audio_reel->write (part); + _audio_reel->write (make_shared(audio, part_frames[0], 0)); } if (part_frames[1]) { - audio.reset (new AudioBuffers(audio, part_frames[1], part_frames[0])); + audio = make_shared(audio, part_frames[1], part_frames[0]); } else { audio.reset (); } diff --git a/src/lib/zipper.cc b/src/lib/zipper.cc index 2c334dc94..2a0723278 100644 --- a/src/lib/zipper.cc +++ b/src/lib/zipper.cc @@ -19,17 +19,18 @@ */ -#include "zipper.h" -#include "exceptions.h" #include "dcpomatic_assert.h" +#include "exceptions.h" +#include "zipper.h" #include #include #include -using std::string; +using std::make_shared; using std::runtime_error; using std::shared_ptr; +using std::string; Zipper::Zipper (boost::filesystem::path file) @@ -48,7 +49,7 @@ Zipper::Zipper (boost::filesystem::path file) void Zipper::add (string name, string content) { - shared_ptr copy(new string(content)); + auto copy = make_shared(content); _store.push_back (copy); auto source = zip_source_buffer (_zip, copy->c_str(), copy->length(), 0); @@ -68,7 +69,7 @@ Zipper::close () if (zip_close(_zip) == -1) { throw runtime_error ("failed to close ZIP archive"); } - _zip = 0; + _zip = nullptr; } diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 459832963..fa61d4e1d 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -630,7 +630,7 @@ private: int const r = d->ShowModal (); if (r == wxID_OK && d->check_path() && maybe_save_film()) { - shared_ptr film (new Film (d->path())); + auto film = make_shared(d->path()); film->copy_from (_film); film->set_name (d->path().filename().generic_string()); film->write_metadata (); diff --git a/src/wx/job_manager_view.cc b/src/wx/job_manager_view.cc index 19243393c..35b6d98b9 100644 --- a/src/wx/job_manager_view.cc +++ b/src/wx/job_manager_view.cc @@ -25,24 +25,24 @@ */ -#include "job_manager_view.h" #include "batch_job_view.h" +#include "job_manager_view.h" #include "normal_job_view.h" #include "wx_util.h" -#include "lib/job_manager.h" +#include "lib/compose.hpp" +#include "lib/exceptions.h" #include "lib/job.h" +#include "lib/job_manager.h" #include "lib/util.h" -#include "lib/exceptions.h" -#include "lib/compose.hpp" #include -using std::string; +using std::cout; using std::list; using std::map; using std::min; -using std::cout; using std::shared_ptr; +using std::string; using std::weak_ptr; using boost::bind; #if BOOST_VERSION >= 106100 diff --git a/src/wx/subtitle_appearance_dialog.cc b/src/wx/subtitle_appearance_dialog.cc index b5ab8c2db..aa8e31a4e 100644 --- a/src/wx/subtitle_appearance_dialog.cc +++ b/src/wx/subtitle_appearance_dialog.cc @@ -39,11 +39,12 @@ DCPOMATIC_DISABLE_WARNINGS DCPOMATIC_ENABLE_WARNINGS +using std::dynamic_pointer_cast; +using std::make_shared; using std::map; -using std::string; using std::shared_ptr; +using std::string; using boost::bind; -using std::dynamic_pointer_cast; using boost::optional; using namespace dcpomatic; #if BOOST_VERSION >= 106100 @@ -68,7 +69,7 @@ SubtitleAppearanceDialog::SubtitleAppearanceDialog (wxWindow* parent, shared_ptr /* XXX: assuming that all FFmpeg streams have bitmap subs */ if (_stream->colours().empty()) { _job_manager_connection = JobManager::instance()->ActiveJobsChanged.connect(boost::bind(&SubtitleAppearanceDialog::active_jobs_changed, this, _1)); - _job = JobManager::instance()->add(shared_ptr(new ExamineFFmpegSubtitlesJob(film, ff))); + _job = JobManager::instance()->add(make_shared(film, ff)); } } -- 2.30.2