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
ParentTrack::remove_descendant_track(const boost::shared_ptr<Track> track)
ParentTrack::remove_descendant_track(
const boost::shared_ptr<Track> 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);
if(track.get() == child_track.get())
{
tracks.remove(track);
return true;
}
if(child_track->remove_descendant_track(track))
return true;
parent->tracks.remove(track);
return true;
}
return false;

View file

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

View file

@ -69,16 +69,7 @@ public:
* Returns true if this track can own any child tracks.
**/
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
* searching through the tree from this track downward.