Pass unique_ptrs around by value

This commit is contained in:
Thomas Goyne 2013-09-16 06:43:17 -07:00
parent 40a0d8b2f7
commit af2028e971
20 changed files with 28 additions and 28 deletions

View file

@ -50,7 +50,7 @@ AssExportFilter::AssExportFilter(std::string const& name, std::string const& des
{
}
void AssExportFilterChain::Register(std::unique_ptr<AssExportFilter>&& filter) {
void AssExportFilterChain::Register(std::unique_ptr<AssExportFilter> filter) {
int filter_copy = 1;
std::string name = filter->name;
// Find a unique name

View file

@ -87,7 +87,7 @@ typedef boost::intrusive::make_list<AssExportFilter, boost::intrusive::constant_
class AssExportFilterChain {
public:
/// Register an export filter
static void Register(std::unique_ptr<AssExportFilter>&& filter);
static void Register(std::unique_ptr<AssExportFilter> filter);
/// Unregister and delete all export filters
static void Clear();
/// Get a filter by name or nullptr if it doesn't exist

View file

@ -48,7 +48,7 @@
AssStyleStorage::~AssStyleStorage() { }
void AssStyleStorage::clear() { style.clear(); }
void AssStyleStorage::push_back( std::unique_ptr<AssStyle>&& new_style ) { style.emplace_back(std::move(new_style)); }
void AssStyleStorage::push_back(std::unique_ptr<AssStyle> new_style) { style.emplace_back(std::move(new_style)); }
void AssStyleStorage::Save() const {
if (file.empty()) return;

View file

@ -54,7 +54,7 @@ public:
iterator end() { return style.end(); }
const_iterator begin() const { return style.begin(); }
const_iterator end() const { return style.end(); }
void push_back(std::unique_ptr<AssStyle>&& new_style);
void push_back(std::unique_ptr<AssStyle> new_style);
AssStyle *back() { return style.back().get(); }
AssStyle *operator[](size_t idx) const { return style[idx].get(); }
size_t size() const { return style.size(); }

View file

@ -36,7 +36,7 @@ class AudioProviderConverter : public AudioProvider {
protected:
std::unique_ptr<AudioProvider> source;
public:
AudioProviderConverter(std::unique_ptr<AudioProvider>&& src)
AudioProviderConverter(std::unique_ptr<AudioProvider> src)
: source(std::move(src))
{
channels = source->GetChannels();
@ -54,7 +54,7 @@ template<class Target>
class BitdepthConvertAudioProvider : public AudioProviderConverter {
int src_bytes_per_sample;
public:
BitdepthConvertAudioProvider(std::unique_ptr<AudioProvider>&& src) : AudioProviderConverter(std::move(src)) {
BitdepthConvertAudioProvider(std::unique_ptr<AudioProvider> src) : AudioProviderConverter(std::move(src)) {
if (bytes_per_sample > 8)
throw agi::AudioProviderOpenError("Audio format converter: audio with bitdepths greater than 64 bits/sample is currently unsupported", 0);
@ -94,7 +94,7 @@ public:
template<class Source, class Target>
class FloatConvertAudioProvider : public AudioProviderConverter {
public:
FloatConvertAudioProvider(std::unique_ptr<AudioProvider>&& src) : AudioProviderConverter(std::move(src)) {
FloatConvertAudioProvider(std::unique_ptr<AudioProvider> src) : AudioProviderConverter(std::move(src)) {
bytes_per_sample = sizeof(Target);
float_samples = false;
}
@ -126,7 +126,7 @@ public:
class DownmixAudioProvider : public AudioProviderConverter {
int src_channels;
public:
DownmixAudioProvider(std::unique_ptr<AudioProvider>&& src) : AudioProviderConverter(std::move(src)) {
DownmixAudioProvider(std::unique_ptr<AudioProvider> src) : AudioProviderConverter(std::move(src)) {
if (bytes_per_sample != 2)
throw agi::InternalError("DownmixAudioProvider requires 16-bit input", 0);
if (channels == 1)
@ -156,7 +156,7 @@ public:
/// Requires 16-bit mono input
class SampleDoublingAudioProvider : public AudioProviderConverter {
public:
SampleDoublingAudioProvider(std::unique_ptr<AudioProvider>&& src) : AudioProviderConverter(std::move(src)) {
SampleDoublingAudioProvider(std::unique_ptr<AudioProvider> src) : AudioProviderConverter(std::move(src)) {
if (source->GetBytesPerSample() != 2)
throw agi::InternalError("UpsampleAudioProvider requires 16-bit input", 0);
if (source->GetChannels() != 1)
@ -192,7 +192,7 @@ public:
}
};
std::unique_ptr<AudioProvider> CreateConvertAudioProvider(std::unique_ptr<AudioProvider>&& provider) {
std::unique_ptr<AudioProvider> CreateConvertAudioProvider(std::unique_ptr<AudioProvider> provider) {
// Ensure 16-bit audio with proper endianness
if (provider->AreSamplesFloat()) {
LOG_D("audio_provider") << "Converting float to S16";
@ -218,5 +218,5 @@ std::unique_ptr<AudioProvider> CreateConvertAudioProvider(std::unique_ptr<AudioP
provider = agi::util::make_unique<SampleDoublingAudioProvider>(std::move(provider));
}
return std::move(provider);
return provider;
}

View file

@ -24,4 +24,4 @@
class AudioProvider;
/// Get an audio provider which supplies audio in a format supported by Aegisub's players
std::unique_ptr<AudioProvider> CreateConvertAudioProvider(std::unique_ptr<AudioProvider>&& source_provider);
std::unique_ptr<AudioProvider> CreateConvertAudioProvider(std::unique_ptr<AudioProvider> source_provider);

View file

@ -89,7 +89,7 @@ public:
}
HDAudioProvider::HDAudioProvider(std::unique_ptr<AudioProvider>&& src, agi::BackgroundRunner *br) {
HDAudioProvider::HDAudioProvider(std::unique_ptr<AudioProvider> src, agi::BackgroundRunner *br) {
bytes_per_sample = src->GetBytesPerSample();
num_samples = src->GetNumSamples();
channels = src->GetChannels();

View file

@ -54,6 +54,6 @@ class HDAudioProvider : public AudioProvider {
void FillBuffer(void *buf, int64_t start, int64_t count) const;
public:
HDAudioProvider(std::unique_ptr<AudioProvider>&& source, agi::BackgroundRunner *br);
HDAudioProvider(std::unique_ptr<AudioProvider> source, agi::BackgroundRunner *br);
~HDAudioProvider();
};

View file

@ -20,7 +20,7 @@
#include "audio_provider_lock.h"
LockAudioProvider::LockAudioProvider(std::unique_ptr<AudioProvider>&& src)
LockAudioProvider::LockAudioProvider(std::unique_ptr<AudioProvider> src)
: source(std::move(src))
{
channels = source->GetChannels();

View file

@ -27,5 +27,5 @@ class LockAudioProvider : public AudioProvider {
void FillBuffer(void *buf, int64_t start, int64_t count) const;
public:
LockAudioProvider(std::unique_ptr<AudioProvider>&& source);
LockAudioProvider(std::unique_ptr<AudioProvider> source);
};

View file

@ -46,7 +46,7 @@
#define CacheBits 22
#define CacheBlockSize (1 << CacheBits)
RAMAudioProvider::RAMAudioProvider(std::unique_ptr<AudioProvider>&& src, agi::BackgroundRunner *br) {
RAMAudioProvider::RAMAudioProvider(std::unique_ptr<AudioProvider> src, agi::BackgroundRunner *br) {
try {
blockcache.resize((src->GetNumSamples() * src->GetBytesPerSample() + CacheBlockSize - 1) >> CacheBits);
}

View file

@ -53,5 +53,5 @@ class RAMAudioProvider : public AudioProvider {
void FillBuffer(void *buf, int64_t start, int64_t count) const;
public:
RAMAudioProvider(std::unique_ptr<AudioProvider>&& source, agi::BackgroundRunner *br);
RAMAudioProvider(std::unique_ptr<AudioProvider> source, agi::BackgroundRunner *br);
};

View file

@ -291,7 +291,7 @@ namespace Automation4 {
{
}
void ScriptManager::Add(std::unique_ptr<Script>&& script)
void ScriptManager::Add(std::unique_ptr<Script> script)
{
if (find(scripts.begin(), scripts.end(), script) == scripts.end())
scripts.emplace_back(std::move(script));
@ -460,7 +460,7 @@ namespace Automation4 {
{
}
void ScriptFactory::Register(std::unique_ptr<ScriptFactory>&& factory)
void ScriptFactory::Register(std::unique_ptr<ScriptFactory> factory)
{
if (find(Factories().begin(), Factories().end(), factory) != Factories().end())
throw agi::InternalError("Automation 4: Attempt to register the same script factory multiple times. This should never happen.", 0);

View file

@ -197,7 +197,7 @@ namespace Automation4 {
/// Deletes all scripts managed
virtual ~ScriptManager();
/// Add a script to the manager.
void Add(std::unique_ptr<Script>&& script);
void Add(std::unique_ptr<Script> script);
/// Remove a script from the manager, and delete the Script object.
void Remove(Script *script);
/// Deletes all scripts managed
@ -265,7 +265,7 @@ namespace Automation4 {
const std::string& GetFilenamePattern() const { return filename_pattern; }
/// Register an automation engine.
static void Register(std::unique_ptr<ScriptFactory>&& factory);
static void Register(std::unique_ptr<ScriptFactory> factory);
/// Get the full wildcard string for all loaded engines
static std::string GetWildcardStr();

View file

@ -36,7 +36,7 @@ namespace cmd {
return it;
}
void reg(std::unique_ptr<Command>&& cmd) {
void reg(std::unique_ptr<Command> cmd) {
cmd_map[cmd->name()] = std::move(cmd);
}

View file

@ -138,7 +138,7 @@ namespace cmd {
/// Register a command.
/// @param cmd Command object to register.
void reg(std::unique_ptr<Command>&& cmd);
void reg(std::unique_ptr<Command> cmd);
/// Unregister a command.
/// @param cmd Command name to unregister. The associated command object is deleted.

View file

@ -590,7 +590,7 @@ Advanced_Video::Advanced_Video(wxTreebook *book, Preferences *parent): OptionPag
SetSizerAndFit(sizer);
}
void Preferences::SetOption(std::unique_ptr<agi::OptionValue>&& new_value) {
void Preferences::SetOption(std::unique_ptr<agi::OptionValue> new_value) {
pending_changes[new_value->GetName()] = std::move(new_value);
if (IsEnabled())
applyButton->Enable(true);

View file

@ -56,7 +56,7 @@ public:
/// Add an option to be set when the OK or Apply button is clicked
/// @param new_value Clone of the option with the new value to copy over
void SetOption(std::unique_ptr<agi::OptionValue>&& new_value);
void SetOption(std::unique_ptr<agi::OptionValue> new_value);
/// All a function to call when the OK or Apply button is clicked
/// @param callback Function to call

View file

@ -407,7 +407,7 @@ void VideoDisplay::SetZoomFromBoxText(wxCommandEvent &) {
SetZoom(value / 100.);
}
void VideoDisplay::SetTool(std::unique_ptr<VisualToolBase>&& new_tool) {
void VideoDisplay::SetTool(std::unique_ptr<VisualToolBase> new_tool) {
toolBar->ClearTools();
toolBar->Realize();
toolBar->Show(false);

View file

@ -160,7 +160,7 @@ public:
/// Get the last seen position of the mouse in script coordinates
Vector2D GetMousePosition() const;
void SetTool(std::unique_ptr<VisualToolBase>&& new_tool);
void SetTool(std::unique_ptr<VisualToolBase> new_tool);
bool ToolIsType(std::type_info const& type) const;