Replace deprecated std::auto_ptr with new std::unique_ptr.
This commit is contained in:
parent
823aed98a1
commit
38207e4ea7
|
@ -197,13 +197,13 @@ return out.str();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::auto_ptr<Preset> IdlePresets::allocate(const std::string & name, PresetOutputs & presetOutputs)
|
std::unique_ptr<Preset> IdlePresets::allocate(const std::string & name, PresetOutputs & presetOutputs)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (name == IDLE_PRESET_NAME) {
|
if (name == IDLE_PRESET_NAME) {
|
||||||
std::istringstream in(presetText());
|
std::istringstream in(presetText());
|
||||||
return std::auto_ptr<Preset>(new MilkdropPreset(in, IDLE_PRESET_NAME, presetOutputs));
|
return std::unique_ptr<Preset>(new MilkdropPreset(in, IDLE_PRESET_NAME, presetOutputs));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return std::auto_ptr<Preset>(0);
|
return std::unique_ptr<Preset>(nullptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ class IdlePresets {
|
||||||
public:
|
public:
|
||||||
/// Allocate a new idle preset instance
|
/// Allocate a new idle preset instance
|
||||||
/// \returns a newly allocated auto pointer of an idle preset instance
|
/// \returns a newly allocated auto pointer of an idle preset instance
|
||||||
static std::auto_ptr<Preset> allocate(const std::string & path, PresetOutputs & outputs);
|
static std::unique_ptr<Preset> allocate(const std::string & path, PresetOutputs & outputs);
|
||||||
private:
|
private:
|
||||||
static std::string presetText();
|
static std::string presetText();
|
||||||
static const std::string IDLE_PRESET_NAME;
|
static const std::string IDLE_PRESET_NAME;
|
||||||
|
|
|
@ -212,7 +212,7 @@ PresetOutputs* MilkdropPresetFactory::createPresetOutputs(int gx, int gy)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::auto_ptr<Preset> MilkdropPresetFactory::allocate(const std::string & url, const std::string & name, const std::string & author) {
|
std::unique_ptr<Preset> MilkdropPresetFactory::allocate(const std::string & url, const std::string & name, const std::string & author) {
|
||||||
|
|
||||||
PresetOutputs *presetOutputs = _usePresetOutputs ? _presetOutputs : _presetOutputs2;
|
PresetOutputs *presetOutputs = _usePresetOutputs ? _presetOutputs : _presetOutputs2;
|
||||||
|
|
||||||
|
@ -223,5 +223,5 @@ std::auto_ptr<Preset> MilkdropPresetFactory::allocate(const std::string & url, c
|
||||||
if (PresetFactory::protocol(url, path) == PresetFactory::IDLE_PRESET_PROTOCOL) {
|
if (PresetFactory::protocol(url, path) == PresetFactory::IDLE_PRESET_PROTOCOL) {
|
||||||
return IdlePresets::allocate(path, *presetOutputs);
|
return IdlePresets::allocate(path, *presetOutputs);
|
||||||
} else
|
} else
|
||||||
return std::auto_ptr<Preset>(new MilkdropPreset(url, name, *presetOutputs));
|
return std::unique_ptr<Preset>(new MilkdropPreset(url, name, *presetOutputs));
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
|
|
||||||
virtual ~MilkdropPresetFactory();
|
virtual ~MilkdropPresetFactory();
|
||||||
|
|
||||||
std::auto_ptr<Preset> allocate(const std::string & url, const std::string & name = std::string(),
|
std::unique_ptr<Preset> allocate(const std::string & url, const std::string & name = std::string(),
|
||||||
const std::string & author = std::string());
|
const std::string & author = std::string());
|
||||||
|
|
||||||
std::string supportedExtensions() const { return "milk prjm"; }
|
std::string supportedExtensions() const { return "milk prjm"; }
|
||||||
|
|
|
@ -1451,7 +1451,7 @@ InitCond * Parser::parse_init_cond(std::istream & fs, char * name, MilkdropPres
|
||||||
if (PARSE_DEBUG) printf("parsed_init_cond: parsing initial condition value... (LINE %d)\n", line_count);
|
if (PARSE_DEBUG) printf("parsed_init_cond: parsing initial condition value... (LINE %d)\n", line_count);
|
||||||
|
|
||||||
/* integer value (boolean is an integer in C) */
|
/* integer value (boolean is an integer in C) */
|
||||||
if ( (param->type == P_TYPE_BOOL))
|
if ( param->type == P_TYPE_BOOL)
|
||||||
{
|
{
|
||||||
int bool_test;
|
int bool_test;
|
||||||
if ((parse_int(fs, &bool_test)) == PROJECTM_PARSE_ERROR)
|
if ((parse_int(fs, &bool_test)) == PROJECTM_PARSE_ERROR)
|
||||||
|
@ -1462,7 +1462,7 @@ InitCond * Parser::parse_init_cond(std::istream & fs, char * name, MilkdropPres
|
||||||
init_val.bool_val = bool_test;
|
init_val.bool_val = bool_test;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ((param->type == P_TYPE_INT))
|
else if (param->type == P_TYPE_INT)
|
||||||
{
|
{
|
||||||
if ((parse_int(fs, (int*)&init_val.int_val)) == PROJECTM_PARSE_ERROR)
|
if ((parse_int(fs, (int*)&init_val.int_val)) == PROJECTM_PARSE_ERROR)
|
||||||
{
|
{
|
||||||
|
@ -1578,7 +1578,7 @@ InitCond * Parser::parse_per_frame_init_eqn(std::istream & fs, MilkdropPreset *
|
||||||
init_val.bool_val = (bool)val;
|
init_val.bool_val = (bool)val;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ((param->type == P_TYPE_INT))
|
else if (param->type == P_TYPE_INT)
|
||||||
{
|
{
|
||||||
init_val.int_val = (int)val;
|
init_val.int_val = (int)val;
|
||||||
}
|
}
|
||||||
|
@ -1771,7 +1771,7 @@ int Parser::parse_wavecode(char * token, std::istream & fs, MilkdropPreset * pr
|
||||||
|
|
||||||
/* integer value (boolean is an integer in C) */
|
/* integer value (boolean is an integer in C) */
|
||||||
|
|
||||||
if ((param->type == P_TYPE_BOOL))
|
if (param->type == P_TYPE_BOOL)
|
||||||
{
|
{
|
||||||
int bool_test;
|
int bool_test;
|
||||||
if ((parse_int(fs, &bool_test)) == PROJECTM_PARSE_ERROR)
|
if ((parse_int(fs, &bool_test)) == PROJECTM_PARSE_ERROR)
|
||||||
|
@ -1782,7 +1782,7 @@ int Parser::parse_wavecode(char * token, std::istream & fs, MilkdropPreset * pr
|
||||||
}
|
}
|
||||||
init_val.bool_val = bool_test;
|
init_val.bool_val = bool_test;
|
||||||
}
|
}
|
||||||
else if ((param->type == P_TYPE_INT))
|
else if (param->type == P_TYPE_INT)
|
||||||
{
|
{
|
||||||
if ((parse_int(fs, (int*)&init_val.int_val)) == PROJECTM_PARSE_ERROR)
|
if ((parse_int(fs, (int*)&init_val.int_val)) == PROJECTM_PARSE_ERROR)
|
||||||
{
|
{
|
||||||
|
@ -1897,7 +1897,7 @@ int Parser::parse_shapecode(char * token, std::istream & fs, MilkdropPreset * p
|
||||||
/* integer value (boolean is an integer in C) */
|
/* integer value (boolean is an integer in C) */
|
||||||
|
|
||||||
|
|
||||||
if ((param->type == P_TYPE_BOOL))
|
if (param->type == P_TYPE_BOOL)
|
||||||
{
|
{
|
||||||
int bool_test;
|
int bool_test;
|
||||||
if ((parse_int(fs, &bool_test)) == PROJECTM_PARSE_ERROR)
|
if ((parse_int(fs, &bool_test)) == PROJECTM_PARSE_ERROR)
|
||||||
|
@ -1907,7 +1907,7 @@ int Parser::parse_shapecode(char * token, std::istream & fs, MilkdropPreset * p
|
||||||
}
|
}
|
||||||
init_val.bool_val = bool_test;
|
init_val.bool_val = bool_test;
|
||||||
}
|
}
|
||||||
else if ((param->type == P_TYPE_INT))
|
else if (param->type == P_TYPE_INT)
|
||||||
{
|
{
|
||||||
if ((parse_int(fs, (int*)&init_val.int_val)) == PROJECTM_PARSE_ERROR)
|
if ((parse_int(fs, (int*)&init_val.int_val)) == PROJECTM_PARSE_ERROR)
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
/// \param presetInputs the preset inputs to associate with the preset upon construction
|
/// \param presetInputs the preset inputs to associate with the preset upon construction
|
||||||
/// \param presetOutputs the preset outputs to associate with the preset upon construction
|
/// \param presetOutputs the preset outputs to associate with the preset upon construction
|
||||||
/// \returns an autopointer of the newly allocated preset
|
/// \returns an autopointer of the newly allocated preset
|
||||||
std::auto_ptr<Preset> allocate();
|
std::unique_ptr<Preset> allocate();
|
||||||
|
|
||||||
/// Set the chooser asocciated with this iterator
|
/// Set the chooser asocciated with this iterator
|
||||||
void setChooser(const PresetChooser & chooser);
|
void setChooser(const PresetChooser & chooser);
|
||||||
|
@ -71,7 +71,7 @@ public:
|
||||||
/// \param presetInputs the preset inputs to associate with the preset upon construction
|
/// \param presetInputs the preset inputs to associate with the preset upon construction
|
||||||
/// \param presetOutputs the preset outputs to associate with the preset upon construction
|
/// \param presetOutputs the preset outputs to associate with the preset upon construction
|
||||||
/// \returns an auto pointer of the newly allocated preset
|
/// \returns an auto pointer of the newly allocated preset
|
||||||
std::auto_ptr<Preset> directoryIndex(std::size_t index) const;
|
std::unique_ptr<Preset> directoryIndex(std::size_t index) const;
|
||||||
|
|
||||||
/// Gets the number of presets last believed to exist in the preset loader's filename collection
|
/// Gets the number of presets last believed to exist in the preset loader's filename collection
|
||||||
/// \returns the number of presets in the collection
|
/// \returns the number of presets in the collection
|
||||||
|
@ -145,7 +145,7 @@ inline bool PresetIterator::operator ==(const PresetIterator & presetPos) const
|
||||||
return (*presetPos == **this);
|
return (*presetPos == **this);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::auto_ptr<Preset> PresetIterator::allocate() {
|
inline std::unique_ptr<Preset> PresetIterator::allocate() {
|
||||||
return _presetChooser->directoryIndex(_currentIndex);
|
return _presetChooser->directoryIndex(_currentIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ inline bool PresetChooser::empty() const {
|
||||||
return _presetLoader->size() == 0;
|
return _presetLoader->size() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::auto_ptr<Preset> PresetChooser::directoryIndex(std::size_t index) const {
|
inline std::unique_ptr<Preset> PresetChooser::directoryIndex(std::size_t index) const {
|
||||||
|
|
||||||
return _presetLoader->loadPreset(index);
|
return _presetLoader->loadPreset(index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public:
|
||||||
/// \param name the preset name
|
/// \param name the preset name
|
||||||
/// \param author the preset author
|
/// \param author the preset author
|
||||||
/// \returns a valid preset object
|
/// \returns a valid preset object
|
||||||
virtual std::auto_ptr<Preset> allocate(const std::string & url, const std::string & name=std::string(),
|
virtual std::unique_ptr<Preset> allocate(const std::string & url, const std::string & name=std::string(),
|
||||||
const std::string & author=std::string()) = 0;
|
const std::string & author=std::string()) = 0;
|
||||||
|
|
||||||
/// Returns a space separated list of supported extensions
|
/// Returns a space separated list of supported extensions
|
||||||
|
|
|
@ -130,7 +130,7 @@ void PresetLoader::rescan()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::auto_ptr<Preset> PresetLoader::loadPreset ( unsigned int index ) const
|
std::unique_ptr<Preset> PresetLoader::loadPreset ( unsigned int index ) const
|
||||||
{
|
{
|
||||||
|
|
||||||
// Check that index isn't insane
|
// Check that index isn't insane
|
||||||
|
@ -146,7 +146,7 @@ std::auto_ptr<Preset> PresetLoader::loadPreset ( unsigned int index ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::auto_ptr<Preset> PresetLoader::loadPreset ( const std::string & url ) const
|
std::unique_ptr<Preset> PresetLoader::loadPreset ( const std::string & url ) const
|
||||||
{
|
{
|
||||||
|
|
||||||
// Return a new autopointer to a preset
|
// Return a new autopointer to a preset
|
||||||
|
|
|
@ -36,8 +36,8 @@ class PresetLoader {
|
||||||
|
|
||||||
/// Load a preset by specifying it's unique identifier given when the preset url
|
/// Load a preset by specifying it's unique identifier given when the preset url
|
||||||
/// was added to this loader
|
/// was added to this loader
|
||||||
std::auto_ptr<Preset> loadPreset(unsigned int index) const;
|
std::unique_ptr<Preset> loadPreset(unsigned int index) const;
|
||||||
std::auto_ptr<Preset> loadPreset ( const std::string & url ) const;
|
std::unique_ptr<Preset> loadPreset ( const std::string & url ) const;
|
||||||
/// Add a preset to the loader's collection.
|
/// Add a preset to the loader's collection.
|
||||||
/// \param url an url referencing the preset
|
/// \param url an url referencing the preset
|
||||||
/// \param presetName a name for the preset
|
/// \param presetName a name for the preset
|
||||||
|
|
|
@ -46,6 +46,8 @@
|
||||||
#include "PCM.hpp" //Sound data handler (buffering, FFT, etc.)
|
#include "PCM.hpp" //Sound data handler (buffering, FFT, etc.)
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
|
||||||
#include "Renderer.hpp"
|
#include "Renderer.hpp"
|
||||||
#include "PresetChooser.hpp"
|
#include "PresetChooser.hpp"
|
||||||
|
@ -415,7 +417,7 @@ static void *thread_callback(void *prjm) {
|
||||||
if ( timeKeeper->IsSmoothing() && timeKeeper->SmoothRatio() > 1.0 )
|
if ( timeKeeper->IsSmoothing() && timeKeeper->SmoothRatio() > 1.0 )
|
||||||
{
|
{
|
||||||
//printf("End Smooth\n");
|
//printf("End Smooth\n");
|
||||||
m_activePreset = m_activePreset2;
|
m_activePreset = std::move(m_activePreset2);
|
||||||
timeKeeper->EndSmoothing();
|
timeKeeper->EndSmoothing();
|
||||||
}
|
}
|
||||||
//printf("Normal\n");
|
//printf("Normal\n");
|
||||||
|
@ -789,7 +791,7 @@ void projectM::selectNext(const bool hardCut) {
|
||||||
*
|
*
|
||||||
* @param targetPreset
|
* @param targetPreset
|
||||||
*/
|
*/
|
||||||
void projectM::switchPreset(std::auto_ptr<Preset> & targetPreset) {
|
void projectM::switchPreset(std::unique_ptr<Preset> & targetPreset) {
|
||||||
|
|
||||||
#ifdef SYNC_PRESET_SWITCHES
|
#ifdef SYNC_PRESET_SWITCHES
|
||||||
pthread_mutex_lock(&preset_mutex);
|
pthread_mutex_lock(&preset_mutex);
|
||||||
|
|
|
@ -302,10 +302,10 @@ private:
|
||||||
PresetChooser * m_presetChooser;
|
PresetChooser * m_presetChooser;
|
||||||
|
|
||||||
/// Currently loaded preset
|
/// Currently loaded preset
|
||||||
std::auto_ptr<Preset> m_activePreset;
|
std::unique_ptr<Preset> m_activePreset;
|
||||||
|
|
||||||
/// Destination preset when smooth preset switching
|
/// Destination preset when smooth preset switching
|
||||||
std::auto_ptr<Preset> m_activePreset2;
|
std::unique_ptr<Preset> m_activePreset2;
|
||||||
|
|
||||||
TimeKeeper *timeKeeper;
|
TimeKeeper *timeKeeper;
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ private:
|
||||||
|
|
||||||
Pipeline* currentPipe;
|
Pipeline* currentPipe;
|
||||||
|
|
||||||
void switchPreset(std::auto_ptr<Preset> & targetPreset);
|
void switchPreset(std::unique_ptr<Preset> & targetPreset);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue