Skip to content

Commit

Permalink
COMP: Remove use of std::auto_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
barche committed Feb 28, 2018
1 parent 0d9b71a commit 3c0f93e
Show file tree
Hide file tree
Showing 38 changed files with 157 additions and 157 deletions.
6 changes: 3 additions & 3 deletions k3dsdk/data.h
Expand Up @@ -1534,7 +1534,7 @@ class iconstraint
virtual void on_constrain(value_t& Value) = 0;

/// Storage for the (optional) next constraint to apply in the chain
const std::auto_ptr<iconstraint<value_t> > m_next_constraint;
const std::unique_ptr<iconstraint<value_t> > m_next_constraint;
};

namespace constraint
Expand Down Expand Up @@ -1650,7 +1650,7 @@ class with_constraint :

private:
/// Stores the (mandatory) chain of constraint nodes to apply to incoming values
const std::auto_ptr<iconstraint<value_t> > m_constraint;
const std::unique_ptr<iconstraint<value_t> > m_constraint;
};

/////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -2058,7 +2058,7 @@ class pointer_storage :

private:
/// Storage for this policy's value
std::auto_ptr<non_pointer_t> m_value;
std::unique_ptr<non_pointer_t> m_value;
/// Set to true if this policy's value is stale and needs to be updated
bool m_update;
/// Stores a slot that will be executed to initialize this policy's value
Expand Down
20 changes: 10 additions & 10 deletions k3dsdk/document.cpp
Expand Up @@ -98,7 +98,7 @@ class state_recorder_implementation :
delete Node;
}

void start_recording(std::auto_ptr<state_change_set> ChangeSet, const char* const Context)
void start_recording(std::unique_ptr<state_change_set> ChangeSet, const char* const Context)
{
if(!ChangeSet.get())
{
Expand All @@ -109,11 +109,11 @@ class state_recorder_implementation :
if(m_current_recording.get())
{
log() << warning << "Forcing termination of unfinished changeset. Context: " << m_current_context << std::endl;
std::auto_ptr<state_change_set> changeset = stop_recording(Context);
commit_change_set(changeset, "Unfinished changeset", Context);
std::unique_ptr<state_change_set> changeset = stop_recording(Context);
commit_change_set(std::move(changeset), "Unfinished changeset", Context);
}

m_current_recording = ChangeSet;
m_current_recording = std::move(ChangeSet);
m_current_context = Context;
}

Expand All @@ -122,12 +122,12 @@ class state_recorder_implementation :
return m_current_recording.get();
}

std::auto_ptr<state_change_set> stop_recording(const char* const Context)
std::unique_ptr<state_change_set> stop_recording(const char* const Context)
{
if(!m_current_recording.get())
{
log() << error << "stop_recording() attempt with NULL changeset. Context: " << Context << std::endl;
return m_current_recording;
return std::move(m_current_recording);
}

// Let the world know that recording is finished ...
Expand All @@ -137,10 +137,10 @@ class state_recorder_implementation :
sigc::signal<void>::slot_list_type slots = m_recording_done_signal.slots();
slots.erase(slots.begin(), slots.end());

return m_current_recording;
return std::move(m_current_recording);
}

void commit_change_set(std::auto_ptr<state_change_set> ChangeSet, const std::string& Label, const char* const Context)
void commit_change_set(std::unique_ptr<state_change_set> ChangeSet, const std::string& Label, const char* const Context)
{
if(!ChangeSet.get())
{
Expand Down Expand Up @@ -229,7 +229,7 @@ class state_recorder_implementation :

private:
/// Stores the current change set
std::auto_ptr<state_change_set> m_current_recording;
std::unique_ptr<state_change_set> m_current_recording;
/// Stores the context for the current change set
const char* m_current_context;
/// Stores the root node(s) (if any)
Expand Down Expand Up @@ -546,7 +546,7 @@ documents_t& documents()

idocument* create_document()
{
std::auto_ptr<detail::document_implementation> document(new detail::document_implementation());
std::unique_ptr<detail::document_implementation> document(new detail::document_implementation());
detail::documents().push_back(document.get());
return document.release()->m_document;
}
Expand Down
4 changes: 2 additions & 2 deletions k3dsdk/explicit_snap_source.h
Expand Up @@ -48,8 +48,8 @@ class explicit_snap_source :

std::string m_label;
k3d::point3 m_position;
std::auto_ptr<k3d::vector3> m_look;
std::auto_ptr<k3d::vector3> m_up;
std::unique_ptr<k3d::vector3> m_look;
std::unique_ptr<k3d::vector3> m_up;
groups_t m_groups;
};

Expand Down
4 changes: 2 additions & 2 deletions k3dsdk/explicit_snap_target.h
Expand Up @@ -49,8 +49,8 @@ class explicit_snap_target :

std::string m_label;
k3d::point3 m_position;
std::auto_ptr<k3d::vector3> m_look;
std::auto_ptr<k3d::vector3> m_up;
std::unique_ptr<k3d::vector3> m_look;
std::unique_ptr<k3d::vector3> m_up;
groups_t m_groups;
};

Expand Down
6 changes: 3 additions & 3 deletions k3dsdk/istate_recorder.h
Expand Up @@ -42,13 +42,13 @@ class istate_recorder :
{
public:
/// Called by clients to register a change set for recording subsequent state changes (the recorder assumes responsibility for the lifetime of the changeset)
virtual void start_recording(std::auto_ptr<state_change_set> ChangeSet, const char* const DebugLabel) = 0;
virtual void start_recording(std::unique_ptr<state_change_set> ChangeSet, const char* const DebugLabel) = 0;
/// Returns the current change set being recorded (if any - could return NULL)
virtual state_change_set* current_change_set() = 0;
/// Called by clients to stop recording a set of state changes (the recorder relinquishes responsibility for the lifetime of the returned changeset)
virtual std::auto_ptr<state_change_set> stop_recording(const char* const DebugLabel) = 0;
virtual std::unique_ptr<state_change_set> stop_recording(const char* const DebugLabel) = 0;
/// Called by clients once a set of changes is complete, to make them a part of the undo/redo tree (the recorder assumes responsibility for the lifetime of the change set)
virtual void commit_change_set(std::auto_ptr<state_change_set> ChangeSet, const std::string& Label, const char* const DebugLabel) = 0;
virtual void commit_change_set(std::unique_ptr<state_change_set> ChangeSet, const std::string& Label, const char* const DebugLabel) = 0;

/// Defines a collection of "nodes" in the hierarchy of recorded state changes
struct node;
Expand Down
8 changes: 4 additions & 4 deletions k3dsdk/ngui/angle_axis.cpp
Expand Up @@ -142,9 +142,9 @@ class spin_button_model :
/////////////////////////////////////////////////////////////////////////////
// control

control::control(std::auto_ptr<idata_proxy> Data) :
control::control(std::unique_ptr<idata_proxy> Data) :
base(3, 3, false),
m_data(Data),
m_data(std::move(Data)),
m_reset_button(new Gtk::Button(_("Reset")))
{
spin_button::control* const x = new spin_button::control(new spin_button_model(*m_data, 0), m_data->state_recorder);
Expand Down Expand Up @@ -181,9 +181,9 @@ void control::on_reset()
/////////////////////////////////////////////////////////////////////////////
// proxy

std::auto_ptr<idata_proxy> proxy(k3d::iproperty& Property, k3d::istate_recorder* const StateRecorder, const Glib::ustring& ChangeMessage)
std::unique_ptr<idata_proxy> proxy(k3d::iproperty& Property, k3d::istate_recorder* const StateRecorder, const Glib::ustring& ChangeMessage)
{
return std::auto_ptr<idata_proxy>(new detail::data_proxy(Property, StateRecorder, ChangeMessage));
return std::unique_ptr<idata_proxy>(new detail::data_proxy(Property, StateRecorder, ChangeMessage));
}

} // namespace angle_axis
Expand Down
6 changes: 3 additions & 3 deletions k3dsdk/ngui/angle_axis.h
Expand Up @@ -90,14 +90,14 @@ class control :
typedef Gtk::Table base;

public:
control(std::auto_ptr<idata_proxy> Data);
control(std::unique_ptr<idata_proxy> Data);

private:
/// Called to reset the object orientation to the origin
void on_reset();

/// Stores a reference to the underlying data object
std::auto_ptr<idata_proxy> m_data;
std::unique_ptr<idata_proxy> m_data;
/// Stores the reset button
Gtk::Button* const m_reset_button;
};
Expand All @@ -106,7 +106,7 @@ class control :
// proxy

/// Convenience factory function for creating k3d::spin_button::idata_proxy objects, specialized for k3d::iproperty
std::auto_ptr<idata_proxy> proxy(k3d::iproperty& Data, k3d::istate_recorder* const StateRecorder = 0, const Glib::ustring& ChangeMessage = Glib::ustring());
std::unique_ptr<idata_proxy> proxy(k3d::iproperty& Data, k3d::istate_recorder* const StateRecorder = 0, const Glib::ustring& ChangeMessage = Glib::ustring());

} // namespace angle_axis

Expand Down
8 changes: 4 additions & 4 deletions k3dsdk/ngui/bitmap_preview.cpp
Expand Up @@ -72,21 +72,21 @@ class property_proxy :
k3d::iproperty& m_readable_data;
};

std::auto_ptr<idata_proxy> proxy(k3d::iproperty& Data)
std::unique_ptr<idata_proxy> proxy(k3d::iproperty& Data)
{
return std::auto_ptr<idata_proxy>(new property_proxy(Data));
return std::unique_ptr<idata_proxy>(new property_proxy(Data));
}

/////////////////////////////////////////////////////////////////////////////
// control

control::control(std::auto_ptr<idata_proxy> Data) :
control::control(std::unique_ptr<idata_proxy> Data) :
base(Gtk::BUTTONBOX_START, 2),
m_image_buffer(64, 64),
m_alpha_buffer(64, 64),
m_image(new Gtk::Image()),
m_alpha(new Gtk::Image()),
m_data(Data)
m_data(std::move(Data))
{
pack_start(*manage(m_image), Gtk::PACK_SHRINK);
pack_start(*manage(m_alpha), Gtk::PACK_SHRINK);
Expand Down
10 changes: 5 additions & 5 deletions k3dsdk/ngui/bitmap_preview.h
Expand Up @@ -73,7 +73,7 @@ class control :
typedef Gtk::HButtonBox base;

public:
control(std::auto_ptr<idata_proxy> Data);
control(std::unique_ptr<idata_proxy> Data);

private:
/// Called whenever the underlying data changes
Expand All @@ -87,7 +87,7 @@ class control :
/// Displays the alpha channel
Gtk::Image* const m_alpha;
/// Storeas a reference to the underlying data object
std::auto_ptr<idata_proxy> m_data;
std::unique_ptr<idata_proxy> m_data;
};

/// Provides an implementation of bitmap_preview::idata_proxy that supports any data source that supports the value(), set_value(), and changed_signal() concepts
Expand Down Expand Up @@ -120,13 +120,13 @@ class data_proxy :

/// Convenience factory function for creating bitmap_preview::idata_proxy objects
template<typename data_t>
std::auto_ptr<idata_proxy> proxy(data_t& Data)
std::unique_ptr<idata_proxy> proxy(data_t& Data)
{
return std::auto_ptr<idata_proxy>(new data_proxy<data_t>(Data));
return std::unique_ptr<idata_proxy>(new data_proxy<data_t>(Data));
}

/// Specialization of proxy() for use with properties
std::auto_ptr<idata_proxy> proxy(k3d::iproperty& Data);
std::unique_ptr<idata_proxy> proxy(k3d::iproperty& Data);

} // namespace bitmap_preview

Expand Down
8 changes: 4 additions & 4 deletions k3dsdk/ngui/bounding_box.cpp
Expand Up @@ -138,9 +138,9 @@ class spin_button_model :
/////////////////////////////////////////////////////////////////////////////
// control

control::control(std::auto_ptr<idata_proxy> Data) :
control::control(std::unique_ptr<idata_proxy> Data) :
base(3, 3, false),
m_data(Data)
m_data(std::move(Data))
{
spin_button::control* const nx = new spin_button::control(new spin_button_model(*m_data, &k3d::bounding_box3::nx), m_data->state_recorder);
spin_button::control* const px = new spin_button::control(new spin_button_model(*m_data, &k3d::bounding_box3::px), m_data->state_recorder);
Expand All @@ -165,9 +165,9 @@ control::control(std::auto_ptr<idata_proxy> Data) :
/////////////////////////////////////////////////////////////////////////////
// proxy

std::auto_ptr<idata_proxy> proxy(k3d::iproperty& Property, k3d::istate_recorder* const StateRecorder, const Glib::ustring& ChangeMessage)
std::unique_ptr<idata_proxy> proxy(k3d::iproperty& Property, k3d::istate_recorder* const StateRecorder, const Glib::ustring& ChangeMessage)
{
return std::auto_ptr<idata_proxy>(new detail::data_proxy(Property, StateRecorder, ChangeMessage));
return std::unique_ptr<idata_proxy>(new detail::data_proxy(Property, StateRecorder, ChangeMessage));
}

} // namespace bounding_box
Expand Down
6 changes: 3 additions & 3 deletions k3dsdk/ngui/bounding_box.h
Expand Up @@ -91,18 +91,18 @@ class control :
typedef Gtk::Table base;

public:
control(std::auto_ptr<idata_proxy> Data);
control(std::unique_ptr<idata_proxy> Data);

private:
/// Stores a reference to the underlying data object
std::auto_ptr<idata_proxy> m_data;
std::unique_ptr<idata_proxy> m_data;
};

/////////////////////////////////////////////////////////////////////////////
// proxy

/// Convenience factory function for creating k3d::spin_button::idata_proxy objects, specialized for k3d::iproperty
std::auto_ptr<idata_proxy> proxy(k3d::iproperty& Data, k3d::istate_recorder* const StateRecorder = 0, const Glib::ustring& ChangeMessage = Glib::ustring());
std::unique_ptr<idata_proxy> proxy(k3d::iproperty& Data, k3d::istate_recorder* const StateRecorder = 0, const Glib::ustring& ChangeMessage = Glib::ustring());

} // namespace bounding_box

Expand Down
12 changes: 6 additions & 6 deletions k3dsdk/ngui/check_button.cpp
Expand Up @@ -82,26 +82,26 @@ class data_proxy<k3d::iproperty> :
k3d::iwritable_property* const m_writable_data;
};

std::auto_ptr<idata_proxy> proxy(k3d::iproperty& Data, k3d::istate_recorder* const StateRecorder, const Glib::ustring& ChangeMessage)
std::unique_ptr<idata_proxy> proxy(k3d::iproperty& Data, k3d::istate_recorder* const StateRecorder, const Glib::ustring& ChangeMessage)
{
return std::auto_ptr<idata_proxy>(new data_proxy<k3d::iproperty>(Data, StateRecorder, ChangeMessage));
return std::unique_ptr<idata_proxy>(new data_proxy<k3d::iproperty>(Data, StateRecorder, ChangeMessage));
}

/////////////////////////////////////////////////////////////////////////////
// control

control::control(std::auto_ptr<idata_proxy> Data) :
m_data(Data)
control::control(std::unique_ptr<idata_proxy> Data) :
m_data(std::move(Data))
{
set_name("k3d-check-button");
attach();

set_sensitive(m_data.get() && m_data->writable());
}

control::control(std::auto_ptr<idata_proxy> Data, const Glib::ustring& label, bool mnemonic) :
control::control(std::unique_ptr<idata_proxy> Data, const Glib::ustring& label, bool mnemonic) :
base(label, mnemonic),
m_data(Data)
m_data(std::move(Data))
{
set_name("k3d-check-button");
attach();
Expand Down
16 changes: 8 additions & 8 deletions k3dsdk/ngui/check_button.h
Expand Up @@ -90,8 +90,8 @@ class control :
typedef Gtk::CheckButton base;

public:
control(std::auto_ptr<idata_proxy> Data);
control(std::auto_ptr<idata_proxy> Data, const Glib::ustring& label, bool mnemonic = false);
control(std::unique_ptr<idata_proxy> Data);
control(std::unique_ptr<idata_proxy> Data, const Glib::ustring& label, bool mnemonic = false);

void on_toggled();

Expand All @@ -101,7 +101,7 @@ class control :
/// Called to update the state of the widget when the underlying data source changes
void update(k3d::ihint*);
/// Storeas a reference to the underlying data object
const std::auto_ptr<idata_proxy> m_data;
const std::unique_ptr<idata_proxy> m_data;
};

/// Provides an implementation of k3d::check_button::idata_proxy that supports any data source that supports the value(), set_value(), and changed_signal() concepts
Expand Down Expand Up @@ -145,18 +145,18 @@ class data_proxy :

/// Convenience factory function for creating check_button::idata_proxy objects
template<typename data_t>
std::auto_ptr<idata_proxy> proxy(data_t& Data, k3d::istate_recorder* const StateRecorder = 0, const Glib::ustring& ChangeMessage = Glib::ustring())
std::unique_ptr<idata_proxy> proxy(data_t& Data, k3d::istate_recorder* const StateRecorder = 0, const Glib::ustring& ChangeMessage = Glib::ustring())
{
return std::auto_ptr<idata_proxy>(new data_proxy<data_t>(Data, StateRecorder, ChangeMessage));
return std::unique_ptr<idata_proxy>(new data_proxy<data_t>(Data, StateRecorder, ChangeMessage));
}

/// Convenience factory function for creating check_button::idata_proxy objects specialized for use with k3d::iproperty
std::auto_ptr<idata_proxy> proxy(k3d::iproperty& Data, k3d::istate_recorder* const StateRecorder = 0, const Glib::ustring& ChangeMessage = Glib::ustring());
std::unique_ptr<idata_proxy> proxy(k3d::iproperty& Data, k3d::istate_recorder* const StateRecorder = 0, const Glib::ustring& ChangeMessage = Glib::ustring());

/// Convenience factory function for creating empty check_button::idata_proxy objects
inline std::auto_ptr<idata_proxy> proxy()
inline std::unique_ptr<idata_proxy> proxy()
{
return std::auto_ptr<idata_proxy>(0);
return std::unique_ptr<idata_proxy>(nullptr);
}

} // namespace check_button
Expand Down

0 comments on commit 3c0f93e

Please sign in to comment.