Refactored ParentTrack::remove_descendant_track

This commit is contained in:
Joel Holdsworth 2009-01-24 12:59:56 +00:00
parent ed1f4abfea
commit 0689e0256c
3 changed files with 8 additions and 28 deletions

View file

@ -51,22 +51,17 @@ ParentTrack::can_host_children() const
} }
bool bool
ParentTrack::remove_descendant_track(const boost::shared_ptr<Track> track) ParentTrack::remove_descendant_track(
const boost::shared_ptr<Track> track)
{ {
REQUIRE(track); REQUIRE(track);
BOOST_FOREACH(const boost::shared_ptr<Track> child_track, tracks) boost::shared_ptr<ParentTrack> parent =
find_descendant_track_parent(track);
if(parent)
{ {
REQUIRE(child_track); parent->tracks.remove(track);
return true;
if(track.get() == child_track.get())
{
tracks.remove(track);
return true;
}
if(child_track->remove_descendant_track(track))
return true;
} }
return false; return false;

View file

@ -61,12 +61,6 @@ Track::can_host_children() const
return false; return false;
} }
bool
Track::remove_descendant_track(const shared_ptr<Track> /*track*/)
{
return false;
}
string string
Track::print_branch() Track::print_branch()
{ {

View file

@ -70,15 +70,6 @@ public:
**/ **/
virtual bool can_host_children() const; virtual bool can_host_children() const;
/**
* Tries to remove a given track from amongst the descendants of this
* track.
* @param The model track to try and remove.
* @return Returns true if the track was successfully removed.
**/
virtual bool remove_descendant_track(
const boost::shared_ptr<Track> track);
/** /**
* A utility function that attempts to find the parent of a track by * A utility function that attempts to find the parent of a track by
* searching through the tree from this track downward. * searching through the tree from this track downward.