aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-26 14:47:58 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-26 19:00:37 +0000
commit79d9f02fb355d81c472f3d94b8b85d5a7639210c (patch)
tree79ea85fca3a70f756d3c43c4ce18e92689060806
parent099a4e90c07e655b98073d8386ef5abaeec55a04 (diff)
downloadpaludis-79d9f02fb355d81c472f3d94b8b85d5a7639210c.tar.gz
paludis-79d9f02fb355d81c472f3d94b8b85d5a7639210c.tar.xz
Move PackageDatabase methods into Environment
-rw-r--r--paludis/environment.hh81
-rw-r--r--paludis/environment_implementation.cc59
-rw-r--r--paludis/environment_implementation.hh24
3 files changed, 163 insertions, 1 deletions
diff --git a/paludis/environment.hh b/paludis/environment.hh
index 8fed149..953f961 100644
--- a/paludis/environment.hh
+++ b/paludis/environment.hh
@@ -40,6 +40,7 @@
#include <paludis/choice-fwd.hh>
#include <paludis/create_output_manager_info-fwd.hh>
#include <paludis/notifier_callback-fwd.hh>
+#include <paludis/filter-fwd.hh>
/** \file
* Declarations for the Environment class.
@@ -76,6 +77,9 @@ namespace paludis
class PALUDIS_VISIBLE Environment :
public MetadataKeyHolder
{
+ private:
+ static const Filter & all_filter() PALUDIS_ATTRIBUTE((warn_unused_result));
+
public:
///\name Basic operations
///\{
@@ -537,6 +541,83 @@ namespace paludis
virtual void trigger_notifier_callback(const NotifierCallbackEvent &) const = 0;
///\}
+
+ ///\name Repositories
+ ///\{
+
+ /**
+ * Add a repository.
+ *
+ * \since 0.61 is in Environment rather than PackageDatabase
+ *
+ * \exception DuplicateRepositoryError if a Repository with the
+ * same name as the new Repository already exists in our
+ * collection.
+ */
+ virtual void add_repository(int importance, const std::shared_ptr<Repository> &) = 0;
+
+ /**
+ * Fetch a named repository.
+ *
+ * \since 0.61 is in Environment rather than PackageDatabase
+ */
+ virtual const std::shared_ptr<const Repository> fetch_repository(const RepositoryName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ /**
+ * Fetch a named repository.
+ *
+ * \since 0.61 is in Environment rather than PackageDatabase
+ */
+ virtual const std::shared_ptr<Repository> fetch_repository(const RepositoryName &)
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ /**
+ * Do we have a named repository?
+ *
+ * \since 0.61 is in Environment rather than PackageDatabase
+ */
+ virtual bool has_repository_named(const RepositoryName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ /**
+ * Disambiguate a package name. If a filter is specified,
+ * limit the potential results to packages that match.
+ *
+ * \throw AmbiguousPackageNameError if there is no unambiguous
+ * disambiguation. If disambiguate is set to false, the
+ * exception will be always thrown in presence of ambiguity.
+ * \since 0.56 takes the disambiguate flag.
+ *
+ * \since 0.61 is in Environment rather than PackageDatabase
+ */
+ virtual QualifiedPackageName fetch_unique_qualified_package_name(
+ const PackageNamePart &, const Filter & = all_filter(), const bool disambiguate = true) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ /**
+ * Return true if the first repository is more important than the second.
+ *
+ * \since 0.61 is in Environment rather than PackageDatabase
+ */
+ virtual bool more_important_than(const RepositoryName &, const RepositoryName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ ///\}
+
+ ///\name Iterate over our repositories
+ ///\{
+
+ struct RepositoryConstIteratorTag;
+ typedef WrappedForwardIterator<RepositoryConstIteratorTag, const std::shared_ptr<Repository> > RepositoryConstIterator;
+
+ virtual RepositoryConstIterator begin_repositories() const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual RepositoryConstIterator end_repositories() const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ ///\}
};
extern template class Pimp<CreateOutputManagerForRepositorySyncInfo>;
diff --git a/paludis/environment_implementation.cc b/paludis/environment_implementation.cc
index dda236a..13975fd 100644
--- a/paludis/environment_implementation.cc
+++ b/paludis/environment_implementation.cc
@@ -33,7 +33,7 @@
#include <paludis/util/sequence.hh>
#include <paludis/util/mutex.hh>
#include <paludis/util/member_iterator-impl.hh>
-#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/wrapped_forward_iterator-impl.hh>
#include <paludis/util/wrapped_output_iterator.hh>
#include <paludis/util/pimp-impl.hh>
#include <paludis/util/make_null_shared_ptr.hh>
@@ -110,6 +110,12 @@ namespace
namespace paludis
{
template <>
+ struct WrappedForwardIteratorTraits<Environment::RepositoryConstIteratorTag>
+ {
+ typedef PackageDatabase::RepositoryConstIterator UnderlyingIterator;
+ };
+
+ template <>
struct Imp<EnvironmentImplementation>
{
std::map<unsigned, NotifierCallbackFunction> notifier_callbacks;
@@ -358,8 +364,59 @@ EnvironmentImplementation::set_always_exists(const SetName & s) const
add_set(s, SetName(stringify(s) + "::default"), make_empty_set, true);
}
+void
+EnvironmentImplementation::add_repository(int importance, const std::shared_ptr<Repository> & repository)
+{
+ package_database()->add_repository(importance, repository);
+}
+
+const std::shared_ptr<const Repository>
+EnvironmentImplementation::fetch_repository(const RepositoryName & name) const
+{
+ return package_database()->fetch_repository(name);
+}
+
+const std::shared_ptr<Repository>
+EnvironmentImplementation::fetch_repository(const RepositoryName & name)
+{
+ return package_database()->fetch_repository(name);
+}
+
+bool
+EnvironmentImplementation::has_repository_named(const RepositoryName & name) const
+{
+ return package_database()->has_repository_named(name);
+}
+
+QualifiedPackageName
+EnvironmentImplementation::fetch_unique_qualified_package_name(const PackageNamePart & name,
+ const Filter & filter, const bool disambiguate) const
+{
+ return package_database()->fetch_unique_qualified_package_name(name, filter, disambiguate);
+}
+
+bool
+EnvironmentImplementation::more_important_than(const RepositoryName & a, const RepositoryName & b) const
+{
+ return package_database()->more_important_than(a, b);
+}
+
+EnvironmentImplementation::RepositoryConstIterator
+EnvironmentImplementation::begin_repositories() const
+{
+ return package_database()->begin_repositories();
+}
+
+EnvironmentImplementation::RepositoryConstIterator
+EnvironmentImplementation::end_repositories() const
+{
+ return package_database()->end_repositories();
+}
+
DuplicateSetError::DuplicateSetError(const SetName & s) throw () :
Exception("A set named '" + stringify(s) + "' already exists")
{
}
+template class WrappedForwardIterator<Environment::RepositoryConstIteratorTag, const std::shared_ptr<Repository> >;
+
diff --git a/paludis/environment_implementation.hh b/paludis/environment_implementation.hh
index 04fff5b..6a4fba7 100644
--- a/paludis/environment_implementation.hh
+++ b/paludis/environment_implementation.hh
@@ -110,6 +110,30 @@ namespace paludis
virtual void remove_selection_cache(
const std::shared_ptr<const SelectionCache> &);
+
+ virtual void add_repository(int importance, const std::shared_ptr<Repository> &);
+
+ virtual const std::shared_ptr<const Repository> fetch_repository(const RepositoryName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::shared_ptr<Repository> fetch_repository(const RepositoryName &)
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool has_repository_named(const RepositoryName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual QualifiedPackageName fetch_unique_qualified_package_name(
+ const PackageNamePart &, const Filter &, const bool disambiguate) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool more_important_than(const RepositoryName &, const RepositoryName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual RepositoryConstIterator begin_repositories() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual RepositoryConstIterator end_repositories() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
};
class PALUDIS_VISIBLE DuplicateSetError :