try to sensibly handle repeated imports of the same file. the same thing might be required for embeds

git-svn-id: svn://localhost/ardour2/branches/3.0@7975 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2010-11-05 20:36:44 +00:00
parent e98cf169eb
commit aa78fb928b
4 changed files with 71 additions and 3 deletions

View file

@ -42,7 +42,9 @@ class RegionFactory {
public:
typedef std::map<PBD::ID,boost::shared_ptr<Region> > RegionMap;
static boost::shared_ptr<Region> wholefile_region_by_name (const std::string& name);
static boost::shared_ptr<Region> region_by_id (const PBD::ID&);
static boost::shared_ptr<Region> region_by_name (const std::string& name);
static const RegionMap all_regions() { return region_map; }
static void clear_map ();

View file

@ -327,13 +327,34 @@ RegionFactory::region_by_id (const PBD::ID& id)
RegionMap::iterator i = region_map.find (id);
if (i == region_map.end()) {
cerr << "ID " << id << " not found in region map\n";
return boost::shared_ptr<Region>();
}
return i->second;
}
boost::shared_ptr<Region>
RegionFactory::wholefile_region_by_name (const std::string& name)
{
for (RegionMap::iterator i = region_map.begin(); i != region_map.end(); ++i) {
if (i->second->whole_file() && i->second->name() == name) {
return i->second;
}
}
return boost::shared_ptr<Region>();
}
boost::shared_ptr<Region>
RegionFactory::region_by_name (const std::string& name)
{
for (RegionMap::iterator i = region_map.begin(); i != region_map.end(); ++i) {
if (i->second->name() == name) {
return i->second;
}
}
return boost::shared_ptr<Region>();
}
void
RegionFactory::clear_map ()
{