aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-11-30 17:08:27 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-11-30 17:08:27 +0000
commit410957de97c3f8c4d91326683f9b8783f46538c2 (patch)
treee00cdddbfc45033526b6db2d4a5eafc26b8d4337
parent94fb8864b45d266e4e0a30bc0d130144c3da9c24 (diff)
downloadpaludis-410957de97c3f8c4d91326683f9b8783f46538c2.tar.gz
paludis-410957de97c3f8c4d91326683f9b8783f46538c2.tar.xz
Allow repositories to define their own disambiguation functions
-rw-r--r--paludis/package_database.cc12
-rw-r--r--paludis/repository.cc14
-rw-r--r--paludis/repository.hh16
3 files changed, 34 insertions, 8 deletions
diff --git a/paludis/package_database.cc b/paludis/package_database.cc
index 6b4eaf5..2f4c0b3 100644
--- a/paludis/package_database.cc
+++ b/paludis/package_database.cc
@@ -188,14 +188,10 @@ PackageDatabase::fetch_unique_qualified_package_name(
{
Context local_context("When looking in repository '" + stringify(r->name()) + "':");
- CategoryNamePartCollection::ConstPointer cats(r->category_names());
- CategoryNamePartCollection::Iterator c(cats->begin()), c_end(cats->end());
- for ( ; c != c_end ; ++c)
- {
- Context very_local_context("When looking in category '" + stringify(*c) + "':");
- if (r->has_package_named(*c + p))
- result->insert(*c + p);
- }
+ CategoryNamePartCollection::ConstPointer cats(r->category_names_containing_package(p));
+ for (CategoryNamePartCollection::Iterator c(cats->begin()), c_end(cats->end()) ;
+ c != c_end ; ++c)
+ result->insert(*c + p);
}
if (result->empty())
diff --git a/paludis/repository.cc b/paludis/repository.cc
index 23d293b..c1aa807 100644
--- a/paludis/repository.cc
+++ b/paludis/repository.cc
@@ -19,6 +19,7 @@
#include <paludis/repository.hh>
#include <paludis/util/compare.hh>
+#include <paludis/util/collection_concrete.hh>
#include <map>
#include <list>
#include <ctype.h>
@@ -179,3 +180,16 @@ RepositoryInfo::end_sections() const
return SectionIterator(_imp->sections.end());
}
+CategoryNamePartCollection::ConstPointer
+Repository::do_category_names_containing_package(const PackageNamePart & p) const
+{
+ CategoryNamePartCollection::Pointer result(new CategoryNamePartCollection::Concrete);
+ CategoryNamePartCollection::ConstPointer cats(category_names());
+ for (CategoryNamePartCollection::Iterator c(cats->begin()), c_end(cats->end()) ;
+ c != c_end ; ++c)
+ if (has_package_named(*c + p))
+ result->insert(*c);
+
+ return result;
+}
+
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 281e94e..127ba83 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -214,6 +214,13 @@ namespace paludis
virtual CategoryNamePartCollection::ConstPointer do_category_names() const = 0;
/**
+ * Override in descendents if a fast implementation is available: fetch category names
+ * that contain a particular package.
+ */
+ virtual CategoryNamePartCollection::ConstPointer do_category_names_containing_package(
+ const PackageNamePart &) const;
+
+ /**
* Override in descendents: check for a package.
*/
virtual bool do_has_package_named(const QualifiedPackageName &) const = 0;
@@ -277,6 +284,15 @@ namespace paludis
}
/**
+ * Fetch categories that contain a named package.
+ */
+ CategoryNamePartCollection::ConstPointer category_names_containing_package(
+ const PackageNamePart & p) const
+ {
+ return do_category_names_containing_package(p);
+ }
+
+ /**
* Fetch our package names.
*/
QualifiedPackageNameCollection::ConstPointer package_names(