aboutsummaryrefslogtreecommitdiff
path: root/paludis/repositories/fake
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-11-16 08:23:00 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-11-16 08:23:00 +0000
commitdc95c2f26ea490fce48575cd19b995d2b34297cf (patch)
treeecf718069b33a1ca5b0ba586ba3bd7f7bdfc09e4 /paludis/repositories/fake
parent7385570bea9b9d1954edf7a824fa61bd42c371e8 (diff)
downloadpaludis-dc95c2f26ea490fce48575cd19b995d2b34297cf.tar.gz
paludis-dc95c2f26ea490fce48575cd19b995d2b34297cf.tar.xz
Replace RepositoryInfo with emtadata keys. Change how we handle ambiguous _imp. Introduce common Literal metadata key classes to reduce duplicated code. Fixes: ticket:438. Fixes: ticket:416
Diffstat (limited to 'paludis/repositories/fake')
-rw-r--r--paludis/repositories/fake/fake_installed_repository.cc47
-rw-r--r--paludis/repositories/fake/fake_installed_repository.hh16
-rw-r--r--paludis/repositories/fake/fake_package_id.cc41
-rw-r--r--paludis/repositories/fake/fake_package_id.hh24
-rw-r--r--paludis/repositories/fake/fake_repository.cc26
-rw-r--r--paludis/repositories/fake/fake_repository.hh7
-rw-r--r--paludis/repositories/fake/fake_repository_base.cc18
-rw-r--r--paludis/repositories/fake/fake_repository_base.hh8
8 files changed, 100 insertions, 87 deletions
diff --git a/paludis/repositories/fake/fake_installed_repository.cc b/paludis/repositories/fake/fake_installed_repository.cc
index 9ea62807b..ba31ae5ad 100644
--- a/paludis/repositories/fake/fake_installed_repository.cc
+++ b/paludis/repositories/fake/fake_installed_repository.cc
@@ -30,12 +30,30 @@
#include <paludis/dep_spec_flattener.hh>
#include <paludis/dep_spec.hh>
#include <paludis/action.hh>
+#include <paludis/literal_metadata_key.hh>
using namespace paludis;
+namespace paludis
+{
+ template <>
+ struct Implementation<FakeInstalledRepository>
+ {
+ tr1::shared_ptr<const MetadataStringKey> format_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> installed_root_key;
+
+ Implementation() :
+ format_key(new LiteralMetadataStringKey(
+ "format", "format", mkt_significant, "installed_fake")),
+ installed_root_key(new LiteralMetadataFSEntryKey(
+ "installed_root", "installed_root", mkt_normal, FSEntry("/")))
+ {
+ }
+ };
+}
+
FakeInstalledRepository::FakeInstalledRepository(const Environment * const e, const RepositoryName & our_name) :
FakeRepositoryBase(e, our_name, RepositoryCapabilities::create()
- .installed_interface(this)
.sets_interface(this)
.syncable_interface(0)
.use_interface(this)
@@ -49,9 +67,12 @@ FakeInstalledRepository::FakeInstalledRepository(const Environment * const e, co
.make_virtuals_interface(0)
.qa_interface(0)
.hook_interface(0)
- .manifest_interface(0),
- "fake-installed")
+ .manifest_interface(0)),
+ PrivateImplementationPattern<FakeInstalledRepository>(new Implementation<FakeInstalledRepository>),
+ _imp(PrivateImplementationPattern<FakeInstalledRepository>::_imp)
{
+ add_metadata_key(_imp->format_key);
+ add_metadata_key(_imp->installed_root_key);
}
FakeInstalledRepository::~FakeInstalledRepository()
@@ -98,16 +119,10 @@ FakeInstalledRepository::provided_packages() const
return result;
}
-FSEntry
-FakeInstalledRepository::root() const
-{
- return FSEntry("/");
-}
-
bool
FakeInstalledRepository::is_default_destination() const
{
- return environment()->root() == root();
+ return environment()->root() == installed_root_key()->value();
}
bool
@@ -172,3 +187,15 @@ FakeInstalledRepository::some_ids_might_support_action(const SupportsActionTestB
return q.result;
}
+const tr1::shared_ptr<const MetadataStringKey>
+FakeInstalledRepository::format_key() const
+{
+ return _imp->format_key;
+}
+
+const tr1::shared_ptr<const MetadataFSEntryKey>
+FakeInstalledRepository::installed_root_key() const
+{
+ return _imp->installed_root_key;
+}
+
diff --git a/paludis/repositories/fake/fake_installed_repository.hh b/paludis/repositories/fake/fake_installed_repository.hh
index 782c22a96..04508246a 100644
--- a/paludis/repositories/fake/fake_installed_repository.hh
+++ b/paludis/repositories/fake/fake_installed_repository.hh
@@ -31,15 +31,14 @@ namespace paludis
*/
class PALUDIS_VISIBLE FakeInstalledRepository :
public FakeRepositoryBase,
- public RepositoryInstalledInterface,
public RepositoryDestinationInterface,
- public RepositoryProvidesInterface
+ public RepositoryProvidesInterface,
+ private PrivateImplementationPattern<FakeInstalledRepository>
{
- protected:
- /* RepositoryInstalledInterface */
-
- virtual FSEntry root() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ private:
+ PrivateImplementationPattern<FakeInstalledRepository>::ImpPtr & _imp;
+ protected:
/* RepositoryDestinationInterface */
virtual bool is_suitable_destination_for(const PackageID &) const
@@ -68,6 +67,11 @@ namespace paludis
///\}
virtual bool some_ids_might_support_action(const SupportsActionTestBase &) const;
+
+ /* Keys */
+ virtual const tr1::shared_ptr<const MetadataStringKey> format_key() const;
+ virtual const tr1::shared_ptr<const MetadataFSEntryKey> installed_root_key() const;
+
};
}
diff --git a/paludis/repositories/fake/fake_package_id.cc b/paludis/repositories/fake/fake_package_id.cc
index 6f0a1cdca..ea502f178 100644
--- a/paludis/repositories/fake/fake_package_id.cc
+++ b/paludis/repositories/fake/fake_package_id.cc
@@ -26,6 +26,7 @@
#include <paludis/environment.hh>
#include <paludis/version_spec.hh>
#include <paludis/formatter.hh>
+#include <paludis/literal_metadata_key.hh>
#include <paludis/dep_spec.hh>
#include <paludis/hashed_containers.hh>
#include <paludis/util/stringify.hh>
@@ -67,7 +68,7 @@ FakeMetadataSetKey<C_>::FakeMetadataSetKey(
const Environment * const e) :
MetadataSetKey<C_>(r, h, t),
PrivateImplementationPattern<FakeMetadataSetKey<C_> >(new Implementation<FakeMetadataSetKey<C_> >(i, e)),
- _imp(PrivateImplementationPattern<FakeMetadataSetKey<C_> >::_imp.get())
+ _imp(PrivateImplementationPattern<FakeMetadataSetKey<C_> >::_imp)
{
}
@@ -154,7 +155,7 @@ FakeMetadataSpecTreeKey<C_>::FakeMetadataSpecTreeKey(const std::string & r, cons
const tr1::function<const tr1::shared_ptr<const typename C_::ConstItem> (const std::string &)> & f, const MetadataKeyType t) :
MetadataSpecTreeKey<C_>(r, h, t),
PrivateImplementationPattern<FakeMetadataSpecTreeKey<C_> >(new Implementation<FakeMetadataSpecTreeKey<C_> >(f)),
- _imp(PrivateImplementationPattern<FakeMetadataSpecTreeKey<C_> >::_imp.get())
+ _imp(PrivateImplementationPattern<FakeMetadataSpecTreeKey<C_> >::_imp)
{
set_from_string(v);
}
@@ -198,7 +199,7 @@ FakeMetadataSpecTreeKey<FetchableURISpecTree>::FakeMetadataSpecTreeKey(const std
MetadataSpecTreeKey<FetchableURISpecTree>(r, h, t),
PrivateImplementationPattern<FakeMetadataSpecTreeKey<FetchableURISpecTree> >(
new Implementation<FakeMetadataSpecTreeKey<FetchableURISpecTree> >(f)),
- _imp(PrivateImplementationPattern<FakeMetadataSpecTreeKey<FetchableURISpecTree> >::_imp.get())
+ _imp(PrivateImplementationPattern<FakeMetadataSpecTreeKey<FetchableURISpecTree> >::_imp)
{
set_from_string(v);
}
@@ -241,34 +242,6 @@ FakeMetadataSpecTreeKey<FetchableURISpecTree>::initial_label() const
namespace paludis
{
template <>
- struct Implementation<FakeMetadataPackageIDKey>
- {
- tr1::shared_ptr<const PackageID> value;
- };
-}
-
-FakeMetadataPackageIDKey::FakeMetadataPackageIDKey(const std::string & r, const std::string & h,
- const tr1::shared_ptr<const PackageID> & v, const MetadataKeyType t) :
- MetadataPackageIDKey(r, h, t),
- PrivateImplementationPattern<FakeMetadataPackageIDKey>(new Implementation<FakeMetadataPackageIDKey>),
- _imp(PrivateImplementationPattern<FakeMetadataPackageIDKey>::_imp.get())
-{
- _imp->value = v;
-}
-
-FakeMetadataPackageIDKey::~FakeMetadataPackageIDKey()
-{
-}
-
-const tr1::shared_ptr<const PackageID>
-FakeMetadataPackageIDKey::value() const
-{
- return _imp->value;
-}
-
-namespace paludis
-{
- template <>
struct Implementation<FakeUnacceptedMask>
{
const char key;
@@ -326,8 +299,8 @@ namespace paludis
const VersionSpec version;
SlotName slot;
- tr1::shared_ptr<FakeMetadataPackageIDKey> package_id;
- tr1::shared_ptr<FakeMetadataPackageIDKey> virtual_for;
+ tr1::shared_ptr<LiteralMetadataPackageIDKey> package_id;
+ tr1::shared_ptr<LiteralMetadataPackageIDKey> virtual_for;
tr1::shared_ptr<FakeMetadataKeywordSetKey> keywords;
tr1::shared_ptr<FakeMetadataIUseSetKey> iuse;
tr1::shared_ptr<FakeMetadataSpecTreeKey<LicenseSpecTree> > license;
@@ -381,7 +354,7 @@ namespace paludis
FakePackageID::FakePackageID(const Environment * const e, const tr1::shared_ptr<const FakeRepositoryBase> & r,
const QualifiedPackageName & q, const VersionSpec & v) :
PrivateImplementationPattern<FakePackageID>(new Implementation<FakePackageID>(e, r, q, v, this)),
- _imp(PrivateImplementationPattern<FakePackageID>::_imp.get())
+ _imp(PrivateImplementationPattern<FakePackageID>::_imp)
{
add_metadata_key(_imp->keywords);
add_metadata_key(_imp->iuse);
diff --git a/paludis/repositories/fake/fake_package_id.hh b/paludis/repositories/fake/fake_package_id.hh
index 20c3dcca5..1c119d0f9 100644
--- a/paludis/repositories/fake/fake_package_id.hh
+++ b/paludis/repositories/fake/fake_package_id.hh
@@ -36,7 +36,7 @@ namespace paludis
private PrivateImplementationPattern<FakeMetadataSetKey<C_> >
{
protected:
- Implementation<FakeMetadataSetKey> * const _imp;
+ typename PrivateImplementationPattern<FakeMetadataSetKey<C_> >::ImpPtr & _imp;
FakeMetadataSetKey(const std::string &, const std::string &, const MetadataKeyType,
const PackageID * const, const Environment * const);
@@ -86,7 +86,7 @@ namespace paludis
private PrivateImplementationPattern<FakeMetadataSpecTreeKey<C_> >
{
private:
- Implementation<FakeMetadataSpecTreeKey<C_> > * const _imp;
+ typename PrivateImplementationPattern<FakeMetadataSpecTreeKey<C_> >::ImpPtr & _imp;
public:
FakeMetadataSpecTreeKey(const std::string &, const std::string &, const std::string &,
@@ -111,7 +111,7 @@ namespace paludis
private PrivateImplementationPattern<FakeMetadataSpecTreeKey<FetchableURISpecTree> >
{
private:
- Implementation<FakeMetadataSpecTreeKey<FetchableURISpecTree> > * const _imp;
+ PrivateImplementationPattern<FakeMetadataSpecTreeKey<FetchableURISpecTree> >::ImpPtr & _imp;
public:
FakeMetadataSpecTreeKey(const std::string &, const std::string &, const std::string &,
@@ -134,22 +134,6 @@ namespace paludis
PALUDIS_ATTRIBUTE((warn_unused_result));
};
- class PALUDIS_VISIBLE FakeMetadataPackageIDKey :
- public MetadataPackageIDKey,
- private PrivateImplementationPattern<FakeMetadataPackageIDKey>
- {
- private:
- Implementation<FakeMetadataPackageIDKey> * const _imp;
-
- public:
- FakeMetadataPackageIDKey(const std::string &, const std::string &,
- const tr1::shared_ptr<const PackageID> &, const MetadataKeyType);
- ~FakeMetadataPackageIDKey();
-
- virtual const tr1::shared_ptr<const PackageID> value() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
class PALUDIS_VISIBLE FakeUnacceptedMask :
public UnacceptedMask,
private PrivateImplementationPattern<FakeUnacceptedMask>
@@ -168,7 +152,7 @@ namespace paludis
private PrivateImplementationPattern<FakePackageID>
{
private:
- Implementation<FakePackageID> * const _imp;
+ PrivateImplementationPattern<FakePackageID>::ImpPtr & _imp;
protected:
virtual void need_keys_added() const;
diff --git a/paludis/repositories/fake/fake_repository.cc b/paludis/repositories/fake/fake_repository.cc
index 4f1d3a49e..49c733ffc 100644
--- a/paludis/repositories/fake/fake_repository.cc
+++ b/paludis/repositories/fake/fake_repository.cc
@@ -27,6 +27,7 @@
#include <paludis/distribution.hh>
#include <paludis/environment.hh>
#include <paludis/package_id.hh>
+#include <paludis/literal_metadata_key.hh>
#include <paludis/action.hh>
#include <map>
@@ -41,8 +42,12 @@ namespace paludis
tr1::shared_ptr<FakeRepository::VirtualsSequence> virtual_packages;
std::map<std::string, std::string> mirrors;
+ tr1::shared_ptr<const MetadataStringKey> format_key;
+
Implementation() :
- virtual_packages(new FakeRepository::VirtualsSequence)
+ virtual_packages(new FakeRepository::VirtualsSequence),
+ format_key(new LiteralMetadataStringKey(
+ "format", "format", mkt_significant, "fake"))
{
mirrors.insert(std::make_pair("example", "http://fake-example/fake-example/"));
mirrors.insert(std::make_pair("repo", "http://fake-repo/fake-repo/"));
@@ -53,7 +58,6 @@ namespace paludis
FakeRepository::FakeRepository(const Environment * const e, const RepositoryName & our_name) :
PrivateImplementationPattern<FakeRepository>(new Implementation<FakeRepository>),
FakeRepositoryBase(e, our_name, RepositoryCapabilities::create()
- .installed_interface(0)
.sets_interface(this)
.syncable_interface(0)
.use_interface(this)
@@ -68,10 +72,10 @@ FakeRepository::FakeRepository(const Environment * const e, const RepositoryName
.make_virtuals_interface(0)
.qa_interface(0)
.hook_interface(0)
- .manifest_interface(0),
- "fake"),
- _imp(PrivateImplementationPattern<FakeRepository>::_imp.get())
+ .manifest_interface(0)),
+ _imp(PrivateImplementationPattern<FakeRepository>::_imp)
{
+ add_metadata_key(_imp->format_key);
}
FakeRepository::~FakeRepository()
@@ -167,3 +171,15 @@ FakeRepository::end_mirrors(const std::string & s) const
return MirrorsConstIterator(_imp->mirrors.equal_range(s).second);
}
+const tr1::shared_ptr<const MetadataStringKey>
+FakeRepository::format_key() const
+{
+ return _imp->format_key;
+}
+
+const tr1::shared_ptr<const MetadataFSEntryKey>
+FakeRepository::installed_root_key() const
+{
+ return tr1::shared_ptr<const MetadataFSEntryKey>();
+}
+
diff --git a/paludis/repositories/fake/fake_repository.hh b/paludis/repositories/fake/fake_repository.hh
index 6eea6335b..efdc61af6 100644
--- a/paludis/repositories/fake/fake_repository.hh
+++ b/paludis/repositories/fake/fake_repository.hh
@@ -36,7 +36,7 @@ namespace paludis
public RepositoryMirrorsInterface
{
private:
- Implementation<FakeRepository> * const _imp;
+ PrivateImplementationPattern<FakeRepository>::ImpPtr & _imp;
public:
///\name Basic operations
@@ -65,6 +65,11 @@ namespace paludis
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual bool some_ids_might_support_action(const SupportsActionTestBase &) const;
+
+ /* Keys */
+
+ virtual const tr1::shared_ptr<const MetadataStringKey> format_key() const;
+ virtual const tr1::shared_ptr<const MetadataFSEntryKey> installed_root_key() const;
};
}
diff --git a/paludis/repositories/fake/fake_repository_base.cc b/paludis/repositories/fake/fake_repository_base.cc
index 54bb6ba25..e2d0ba1ac 100644
--- a/paludis/repositories/fake/fake_repository_base.cc
+++ b/paludis/repositories/fake/fake_repository_base.cc
@@ -27,7 +27,6 @@
#include <paludis/util/set.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/wrapped_output_iterator.hh>
-#include <paludis/repository_info.hh>
#include <map>
/** \file
@@ -75,16 +74,12 @@ namespace paludis
}
FakeRepositoryBase::FakeRepositoryBase(const Environment * const e,
- const RepositoryName & our_name, const RepositoryCapabilities & caps,
- const std::string & f) :
- Repository(our_name, caps, f),
+ const RepositoryName & our_name, const RepositoryCapabilities & caps) :
+ Repository(our_name, caps),
RepositoryUseInterface(),
- PrivateImplementationPattern<FakeRepositoryBase>(new Implementation<FakeRepositoryBase>(e))
+ PrivateImplementationPattern<FakeRepositoryBase>(new Implementation<FakeRepositoryBase>(e)),
+ _imp(PrivateImplementationPattern<FakeRepositoryBase>::_imp)
{
- tr1::shared_ptr<RepositoryInfoSection> config_info(new RepositoryInfoSection("Configuration information"));
- config_info->add_kv("format", "fake");
-
- _info->add_section(config_info);
}
FakeRepositoryBase::~FakeRepositoryBase()
@@ -254,3 +249,8 @@ FakeRepositoryBase::environment() const
return _imp->env;
}
+void
+FakeRepositoryBase::need_keys_added() const
+{
+}
+
diff --git a/paludis/repositories/fake/fake_repository_base.hh b/paludis/repositories/fake/fake_repository_base.hh
index 3af5a5122..eaf20f974 100644
--- a/paludis/repositories/fake/fake_repository_base.hh
+++ b/paludis/repositories/fake/fake_repository_base.hh
@@ -49,12 +49,17 @@ namespace paludis
private PrivateImplementationPattern<FakeRepositoryBase>,
public tr1::enable_shared_from_this<FakeRepositoryBase>
{
+ private:
+ PrivateImplementationPattern<FakeRepositoryBase>::ImpPtr & _imp;
+
protected:
/**
* Constructor.
*/
FakeRepositoryBase(const Environment * const env, const RepositoryName & name,
- const RepositoryCapabilities & caps, const std::string &);
+ const RepositoryCapabilities & caps);
+
+ virtual void need_keys_added() const;
public:
/**
@@ -155,7 +160,6 @@ namespace paludis
virtual bool has_category_named(const CategoryNamePart &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
-
};
}