aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-15 17:16:38 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-15 17:16:38 +0000
commit3c8633aa3b4fd7ffea055a6376c0d9812aa348a9 (patch)
tree7618278e9329137a91a29ee4f29d613b21586680
parent566ed28372bd3e29d5ee3eb263ec9f155fee91b4 (diff)
downloadpaludis-3c8633aa3b4fd7ffea055a6376c0d9812aa348a9.tar.gz
paludis-3c8633aa3b4fd7ffea055a6376c0d9812aa348a9.tar.xz
Add repository->is_arch_flag()
-rw-r--r--paludis/fake_repository.cc6
-rw-r--r--paludis/fake_repository.hh2
-rw-r--r--paludis/portage_repository.cc29
-rw-r--r--paludis/portage_repository.hh2
-rw-r--r--paludis/repository.hh16
5 files changed, 54 insertions, 1 deletions
diff --git a/paludis/fake_repository.cc b/paludis/fake_repository.cc
index d85bd89..1834c3c 100644
--- a/paludis/fake_repository.cc
+++ b/paludis/fake_repository.cc
@@ -187,3 +187,9 @@ FakeRepository::do_query_use_mask(const UseFlagName &) const
return false;
}
+bool
+FakeRepository::do_is_arch_flag(const UseFlagName &) const
+{
+ return false;
+}
+
diff --git a/paludis/fake_repository.hh b/paludis/fake_repository.hh
index 0c7faa9..dbf7f24 100644
--- a/paludis/fake_repository.hh
+++ b/paludis/fake_repository.hh
@@ -71,6 +71,8 @@ namespace paludis
virtual bool do_query_use_mask(const UseFlagName &) const;
+ virtual bool do_is_arch_flag(const UseFlagName &) const;
+
public:
/**
* Constructor.
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index aa25aef..a01b55d 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -19,6 +19,7 @@
#include "config.h"
+#include "create_insert_iterator.hh"
#include "dir_iterator.hh"
#include "filter_insert_iterator.hh"
#include "fs_entry.hh"
@@ -63,6 +64,8 @@ typedef MakeHashedMap<UseFlagName, UseFlagState>::Type UseMap;
typedef MakeHashedSet<UseFlagName>::Type UseMaskSet;
+typedef MakeHashedSet<UseFlagName>::Type ArchListSet;
+
typedef MakeHashedMap<std::pair<QualifiedPackageName, VersionSpec>, VersionMetadata::Pointer>::Type MetadataMap;
namespace paludis
@@ -121,6 +124,12 @@ namespace paludis
/// Have we loaded our profile yet?
mutable bool has_profile;
+ /// Arch flags
+ mutable ArchListSet arch_list;
+
+ /// Do we have arch_list?
+ mutable bool has_arch_list;
+
/// Constructor.
Implementation(const PackageDatabase * const d, const FSEntry & l, const FSEntry & p,
const FSEntry & c);
@@ -141,7 +150,8 @@ Implementation<PortageRepository>::Implementation(const PackageDatabase * const
cache(c),
has_category_names(false),
has_repo_mask(false),
- has_profile(false)
+ has_profile(false),
+ has_arch_list(false)
{
}
@@ -753,3 +763,20 @@ PortageRepositoryConfigurationError::PortageRepositoryConfigurationError(
}
+bool
+PortageRepository::do_is_arch_flag(const UseFlagName & u) const
+{
+ if (! _implementation->has_arch_list)
+ {
+ Context context("When checking arch list for '" + stringify(u) + "':");
+
+ LineConfigFile archs(_implementation->location / "profiles" / "arch.list");
+ std::copy(archs.begin(), archs.end(), create_inserter<UseFlagName>(
+ std::inserter(_implementation->arch_list, _implementation->arch_list.begin())));
+
+ _implementation->has_arch_list = true;
+ }
+
+ return _implementation->arch_list.end() != _implementation->arch_list.find(u);
+}
+
diff --git a/paludis/portage_repository.hh b/paludis/portage_repository.hh
index 180295d..0505b91 100644
--- a/paludis/portage_repository.hh
+++ b/paludis/portage_repository.hh
@@ -82,6 +82,8 @@ namespace paludis
virtual bool do_query_use_mask(const UseFlagName &) const;
+ virtual bool do_is_arch_flag(const UseFlagName &) const;
+
public:
/**
* Constructor.
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 6229dcd..b839db3 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -43,6 +43,9 @@ namespace paludis
/**
* A Repository provides a representation of a physical repository to a
* PackageDatabase.
+ *
+ * We make pretty heavy use of the non-virtual interface idiom here. See
+ * \ref EffCpp items 35 and 37.
*/
class Repository :
private InstantiationPolicy<Repository, instantiation_method::NonCopyableTag>,
@@ -125,6 +128,11 @@ namespace paludis
*/
virtual bool do_query_use_mask(const UseFlagName &) const = 0;
+ /**
+ * Override in descendents: is this an arch flag?
+ */
+ virtual bool do_is_arch_flag(const UseFlagName &) const = 0;
+
public:
/**
* Destructor.
@@ -307,6 +315,14 @@ namespace paludis
{
return do_query_use_mask(u);
}
+
+ /**
+ * Query whether the specified use flag is an arch flag.
+ */
+ bool is_arch_flag(const UseFlagName & u) const
+ {
+ return do_is_arch_flag(u);
+ }
};
/**