LUMIERA.clone/src/gui/model/parent-track.cpp

100 lines
2.5 KiB
C++
Raw Normal View History

/*
parent-track-.cpp - Implementation of the ParentTrack class
2010-12-17 23:28:49 +01:00
Copyright (C) Lumiera.org
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
2010-12-17 23:28:49 +01:00
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
2010-12-17 23:28:49 +01:00
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
2010-12-17 23:28:49 +01:00
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
2010-12-17 23:28:49 +01:00
* *****************************************************/
/** @file parent-track.cpp
** Preliminary UI-model: Implementation of ParentTrack.
** @warning as of 2016 this UI model is known to be a temporary workaround
** and will be replaced in entirety by UI-Bus and diff framework.
** @deprecated the existing timeline implementation will be completely rewritten
*/
#include "parent-track.hpp"
#include <boost/foreach.hpp>
using std::shared_ptr;
2009-01-24 13:50:49 +01:00
namespace gui {
namespace model {
ParentTrack::ParentTrack()
{
}
2016-12-23 04:23:03 +01:00
const std::list<shared_ptr<Track>>&
ParentTrack::get_child_tracks() const
{
2009-01-24 13:18:12 +01:00
return tracks.get_list();
}
2016-12-23 04:23:03 +01:00
lumiera::observable_list<shared_ptr<Track>>&
ParentTrack::get_child_track_list()
{
return tracks;
}
bool
ParentTrack::can_host_children() const
{
return true;
}
bool
ParentTrack::remove_descendant_track(
const shared_ptr<Track> track)
{
REQUIRE(track);
shared_ptr<ParentTrack> parent =
find_descendant_track_parent(track);
if(parent)
{
parent->tracks.remove(track);
return true;
}
return false;
}
shared_ptr<ParentTrack>
ParentTrack::find_descendant_track_parent(shared_ptr<Track> child)
2009-01-24 13:50:49 +01:00
{
using namespace boost; ///////////////////////////////////////////////////////////////////////////////TICKET #1071 no wildcard includes please!
2009-01-24 13:50:49 +01:00
REQUIRE(child != NULL);
BOOST_FOREACH(std::shared_ptr<Track> track, tracks) ///////TODO use a standard foreach loop
2009-01-24 13:50:49 +01:00
{
if(track == child)
return shared_from_this();
std::shared_ptr<ParentTrack> result =
2009-01-24 13:50:49 +01:00
track->find_descendant_track_parent(child);
if(result)
return result;
}
return std::shared_ptr<ParentTrack>();
}
} // namespace model
} // namespace gui