aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--doc/api/cplusplus/examples/example_dep_tree.cc2
-rw-r--r--doc/api/cplusplus/examples/example_metadata_key.cc42
-rw-r--r--doc/api/cplusplus/examples/example_package_database.cc3
-rw-r--r--doc/api/cplusplus/examples/example_repository.cc37
-rw-r--r--paludis/dep_spec_flattener.cc4
-rw-r--r--paludis/dep_spec_flattener.hh2
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/formatter.hh20
-rw-r--r--paludis/install_task.cc6
-rw-r--r--paludis/literal_metadata_key.cc209
-rw-r--r--paludis/literal_metadata_key.hh113
-rw-r--r--paludis/metadata_key.cc3
-rw-r--r--paludis/metadata_key.hh29
-rw-r--r--paludis/query.cc5
-rw-r--r--paludis/report_task.cc2
-rw-r--r--paludis/repositories/cran/cran_installed_repository.cc67
-rw-r--r--paludis/repositories/cran/cran_installed_repository.hh16
-rw-r--r--paludis/repositories/cran/cran_package_id.cc27
-rw-r--r--paludis/repositories/cran/cran_package_id.hh2
-rw-r--r--paludis/repositories/cran/cran_repository.cc76
-rw-r--r--paludis/repositories/cran/cran_repository.hh11
-rw-r--r--paludis/repositories/cran/keys.cc35
-rw-r--r--paludis/repositories/cran/keys.hh28
-rw-r--r--paludis/repositories/e/e_key.cc58
-rw-r--r--paludis/repositories/e/e_key.hh54
-rw-r--r--paludis/repositories/e/e_repository.cc290
-rw-r--r--paludis/repositories/e/e_repository.hh13
-rw-r--r--paludis/repositories/e/ebuild_entries.cc6
-rw-r--r--paludis/repositories/e/ebuild_id.cc18
-rw-r--r--paludis/repositories/e/ebuild_id.hh2
-rw-r--r--paludis/repositories/e/make_ebin_repository.cc8
-rw-r--r--paludis/repositories/e/make_ebuild_repository.cc8
-rw-r--r--paludis/repositories/e/qa/spec_keys.cc4
-rw-r--r--paludis/repositories/e/vdb_id.cc54
-rw-r--r--paludis/repositories/e/vdb_id.hh2
-rw-r--r--paludis/repositories/e/vdb_repository.cc104
-rw-r--r--paludis/repositories/e/vdb_repository.hh32
-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
-rw-r--r--paludis/repositories/gems/gem_specification.cc88
-rw-r--r--paludis/repositories/gems/gem_specification.hh2
-rw-r--r--paludis/repositories/gems/gems_repository.cc71
-rw-r--r--paludis/repositories/gems/gems_repository.hh11
-rw-r--r--paludis/repositories/gems/installed_gems_repository.cc68
-rw-r--r--paludis/repositories/gems/installed_gems_repository.hh16
-rw-r--r--paludis/repositories/gems/params.sr1
-rw-r--r--paludis/repositories/gems/registration.cc5
-rw-r--r--paludis/repositories/unpackaged/installed_id.cc2
-rw-r--r--paludis/repositories/unpackaged/installed_id.hh2
-rw-r--r--paludis/repositories/unpackaged/installed_repository.cc69
-rw-r--r--paludis/repositories/unpackaged/installed_repository.hh16
-rw-r--r--paludis/repositories/unpackaged/unpackaged_id.cc9
-rw-r--r--paludis/repositories/unpackaged/unpackaged_id.hh2
-rw-r--r--paludis/repositories/unpackaged/unpackaged_key.cc66
-rw-r--r--paludis/repositories/unpackaged/unpackaged_key.hh30
-rw-r--r--paludis/repositories/unpackaged/unpackaged_repository.cc76
-rw-r--r--paludis/repositories/unpackaged/unpackaged_repository.hh12
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.cc47
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.hh12
-rw-r--r--paludis/repositories/virtuals/package_id.cc35
-rw-r--r--paludis/repositories/virtuals/package_id.hh19
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc37
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.hh9
-rw-r--r--paludis/repository-fwd.hh1
-rw-r--r--paludis/repository.cc87
-rw-r--r--paludis/repository.hh99
-rw-r--r--paludis/repository.sr1
-rw-r--r--paludis/repository_info.cc135
-rw-r--r--paludis/repository_info.hh125
-rw-r--r--paludis/stringify_formatter-impl.hh8
-rw-r--r--paludis/stringify_formatter.cc34
-rw-r--r--paludis/stringify_formatter.hh9
-rw-r--r--paludis/uninstall_list.cc2
-rw-r--r--paludis/util/files.m41
-rw-r--r--paludis/util/mutex.cc26
-rw-r--r--paludis/util/remove_shared_ptr.hh (renamed from paludis/repository_info-fwd.hh)43
-rwxr-xr-xpython/mask_TEST.py6
-rw-r--r--python/metadata_key.cc6
-rw-r--r--python/repository.cc79
-rwxr-xr-xpython/repository_TEST.py24
-rw-r--r--ruby/metadata_key.cc18
-rw-r--r--ruby/repository.cc134
-rw-r--r--ruby/repository_TEST.rb34
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/markup_formatter.cc18
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/markup_formatter.hh12
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/repository_info_model.cc7
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/repository_info_model.hh2
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/version_info_model.cc5
-rw-r--r--src/clients/importare/importare.cc4
-rw-r--r--src/clients/inquisitio/do_search.cc3
-rw-r--r--src/clients/inquisitio/key_extractor.cc11
-rw-r--r--src/clients/instruo/instruo.cc5
-rw-r--r--src/clients/paludis/applets.cc166
-rw-r--r--src/clients/paludis/info.cc147
-rw-r--r--src/clients/paludis/list.cc22
-rw-r--r--src/clients/paludis/owner.cc3
-rw-r--r--src/clients/qualudis/qualudis.cc10
-rw-r--r--src/output/colour_formatter.cc18
-rw-r--r--src/output/colour_formatter.hh12
-rw-r--r--src/output/console_query_task.cc26
-rw-r--r--src/output/mask_displayer.cc34
107 files changed, 2029 insertions, 1634 deletions
diff --git a/doc/api/cplusplus/examples/example_dep_tree.cc b/doc/api/cplusplus/examples/example_dep_tree.cc
index defa451..12ea68e 100644
--- a/doc/api/cplusplus/examples/example_dep_tree.cc
+++ b/doc/api/cplusplus/examples/example_dep_tree.cc
@@ -235,7 +235,7 @@ int main(int argc, char * argv[])
/* Display our results */
cout << left << setw(60) << "Package" << "| " << left << setw(4) << "Dep" << "| " << "Ext" << endl;
- cout << std::string(60, '-') << "+" << std::string(4, '-') << "+" << std::string(4, '-') << endl;
+ cout << std::string(60, '-') << "+" << std::string(5, '-') << "+" << std::string(5, '-') << endl;
for (ResultsMap::const_iterator r(results.begin()), r_end(results.end()) ;
r != r_end ; ++r)
cout << left << setw(60) << r->first << "| "
diff --git a/doc/api/cplusplus/examples/example_metadata_key.cc b/doc/api/cplusplus/examples/example_metadata_key.cc
index 8df5d15..2d0b672 100644
--- a/doc/api/cplusplus/examples/example_metadata_key.cc
+++ b/doc/api/cplusplus/examples/example_metadata_key.cc
@@ -10,7 +10,7 @@
/** \example example_metadata_key.cc
*
* This example demonstrates how to use MetadataKey. It displays all the
- * metadata keys for a particular PackageID.
+ * metadata keys for a particular PackageID and all repositories.
*/
#include <paludis/paludis.hh>
@@ -176,6 +176,12 @@ namespace
cout << indent << left << setw(30) << " Value:" << " " << join(key.value()->begin(), key.value()->end(), " ") << endl;
}
+ void visit(const MetadataSetKey<FSEntrySequence> & key)
+ {
+ cout << indent << left << setw(30) << " Class:" << " " << "MetadataSpecTreeKey<FSEntrySequence>" << endl;
+ cout << indent << left << setw(30) << " Value:" << " " << join(key.value()->begin(), key.value()->end(), " ") << endl;
+ }
+
void visit(const MetadataSetKey<PackageIDSequence> & key)
{
cout << indent << left << setw(30) << " Class:" << " " << "MetadataSpecTreeKey<PackageIDSequence>" << endl;
@@ -189,15 +195,15 @@ namespace
void visit(const MetadataSectionKey & key)
{
cout << indent << left << setw(30) << " Class:" << " " << "MetadataSectionKey" << endl;
+ cout << indent << left << setw(30) << " Keys:" << endl;
- /* A MetadataSectionKey contains other keys. It has one potentially special
- * key, for the title, which if it exists is always a MetadataStringKey. */
- if (key.title_key())
- cout << indent << left << setw(30) << " Title:" << " " << key.title_key()->value() << endl;
-
+ /* A MetadataSectionKey contains other keys. */
for (MetadataSectionKey::MetadataConstIterator k(key.begin_metadata()), k_end(key.end_metadata()) ;
k != k_end ; ++k)
- show_key(**k, indent + " ");
+ {
+ show_key(**k, indent + " ");
+ cout << endl;
+ }
}
};
@@ -219,7 +225,7 @@ namespace
* use a visitor. This lets us write type-safe handling code for
* the appropriate MetadataKey subclass without the need for any
* runtime type information queries. */
- MetadataKeyInformationVisitor v;
+ MetadataKeyInformationVisitor v(indent);
key.accept(v);
}
}
@@ -260,6 +266,26 @@ int main(int argc, char * argv[])
cout << endl;
}
+
+ /* And for each repository: */
+ for (PackageDatabase::RepositoryConstIterator r(env->package_database()->begin_repositories()),
+ r_end(env->package_database()->end_repositories()) ;
+ r != r_end ; ++r)
+ {
+ cout << (*r)->name() << ":" << endl;
+
+ /* For each metadata key: */
+ for (Repository::MetadataConstIterator k((*r)->begin_metadata()), k_end((*r)->end_metadata()) ;
+ k != k_end ; ++k)
+ {
+ /* Display it. Repository::MetadataConstIterator also returns a
+ * tr1::shared_ptr to the key. */
+ show_key(**k);
+ cout << endl;
+ }
+
+ cout << endl;
+ }
}
catch (const Exception & e)
{
diff --git a/doc/api/cplusplus/examples/example_package_database.cc b/doc/api/cplusplus/examples/example_package_database.cc
index 6adb7a6..521c7e4 100644
--- a/doc/api/cplusplus/examples/example_package_database.cc
+++ b/doc/api/cplusplus/examples/example_package_database.cc
@@ -45,7 +45,8 @@ int main(int argc, char * argv[])
if (env->package_database()->has_repository_named(RepositoryName("gentoo")))
{
tr1::shared_ptr<const Repository> repo(env->package_database()->fetch_repository(RepositoryName("gentoo")));
- cout << "Repository 'gentoo' exists, and has format '" << repo->format() << "'" << endl;
+ cout << "Repository 'gentoo' exists, and has format '" <<
+ (repo->format_key() ? repo->format_key()->value() : "") << "'" << endl;
}
/* Our favourite repository is the least important non-special (e.g.
diff --git a/doc/api/cplusplus/examples/example_repository.cc b/doc/api/cplusplus/examples/example_repository.cc
index 07608a4..75a5a41 100644
--- a/doc/api/cplusplus/examples/example_repository.cc
+++ b/doc/api/cplusplus/examples/example_repository.cc
@@ -46,21 +46,16 @@ int main(int argc, char * argv[])
/* A repository is identified by its name. */
cout << left << (*r)->name() << ":" << endl;
- /* Configuration and possibly additional information is available
- * via Repository::info. */
- tr1::shared_ptr<const RepositoryInfo> info((*r)->info(true));
-
- cout << left << setw(30) << " Info:" << " " << endl;
- /* RepositoryInfo is made up of a number of sections... */
- for (RepositoryInfo::SectionConstIterator s(info->begin_sections()), s_end(info->end_sections()) ;
- s != s_end ; ++s)
- {
- cout << left << setw(30) << (" " + (*s)->heading() + ":") << " " << endl;
- /* And a section is made up of key+value pairs */
- for (RepositoryInfoSection::KeyValueConstIterator v((*s)->begin_kvs()), v_end((*s)->end_kvs()) ;
- v != v_end ; ++v)
- cout << left << setw(30) << (" " + v->first + ":") << " " << v->second << endl;
- }
+ /* Like a PackageID, a Repository has metadata. Usually metadata
+ * keys will be available for all of the configuration options for
+ * that repository; some repositories also provide more (ebuild
+ * format repositories, for example, provide info_pkgs too). See
+ * \ref example_metadata_key.cc "example_metadata_key.cc" for how to
+ * display a metadata key in detail. */
+ cout << left << setw(30) << " Metadata keys:" << endl;
+ for (Repository::MetadataConstIterator k((*r)->begin_metadata()), k_end((*r)->end_metadata()) ;
+ k != k_end ; ++k)
+ cout << " " << (*k)->human_name() << endl;
/* Repositories support various methods for querying categories,
* packages, IDs and so on. These methods are used by
@@ -72,18 +67,6 @@ int main(int argc, char * argv[])
cout << left << setw(30) << " IDs for sys-apps/paludis:" << " " <<
join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " ") << endl;
- /* Much of the Repository functionality is optional -- for example,
- * not all repositories support use flags as a concept, and not all
- * repositories are syncable, and merging only makes sense to
- * certain repositories. We gain access to optional functionality
- * via interface methods, all of which may return a zero pointer.
- * Many Repository interfaces are of little direct use to clients;
- * we cover only those that are here. */
- if ((*r)->installed_interface)
- cout << left << setw(30) << " Root:" << " " << (*r)->installed_interface->root() << endl;
- if ((*r)->syncable_interface)
- cout << left << setw(30) << " Syncable:" << " " << "yes" << endl;
-
cout << endl;
}
}
diff --git a/paludis/dep_spec_flattener.cc b/paludis/dep_spec_flattener.cc
index 1239c08..2b152e3 100644
--- a/paludis/dep_spec_flattener.cc
+++ b/paludis/dep_spec_flattener.cc
@@ -58,7 +58,7 @@ DepSpecFlattener<Heirarchy_, Item_>::DepSpecFlattener(
const PackageID & pkg) :
PrivateImplementationPattern<DepSpecFlattener<Heirarchy_, Item_> >(
new Implementation<DepSpecFlattener<Heirarchy_, Item_> >(env, &pkg)),
- _imp(PrivateImplementationPattern<DepSpecFlattener<Heirarchy_, Item_> >::_imp.get())
+ _imp(PrivateImplementationPattern<DepSpecFlattener<Heirarchy_, Item_> >::_imp)
{
}
@@ -70,7 +70,7 @@ DepSpecFlattener<Heirarchy_, Item_>::DepSpecFlattener(
NoType<0u>, Empty>::Type &) :
PrivateImplementationPattern<DepSpecFlattener<Heirarchy_, Item_> >(
new Implementation<DepSpecFlattener<Heirarchy_, Item_> >(e, 0)),
- _imp(PrivateImplementationPattern<DepSpecFlattener<Heirarchy_, Item_> >::_imp.get())
+ _imp(PrivateImplementationPattern<DepSpecFlattener<Heirarchy_, Item_> >::_imp)
{
}
diff --git a/paludis/dep_spec_flattener.hh b/paludis/dep_spec_flattener.hh
index 51cefdb..398af61 100644
--- a/paludis/dep_spec_flattener.hh
+++ b/paludis/dep_spec_flattener.hh
@@ -155,7 +155,7 @@ namespace paludis
Heirarchy_, Item_, ConstVisitor<Heirarchy_>::template Contains<const ConstTreeSequence<Heirarchy_, UseDepSpec> >::value>;
private:
- Implementation<DepSpecFlattener<Heirarchy_, Item_> > * const _imp;
+ typename PrivateImplementationPattern<DepSpecFlattener<Heirarchy_, Item_> >::ImpPtr & _imp;
public:
///\name Visit methods
diff --git a/paludis/files.m4 b/paludis/files.m4
index 2704b1e..9f878ec 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -33,6 +33,7 @@ add(`hook', `hh', `cc', `fwd',`se', `sr')
add(`hooker', `hh', `cc', `test', `testscript')
add(`host_tuple_name', `hh', `cc', `sr', `test')
add(`install_task', `hh', `cc', `se')
+add(`literal_metadata_key', `hh', `cc')
add(`mask', `hh', `cc', `fwd', `sr')
add(`match_package', `hh', `cc')
add(`merger', `hh', `cc', `sr', `test', `testscript')
@@ -50,7 +51,6 @@ add(`query_visitor', `hh', `cc')
add(`range_rewriter', `hh', `cc', `test')
add(`report_task', `hh', `cc')
add(`repository', `hh', `fwd', `cc', `sr')
-add(`repository_info', `hh', `fwd', `cc')
add(`repository_maker', `hh', `cc')
add(`repository_name_cache', `hh', `cc', `test', `testscript')
add(`set_file', `hh', `cc', `se', `sr', `test', `testscript')
diff --git a/paludis/formatter.hh b/paludis/formatter.hh
index 48be6c2..b237466 100644
--- a/paludis/formatter.hh
+++ b/paludis/formatter.hh
@@ -355,7 +355,7 @@ namespace paludis
};
/**
- * A tr1::shared_ptr<T_> supports the same roles as T_.
+ * A tr1::shared_ptr<T_> shouldn't be specified.
*
* \ingroup g_formatters
* \since 0.26
@@ -364,8 +364,22 @@ namespace paludis
template <typename T_>
struct CategorySelector<tr1::shared_ptr<T_> >
{
- /// The roles this type supports.
- typedef typename CategorySelector<T_>::Category Category;
+ /// This role is wrong.
+ typedef typename CategorySelector<T_>::ThisRoleIsWrong ThisRoleIsWrong;
+ };
+
+ /**
+ * A tr1::shared_ptr<const T_> shouldn't be specified.
+ *
+ * \ingroup g_formatters
+ * \since 0.26
+ * \nosubgrouping
+ */
+ template <typename T_>
+ struct CategorySelector<tr1::shared_ptr<const T_> >
+ {
+ /// This role is wrong.
+ typedef typename CategorySelector<T_>::ThisRoleIsWrong ThisRoleIsWrong;
};
/**
diff --git a/paludis/install_task.cc b/paludis/install_task.cc
index 5349bed..8379acd 100644
--- a/paludis/install_task.cc
+++ b/paludis/install_task.cc
@@ -499,12 +499,10 @@ InstallTask::_one(const DepList::Iterator dep, const int x, const int y, const i
/* figure out whether we need to unmerge (clean) anything */
on_build_cleanlist_pre(*dep);
- // manually invalidate any installed repos, they're probably
- // wrong now
+ // manually invalidate repos, they're probably wrong now
for (PackageDatabase::RepositoryConstIterator r(_imp->env->package_database()->begin_repositories()),
r_end(_imp->env->package_database()->end_repositories()) ; r != r_end ; ++r)
- if ((*r)->installed_interface)
- ((*r).get())->invalidate();
+ (*r)->invalidate();
// look for packages with the same name in the same slot in the destination repos
tr1::shared_ptr<const PackageIDSequence> collision_list;
diff --git a/paludis/literal_metadata_key.cc b/paludis/literal_metadata_key.cc
new file mode 100644
index 0000000..a272ea0
--- /dev/null
+++ b/paludis/literal_metadata_key.cc
@@ -0,0 +1,209 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/literal_metadata_key.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/join.hh>
+#include <paludis/util/tr1_functional.hh>
+#include <paludis/formatter.hh>
+#include <paludis/package_id.hh>
+
+using namespace paludis;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<LiteralMetadataStringKey>
+ {
+ const std::string value;
+
+ Implementation(const std::string & v) :
+ value(v)
+ {
+ }
+ };
+
+ template <>
+ struct Implementation<LiteralMetadataFSEntryKey>
+ {
+ const FSEntry value;
+
+ Implementation(const FSEntry & v) :
+ value(v)
+ {
+ }
+ };
+
+ template <>
+ struct Implementation<LiteralMetadataPackageIDKey>
+ {
+ const tr1::shared_ptr<const PackageID> value;
+
+ Implementation(const tr1::shared_ptr<const PackageID> & v) :
+ value(v)
+ {
+ }
+ };
+
+ template <>
+ struct Implementation<LiteralMetadataFSEntrySequenceKey>
+ {
+ const tr1::shared_ptr<const FSEntrySequence> value;
+
+ Implementation(const tr1::shared_ptr<const FSEntrySequence> & v) :
+ value(v)
+ {
+ }
+ };
+
+ template <>
+ struct Implementation<LiteralMetadataStringSetKey>
+ {
+ const tr1::shared_ptr<const Set<std::string> > value;
+
+ Implementation(const tr1::shared_ptr<const Set<std::string> > & v) :
+ value(v)
+ {
+ }
+ };
+}
+
+LiteralMetadataStringKey::LiteralMetadataStringKey(const std::string & h, const std::string & r,
+ const MetadataKeyType t, const std::string & v) :
+ MetadataStringKey(h, r, t),
+ PrivateImplementationPattern<LiteralMetadataStringKey>(new Implementation<LiteralMetadataStringKey>(v)),
+ _imp(PrivateImplementationPattern<LiteralMetadataStringKey>::_imp)
+{
+}
+
+LiteralMetadataStringKey::~LiteralMetadataStringKey()
+{
+}
+
+const std::string
+LiteralMetadataStringKey::value() const
+{
+ return _imp->value;
+}
+
+LiteralMetadataFSEntryKey::LiteralMetadataFSEntryKey(const std::string & h, const std::string & r,
+ const MetadataKeyType t, const FSEntry & v) :
+ MetadataFSEntryKey(h, r, t),
+ PrivateImplementationPattern<LiteralMetadataFSEntryKey>(new Implementation<LiteralMetadataFSEntryKey>(v)),
+ _imp(PrivateImplementationPattern<LiteralMetadataFSEntryKey>::_imp)
+{
+}
+
+LiteralMetadataFSEntryKey::~LiteralMetadataFSEntryKey()
+{
+}
+
+const FSEntry
+LiteralMetadataFSEntryKey::value() const
+{
+ return _imp->value;
+}
+
+LiteralMetadataPackageIDKey::LiteralMetadataPackageIDKey(const std::string & h, const std::string & r,
+ const MetadataKeyType t, const tr1::shared_ptr<const PackageID> & v) :
+ MetadataPackageIDKey(h, r, t),
+ PrivateImplementationPattern<LiteralMetadataPackageIDKey>(new Implementation<LiteralMetadataPackageIDKey>(v)),
+ _imp(PrivateImplementationPattern<LiteralMetadataPackageIDKey>::_imp)
+{
+}
+
+LiteralMetadataPackageIDKey::~LiteralMetadataPackageIDKey()
+{
+}
+
+const tr1::shared_ptr<const PackageID>
+LiteralMetadataPackageIDKey::value() const
+{
+ return _imp->value;
+}
+
+LiteralMetadataFSEntrySequenceKey::LiteralMetadataFSEntrySequenceKey(const std::string & h, const std::string & r,
+ const MetadataKeyType t, const tr1::shared_ptr<const FSEntrySequence> & v) :
+ MetadataSetKey<FSEntrySequence>(h, r, t),
+ PrivateImplementationPattern<LiteralMetadataFSEntrySequenceKey>(new Implementation<LiteralMetadataFSEntrySequenceKey>(v)),
+ _imp(PrivateImplementationPattern<LiteralMetadataFSEntrySequenceKey>::_imp)
+{
+}
+
+LiteralMetadataFSEntrySequenceKey::~LiteralMetadataFSEntrySequenceKey()
+{
+}
+
+const tr1::shared_ptr<const FSEntrySequence>
+LiteralMetadataFSEntrySequenceKey::value() const
+{
+ return _imp->value;
+}
+
+namespace
+{
+ std::string format_fsentry(const FSEntry & i, const Formatter<FSEntry> & f)
+ {
+ return f.format(i, format::Plain());
+ }
+}
+
+std::string
+LiteralMetadataFSEntrySequenceKey::pretty_print_flat(const Formatter<FSEntry> & f) const
+{
+ using namespace tr1::placeholders;
+ return join(value()->begin(), value()->end(), " ", tr1::bind(&format_fsentry, _1, f));
+}
+
+LiteralMetadataStringSetKey::LiteralMetadataStringSetKey(const std::string & h, const std::string & r,
+ const MetadataKeyType t, const tr1::shared_ptr<const Set<std::string> > & v) :
+ MetadataSetKey<Set<std::string> >(h, r, t),
+ PrivateImplementationPattern<LiteralMetadataStringSetKey>(new Implementation<LiteralMetadataStringSetKey>(v)),
+ _imp(PrivateImplementationPattern<LiteralMetadataStringSetKey>::_imp)
+{
+}
+
+LiteralMetadataStringSetKey::~LiteralMetadataStringSetKey()
+{
+}
+
+const tr1::shared_ptr<const Set<std::string> >
+LiteralMetadataStringSetKey::value() const
+{
+ return _imp->value;
+}
+
+namespace
+{
+ std::string format_string(const std::string & i, const Formatter<std::string> & f)
+ {
+ return f.format(i, format::Plain());
+ }
+}
+
+std::string
+LiteralMetadataStringSetKey::pretty_print_flat(const Formatter<std::string> & f) const
+{
+ using namespace tr1::placeholders;
+ return join(value()->begin(), value()->end(), " ", tr1::bind(&format_string, _1, f));
+}
+
diff --git a/paludis/literal_metadata_key.hh b/paludis/literal_metadata_key.hh
new file mode 100644
index 0000000..14b46eb
--- /dev/null
+++ b/paludis/literal_metadata_key.hh
@@ -0,0 +1,113 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_LITERAL_METADATA_KEY_HH
+#define PALUDIS_GUARD_PALUDIS_LITERAL_METADATA_KEY_HH 1
+
+#include <paludis/metadata_key.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/set.hh>
+
+namespace paludis
+{
+ class PALUDIS_VISIBLE LiteralMetadataStringKey :
+ public MetadataStringKey,
+ private PrivateImplementationPattern<LiteralMetadataStringKey>
+ {
+ private:
+ PrivateImplementationPattern<LiteralMetadataStringKey>::ImpPtr & _imp;
+
+ public:
+ LiteralMetadataStringKey(const std::string &, const std::string &, const MetadataKeyType,
+ const std::string &);
+ ~LiteralMetadataStringKey();
+
+ virtual const std::string value() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class PALUDIS_VISIBLE LiteralMetadataFSEntryKey :
+ public MetadataFSEntryKey,
+ private PrivateImplementationPattern<LiteralMetadataFSEntryKey>
+ {
+ private:
+ PrivateImplementationPattern<LiteralMetadataFSEntryKey>::ImpPtr & _imp;
+
+ public:
+ LiteralMetadataFSEntryKey(const std::string &, const std::string &, const MetadataKeyType,
+ const FSEntry &);
+ ~LiteralMetadataFSEntryKey();
+
+ virtual const FSEntry value() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class PALUDIS_VISIBLE LiteralMetadataPackageIDKey :
+ public MetadataPackageIDKey,
+ private PrivateImplementationPattern<LiteralMetadataPackageIDKey>
+ {
+ private:
+ PrivateImplementationPattern<LiteralMetadataPackageIDKey>::ImpPtr & _imp;
+
+ public:
+ LiteralMetadataPackageIDKey(const std::string &, const std::string &, const MetadataKeyType,
+ const tr1::shared_ptr<const PackageID> &);
+ ~LiteralMetadataPackageIDKey();
+
+ virtual const tr1::shared_ptr<const PackageID> value() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class PALUDIS_VISIBLE LiteralMetadataFSEntrySequenceKey :
+ public MetadataSetKey<FSEntrySequence>,
+ private PrivateImplementationPattern<LiteralMetadataFSEntrySequenceKey>
+ {
+ private:
+ PrivateImplementationPattern<LiteralMetadataFSEntrySequenceKey>::ImpPtr & _imp;
+
+ public:
+ LiteralMetadataFSEntrySequenceKey(const std::string &, const std::string &, const MetadataKeyType,
+ const tr1::shared_ptr<const FSEntrySequence> &);
+ ~LiteralMetadataFSEntrySequenceKey();
+
+ virtual const tr1::shared_ptr<const FSEntrySequence> value() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::string pretty_print_flat(const Formatter<FSEntry> &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class PALUDIS_VISIBLE LiteralMetadataStringSetKey :
+ public MetadataSetKey<Set<std::string> >,
+ private PrivateImplementationPattern<LiteralMetadataStringSetKey>
+ {
+ private:
+ PrivateImplementationPattern<LiteralMetadataStringSetKey>::ImpPtr & _imp;
+
+ public:
+ LiteralMetadataStringSetKey(const std::string &, const std::string &, const MetadataKeyType,
+ const tr1::shared_ptr<const Set<std::string> > &);
+ ~LiteralMetadataStringSetKey();
+
+ virtual const tr1::shared_ptr<const Set<std::string> > value() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::string pretty_print_flat(const Formatter<std::string> &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+}
+
+#endif
diff --git a/paludis/metadata_key.cc b/paludis/metadata_key.cc
index 902d289..4420222 100644
--- a/paludis/metadata_key.cc
+++ b/paludis/metadata_key.cc
@@ -120,7 +120,7 @@ namespace paludis
MetadataSectionKey::MetadataSectionKey(const std::string & r, const std::string & h, const MetadataKeyType t) :
MetadataKey(r, h, t),
PrivateImplementationPattern<MetadataSectionKey>(new Implementation<MetadataSectionKey>),
- _imp(PrivateImplementationPattern<MetadataSectionKey>::_imp.get())
+ _imp(PrivateImplementationPattern<MetadataSectionKey>::_imp)
{
}
@@ -191,6 +191,7 @@ template class MetadataSetKey<IUseFlagSet>;
template class MetadataSetKey<Set<std::string> >;
template class MetadataSetKey<UseFlagNameSet>;
template class MetadataSetKey<PackageIDSequence>;
+template class MetadataSetKey<FSEntrySequence>;
template class MetadataSpecTreeKey<LicenseSpecTree>;
template class MetadataSpecTreeKey<ProvideSpecTree>;
diff --git a/paludis/metadata_key.hh b/paludis/metadata_key.hh
index c3619a3..549885a 100644
--- a/paludis/metadata_key.hh
+++ b/paludis/metadata_key.hh
@@ -34,6 +34,8 @@
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/visitor.hh>
+#include <paludis/util/remove_shared_ptr.hh>
+#include <paludis/util/tr1_type_traits.hh>
#include <string>
/** \file
@@ -65,6 +67,7 @@ namespace paludis
MetadataSetKey<KeywordNameSet>,
MetadataSetKey<Set<std::string> >,
MetadataSetKey<PackageIDSequence>,
+ MetadataSetKey<FSEntrySequence>,
MetadataSpecTreeKey<DependencySpecTree>,
MetadataSpecTreeKey<LicenseSpecTree>,
MetadataSpecTreeKey<FetchableURISpecTree>,
@@ -83,7 +86,7 @@ namespace paludis
/**
* A MetadataKey is a generic key that contains a particular piece of
- * information about a PackageID instance.
+ * information about a PackageID or Repository instance.
*
* A basic MetadataKey has:
*
@@ -91,13 +94,14 @@ namespace paludis
* represent the internal name. For example, ebuilds and VDB IDs use
* raw names like 'DESCRIPTION' and 'KEYWORDS', whereas CRAN uses names
* like 'Title' and 'BundleDescription'. The raw name is unique in a
- * PackageID.
+ * PackageID or Repository.
*
* - A human name. This is the name that should be used when outputting
* normally for a human to read.
*
* - A MetadataKeyType. This is a hint to clients as to whether the key
- * should be displayed when outputting information about a package ID.
+ * should be displayed when outputting information about a package ID
+ * or Repository.
*
* Subclasses provide additional information, including the 'value' of the
* key. A ConstVisitor using MetadataKeyVisitorTypes can be used to get more
@@ -305,7 +309,7 @@ namespace paludis
};
/**
- * A MetadataSectionKey is a MetadataKey that has a title and holds a number of other
+ * A MetadataSectionKey is a MetadataKey that holds a number of other
* MetadataKey instances.
*
* \ingroup g_metadata_key
@@ -318,7 +322,7 @@ namespace paludis
private PrivateImplementationPattern<MetadataSectionKey>
{
private:
- Implementation<MetadataSectionKey> * const _imp;
+ PrivateImplementationPattern<MetadataSectionKey>::ImpPtr & _imp;
protected:
///\name Basic operations
@@ -349,18 +353,6 @@ namespace paludis
///\}
- ///\name Specific metadata keys
- ///\{
-
- /**
- * Our title key.
- *
- * May be a zero pointer for untitled sections.
- */
- virtual const tr1::shared_ptr<const MetadataStringKey> title_key() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
-
- ///\}
-
///\name Finding and iterating over metadata keys
///\{
@@ -406,7 +398,8 @@ namespace paludis
* Return a single-line formatted version of our value, using the
* supplied Formatter to format individual items.
*/
- virtual std::string pretty_print_flat(const Formatter<typename C_::value_type> &) const
+ virtual std::string pretty_print_flat(const Formatter<
+ typename tr1::remove_const<typename RemoveSharedPtr<typename C_::value_type>::Type>::type> &) const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
};
diff --git a/paludis/query.cc b/paludis/query.cc
index 5488593..25d9b06 100644
--- a/paludis/query.cc
+++ b/paludis/query.cc
@@ -30,6 +30,7 @@
#include <paludis/match_package.hh>
#include <paludis/action.hh>
#include <paludis/package_id.hh>
+#include <paludis/metadata_key.hh>
#include <algorithm>
#include <set>
@@ -286,8 +287,8 @@ namespace
for (PackageDatabase::RepositoryConstIterator i(e.package_database()->begin_repositories()),
i_end(e.package_database()->end_repositories()) ; i != i_end ; ++i)
- if ((*i)->installed_interface)
- if (root == (*i)->installed_interface->root())
+ if ((*i)->installed_root_key())
+ if (root == (*i)->installed_root_key()->value())
result->push_back((*i)->name());
return result;
diff --git a/paludis/report_task.cc b/paludis/report_task.cc
index 3bcec4e..69ec926 100644
--- a/paludis/report_task.cc
+++ b/paludis/report_task.cc
@@ -171,7 +171,7 @@ ReportTask::execute()
r_end(e->package_database()->end_repositories()) ; r != r_end ; ++r)
{
tr1::shared_ptr<const Repository> rr(e->package_database()->fetch_repository((*r)->name()));
- if (! rr->installed_interface)
+ if (! rr->installed_root_key())
continue;
tr1::shared_ptr<const CategoryNamePartSet> cat_names(rr->category_names());
diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc
index a16252c..cd69c35 100644
--- a/paludis/repositories/cran/cran_installed_repository.cc
+++ b/paludis/repositories/cran/cran_installed_repository.cc
@@ -21,12 +21,12 @@
#include <paludis/hashed_containers.hh>
#include <paludis/environment.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
-#include <paludis/repository_info.hh>
#include <paludis/dep_spec.hh>
#include <paludis/dep_tag.hh>
#include <paludis/util/config_file.hh>
#include <paludis/set_file.hh>
#include <paludis/action.hh>
+#include <paludis/literal_metadata_key.hh>
#include <paludis/repositories/cran/cran_package_id.hh>
#include <paludis/repositories/cran/cran_dep_parser.hh>
#include <paludis/repositories/cran/cran_installed_repository.hh>
@@ -64,17 +64,21 @@ namespace paludis
mutable bool has_ids;
mutable IDMap ids;
- /// Constructor.
Implementation(const CRANInstalledRepositoryParams &);
-
- /// Destructor.
~Implementation();
+
+ tr1::shared_ptr<const MetadataFSEntryKey> location_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> installed_root_key;
+ tr1::shared_ptr<const MetadataStringKey> format_key;
};
}
Implementation<CRANInstalledRepository>::Implementation(const CRANInstalledRepositoryParams & p) :
params(p),
- has_ids(false)
+ has_ids(false),
+ location_key(new LiteralMetadataFSEntryKey("location", "location", mkt_significant, params.location)),
+ installed_root_key(new LiteralMetadataFSEntryKey("root", "root", mkt_normal, params.root)),
+ format_key(new LiteralMetadataStringKey("format", "format", mkt_significant, "installed_cran"))
{
}
@@ -149,7 +153,6 @@ Implementation<CRANInstalledRepository>::need_ids() const
CRANInstalledRepository::CRANInstalledRepository(const CRANInstalledRepositoryParams & p) :
Repository(RepositoryName("installed-cran"),
RepositoryCapabilities::create()
- .installed_interface(this)
.sets_interface(this)
.syncable_interface(0)
.use_interface(0)
@@ -163,23 +166,26 @@ CRANInstalledRepository::CRANInstalledRepository(const CRANInstalledRepositoryPa
.qa_interface(0)
.make_virtuals_interface(0)
.hook_interface(0)
- .manifest_interface(0),
- "installed_cran"),
- PrivateImplementationPattern<CRANInstalledRepository>(new Implementation<CRANInstalledRepository>(p))
+ .manifest_interface(0)),
+ PrivateImplementationPattern<CRANInstalledRepository>(new Implementation<CRANInstalledRepository>(p)),
+ _imp(PrivateImplementationPattern<CRANInstalledRepository>::_imp)
{
- tr1::shared_ptr<RepositoryInfoSection> config_info(new RepositoryInfoSection("Configuration information"));
-
- config_info->add_kv("location", stringify(_imp->params.location));
- config_info->add_kv("root", stringify(_imp->params.root));
- config_info->add_kv("format", "installed_cran");
-
- _info->add_section(config_info);
+ _add_metadata_keys();
}
CRANInstalledRepository::~CRANInstalledRepository()
{
}
+void
+CRANInstalledRepository::_add_metadata_keys() const
+{
+ clear_metadata_keys();
+ add_metadata_key(_imp->location_key);
+ add_metadata_key(_imp->installed_root_key);
+ add_metadata_key(_imp->format_key);
+}
+
bool
CRANInstalledRepository::has_category_named(const CategoryNamePart & c) const
{
@@ -486,6 +492,7 @@ void
CRANInstalledRepository::invalidate()
{
_imp.reset(new Implementation<CRANInstalledRepository>(_imp->params));
+ _add_metadata_keys();
}
void
@@ -541,7 +548,7 @@ CRANInstalledRepository::remove_string_from_world(const std::string & n) const
bool
CRANInstalledRepository::is_suitable_destination_for(const PackageID & e) const
{
- std::string f(e.repository()->format());
+ std::string f(e.repository()->format_key() ? e.repository()->format_key()->value() : "");
return f == "cran";
}
@@ -569,16 +576,10 @@ CRANInstalledRepository::remove_from_world(const SetName & n) const
remove_string_from_world(stringify(n));
}
-FSEntry
-CRANInstalledRepository::root() const
-{
- return _imp->params.root;
-}
-
bool
CRANInstalledRepository::is_default_destination() const
{
- return _imp->params.environment->root() == root();
+ return _imp->params.environment->root() == installed_root_key()->value();
}
bool
@@ -655,3 +656,21 @@ CRANInstalledRepository::need_ids() const
{
}
+void
+CRANInstalledRepository::need_keys_added() const
+{
+}
+
+const tr1::shared_ptr<const MetadataStringKey>
+CRANInstalledRepository::format_key() const
+{
+ return _imp->format_key;
+}
+
+const tr1::shared_ptr<const MetadataFSEntryKey>
+CRANInstalledRepository::installed_root_key() const
+{
+ return _imp->installed_root_key;
+}
+
+
diff --git a/paludis/repositories/cran/cran_installed_repository.hh b/paludis/repositories/cran/cran_installed_repository.hh
index 00b141a..7c95959 100644
--- a/paludis/repositories/cran/cran_installed_repository.hh
+++ b/paludis/repositories/cran/cran_installed_repository.hh
@@ -46,17 +46,22 @@ namespace paludis
*/
class PALUDIS_VISIBLE CRANInstalledRepository :
public Repository,
- public RepositoryInstalledInterface,
public RepositorySetsInterface,
public RepositoryWorldInterface,
public RepositoryDestinationInterface,
public PrivateImplementationPattern<CRANInstalledRepository>
{
private:
+ PrivateImplementationPattern<CRANInstalledRepository>::ImpPtr & _imp;
+ void _add_metadata_keys() const;
+
void need_ids() const;
void add_string_to_world(const std::string & n) const;
void remove_string_from_world(const std::string &) const;
+ protected:
+ virtual void need_keys_added() const;
+
public:
/**
* Constructor.
@@ -78,10 +83,6 @@ namespace paludis
virtual void invalidate();
virtual void invalidate_masks();
- /* RepositoryInstalledInterface */
-
- virtual FSEntry root() const PALUDIS_ATTRIBUTE((warn_unused_result));
-
/* RepositorySetsInterface */
virtual tr1::shared_ptr<const SetNameSet> sets_list() const
@@ -132,6 +133,11 @@ namespace paludis
virtual tr1::shared_ptr<SetSpecTree::ConstItem> package_set(const SetName & id) const
PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ /* 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/cran/cran_package_id.cc b/paludis/repositories/cran/cran_package_id.cc
index c50c4a9..b6fe77f 100644
--- a/paludis/repositories/cran/cran_package_id.cc
+++ b/paludis/repositories/cran/cran_package_id.cc
@@ -33,6 +33,7 @@
#include <paludis/util/stringify.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/literal_metadata_key.hh>
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
#include <paludis/action.hh>
@@ -61,10 +62,10 @@ namespace paludis
QualifiedPackageName name;
VersionSpec version;
- tr1::shared_ptr<FSLocationKey> fs_location_key;
+ tr1::shared_ptr<LiteralMetadataFSEntryKey> fs_location_key;
tr1::shared_ptr<SimpleURIKey> homepage_key;
- tr1::shared_ptr<StringKey> short_description_key;
- tr1::shared_ptr<StringKey> long_description_key;
+ tr1::shared_ptr<LiteralMetadataStringKey> short_description_key;
+ tr1::shared_ptr<LiteralMetadataStringKey> long_description_key;
tr1::shared_ptr<PackageIDKey> contained_in_key;
tr1::shared_ptr<PackageIDSequenceKey> contains_key;
tr1::shared_ptr<DepKey> depends_key;
@@ -95,7 +96,7 @@ namespace paludis
CRANPackageID::CRANPackageID(const Environment * const env, const tr1::shared_ptr<const CRANRepository> & r, const FSEntry & f) :
PrivateImplementationPattern<CRANPackageID>(new Implementation<CRANPackageID>(env, r, f)),
- _imp(PrivateImplementationPattern<CRANPackageID>::_imp.get())
+ _imp(PrivateImplementationPattern<CRANPackageID>::_imp)
{
Context context("When parsing file '" + stringify(f) + "' to create a CRAN Package ID:");
@@ -106,8 +107,8 @@ CRANPackageID::CRANPackageID(const Environment * const env, const tr1::shared_pt
return;
}
- _imp->fs_location_key.reset(new FSLocationKey("DescriptionFileLocation", "Description File Location",
- f, mkt_internal));
+ _imp->fs_location_key.reset(new LiteralMetadataFSEntryKey("DescriptionFileLocation", "Description File Location",
+ mkt_internal, f));
add_metadata_key(_imp->fs_location_key);
try
@@ -158,33 +159,33 @@ CRANPackageID::CRANPackageID(const Environment * const env, const tr1::shared_pt
if (! file.get("Title").empty())
{
Context local_context("When handling Title: key:");
- _imp->short_description_key.reset(new StringKey("Title", "Title", file.get("Title"), mkt_significant));
+ _imp->short_description_key.reset(new LiteralMetadataStringKey("Title", "Title", mkt_significant, file.get("Title")));
add_metadata_key(_imp->short_description_key);
}
if (! file.get("Description").empty())
{
Context local_context("When handling Description: key:");
- _imp->long_description_key.reset(new StringKey("Description", "Description", file.get("Description"), mkt_normal));
+ _imp->long_description_key.reset(new LiteralMetadataStringKey("Description", "Description", mkt_normal, file.get("Description")));
add_metadata_key(_imp->long_description_key);
}
else if (! file.get("BundleDescription").empty())
{
Context local_context("When handling BundleDescription: key:");
- _imp->long_description_key.reset(new StringKey("BundleDescription", "Bundle Description",
- file.get("BundleDescription"), mkt_normal));
+ _imp->long_description_key.reset(new LiteralMetadataStringKey("BundleDescription", "Bundle Description",
+ mkt_normal, file.get("BundleDescription")));
}
if (! file.get("Author").empty())
{
Context local_context("When handling Author: key:");
- add_metadata_key(make_shared_ptr(new StringKey("Author", "Author", file.get("Author"), mkt_normal)));
+ add_metadata_key(make_shared_ptr(new LiteralMetadataStringKey("Author", "Author", mkt_normal, file.get("Author"))));
}
if (! file.get("Maintainer").empty())
{
Context local_context("When handling Maintainer: key:");
- add_metadata_key(make_shared_ptr(new StringKey("Maintainer", "Maintainer", file.get("Maintainer"), mkt_normal)));
+ add_metadata_key(make_shared_ptr(new LiteralMetadataStringKey("Maintainer", "Maintainer", mkt_normal, file.get("Maintainer"))));
}
if (! file.get("Contains").empty())
@@ -266,7 +267,7 @@ CRANPackageID::CRANPackageID(const Environment * const env, const tr1::shared_pt
CRANPackageID::CRANPackageID(const Environment * const e,
const tr1::shared_ptr<const CRANRepository> & c, const CRANPackageID * const r, const std::string & t) :
PrivateImplementationPattern<CRANPackageID>(new Implementation<CRANPackageID>(e, c, r, t)),
- _imp(PrivateImplementationPattern<CRANPackageID>::_imp.get())
+ _imp(PrivateImplementationPattern<CRANPackageID>::_imp)
{
Context context("When creating contained ID '" + stringify(t) + "' in " + stringify(*r) + "':");
diff --git a/paludis/repositories/cran/cran_package_id.hh b/paludis/repositories/cran/cran_package_id.hh
index f46c103..3738f72 100644
--- a/paludis/repositories/cran/cran_package_id.hh
+++ b/paludis/repositories/cran/cran_package_id.hh
@@ -37,7 +37,7 @@ namespace paludis
public tr1::enable_shared_from_this<CRANPackageID>
{
private:
- Implementation<CRANPackageID> * const _imp;
+ PrivateImplementationPattern<CRANPackageID>::ImpPtr & _imp;
protected:
virtual void need_keys_added() const;
diff --git a/paludis/repositories/cran/cran_repository.cc b/paludis/repositories/cran/cran_repository.cc
index acc9ed7..20d1214 100644
--- a/paludis/repositories/cran/cran_repository.cc
+++ b/paludis/repositories/cran/cran_repository.cc
@@ -24,10 +24,10 @@
#include <paludis/environment.hh>
#include <paludis/action.hh>
#include <paludis/metadata_key.hh>
+#include <paludis/literal_metadata_key.hh>
#include <paludis/repositories/cran/cran_package_id.hh>
#include <paludis/repositories/cran/cran_repository.hh>
#include <paludis/repository_maker.hh>
-#include <paludis/repository_info.hh>
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/set.hh>
#include <paludis/util/sequence.hh>
@@ -50,12 +50,6 @@
#include <functional>
#include <algorithm>
-/** \file
- * Implementation CRANRepository.
- *
- * \ingroup grpcranrepository
- */
-
using namespace paludis;
#include <paludis/repositories/cran/cran_repository-sr.cc>
@@ -64,11 +58,6 @@ typedef MakeHashedMap<QualifiedPackageName, tr1::shared_ptr<const cranrepository
namespace paludis
{
- /**
- * Implementation data for a CRANRepository.
- *
- * \ingroup grperepository
- */
template <>
struct Implementation<CRANRepository>
{
@@ -80,13 +69,26 @@ namespace paludis
Implementation(const CRANRepositoryParams &, const tr1::shared_ptr<Mutex> &);
~Implementation();
+
+ tr1::shared_ptr<const MetadataFSEntryKey> location_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> distdir_key;
+ tr1::shared_ptr<const MetadataStringKey> format_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> builddir_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> library_key;
+ tr1::shared_ptr<const MetadataStringKey> sync_key;
};
}
Implementation<CRANRepository>::Implementation(const CRANRepositoryParams & p, const tr1::shared_ptr<Mutex> & m) :
params(p),
big_nasty_mutex(m),
- has_ids(false)
+ has_ids(false),
+ location_key(new LiteralMetadataFSEntryKey("location", "location", mkt_significant, params.location)),
+ distdir_key(new LiteralMetadataFSEntryKey("distdir", "distdir", mkt_normal, params.distdir)),
+ format_key(new LiteralMetadataStringKey("format", "format", mkt_significant, "cran")),
+ builddir_key(new LiteralMetadataFSEntryKey("builddir", "builddir", mkt_normal, params.builddir)),
+ library_key(new LiteralMetadataFSEntryKey("library", "library", mkt_normal, params.library)),
+ sync_key(new LiteralMetadataStringKey("sync", "sync", mkt_normal, params.sync))
{
}
@@ -98,7 +100,6 @@ Implementation<CRANRepository>::~Implementation()
CRANRepository::CRANRepository(const CRANRepositoryParams & p) :
Repository(CRANRepository::fetch_repo_name(stringify(p.location)),
RepositoryCapabilities::create()
- .installed_interface(0)
.sets_interface(this)
.syncable_interface(this)
.use_interface(0)
@@ -112,26 +113,29 @@ CRANRepository::CRANRepository(const CRANRepositoryParams & p) :
.e_interface(0)
.qa_interface(0)
.hook_interface(0)
- .manifest_interface(0),
- "cran"),
- PrivateImplementationPattern<CRANRepository>(new Implementation<CRANRepository>(p, make_shared_ptr(new Mutex)))
+ .manifest_interface(0)),
+ PrivateImplementationPattern<CRANRepository>(new Implementation<CRANRepository>(p, make_shared_ptr(new Mutex))),
+ _imp(PrivateImplementationPattern<CRANRepository>::_imp)
{
- tr1::shared_ptr<RepositoryInfoSection> config_info(new RepositoryInfoSection("Configuration information"));
-
- config_info->add_kv("location", stringify(_imp->params.location));
- config_info->add_kv("distdir", stringify(_imp->params.distdir));
- config_info->add_kv("format", "cran");
- config_info->add_kv("builddir", stringify(_imp->params.builddir));
- config_info->add_kv("library", stringify(_imp->params.library));
- config_info->add_kv("sync", _imp->params.sync);
-
- _info->add_section(config_info);
+ _add_metadata_keys();
}
CRANRepository::~CRANRepository()
{
}
+void
+CRANRepository::_add_metadata_keys() const
+{
+ clear_metadata_keys();
+ add_metadata_key(_imp->location_key);
+ add_metadata_key(_imp->distdir_key);
+ add_metadata_key(_imp->format_key);
+ add_metadata_key(_imp->builddir_key);
+ add_metadata_key(_imp->library_key);
+ add_metadata_key(_imp->sync_key);
+}
+
bool
CRANRepository::has_category_named(const CategoryNamePart & c) const
{
@@ -446,6 +450,7 @@ void
CRANRepository::invalidate()
{
_imp.reset(new Implementation<CRANRepository>(_imp->params, _imp->big_nasty_mutex));
+ _add_metadata_keys();
}
void
@@ -505,3 +510,20 @@ CRANRepository::some_ids_might_support_action(const SupportsActionTestBase & a)
return q.result;
}
+void
+CRANRepository::need_keys_added() const
+{
+}
+
+const tr1::shared_ptr<const MetadataStringKey>
+CRANRepository::format_key() const
+{
+ return _imp->format_key;
+}
+
+const tr1::shared_ptr<const MetadataFSEntryKey>
+CRANRepository::installed_root_key() const
+{
+ return tr1::shared_ptr<const MetadataFSEntryKey>();
+}
+
diff --git a/paludis/repositories/cran/cran_repository.hh b/paludis/repositories/cran/cran_repository.hh
index a8e54c9..2355eeb 100644
--- a/paludis/repositories/cran/cran_repository.hh
+++ b/paludis/repositories/cran/cran_repository.hh
@@ -55,9 +55,15 @@ namespace paludis
public tr1::enable_shared_from_this<CRANRepository>
{
private:
+ PrivateImplementationPattern<CRANRepository>::ImpPtr & _imp;
+ void _add_metadata_keys() const;
+
void need_ids() const;
protected:
+ virtual void need_keys_added() const;
+
+ protected:
/**
* Try to get the repository name for a particular repository.
*/
@@ -114,6 +120,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/cran/keys.cc b/paludis/repositories/cran/keys.cc
index 26332ed..b5c5f28 100644
--- a/paludis/repositories/cran/keys.cc
+++ b/paludis/repositories/cran/keys.cc
@@ -27,6 +27,7 @@
#include <paludis/util/join.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/tr1_functional.hh>
+#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/dep_spec.hh>
#include <paludis/stringify_formatter-impl.hh>
#include <paludis/formatter.hh>
@@ -58,31 +59,6 @@ SimpleURIKey::pretty_print_flat(const SimpleURISpecTree::ItemFormatter & f) cons
return f.format(_v, format::Plain());
}
-StringKey::StringKey(const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
- MetadataStringKey(r, h, t),
- _v(v)
-{
-}
-
-const std::string
-StringKey::value() const
-{
- return _v;
-}
-
-FSLocationKey::FSLocationKey(const std::string & r, const std::string & h,
- const FSEntry & v, const MetadataKeyType t) :
- MetadataFSEntryKey(r, h, t),
- _v(v)
-{
-}
-
-const FSEntry
-FSLocationKey::value() const
-{
- return _v;
-}
-
PackageIDSequenceKey::PackageIDSequenceKey(const Environment * const e,
const std::string & r, const std::string & h, const MetadataKeyType t) :
MetadataSetKey<PackageIDSequence>(r, h, t),
@@ -104,13 +80,12 @@ PackageIDSequenceKey::push_back(const tr1::shared_ptr<const PackageID> & i)
}
std::string
-PackageIDSequenceKey::pretty_print_flat(const Formatter<tr1::shared_ptr<const PackageID> > & f) const
+PackageIDSequenceKey::pretty_print_flat(const Formatter<PackageID> & f) const
{
using namespace tr1::placeholders;
- return join(value()->begin(), value()->end(), " ", tr1::bind(
- static_cast<std::string (Formatter<tr1::shared_ptr<const PackageID> >::*)(
- const tr1::shared_ptr<const PackageID> &, const format::Plain &) const>(
- &Formatter<tr1::shared_ptr<const PackageID> >::format),
+ return join(indirect_iterator(value()->begin()), indirect_iterator(value()->end()), " ",
+ tr1::bind(static_cast<std::string (Formatter<PackageID>::*)(const PackageID &, const format::Plain &) const>(
+ &Formatter<PackageID>::format),
tr1::cref(f), _1, format::Plain()));
}
diff --git a/paludis/repositories/cran/keys.hh b/paludis/repositories/cran/keys.hh
index 6207250..2dbda3a 100644
--- a/paludis/repositories/cran/keys.hh
+++ b/paludis/repositories/cran/keys.hh
@@ -50,32 +50,6 @@ namespace paludis
PALUDIS_ATTRIBUTE((warn_unused_result));
};
- class StringKey :
- public MetadataStringKey
- {
- private:
- const std::string _v;
-
- public:
- StringKey(const std::string &, const std::string &, const std::string &, const MetadataKeyType);
-
- virtual const std::string value() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
- class FSLocationKey :
- public MetadataFSEntryKey
- {
- private:
- const FSEntry _v;
-
- public:
- FSLocationKey(const std::string &, const std::string &, const FSEntry &, const MetadataKeyType);
-
- virtual const FSEntry value() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
class PackageIDSequenceKey :
public MetadataSetKey<PackageIDSequence>
{
@@ -92,7 +66,7 @@ namespace paludis
void push_back(const tr1::shared_ptr<const PackageID> &);
- virtual std::string pretty_print_flat(const Formatter<tr1::shared_ptr<const PackageID> > &) const
+ virtual std::string pretty_print_flat(const Formatter<PackageID> &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
};
diff --git a/paludis/repositories/e/e_key.cc b/paludis/repositories/e/e_key.cc
index 2d8caef..9d1a72e 100644
--- a/paludis/repositories/e/e_key.cc
+++ b/paludis/repositories/e/e_key.cc
@@ -50,23 +50,6 @@
using namespace paludis;
using namespace paludis::erepository;
-EStringKey::EStringKey(const tr1::shared_ptr<const ERepositoryID> &,
- const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
- MetadataStringKey(r, h, t),
- _value(v)
-{
-}
-
-EStringKey::~EStringKey()
-{
-}
-
-const std::string
-EStringKey::value() const
-{
- return _value;
-}
-
EMutableRepositoryMaskInfoKey::EMutableRepositoryMaskInfoKey(const tr1::shared_ptr<const ERepositoryID> &,
const std::string & r, const std::string & h, tr1::shared_ptr<const RepositoryMaskInfo> v, const MetadataKeyType t) :
MetadataRepositoryMaskInfoKey(r, h, t),
@@ -119,7 +102,7 @@ EDependenciesKey::EDependenciesKey(
const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
MetadataSpecTreeKey<DependencySpecTree>(r, h, t),
PrivateImplementationPattern<EDependenciesKey>(new Implementation<EDependenciesKey>(e, id, v)),
- _imp(PrivateImplementationPattern<EDependenciesKey>::_imp.get())
+ _imp(PrivateImplementationPattern<EDependenciesKey>::_imp)
{
}
@@ -192,7 +175,7 @@ ELicenseKey::ELicenseKey(
const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
MetadataSpecTreeKey<LicenseSpecTree>(r, h, t),
PrivateImplementationPattern<ELicenseKey>(new Implementation<ELicenseKey>(e, id, v)),
- _imp(PrivateImplementationPattern<ELicenseKey>::_imp.get())
+ _imp(PrivateImplementationPattern<ELicenseKey>::_imp)
{
}
@@ -263,7 +246,7 @@ EFetchableURIKey::EFetchableURIKey(const Environment * const e,
const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
MetadataSpecTreeKey<FetchableURISpecTree>(r, h, t),
PrivateImplementationPattern<EFetchableURIKey>(new Implementation<EFetchableURIKey>(e, id, v)),
- _imp(PrivateImplementationPattern<EFetchableURIKey>::_imp.get())
+ _imp(PrivateImplementationPattern<EFetchableURIKey>::_imp)
{
}
@@ -358,7 +341,7 @@ ESimpleURIKey::ESimpleURIKey(const Environment * const e,
const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
MetadataSpecTreeKey<SimpleURISpecTree>(r, h, t),
PrivateImplementationPattern<ESimpleURIKey>(new Implementation<ESimpleURIKey>(e, id, v)),
- _imp(PrivateImplementationPattern<ESimpleURIKey>::_imp.get())
+ _imp(PrivateImplementationPattern<ESimpleURIKey>::_imp)
{
}
@@ -422,7 +405,7 @@ ERestrictKey::ERestrictKey(const Environment * const e,
const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
MetadataSpecTreeKey<RestrictSpecTree>(r, h, t),
PrivateImplementationPattern<ERestrictKey>(new Implementation<ERestrictKey>(e, id, v)),
- _imp(PrivateImplementationPattern<ERestrictKey>::_imp.get())
+ _imp(PrivateImplementationPattern<ERestrictKey>::_imp)
{
}
@@ -485,7 +468,7 @@ EProvideKey::EProvideKey(const Environment * const e, const tr1::shared_ptr<cons
const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
MetadataSpecTreeKey<ProvideSpecTree>(r, h, t),
PrivateImplementationPattern<EProvideKey>(new Implementation<EProvideKey>(e, id, v)),
- _imp(PrivateImplementationPattern<EProvideKey>::_imp.get())
+ _imp(PrivateImplementationPattern<EProvideKey>::_imp)
{
}
@@ -551,7 +534,7 @@ EIUseKey::EIUseKey(
const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
MetadataSetKey<IUseFlagSet>(r, h, t),
PrivateImplementationPattern<EIUseKey>(new Implementation<EIUseKey>(id, e, v)),
- _imp(PrivateImplementationPattern<EIUseKey>::_imp.get())
+ _imp(PrivateImplementationPattern<EIUseKey>::_imp)
{
}
@@ -780,7 +763,7 @@ EKeywordsKey::EKeywordsKey(const Environment * const e, const tr1::shared_ptr<co
const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
MetadataSetKey<KeywordNameSet>(r, h, t),
PrivateImplementationPattern<EKeywordsKey>(new Implementation<EKeywordsKey>(id, e, v)),
- _imp(PrivateImplementationPattern<EKeywordsKey>::_imp.get())
+ _imp(PrivateImplementationPattern<EKeywordsKey>::_imp)
{
}
@@ -853,7 +836,7 @@ EUseKey::EUseKey(const Environment * const e, const tr1::shared_ptr<const ERepos
const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
MetadataSetKey<UseFlagNameSet>(r, h, t),
PrivateImplementationPattern<EUseKey>(new Implementation<EUseKey>(id, e, v)),
- _imp(PrivateImplementationPattern<EUseKey>::_imp.get())
+ _imp(PrivateImplementationPattern<EUseKey>::_imp)
{
}
@@ -925,7 +908,7 @@ EInheritedKey::EInheritedKey(const tr1::shared_ptr<const ERepositoryID> & id,
const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
MetadataSetKey<Set<std::string> >(r, h, t),
PrivateImplementationPattern<EInheritedKey>(new Implementation<EInheritedKey>(id, v)),
- _imp(PrivateImplementationPattern<EInheritedKey>::_imp.get())
+ _imp(PrivateImplementationPattern<EInheritedKey>::_imp)
{
}
@@ -975,7 +958,7 @@ EContentsKey::EContentsKey(const tr1::shared_ptr<const ERepositoryID> & id,
const std::string & r, const std::string & h, const FSEntry & v, const MetadataKeyType t) :
MetadataContentsKey(r, h, t),
PrivateImplementationPattern<EContentsKey>(new Implementation<EContentsKey>(id, v)),
- _imp(PrivateImplementationPattern<EContentsKey>::_imp.get())
+ _imp(PrivateImplementationPattern<EContentsKey>::_imp)
{
}
@@ -1060,7 +1043,7 @@ ECTimeKey::ECTimeKey(const tr1::shared_ptr<const ERepositoryID> & id,
const std::string & r, const std::string & h, const FSEntry & v, const MetadataKeyType t) :
MetadataTimeKey(r, h, t),
PrivateImplementationPattern<ECTimeKey>(new Implementation<ECTimeKey>(id, v)),
- _imp(PrivateImplementationPattern<ECTimeKey>::_imp.get())
+ _imp(PrivateImplementationPattern<ECTimeKey>::_imp)
{
}
@@ -1092,20 +1075,3 @@ ECTimeKey::value() const
return *_imp->value;
}
-EFSLocationKey::EFSLocationKey(const tr1::shared_ptr<const ERepositoryID> &,
- const std::string & r, const std::string & h, const FSEntry & v, const MetadataKeyType t) :
- MetadataFSEntryKey(r, h, t),
- _value(v)
-{
-}
-
-EFSLocationKey::~EFSLocationKey()
-{
-}
-
-const FSEntry
-EFSLocationKey::value() const
-{
- return _value;
-}
-
diff --git a/paludis/repositories/e/e_key.hh b/paludis/repositories/e/e_key.hh
index 054446e..05c774a 100644
--- a/paludis/repositories/e/e_key.hh
+++ b/paludis/repositories/e/e_key.hh
@@ -30,21 +30,6 @@ namespace paludis
{
class ERepositoryID;
- class EStringKey :
- public MetadataStringKey
- {
- private:
- const std::string _value;
-
- public:
- EStringKey(const tr1::shared_ptr<const ERepositoryID> &,
- const std::string &, const std::string &, const std::string &, const MetadataKeyType);
- ~EStringKey();
-
- virtual const std::string value() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
class EMutableRepositoryMaskInfoKey :
public MetadataRepositoryMaskInfoKey
{
@@ -67,7 +52,7 @@ namespace paludis
private PrivateImplementationPattern<EDependenciesKey>
{
private:
- Implementation<EDependenciesKey> * const _imp;
+ PrivateImplementationPattern<EDependenciesKey>::ImpPtr & _imp;
public:
EDependenciesKey(
@@ -91,7 +76,7 @@ namespace paludis
private PrivateImplementationPattern<EFetchableURIKey>
{
private:
- Implementation<EFetchableURIKey> * const _imp;
+ PrivateImplementationPattern<EFetchableURIKey>::ImpPtr & _imp;
public:
EFetchableURIKey(const Environment * const,
@@ -117,7 +102,7 @@ namespace paludis
private PrivateImplementationPattern<ESimpleURIKey>
{
private:
- Implementation<ESimpleURIKey> * const _imp;
+ PrivateImplementationPattern<ESimpleURIKey>::ImpPtr & _imp;
public:
ESimpleURIKey(const Environment * const,
@@ -140,7 +125,7 @@ namespace paludis
private PrivateImplementationPattern<ERestrictKey>
{
private:
- Implementation<ERestrictKey> * const _imp;
+ PrivateImplementationPattern<ERestrictKey>::ImpPtr & _imp;
public:
ERestrictKey(const Environment * const,
@@ -163,7 +148,7 @@ namespace paludis
private PrivateImplementationPattern<EProvideKey>
{
private:
- Implementation<EProvideKey> * const _imp;
+ PrivateImplementationPattern<EProvideKey>::ImpPtr & _imp;
public:
EProvideKey(const Environment * const,
@@ -186,7 +171,7 @@ namespace paludis
private PrivateImplementationPattern<ELicenseKey>
{
private:
- Implementation<ELicenseKey> * const _imp;
+ PrivateImplementationPattern<ELicenseKey>::ImpPtr & _imp;
public:
ELicenseKey(
@@ -210,7 +195,7 @@ namespace paludis
private PrivateImplementationPattern<EIUseKey>
{
private:
- Implementation<EIUseKey> * const _imp;
+ PrivateImplementationPattern<EIUseKey>::ImpPtr & _imp;
public:
EIUseKey(
@@ -238,7 +223,7 @@ namespace paludis
private PrivateImplementationPattern<EKeywordsKey>
{
private:
- Implementation<EKeywordsKey> * const _imp;
+ PrivateImplementationPattern<EKeywordsKey>::ImpPtr & _imp;
public:
EKeywordsKey(
@@ -259,7 +244,7 @@ namespace paludis
private PrivateImplementationPattern<EUseKey>
{
private:
- Implementation<EUseKey> * const _imp;
+ PrivateImplementationPattern<EUseKey>::ImpPtr & _imp;
public:
EUseKey(
@@ -280,7 +265,7 @@ namespace paludis
private PrivateImplementationPattern<EInheritedKey>
{
private:
- Implementation<EInheritedKey> * const _imp;
+ PrivateImplementationPattern<EInheritedKey>::ImpPtr & _imp;
public:
EInheritedKey(const tr1::shared_ptr<const ERepositoryID> &,
@@ -299,7 +284,7 @@ namespace paludis
private PrivateImplementationPattern<EContentsKey>
{
private:
- Implementation<EContentsKey> * const _imp;
+ PrivateImplementationPattern<EContentsKey>::ImpPtr & _imp;
public:
EContentsKey(
@@ -316,7 +301,7 @@ namespace paludis
private PrivateImplementationPattern<ECTimeKey>
{
private:
- Implementation<ECTimeKey> * const _imp;
+ PrivateImplementationPattern<ECTimeKey>::ImpPtr & _imp;
public:
ECTimeKey(const tr1::shared_ptr<const ERepositoryID> &,
@@ -326,21 +311,6 @@ namespace paludis
time_t value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
};
-
- class EFSLocationKey :
- public MetadataFSEntryKey
- {
- private:
- const FSEntry _value;
-
- public:
- EFSLocationKey(const tr1::shared_ptr<const ERepositoryID> &,
- const std::string &, const std::string &, const FSEntry &, const MetadataKeyType);
- ~EFSLocationKey();
-
- const FSEntry value() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
- };
}
}
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index 3b3f3e8..90e3611 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -37,11 +37,11 @@
# include <paludis/repositories/e/qa/qa_controller.hh>
#endif
-#include <paludis/repository_info.hh>
#include <paludis/util/config_file.hh>
#include <paludis/util/create_iterator-impl.hh>
#include <paludis/distribution.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/literal_metadata_key.hh>
#include <paludis/environment.hh>
#include <paludis/hashed_containers.hh>
#include <paludis/hook.hh>
@@ -99,11 +99,82 @@
using namespace paludis;
-typedef MakeHashedMap<QualifiedPackageName, std::list<std::pair<tr1::shared_ptr<const PackageDepSpec>, tr1::shared_ptr<const RepositoryMaskInfo> > > >::Type RepositoryMaskMap;
+typedef MakeHashedMap<QualifiedPackageName,
+ std::list<std::pair<tr1::shared_ptr<const PackageDepSpec>, tr1::shared_ptr<const RepositoryMaskInfo> > > >::Type RepositoryMaskMap;
typedef MakeHashedMultiMap<std::string, std::string>::Type MirrorMap;
typedef MakeHashedMap<QualifiedPackageName, tr1::shared_ptr<const PackageDepSpec> >::Type VirtualsMap;
typedef std::list<RepositoryEInterface::ProfilesDescLine> ProfilesDesc;
+namespace
+{
+ class PkgInfoSectionKey :
+ public MetadataSectionKey
+ {
+ private:
+ mutable Mutex _mutex;
+ mutable bool _added;
+
+ const Environment * const _env;
+ const FSEntry _f;
+
+ protected:
+ virtual void need_keys_added() const
+ {
+ Lock l(_mutex);
+ if (_added)
+ return;
+ _added = true;
+
+ // don't inherit from master_repository, just causes clutter
+ std::set<std::string> info_pkgs;
+ if (_f.exists())
+ {
+ LineConfigFile vars(_f, LineConfigFileOptions());
+ info_pkgs.insert(vars.begin(), vars.end());
+ }
+
+ if (! info_pkgs.empty())
+ {
+ for (std::set<std::string>::const_iterator i(info_pkgs.begin()),
+ i_end(info_pkgs.end()) ; i != i_end ; ++i)
+ {
+ tr1::shared_ptr<MetadataKey> key;
+ tr1::shared_ptr<const PackageIDSequence> q(
+ _env->package_database()->query(
+ query::Matches(PackageDepSpec(*i, pds_pm_eapi_0)) &
+ query::InstalledAtRoot(_env->root()),
+ qo_order_by_version));
+ if (q->empty())
+ key.reset(new LiteralMetadataStringKey(*i, *i, mkt_normal, "(none)"));
+ else
+ {
+ using namespace tr1::placeholders;
+ tr1::shared_ptr<Set<std::string> > s(new Set<std::string>);
+ std::transform(q->begin(), q->end(), s->inserter(),
+ tr1::bind(tr1::mem_fn(&PackageID::canonical_form), _1, idcf_version));
+ key.reset(new LiteralMetadataStringSetKey(*i, *i, mkt_normal, s));
+ }
+
+ add_metadata_key(key);
+ }
+ }
+ }
+
+ public:
+ PkgInfoSectionKey(const Environment * const e, const FSEntry & f) :
+ MetadataSectionKey("info_pkgs", "Package information", mkt_normal),
+ _added(false),
+ _env(e),
+ _f(f)
+ {
+ }
+
+ ~PkgInfoSectionKey()
+ {
+ }
+ };
+}
+
namespace paludis
{
/**
@@ -160,6 +231,29 @@ namespace paludis
void need_profiles() const;
void need_profiles_desc() const;
+
+ tr1::shared_ptr<const MetadataStringKey> format_key;
+ tr1::shared_ptr<const MetadataStringKey> layout_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> location_key;
+ tr1::shared_ptr<const MetadataSetKey<FSEntrySequence> > profiles_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> cache_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> write_cache_key;
+ tr1::shared_ptr<const MetadataStringKey> append_repository_name_to_write_cache_key;
+ tr1::shared_ptr<const MetadataStringKey> ignore_deprecated_profiles;
+ tr1::shared_ptr<const MetadataFSEntryKey> names_cache_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> distdir_key;
+ tr1::shared_ptr<const MetadataSetKey<FSEntrySequence> > eclassdirs_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> securitydir_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> setsdir_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> newsdir_key;
+ tr1::shared_ptr<const MetadataStringKey> sync_key;
+ tr1::shared_ptr<const MetadataStringKey> sync_options_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> builddir_key;
+ tr1::shared_ptr<const MetadataStringKey> master_repository_key;
+ tr1::shared_ptr<const MetadataStringKey> eapi_when_unknown_key;
+ tr1::shared_ptr<const MetadataStringKey> eapi_when_unspecified_key;
+ tr1::shared_ptr<const MetadataStringKey> profile_eapi_key;
+ tr1::shared_ptr<const MetadataSectionKey> info_pkgs_key;
};
Implementation<ERepository>::Implementation(ERepository * const r,
@@ -177,7 +271,57 @@ namespace paludis
layout(erepository::LayoutMaker::get_instance()->find_maker(
params.layout)(r, params.location, entries_ptr, params.master_repository ?
make_shared_ptr(new FSEntry(params.master_repository->params().location)) :
- tr1::shared_ptr<FSEntry>()))
+ tr1::shared_ptr<FSEntry>())),
+ format_key(new LiteralMetadataStringKey("format", "format",
+ mkt_significant, params.entry_format)),
+ layout_key(new LiteralMetadataStringKey("layout", "layout",
+ mkt_normal, params.layout)),
+ location_key(new LiteralMetadataFSEntryKey("location", "location",
+ mkt_significant, params.location)),
+ profiles_key(new LiteralMetadataFSEntrySequenceKey(
+ "profiles", "profiles", mkt_normal, params.profiles)),
+ cache_key(new LiteralMetadataFSEntryKey("cache", "cache",
+ mkt_normal, params.cache)),
+ write_cache_key(new LiteralMetadataFSEntryKey("write_cache", "write_cache",
+ mkt_normal, params.write_cache)),
+ append_repository_name_to_write_cache_key(new LiteralMetadataStringKey(
+ "append_repository_name_to_write_cache", "append_repository_name_to_write_cache",
+ mkt_normal, stringify(params.append_repository_name_to_write_cache))),
+ ignore_deprecated_profiles(new LiteralMetadataStringKey(
+ "ignore_deprecated_profiles", "ignore_deprecated_profiles",
+ mkt_normal, stringify(params.ignore_deprecated_profiles))),
+ names_cache_key(new LiteralMetadataFSEntryKey(
+ "names_cache", "names_cache", mkt_normal, params.names_cache)),
+ distdir_key(new LiteralMetadataFSEntryKey(
+ "distdir", "distdir", mkt_normal, params.distdir)),
+ eclassdirs_key(new LiteralMetadataFSEntrySequenceKey(
+ "eclassdirs", "eclassdirs", mkt_normal, params.eclassdirs)),
+ securitydir_key(new LiteralMetadataFSEntryKey(
+ "securitydir", "securitydir", mkt_normal, params.securitydir)),
+ setsdir_key(new LiteralMetadataFSEntryKey(
+ "setsdir", "setsdir", mkt_normal, params.setsdir)),
+ newsdir_key(new LiteralMetadataFSEntryKey(
+ "newsdir", "newsdir", mkt_normal, params.newsdir)),
+ sync_key(new LiteralMetadataStringKey(
+ "sync", "sync", mkt_normal, params.sync)),
+ sync_options_key(new LiteralMetadataStringKey(
+ "sync_options", "sync_options", mkt_normal, params.sync_options)),
+ builddir_key(new LiteralMetadataFSEntryKey(
+ "builddir", "builddir", mkt_normal, params.builddir)),
+ master_repository_key(params.master_repository ?
+ tr1::shared_ptr<MetadataStringKey>(new LiteralMetadataStringKey(
+ "master_repository", "master_repository", mkt_normal, stringify(params.master_repository->name()))) :
+ tr1::shared_ptr<MetadataStringKey>()),
+ eapi_when_unknown_key(new LiteralMetadataStringKey(
+ "eapi_when_unknown", "eapi_when_unknown", mkt_normal, params.eapi_when_unknown)),
+ eapi_when_unspecified_key(new LiteralMetadataStringKey(
+ "eapi_when_unspecified", "eapi_when_unspecified", mkt_normal, params.eapi_when_unspecified)),
+ profile_eapi_key(new LiteralMetadataStringKey(
+ "profile_eapi", "profile_eapi", mkt_normal, params.profile_eapi)),
+ info_pkgs_key((layout->info_packages_file(params.location / "profiles")).exists() ?
+ tr1::shared_ptr<MetadataSectionKey>(new PkgInfoSectionKey(
+ params.environment, layout->info_packages_file(params.location / "profiles"))) :
+ tr1::shared_ptr<MetadataSectionKey>())
{
}
@@ -292,7 +436,6 @@ namespace
ERepository::ERepository(const ERepositoryParams & p) :
Repository(fetch_repo_name(p.location),
RepositoryCapabilities::create()
- .installed_interface(0)
.sets_interface(this)
.syncable_interface(this)
.use_interface(this)
@@ -311,48 +454,47 @@ ERepository::ERepository(const ERepositoryParams & p) :
.qa_interface(0)
#endif
.hook_interface(this)
- .manifest_interface(this),
- p.entry_format),
- PrivateImplementationPattern<ERepository>(new Implementation<ERepository>(this, p))
+ .manifest_interface(this)),
+ PrivateImplementationPattern<ERepository>(new Implementation<ERepository>(this, p)),
+ _imp(PrivateImplementationPattern<ERepository>::_imp)
{
- // the info_vars and info_pkgs info is only added on demand, since it's
- // fairly slow to calculate.
- tr1::shared_ptr<RepositoryInfoSection> config_info(new RepositoryInfoSection("Configuration information"));
-
- config_info->add_kv("entry_format", _imp->params.entry_format);
- config_info->add_kv("layout", _imp->params.layout);
- config_info->add_kv("location", stringify(_imp->params.location));
- config_info->add_kv("profiles", join(_imp->params.profiles->begin(),
- _imp->params.profiles->end(), " "));
- config_info->add_kv("cache", stringify(_imp->params.cache));
- config_info->add_kv("write_cache", stringify(_imp->params.write_cache));
- config_info->add_kv("append_repository_name_to_write_cache", stringify(_imp->params.append_repository_name_to_write_cache));
- config_info->add_kv("ignore_deprecated_profiles", stringify(_imp->params.ignore_deprecated_profiles));
- config_info->add_kv("names_cache", stringify(_imp->params.names_cache));
- config_info->add_kv("distdir", stringify(_imp->params.distdir));
- config_info->add_kv("eclassdirs", join(_imp->params.eclassdirs->begin(),
- _imp->params.eclassdirs->end(), " "));
- config_info->add_kv("securitydir", stringify(_imp->params.securitydir));
- config_info->add_kv("setsdir", stringify(_imp->params.setsdir));
- config_info->add_kv("newsdir", stringify(_imp->params.newsdir));
- config_info->add_kv("sync", _imp->params.sync);
- config_info->add_kv("sync_options", _imp->params.sync_options);
- config_info->add_kv("builddir", stringify(_imp->params.builddir));
- if (_imp->params.master_repository)
- config_info->add_kv("master_repository", stringify(_imp->params.master_repository->name()));
- config_info->add_kv("format", _imp->params.entry_format);
- config_info->add_kv("layout", _imp->params.layout);
- config_info->add_kv("eapi_when_unknown", _imp->params.eapi_when_unknown);
- config_info->add_kv("eapi_when_unspecified", _imp->params.eapi_when_unspecified);
- config_info->add_kv("profile_eapi", _imp->params.profile_eapi);
-
- _info->add_section(config_info);
+ _add_metadata_keys();
}
ERepository::~ERepository()
{
}
+void
+ERepository::_add_metadata_keys() const
+{
+ clear_metadata_keys();
+ add_metadata_key(_imp->format_key);
+ add_metadata_key(_imp->layout_key);
+ add_metadata_key(_imp->location_key);
+ add_metadata_key(_imp->profiles_key);
+ add_metadata_key(_imp->cache_key);
+ add_metadata_key(_imp->write_cache_key);
+ add_metadata_key(_imp->append_repository_name_to_write_cache_key);
+ add_metadata_key(_imp->ignore_deprecated_profiles);
+ add_metadata_key(_imp->names_cache_key);
+ add_metadata_key(_imp->distdir_key);
+ add_metadata_key(_imp->eclassdirs_key);
+ add_metadata_key(_imp->securitydir_key);
+ add_metadata_key(_imp->setsdir_key);
+ add_metadata_key(_imp->newsdir_key);
+ add_metadata_key(_imp->sync_key);
+ add_metadata_key(_imp->sync_options_key);
+ add_metadata_key(_imp->builddir_key);
+ add_metadata_key(_imp->eapi_when_unknown_key);
+ add_metadata_key(_imp->eapi_when_unspecified_key);
+ add_metadata_key(_imp->profile_eapi_key);
+ if (_imp->master_repository_key)
+ add_metadata_key(_imp->master_repository_key);
+ if (_imp->info_pkgs_key)
+ add_metadata_key(_imp->info_pkgs_key);
+}
+
bool
ERepository::has_category_named(const CategoryNamePart & c) const
{
@@ -611,6 +753,7 @@ void
ERepository::invalidate()
{
_imp.reset(new Implementation<ERepository>(this, _imp->params, _imp->mutexes));
+ _add_metadata_keys();
}
void
@@ -668,56 +811,6 @@ ERepository::get_environment_variable(
var, _imp->profile_ptr);
}
-tr1::shared_ptr<const RepositoryInfo>
-ERepository::info(bool verbose) const
-{
- tr1::shared_ptr<const RepositoryInfo> result_non_verbose(Repository::info(verbose));
- if (! verbose)
- return result_non_verbose;
-
- tr1::shared_ptr<RepositoryInfo> result(new RepositoryInfo);
-
- for (RepositoryInfo::SectionConstIterator s(result_non_verbose->begin_sections()),
- s_end(result_non_verbose->end_sections()) ; s != s_end ; ++s)
- result->add_section(*s);
-
- // don't inherit from master_repository, just causes clutter
- std::set<std::string> info_pkgs;
- if ((_imp->layout->info_packages_file(_imp->params.location / "profiles")).exists())
- {
- LineConfigFile vars(_imp->layout->info_packages_file(_imp->params.location / "profiles"), LineConfigFileOptions());
- info_pkgs.insert(vars.begin(), vars.end());
- }
-
- if (! info_pkgs.empty())
- {
- tr1::shared_ptr<RepositoryInfoSection> package_info(new RepositoryInfoSection("Package information"));
- for (std::set<std::string>::const_iterator i(info_pkgs.begin()),
- i_end(info_pkgs.end()) ; i != i_end ; ++i)
- {
- tr1::shared_ptr<const PackageIDSequence> q(
- _imp->params.environment->package_database()->query(
- query::Matches(PackageDepSpec(*i, pds_pm_eapi_0)) &
- query::InstalledAtRoot(_imp->params.environment->root()),
- qo_order_by_version));
- if (q->empty())
- package_info->add_kv(*i, "(none)");
- else
- {
- using namespace tr1::placeholders;
- std::set<VersionSpec> versions;
- std::transform(q->begin(), q->end(), std::inserter(versions, versions.begin()),
- tr1::bind<const VersionSpec>(tr1::mem_fn(&PackageID::version), _1));
- package_info->add_kv(*i, join(versions.begin(), versions.end(), ", "));
- }
- }
-
- result->add_section(package_info);
- }
-
- return result;
-}
-
std::string
ERepository::profile_variable(const std::string & s) const
{
@@ -935,7 +1028,7 @@ ERepository::params() const
bool
ERepository::is_suitable_destination_for(const PackageID & e) const
{
- std::string f(e.repository()->format());
+ std::string f(e.repository()->format_key() ? e.repository()->format_key()->value() : "");
return f == "ebuild" || f == "ebin";
}
@@ -1217,3 +1310,20 @@ ERepository::info_variables_file(const FSEntry & f) const
return layout()->info_variables_file(f);
}
+void
+ERepository::need_keys_added() const
+{
+}
+
+const tr1::shared_ptr<const MetadataStringKey>
+ERepository::format_key() const
+{
+ return _imp->format_key;
+}
+
+const tr1::shared_ptr<const MetadataFSEntryKey>
+ERepository::installed_root_key() const
+{
+ return tr1::shared_ptr<const MetadataFSEntryKey>();
+}
+
diff --git a/paludis/repositories/e/e_repository.hh b/paludis/repositories/e/e_repository.hh
index 576f176..d2beabc 100644
--- a/paludis/repositories/e/e_repository.hh
+++ b/paludis/repositories/e/e_repository.hh
@@ -66,11 +66,15 @@ namespace paludis
private PrivateImplementationPattern<ERepository>
{
private:
+ PrivateImplementationPattern<ERepository>::ImpPtr & _imp;
+ void _add_metadata_keys() const;
+
void need_mirrors() const;
- public:
- virtual tr1::shared_ptr<const RepositoryInfo> info(bool verbose) const;
+ protected:
+ virtual void need_keys_added() const;
+ public:
/**
* Constructor.
*/
@@ -233,6 +237,11 @@ namespace paludis
tr1::shared_ptr<const RepositoryMaskInfo> repository_masked(const PackageID &) const;
void regenerate_cache() 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/e/ebuild_entries.cc b/paludis/repositories/e/ebuild_entries.cc
index 5374be8..7294bd1 100644
--- a/paludis/repositories/e/ebuild_entries.cc
+++ b/paludis/repositories/e/ebuild_entries.cc
@@ -187,8 +187,8 @@ namespace
if (destinations)
for (DestinationsSet::ConstIterator d(destinations->begin()), d_end(destinations->end()) ;
d != d_end ; ++d)
- if ((*d)->installed_interface)
- return (*d)->installed_interface->root();
+ if ((*d)->installed_root_key())
+ return ((*d)->installed_root_key()->value());
return FSEntry("/");
}
@@ -609,7 +609,7 @@ EbuildEntries::install(const tr1::shared_ptr<const ERepositoryID> & id,
.aa(all_archives)
.use_expand(join(p->begin_use_expand(), p->end_use_expand(), " "))
.expand_vars(expand_vars)
- .root(o.destination->installed_interface ? stringify(o.destination->installed_interface->root()) : "/")
+ .root(o.destination->installed_root_key() ? stringify(o.destination->installed_root_key()->value()) : "/")
.profiles(_imp->params.profiles)
.disable_cfgpro(o.no_config_protect)
.debug_build(o.debug_build)
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index d116e95..94737aa 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -33,6 +33,7 @@
#include <paludis/distribution.hh>
#include <paludis/environment.hh>
#include <paludis/action.hh>
+#include <paludis/literal_metadata_key.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/stringify.hh>
@@ -82,8 +83,8 @@ namespace paludis
mutable bool has_keys;
mutable bool has_masks;
- mutable tr1::shared_ptr<const EFSLocationKey> fs_location;
- mutable tr1::shared_ptr<const EStringKey> short_description;
+ mutable tr1::shared_ptr<const LiteralMetadataFSEntryKey> fs_location;
+ mutable tr1::shared_ptr<const LiteralMetadataStringKey> short_description;
mutable tr1::shared_ptr<const EDependenciesKey> build_dependencies;
mutable tr1::shared_ptr<const EDependenciesKey> run_dependencies;
mutable tr1::shared_ptr<const EDependenciesKey> post_dependencies;
@@ -125,7 +126,7 @@ EbuildID::EbuildID(const QualifiedPackageName & q, const VersionSpec & v,
const time_t t,
const tr1::shared_ptr<const EclassMtimes> & m) :
PrivateImplementationPattern<EbuildID>(new Implementation<EbuildID>(q, v, e, r, f, g, t, m)),
- _imp(PrivateImplementationPattern<EbuildID>::_imp.get())
+ _imp(PrivateImplementationPattern<EbuildID>::_imp)
{
}
@@ -146,8 +147,8 @@ EbuildID::need_keys_added() const
// fs_location key could have been loaded by the ::fs_location_key() already.
if (! _imp->fs_location)
{
- _imp->fs_location.reset(new EFSLocationKey(shared_from_this(), "EBUILD", "Ebuild Location",
- _imp->ebuild, mkt_internal));
+ _imp->fs_location.reset(new LiteralMetadataFSEntryKey("EBUILD", "Ebuild Location",
+ mkt_internal, _imp->ebuild));
add_metadata_key(_imp->fs_location);
}
@@ -251,7 +252,7 @@ EbuildID::need_keys_added() const
}
}
- add_metadata_key(make_shared_ptr(new EStringKey(shared_from_this(), "EAPI", "EAPI", _imp->eapi->name, mkt_internal)));
+ add_metadata_key(make_shared_ptr(new LiteralMetadataStringKey("EAPI", "EAPI", mkt_internal, _imp->eapi->name)));
_imp->repository_mask = make_shared_ptr(new EMutableRepositoryMaskInfoKey(shared_from_this(), "repository_mask", "Repository masked",
tr1::static_pointer_cast<const ERepository>(repository())->repository_masked(*this), mkt_internal));
@@ -595,8 +596,7 @@ EbuildID::fs_location_key() const
{
Lock l(_imp->mutex);
- _imp->fs_location.reset(new EFSLocationKey(shared_from_this(), "EBUILD", "Ebuild Location",
- _imp->ebuild, mkt_internal));
+ _imp->fs_location.reset(new LiteralMetadataFSEntryKey("EBUILD", "Ebuild Location", mkt_internal, _imp->ebuild));
add_metadata_key(_imp->fs_location);
}
@@ -639,7 +639,7 @@ void
EbuildID::load_short_description(const std::string & r, const std::string & h, const std::string & v) const
{
Lock l(_imp->mutex);
- _imp->short_description.reset(new EStringKey(shared_from_this(), r, h, v, mkt_significant));
+ _imp->short_description.reset(new LiteralMetadataStringKey(r, h, mkt_significant, v));
add_metadata_key(_imp->short_description);
}
diff --git a/paludis/repositories/e/ebuild_id.hh b/paludis/repositories/e/ebuild_id.hh
index 65e54fc..29dc6ca 100644
--- a/paludis/repositories/e/ebuild_id.hh
+++ b/paludis/repositories/e/ebuild_id.hh
@@ -39,7 +39,7 @@ namespace paludis
private PrivateImplementationPattern<EbuildID>
{
private:
- Implementation<EbuildID> * const _imp;
+ PrivateImplementationPattern<EbuildID>::ImpPtr & _imp;
protected:
virtual void need_keys_added() const;
diff --git a/paludis/repositories/e/make_ebin_repository.cc b/paludis/repositories/e/make_ebin_repository.cc
index cfb8717..dfd0ce6 100644
--- a/paludis/repositories/e/make_ebin_repository.cc
+++ b/paludis/repositories/e/make_ebin_repository.cc
@@ -29,6 +29,7 @@
#include <paludis/repositories/e/e_repository_exceptions.hh>
#include <paludis/environment.hh>
#include <paludis/distribution.hh>
+#include <paludis/metadata_key.hh>
using namespace paludis;
@@ -58,9 +59,12 @@ paludis::make_ebin_repository(
tr1::shared_ptr<const Repository> master_repository_uncasted(
env->package_database()->fetch_repository(*master_repository_name));
- if (master_repository_uncasted->format() != "ebuild" && master_repository_uncasted->format() != "ebin")
+ std::string format("unknown");
+ if (master_repository_uncasted->format_key())
+ format = master_repository_uncasted->format_key()->value();
+ if (format != "ebuild" && format != "ebin")
throw ERepositoryConfigurationError("Master repository format is '" +
- stringify(master_repository_uncasted->format()) + "', not 'ebuild' or 'ebin'");
+ stringify(format) + "', not 'ebuild' or 'ebin'");
master_repository = tr1::static_pointer_cast<const ERepository>(master_repository_uncasted);
diff --git a/paludis/repositories/e/make_ebuild_repository.cc b/paludis/repositories/e/make_ebuild_repository.cc
index 708c142..5f50796 100644
--- a/paludis/repositories/e/make_ebuild_repository.cc
+++ b/paludis/repositories/e/make_ebuild_repository.cc
@@ -29,6 +29,7 @@
#include <paludis/repositories/e/e_repository_exceptions.hh>
#include <paludis/environment.hh>
#include <paludis/distribution.hh>
+#include <paludis/metadata_key.hh>
using namespace paludis;
@@ -58,9 +59,12 @@ paludis::make_ebuild_repository(
tr1::shared_ptr<const Repository> master_repository_uncasted(
env->package_database()->fetch_repository(*master_repository_name));
- if (master_repository_uncasted->format() != "ebuild")
+ std::string format("unknown");
+ if (master_repository_uncasted->format_key())
+ format = master_repository_uncasted->format_key()->value();
+ if (format != "ebuild")
throw ERepositoryConfigurationError("Master repository format is '" +
- stringify(master_repository_uncasted->format()) + "', not 'ebuild'");
+ stringify(format) + "', not 'ebuild'");
master_repository = tr1::static_pointer_cast<const ERepository>(master_repository_uncasted);
diff --git a/paludis/repositories/e/qa/spec_keys.cc b/paludis/repositories/e/qa/spec_keys.cc
index 2f8441d..c839143 100644
--- a/paludis/repositories/e/qa/spec_keys.cc
+++ b/paludis/repositories/e/qa/spec_keys.cc
@@ -294,6 +294,10 @@ namespace
{
}
+ void visit(const MetadataSetKey<FSEntrySequence> &)
+ {
+ }
+
void visit(const MetadataSetKey<UseFlagNameSet> &)
{
}
diff --git a/paludis/repositories/e/vdb_id.cc b/paludis/repositories/e/vdb_id.cc
index b86b3c2..24e86d4 100644
--- a/paludis/repositories/e/vdb_id.cc
+++ b/paludis/repositories/e/vdb_id.cc
@@ -36,6 +36,7 @@
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/strip.hh>
#include <paludis/util/mutex.hh>
+#include <paludis/literal_metadata_key.hh>
#include <iterator>
#include <fstream>
@@ -119,7 +120,7 @@ VDBID::VDBID(const QualifiedPackageName & q, const VersionSpec & v,
const tr1::shared_ptr<const Repository> & r,
const FSEntry & f) :
PrivateImplementationPattern<VDBID>(new Implementation<VDBID>(q, v, e, r, f)),
- _imp(PrivateImplementationPattern<VDBID>::_imp.get())
+ _imp(PrivateImplementationPattern<VDBID>::_imp)
{
}
@@ -140,8 +141,8 @@ VDBID::need_keys_added() const
// fs_location key could have been loaded by the ::fs_location_key() already.
if (! _imp->fs_location)
{
- _imp->fs_location.reset(new EFSLocationKey(shared_from_this(), "VDBDIR", "VDB Location",
- _imp->dir, mkt_internal));
+ _imp->fs_location.reset(new LiteralMetadataFSEntryKey("VDBDIR", "VDB Location",
+ mkt_internal, _imp->dir));
add_metadata_key(_imp->fs_location);
}
@@ -245,8 +246,8 @@ VDBID::need_keys_added() const
if (! vars->metadata_description.empty())
if ((_imp->dir / vars->metadata_description).exists())
{
- _imp->short_description.reset(new EStringKey(shared_from_this(), vars->metadata_description,
- vars->description_description, file_contents(_imp->dir / vars->metadata_description), mkt_significant));
+ _imp->short_description.reset(new LiteralMetadataStringKey(vars->metadata_description,
+ vars->description_description, mkt_significant, file_contents(_imp->dir / vars->metadata_description)));
add_metadata_key(_imp->short_description);
}
@@ -268,71 +269,71 @@ VDBID::need_keys_added() const
if ((_imp->dir / "REPOSITORY").exists())
{
- _imp->source_origin.reset(new EStringKey(shared_from_this(), "REPOSITORY", "Source repository",
- file_contents(_imp->dir / "REPOSITORY"), mkt_normal));
+ _imp->source_origin.reset(new LiteralMetadataStringKey("REPOSITORY", "Source repository",
+ mkt_normal, file_contents(_imp->dir / "REPOSITORY")));
add_metadata_key(_imp->source_origin);
}
if ((_imp->dir / "BINARY_REPOSITORY").exists())
{
- _imp->binary_origin.reset(new EStringKey(shared_from_this(), "BINARY_REPOSITORY", "Binary repository",
- file_contents(_imp->dir / "BINARY_REPOSITORY"), mkt_normal));
+ _imp->binary_origin.reset(new LiteralMetadataStringKey("BINARY_REPOSITORY", "Binary repository",
+ mkt_normal, file_contents(_imp->dir / "BINARY_REPOSITORY")));
add_metadata_key(_imp->binary_origin);
}
if ((_imp->dir / "ASFLAGS").exists())
{
- _imp->asflags.reset(new EStringKey(shared_from_this(), "ASFLAGS", "ASFLAGS",
- file_contents(_imp->dir / "ASFLAGS"), mkt_internal));
+ _imp->asflags.reset(new LiteralMetadataStringKey("ASFLAGS", "ASFLAGS",
+ mkt_internal, file_contents(_imp->dir / "ASFLAGS")));
add_metadata_key(_imp->asflags);
}
if ((_imp->dir / "CBUILD").exists())
{
- _imp->cbuild.reset(new EStringKey(shared_from_this(), "CBUILD", "CBUILD",
- file_contents(_imp->dir / "CBUILD"), mkt_internal));
+ _imp->cbuild.reset(new LiteralMetadataStringKey("CBUILD", "CBUILD",
+ mkt_internal, file_contents(_imp->dir / "CBUILD")));
add_metadata_key(_imp->cbuild);
}
if ((_imp->dir / "CFLAGS").exists())
{
- _imp->cflags.reset(new EStringKey(shared_from_this(), "CFLAGS", "CFLAGS",
- file_contents(_imp->dir / "CFLAGS"), mkt_internal));
+ _imp->cflags.reset(new LiteralMetadataStringKey("CFLAGS", "CFLAGS",
+ mkt_internal, file_contents(_imp->dir / "CFLAGS")));
add_metadata_key(_imp->cflags);
}
if ((_imp->dir / "CHOST").exists())
{
- _imp->chost.reset(new EStringKey(shared_from_this(), "CHOST", "CHOST",
- file_contents(_imp->dir / "CHOST"), mkt_internal));
+ _imp->chost.reset(new LiteralMetadataStringKey("CHOST", "CHOST",
+ mkt_internal, file_contents(_imp->dir / "CHOST")));
add_metadata_key(_imp->chost);
}
if ((_imp->dir / "CXXFLAGS").exists())
{
- _imp->cxxflags.reset(new EStringKey(shared_from_this(), "CXXFLAGS", "CXXFLAGS",
- file_contents(_imp->dir / "CXXFLAGS"), mkt_internal));
+ _imp->cxxflags.reset(new LiteralMetadataStringKey("CXXFLAGS", "CXXFLAGS",
+ mkt_internal, file_contents(_imp->dir / "CXXFLAGS")));
add_metadata_key(_imp->cxxflags);
}
if ((_imp->dir / "LDFLAGS").exists())
{
- _imp->ldflags.reset(new EStringKey(shared_from_this(), "LDFLAGS", "LDFLAGS",
- file_contents(_imp->dir / "LDFLAGS"), mkt_internal));
+ _imp->ldflags.reset(new LiteralMetadataStringKey("LDFLAGS", "LDFLAGS",
+ mkt_internal, file_contents(_imp->dir / "LDFLAGS")));
add_metadata_key(_imp->ldflags);
}
if ((_imp->dir / "PKGMANAGER").exists())
{
- _imp->pkgmanager.reset(new EStringKey(shared_from_this(), "PKGMANAGER", "Installed using",
- file_contents(_imp->dir / "PKGMANAGER"), mkt_normal));
+ _imp->pkgmanager.reset(new LiteralMetadataStringKey("PKGMANAGER", "Installed using",
+ mkt_normal, file_contents(_imp->dir / "PKGMANAGER")));
add_metadata_key(_imp->pkgmanager);
}
if ((_imp->dir / "VDB_FORMAT").exists())
{
- _imp->vdb_format.reset(new EStringKey(shared_from_this(), "VDB_FORMAT", "VDB Format",
- file_contents(_imp->dir / "VDB_FORMAT"), mkt_internal));
+ _imp->vdb_format.reset(new LiteralMetadataStringKey("VDB_FORMAT", "VDB Format",
+ mkt_internal, file_contents(_imp->dir / "VDB_FORMAT")));
add_metadata_key(_imp->vdb_format);
}
}
@@ -572,8 +573,7 @@ VDBID::fs_location_key() const
{
Lock l(_imp->mutex);
- _imp->fs_location.reset(new EFSLocationKey(shared_from_this(), "VDBDIR", "VDB Location",
- _imp->dir, mkt_internal));
+ _imp->fs_location.reset(new LiteralMetadataFSEntryKey("VDBDIR", "VDB Location", mkt_internal, _imp->dir));
add_metadata_key(_imp->fs_location);
}
diff --git a/paludis/repositories/e/vdb_id.hh b/paludis/repositories/e/vdb_id.hh
index d1582a9..c61a5e3 100644
--- a/paludis/repositories/e/vdb_id.hh
+++ b/paludis/repositories/e/vdb_id.hh
@@ -36,7 +36,7 @@ namespace paludis
private PrivateImplementationPattern<VDBID>
{
private:
- Implementation<VDBID> * const _imp;
+ PrivateImplementationPattern<VDBID>::ImpPtr & _imp;
protected:
virtual void need_keys_added() const;
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index caa598a..8e1c25b 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -31,6 +31,7 @@
#include <paludis/action.hh>
#include <paludis/util/config_file.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/literal_metadata_key.hh>
#include <paludis/dep_spec_flattener.hh>
#include <paludis/dep_tag.hh>
#include <paludis/distribution.hh>
@@ -42,7 +43,6 @@
#include <paludis/package_database.hh>
#include <paludis/package_id.hh>
#include <paludis/repositories/e/ebuild.hh>
-#include <paludis/repository_info.hh>
#include <paludis/repository_name_cache.hh>
#include <paludis/set_file.hh>
#include <paludis/version_operator.hh>
@@ -74,12 +74,6 @@
#include <vector>
#include <list>
-/** \file
- * Implementation for VDBRepository.
- *
- * \ingroup grpvdbrepository
- */
-
using namespace paludis;
using namespace paludis::erepository;
@@ -90,11 +84,6 @@ typedef MakeHashedMap<QualifiedPackageName, tr1::shared_ptr<PackageIDSequence> >
namespace paludis
{
- /**
- * Implementation data for VDBRepository.
- *
- * \ingroup grpvdbrepository
- */
template <>
struct Implementation<VDBRepository>
{
@@ -111,6 +100,14 @@ namespace paludis
Implementation(const VDBRepository * const, const VDBRepositoryParams &, tr1::shared_ptr<Mutex> = make_shared_ptr(new Mutex));
~Implementation();
+
+ tr1::shared_ptr<const MetadataFSEntryKey> location_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> root_key;
+ tr1::shared_ptr<const MetadataStringKey> format_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> world_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> provides_cache_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> names_cache_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> builddir_key;
};
Implementation<VDBRepository>::Implementation(const VDBRepository * const r,
@@ -118,7 +115,21 @@ namespace paludis
params(p),
big_nasty_mutex(m),
has_category_names(false),
- names_cache(new RepositoryNameCache(p.names_cache, r))
+ names_cache(new RepositoryNameCache(p.names_cache, r)),
+ location_key(new LiteralMetadataFSEntryKey("location", "location",
+ mkt_significant, params.location)),
+ root_key(new LiteralMetadataFSEntryKey("root", "root",
+ mkt_normal, params.root)),
+ format_key(new LiteralMetadataStringKey("format", "format",
+ mkt_significant, "vdb")),
+ world_key(new LiteralMetadataFSEntryKey("world", "world",
+ mkt_normal, params.world)),
+ provides_cache_key(new LiteralMetadataFSEntryKey("provides_cache", "provides_cache",
+ mkt_normal, params.provides_cache)),
+ names_cache_key(new LiteralMetadataFSEntryKey("names_cache", "names_cache",
+ mkt_normal, params.names_cache)),
+ builddir_key(new LiteralMetadataFSEntryKey("builddir", "builddir",
+ mkt_normal, params.builddir))
{
}
@@ -130,7 +141,6 @@ namespace paludis
VDBRepository::VDBRepository(const VDBRepositoryParams & p) :
Repository(RepositoryName("installed"),
RepositoryCapabilities::create()
- .installed_interface(this)
.sets_interface(this)
.syncable_interface(0)
.use_interface(this)
@@ -144,27 +154,30 @@ VDBRepository::VDBRepository(const VDBRepositoryParams & p) :
.make_virtuals_interface(0)
.qa_interface(0)
.hook_interface(this)
- .manifest_interface(0),
- "vdb"),
- PrivateImplementationPattern<VDBRepository>(new Implementation<VDBRepository>(this, p))
+ .manifest_interface(0)),
+ PrivateImplementationPattern<VDBRepository>(new Implementation<VDBRepository>(this, p)),
+ _imp(PrivateImplementationPattern<VDBRepository>::_imp)
{
- tr1::shared_ptr<RepositoryInfoSection> config_info(new RepositoryInfoSection("Configuration information"));
-
- config_info->add_kv("location", stringify(_imp->params.location));
- config_info->add_kv("root", stringify(_imp->params.root));
- config_info->add_kv("format", "vdb");
- config_info->add_kv("world", stringify(_imp->params.world));
- config_info->add_kv("provides_cache", stringify(_imp->params.provides_cache));
- config_info->add_kv("names_cache", stringify(_imp->params.names_cache));
- config_info->add_kv("builddir", stringify(_imp->params.builddir));
-
- _info->add_section(config_info);
+ _add_metadata_keys();
}
VDBRepository::~VDBRepository()
{
}
+void
+VDBRepository::_add_metadata_keys() const
+{
+ clear_metadata_keys();
+ add_metadata_key(_imp->location_key);
+ add_metadata_key(_imp->root_key);
+ add_metadata_key(_imp->format_key);
+ add_metadata_key(_imp->world_key);
+ add_metadata_key(_imp->provides_cache_key);
+ add_metadata_key(_imp->names_cache_key);
+ add_metadata_key(_imp->builddir_key);
+}
+
bool
VDBRepository::has_category_named(const CategoryNamePart & c) const
{
@@ -404,7 +417,7 @@ VDBRepository::perform_uninstall(const tr1::shared_ptr<const ERepositoryID> & id
VDBUnmerger unmerger(
VDBUnmergerOptions::create()
.environment(_imp->params.environment)
- .root(root())
+ .root(installed_root_key()->value())
.contents_file(pkg_dir / "CONTENTS")
.config_protect(config_protect)
.config_protect_mask(config_protect_mask)
@@ -654,8 +667,8 @@ void
VDBRepository::invalidate()
{
Lock l(*_imp->big_nasty_mutex);
-
_imp.reset(new Implementation<VDBRepository>(this, _imp->params, _imp->big_nasty_mutex));
+ _add_metadata_keys();
}
void
@@ -1038,14 +1051,14 @@ VDBRepository::category_names_containing_package(const PackageNamePart & p) cons
bool
VDBRepository::is_suitable_destination_for(const PackageID & e) const
{
- std::string f(e.repository()->format());
+ std::string f(e.repository()->format_key() ? e.repository()->format_key()->value() : "");
return f == "ebuild" || f == "ebin";
}
bool
VDBRepository::is_default_destination() const
{
- return _imp->params.environment->root() == root();
+ return _imp->params.environment->root() == installed_root_key()->value();
}
std::string
@@ -1054,12 +1067,6 @@ VDBRepository::describe_use_flag(const UseFlagName &, const PackageID &) const
return "";
}
-FSEntry
-VDBRepository::root() const
-{
- return _imp->params.root;
-}
-
bool
VDBRepository::want_pre_post_phases() const
{
@@ -1113,7 +1120,7 @@ VDBRepository::merge(const MergeOptions & m)
VDBMergerOptions::create()
.environment(_imp->params.environment)
.image(m.image_dir)
- .root(root())
+ .root(installed_root_key()->value())
.contents_file(vdb_dir / "CONTENTS")
.config_protect(config_protect)
.config_protect_mask(config_protect_mask)
@@ -1149,7 +1156,7 @@ VDBRepository::merge(const MergeOptions & m)
VDBPostMergeCommand post_merge_command(
VDBPostMergeCommandParams::create()
- .root(root()));
+ .root(installed_root_key()->value()));
post_merge_command();
}
@@ -1312,3 +1319,20 @@ VDBRepository::some_ids_might_support_action(const SupportsActionTestBase & a) c
return q.result;
}
+void
+VDBRepository::need_keys_added() const
+{
+}
+
+const tr1::shared_ptr<const MetadataStringKey>
+VDBRepository::format_key() const
+{
+ return _imp->format_key;
+}
+
+const tr1::shared_ptr<const MetadataFSEntryKey>
+VDBRepository::installed_root_key() const
+{
+ return _imp->root_key;
+}
+
diff --git a/paludis/repositories/e/vdb_repository.hh b/paludis/repositories/e/vdb_repository.hh
index bd65893..0469d1c 100644
--- a/paludis/repositories/e/vdb_repository.hh
+++ b/paludis/repositories/e/vdb_repository.hh
@@ -50,7 +50,6 @@ namespace paludis
*/
class PALUDIS_VISIBLE VDBRepository :
public Repository,
- public RepositoryInstalledInterface,
public RepositoryUseInterface,
public RepositorySetsInterface,
public RepositoryWorldInterface,
@@ -62,6 +61,9 @@ namespace paludis
public PrivateImplementationPattern<VDBRepository>
{
private:
+ PrivateImplementationPattern<VDBRepository>::ImpPtr & _imp;
+ void _add_metadata_keys() const;
+
bool load_provided_using_cache() const;
void load_provided_the_slow_way() const;
@@ -81,6 +83,9 @@ namespace paludis
const FSEntry &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
+ protected:
+ virtual void need_keys_added() const;
+
public:
/**
* Constructor.
@@ -117,11 +122,6 @@ namespace paludis
///\}
- /* RepositoryInstalledInterface */
-
- virtual FSEntry root() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
/* RepositoryUseInterface */
virtual UseFlagState query_use(const UseFlagName &, const PackageID &) const
@@ -203,40 +203,28 @@ namespace paludis
const QualifiedPackageName &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- /**
- * Override in descendents: fetch package names.
- */
virtual tr1::shared_ptr<const QualifiedPackageNameSet> package_names(
const CategoryNamePart &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- /**
- * Override in descendents: fetch category names.
- */
virtual tr1::shared_ptr<const CategoryNamePartSet> category_names() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- /**
- * Override in descendents if a fast implementation is available: fetch category names
- * that contain a particular package.
- */
virtual tr1::shared_ptr<const CategoryNamePartSet> category_names_containing_package(
const PackageNamePart &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- /**
- * Override in descendents: check for a package.
- */
virtual bool has_package_named(const QualifiedPackageName &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- /**
- * Override in descendents: check for a category.
- */
virtual bool has_category_named(const CategoryNamePart &) const
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_installed_repository.cc b/paludis/repositories/fake/fake_installed_repository.cc
index 9ea6280..ba31ae5 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 782c22a..0450824 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 6f0a1cd..ea502f1 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 20c3dcc..1c119d0 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 4f1d3a4..49c733f 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 6eea633..efdc61a 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 54bb6ba..e2d0ba1 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 3af5a51..eaf20f9 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));
-
};
}
diff --git a/paludis/repositories/gems/gem_specification.cc b/paludis/repositories/gems/gem_specification.cc
index 47bd40b..4100627 100644
--- a/paludis/repositories/gems/gem_specification.cc
+++ b/paludis/repositories/gems/gem_specification.cc
@@ -30,69 +30,11 @@
#include <paludis/metadata_key.hh>
#include <paludis/action.hh>
#include <paludis/environment.hh>
+#include <paludis/literal_metadata_key.hh>
using namespace paludis;
using namespace paludis::gems;
-namespace
-{
- class GemMetadataStringKey :
- public MetadataStringKey
- {
- private:
- const std::string _value;
-
- public:
- GemMetadataStringKey(const std::string &, const std::string &, const std::string &,
- const MetadataKeyType);
-
- virtual const std::string value() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
-
- GemMetadataStringKey::GemMetadataStringKey(const std::string & r, const std::string & h, const std::string & v,
- const MetadataKeyType t) :
- MetadataStringKey(r, h, t),
- _value(v)
- {
- }
-
- const std::string
- GemMetadataStringKey::value() const
- {
- return _value;
- }
-
- class GemMetadataFSEntryKey :
- public MetadataFSEntryKey
- {
- private:
- const FSEntry _value;
-
- public:
- GemMetadataFSEntryKey(const std::string &, const std::string &, const FSEntry &,
- const MetadataKeyType);
-
- virtual const FSEntry value() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
-
- GemMetadataFSEntryKey::GemMetadataFSEntryKey(const std::string & r, const std::string & h,
- const FSEntry & v, const MetadataKeyType t) :
- MetadataFSEntryKey(r, h, t),
- _value(v)
- {
- }
-
- const FSEntry
- GemMetadataFSEntryKey::value() const
- {
- return _value;
- }
-}
-
namespace paludis
{
template <>
@@ -106,11 +48,11 @@ namespace paludis
std::string platform;
std::string homepage;
- tr1::shared_ptr<GemMetadataStringKey> description_key;
- tr1::shared_ptr<GemMetadataStringKey> summary_key;
- tr1::shared_ptr<GemMetadataStringKey> authors_key;
- tr1::shared_ptr<GemMetadataStringKey> rubyforge_project_key;
- tr1::shared_ptr<GemMetadataFSEntryKey> fs_location_key;
+ tr1::shared_ptr<LiteralMetadataStringKey> description_key;
+ tr1::shared_ptr<LiteralMetadataStringKey> summary_key;
+ tr1::shared_ptr<LiteralMetadataStringKey> authors_key;
+ tr1::shared_ptr<LiteralMetadataStringKey> rubyforge_project_key;
+ tr1::shared_ptr<LiteralMetadataFSEntryKey> fs_location_key;
tr1::shared_ptr<const FSEntry> load_from_file;
@@ -263,20 +205,20 @@ namespace
{
std::string summary(required_text_only_key(n, "summary"));
if (! summary.empty())
- _imp->summary_key.reset(new GemMetadataStringKey("summary", "Summary", summary, mkt_significant));
+ _imp->summary_key.reset(new LiteralMetadataStringKey("summary", "Summary", mkt_significant, summary));
std::string description(optional_text_only_key(n, "description"));
if (! description.empty())
- _imp->description_key.reset(new GemMetadataStringKey("description", "Description", description, mkt_normal));
+ _imp->description_key.reset(new LiteralMetadataStringKey("description", "Description", mkt_normal, description));
std::string authors(optional_text_sequence_key(n, "authors"));
if (! authors.empty())
- _imp->authors_key.reset(new GemMetadataStringKey("authors", "Authors", authors, mkt_normal));
+ _imp->authors_key.reset(new LiteralMetadataStringKey("authors", "Authors", mkt_normal, authors));
std::string rubyforge_project(optional_text_sequence_key(n, "rubyforge_project"));
if (! rubyforge_project.empty())
- _imp->rubyforge_project_key.reset(new GemMetadataStringKey("rubyforge_project", "Rubyforge Project", rubyforge_project,
- mkt_normal));
+ _imp->rubyforge_project_key.reset(new LiteralMetadataStringKey("rubyforge_project", "Rubyforge Project",
+ mkt_normal, rubyforge_project));
_imp->date = required_text_only_key(n, "date");
_imp->platform = required_text_only_key(n, "platform");
@@ -303,9 +245,9 @@ namespace
GemSpecification::GemSpecification(const Environment * const e,
const tr1::shared_ptr<const Repository> & r, const yaml::Node & node) :
PrivateImplementationPattern<GemSpecification>(new Implementation<GemSpecification>(e, r)),
- _imp(PrivateImplementationPattern<GemSpecification>::_imp.get())
+ _imp(PrivateImplementationPattern<GemSpecification>::_imp)
{
- TopVisitor v(_imp);
+ TopVisitor v(_imp.get());
node.accept(v);
if (_imp->summary_key)
@@ -325,12 +267,12 @@ GemSpecification::GemSpecification(const Environment * const e,
GemSpecification::GemSpecification(const Environment * const e, const tr1::shared_ptr<const Repository> & r,
const PackageNamePart & q, const VersionSpec & v, const FSEntry & f) :
PrivateImplementationPattern<GemSpecification>(new Implementation<GemSpecification>(e, r)),
- _imp(PrivateImplementationPattern<GemSpecification>::_imp.get())
+ _imp(PrivateImplementationPattern<GemSpecification>::_imp)
{
_imp->name_part = stringify(q);
_imp->version = stringify(v);
_imp->load_from_file.reset(new FSEntry(f));
- _imp->fs_location_key.reset(new GemMetadataFSEntryKey("GEM", "Gem Location", f, mkt_internal));
+ _imp->fs_location_key.reset(new LiteralMetadataFSEntryKey("GEM", "Gem Location", mkt_internal, f));
add_metadata_key(_imp->fs_location_key);
}
diff --git a/paludis/repositories/gems/gem_specification.hh b/paludis/repositories/gems/gem_specification.hh
index 06388dd..a8015dd 100644
--- a/paludis/repositories/gems/gem_specification.hh
+++ b/paludis/repositories/gems/gem_specification.hh
@@ -64,7 +64,7 @@ namespace paludis
public PackageID
{
private:
- Implementation<GemSpecification> * const _imp;
+ PrivateImplementationPattern<GemSpecification>::ImpPtr & _imp;
protected:
void need_keys_added() const;
diff --git a/paludis/repositories/gems/gems_repository.cc b/paludis/repositories/gems/gems_repository.cc
index 83f0f2d..9153a7c 100644
--- a/paludis/repositories/gems/gems_repository.cc
+++ b/paludis/repositories/gems/gems_repository.cc
@@ -22,7 +22,6 @@
#include <paludis/repositories/gems/yaml.hh>
#include <paludis/repositories/gems/gem_specification.hh>
#include <paludis/repositories/gems/gem_specifications.hh>
-#include <paludis/repository_info.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/make_shared_ptr.hh>
@@ -33,6 +32,8 @@
#include <paludis/util/visitor-impl.hh>
#include <paludis/hashed_containers.hh>
#include <paludis/action.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/literal_metadata_key.hh>
#include <fstream>
using namespace paludis;
@@ -53,11 +54,30 @@ namespace paludis
mutable bool has_category_names;
mutable bool has_ids;
+ tr1::shared_ptr<const MetadataFSEntryKey> location_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> install_dir_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> builddir_key;
+ tr1::shared_ptr<const MetadataStringKey> sync_key;
+ tr1::shared_ptr<const MetadataStringKey> sync_options_key;
+ tr1::shared_ptr<const MetadataStringKey> format_key;
+
Implementation(const gems::RepositoryParams p, tr1::shared_ptr<Mutex> m = make_shared_ptr(new Mutex)) :
params(p),
big_nasty_mutex(m),
has_category_names(false),
- has_ids(false)
+ has_ids(false),
+ location_key(new LiteralMetadataFSEntryKey("location", "location",
+ mkt_significant, params.location)),
+ install_dir_key(new LiteralMetadataFSEntryKey("install_dir", "install_dir",
+ mkt_normal, params.install_dir)),
+ builddir_key(new LiteralMetadataFSEntryKey("builddir", "builddir",
+ mkt_normal, params.builddir)),
+ sync_key(new LiteralMetadataStringKey("sync", "sync",
+ mkt_normal, params.sync)),
+ sync_options_key(new LiteralMetadataStringKey(
+ "sync_options", "sync_options", mkt_normal, params.sync_options)),
+ format_key(new LiteralMetadataStringKey("format", "format",
+ mkt_significant, "gems"))
{
}
};
@@ -66,7 +86,6 @@ namespace paludis
GemsRepository::GemsRepository(const gems::RepositoryParams & params) :
Repository(RepositoryName("gems"),
RepositoryCapabilities::create()
- .installed_interface(0)
.sets_interface(0)
.syncable_interface(0)
.use_interface(0)
@@ -80,19 +99,11 @@ GemsRepository::GemsRepository(const gems::RepositoryParams & params) :
.qa_interface(0)
.make_virtuals_interface(0)
.hook_interface(0)
- .manifest_interface(0),
- "gems"),
- PrivateImplementationPattern<GemsRepository>(new Implementation<GemsRepository>(params))
+ .manifest_interface(0)),
+ PrivateImplementationPattern<GemsRepository>(new Implementation<GemsRepository>(params)),
+ _imp(PrivateImplementationPattern<GemsRepository>::_imp)
{
- tr1::shared_ptr<RepositoryInfoSection> config_info(new RepositoryInfoSection("Configuration information"));
-
- config_info->add_kv("location", stringify(_imp->params.location));
- config_info->add_kv("install_dir", stringify(_imp->params.install_dir));
- config_info->add_kv("builddir", stringify(_imp->params.builddir));
- config_info->add_kv("sync", _imp->params.sync);
- config_info->add_kv("sync_options", _imp->params.sync_options);
-
- _info->add_section(config_info);
+ _add_metadata_keys();
}
GemsRepository::~GemsRepository()
@@ -100,11 +111,24 @@ GemsRepository::~GemsRepository()
}
void
+GemsRepository::_add_metadata_keys() const
+{
+ clear_metadata_keys();
+ add_metadata_key(_imp->location_key);
+ add_metadata_key(_imp->install_dir_key);
+ add_metadata_key(_imp->builddir_key);
+ add_metadata_key(_imp->sync_key);
+ add_metadata_key(_imp->sync_options_key);
+ add_metadata_key(_imp->format_key);
+}
+
+void
GemsRepository::invalidate()
{
Lock l(*_imp->big_nasty_mutex);
_imp.reset(new Implementation<GemsRepository>(_imp->params, _imp->big_nasty_mutex));
+ _add_metadata_keys();
}
void
@@ -305,3 +329,20 @@ GemsRepository::some_ids_might_support_action(const SupportsActionTestBase & a)
return q.result;
}
+void
+GemsRepository::need_keys_added() const
+{
+}
+
+const tr1::shared_ptr<const MetadataStringKey>
+GemsRepository::format_key() const
+{
+ return _imp->format_key;
+}
+
+const tr1::shared_ptr<const MetadataFSEntryKey>
+GemsRepository::installed_root_key() const
+{
+ return tr1::shared_ptr<const MetadataFSEntryKey>();
+}
+
diff --git a/paludis/repositories/gems/gems_repository.hh b/paludis/repositories/gems/gems_repository.hh
index a387ed0..e96113b 100644
--- a/paludis/repositories/gems/gems_repository.hh
+++ b/paludis/repositories/gems/gems_repository.hh
@@ -39,9 +39,15 @@ namespace paludis
public tr1::enable_shared_from_this<GemsRepository>
{
private:
+ PrivateImplementationPattern<GemsRepository>::ImpPtr & _imp;
+ void _add_metadata_keys() const;
+
void need_category_names() const;
void need_ids() const;
+ protected:
+ virtual void need_keys_added() const;
+
public:
/**
* Constructor.
@@ -77,6 +83,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/gems/installed_gems_repository.cc b/paludis/repositories/gems/installed_gems_repository.cc
index a693c37..c7dc591 100644
--- a/paludis/repositories/gems/installed_gems_repository.cc
+++ b/paludis/repositories/gems/installed_gems_repository.cc
@@ -21,7 +21,6 @@
#include <paludis/repositories/gems/params.hh>
#include <paludis/repositories/gems/gem_specification.hh>
#include <paludis/repositories/gems/yaml.hh>
-#include <paludis/repository_info.hh>
#include <paludis/package_database.hh>
#include <paludis/environment.hh>
#include <paludis/util/stringify.hh>
@@ -37,6 +36,7 @@
#include <paludis/util/mutex.hh>
#include <paludis/util/log.hh>
#include <paludis/util/strip.hh>
+#include <paludis/literal_metadata_key.hh>
#include <paludis/hashed_containers.hh>
#include <paludis/action.hh>
@@ -60,12 +60,25 @@ namespace paludis
mutable bool has_category_names;
mutable bool has_ids;
+ tr1::shared_ptr<const MetadataFSEntryKey> install_dir_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> builddir_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> root_key;
+ tr1::shared_ptr<const MetadataStringKey> format_key;
+
Implementation(const gems::InstalledRepositoryParams p,
tr1::shared_ptr<Mutex> m = make_shared_ptr(new Mutex)) :
big_nasty_mutex(m),
params(p),
has_category_names(false),
- has_ids(false)
+ has_ids(false),
+ install_dir_key(new LiteralMetadataFSEntryKey("install_dir", "install_dir",
+ mkt_normal, params.install_dir)),
+ builddir_key(new LiteralMetadataFSEntryKey("builddir", "builddir",
+ mkt_normal, params.builddir)),
+ root_key(new LiteralMetadataFSEntryKey(
+ "root", "root", mkt_normal, params.root)),
+ format_key(new LiteralMetadataStringKey("format", "format",
+ mkt_significant, "gems"))
{
}
};
@@ -74,7 +87,6 @@ namespace paludis
InstalledGemsRepository::InstalledGemsRepository(const gems::InstalledRepositoryParams & params) :
Repository(RepositoryName("installed-gems"),
RepositoryCapabilities::create()
- .installed_interface(this)
.sets_interface(0)
.syncable_interface(0)
.use_interface(0)
@@ -88,16 +100,11 @@ InstalledGemsRepository::InstalledGemsRepository(const gems::InstalledRepository
.qa_interface(0)
.make_virtuals_interface(0)
.hook_interface(0)
- .manifest_interface(0),
- "installed_gems"),
- PrivateImplementationPattern<InstalledGemsRepository>(new Implementation<InstalledGemsRepository>(params))
+ .manifest_interface(0)),
+ PrivateImplementationPattern<InstalledGemsRepository>(new Implementation<InstalledGemsRepository>(params)),
+ _imp(PrivateImplementationPattern<InstalledGemsRepository>::_imp)
{
- tr1::shared_ptr<RepositoryInfoSection> config_info(new RepositoryInfoSection("Configuration information"));
-
- config_info->add_kv("install_dir", stringify(_imp->params.install_dir));
- config_info->add_kv("builddir", stringify(_imp->params.builddir));
-
- _info->add_section(config_info);
+ _add_metadata_keys();
}
InstalledGemsRepository::~InstalledGemsRepository()
@@ -105,11 +112,21 @@ InstalledGemsRepository::~InstalledGemsRepository()
}
void
+InstalledGemsRepository::_add_metadata_keys() const
+{
+ clear_metadata_keys();
+ add_metadata_key(_imp->install_dir_key);
+ add_metadata_key(_imp->builddir_key);
+ add_metadata_key(_imp->format_key);
+ add_metadata_key(_imp->root_key);
+}
+
+void
InstalledGemsRepository::invalidate()
{
Lock l(*_imp->big_nasty_mutex);
-
_imp.reset(new Implementation<InstalledGemsRepository>(_imp->params, _imp->big_nasty_mutex));
+ _add_metadata_keys();
}
void
@@ -243,7 +260,7 @@ InstalledGemsRepository::is_suitable_destination_for(const PackageID & e) const
{
Lock l(*_imp->big_nasty_mutex);
- std::string f(e.repository()->format());
+ std::string f(e.repository()->format_key() ? e.repository()->format_key()->value() : "");
return f == "gems";
}
@@ -265,12 +282,6 @@ InstalledGemsRepository::merge(const MergeOptions &)
throw InternalError(PALUDIS_HERE, "Invalid target for merge");
}
-FSEntry
-InstalledGemsRepository::root() const
-{
- return FSEntry("/");
-}
-
#if 0
void
InstalledGemsRepository::do_uninstall(const tr1::shared_ptr<const PackageID> & id,
@@ -338,3 +349,20 @@ InstalledGemsRepository::some_ids_might_support_action(const SupportsActionTestB
return q.result;
}
+void
+InstalledGemsRepository::need_keys_added() const
+{
+}
+
+const tr1::shared_ptr<const MetadataStringKey>
+InstalledGemsRepository::format_key() const
+{
+ return _imp->format_key;
+}
+
+const tr1::shared_ptr<const MetadataFSEntryKey>
+InstalledGemsRepository::installed_root_key() const
+{
+ return _imp->root_key;
+}
+
diff --git a/paludis/repositories/gems/installed_gems_repository.hh b/paludis/repositories/gems/installed_gems_repository.hh
index 1b6c2ab..3b25b9e 100644
--- a/paludis/repositories/gems/installed_gems_repository.hh
+++ b/paludis/repositories/gems/installed_gems_repository.hh
@@ -36,14 +36,19 @@ namespace paludis
class PALUDIS_VISIBLE InstalledGemsRepository :
public Repository,
public RepositoryDestinationInterface,
- public RepositoryInstalledInterface,
public tr1::enable_shared_from_this<InstalledGemsRepository>,
private PrivateImplementationPattern<InstalledGemsRepository>
{
private:
+ PrivateImplementationPattern<InstalledGemsRepository>::ImpPtr & _imp;
+ void _add_metadata_keys() const;
+
void need_category_names() const;
void need_ids() const;
+ protected:
+ virtual void need_keys_added() const;
+
public:
/**
* Constructor.
@@ -73,10 +78,6 @@ namespace paludis
virtual void merge(const MergeOptions &) PALUDIS_ATTRIBUTE((noreturn));
public:
- /* RepositoryInstalledInterface */
-
- virtual FSEntry root() const PALUDIS_ATTRIBUTE((warn_unused_result));
-
/* Repository */
virtual tr1::shared_ptr<const PackageIDSequence> package_ids(
@@ -97,6 +98,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/gems/params.sr b/paludis/repositories/gems/params.sr
index 254c716..f4c4ede 100644
--- a/paludis/repositories/gems/params.sr
+++ b/paludis/repositories/gems/params.sr
@@ -22,6 +22,7 @@ make_class_InstalledRepositoryParams()
key environment "Environment *"
key builddir FSEntry
key install_dir FSEntry
+ key root FSEntry
allow_named_args
}
diff --git a/paludis/repositories/gems/registration.cc b/paludis/repositories/gems/registration.cc
index f61890c..078271a 100644
--- a/paludis/repositories/gems/registration.cc
+++ b/paludis/repositories/gems/registration.cc
@@ -79,9 +79,14 @@ namespace
if (m->end() == m->find("builddir") || ((builddir = m->find("builddir")->second)).empty())
builddir = DistributionData::get_instance()->distribution_from_string(env->default_distribution())->default_ebuild_builddir;
+ std::string root;
+ if (m->end() == m->find("root") || ((root = m->find("root")->second)).empty())
+ root = "/";
+
return make_shared_ptr(new InstalledGemsRepository(gems::InstalledRepositoryParams::create()
.environment(env)
.install_dir(install_dir)
+ .root(root)
.builddir(builddir)));
}
}
diff --git a/paludis/repositories/unpackaged/installed_id.cc b/paludis/repositories/unpackaged/installed_id.cc
index 9e20f67..135a824 100644
--- a/paludis/repositories/unpackaged/installed_id.cc
+++ b/paludis/repositories/unpackaged/installed_id.cc
@@ -293,7 +293,7 @@ InstalledUnpackagedID::InstalledUnpackagedID(const Environment * const e, const
const VersionSpec & v, const SlotName & s, const RepositoryName & n, const FSEntry & l,
const std::string &, const FSEntry & ro, const NDBAM * const d) :
PrivateImplementationPattern<InstalledUnpackagedID>(new Implementation<InstalledUnpackagedID>(e, this, q, v, s, n, l, ro, d)),
- _imp(PrivateImplementationPattern<InstalledUnpackagedID>::_imp.get())
+ _imp(PrivateImplementationPattern<InstalledUnpackagedID>::_imp)
{
add_metadata_key(_imp->fs_location_key);
if (_imp->contents_key)
diff --git a/paludis/repositories/unpackaged/installed_id.hh b/paludis/repositories/unpackaged/installed_id.hh
index 959ddf4..e9987dc 100644
--- a/paludis/repositories/unpackaged/installed_id.hh
+++ b/paludis/repositories/unpackaged/installed_id.hh
@@ -38,7 +38,7 @@ namespace paludis
public tr1::enable_shared_from_this<InstalledUnpackagedID>
{
private:
- Implementation<InstalledUnpackagedID> * const _imp;
+ PrivateImplementationPattern<InstalledUnpackagedID>::ImpPtr & _imp;
protected:
void need_keys_added() const;
diff --git a/paludis/repositories/unpackaged/installed_repository.cc b/paludis/repositories/unpackaged/installed_repository.cc
index 7322c9b..c8ff42e 100644
--- a/paludis/repositories/unpackaged/installed_repository.cc
+++ b/paludis/repositories/unpackaged/installed_repository.cc
@@ -29,12 +29,12 @@
#include <paludis/util/set.hh>
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/system.hh>
-#include <paludis/repository_info.hh>
#include <paludis/stringify_formatter.hh>
#include <paludis/action.hh>
#include <paludis/environment.hh>
#include <paludis/dep_tag.hh>
#include <paludis/metadata_key.hh>
+#include <paludis/literal_metadata_key.hh>
#include <fstream>
#include <sstream>
#include <sys/time.h>
@@ -60,9 +60,19 @@ namespace paludis
const InstalledUnpackagedRepositoryParams params;
mutable NDBAM ndbam;
+ tr1::shared_ptr<const MetadataFSEntryKey> location_key;
+ tr1::shared_ptr<const MetadataFSEntryKey> root_key;
+ tr1::shared_ptr<const MetadataStringKey> format_key;
+
Implementation(const InstalledUnpackagedRepositoryParams & p) :
params(p),
- ndbam(p.location, &supported_installed_unpackaged, "installed_unpackaged-1")
+ ndbam(p.location, &supported_installed_unpackaged, "installed_unpackaged-1"),
+ location_key(new LiteralMetadataFSEntryKey("location", "location",
+ mkt_significant, params.location)),
+ root_key(new LiteralMetadataFSEntryKey("root", "root",
+ mkt_normal, params.root)),
+ format_key(new LiteralMetadataStringKey(
+ "format", "format", mkt_significant, "installed_unpackaged"))
{
}
};
@@ -72,7 +82,6 @@ InstalledUnpackagedRepository::InstalledUnpackagedRepository(
const RepositoryName & n, const InstalledUnpackagedRepositoryParams & p) :
PrivateImplementationPattern<InstalledUnpackagedRepository>(new Implementation<InstalledUnpackagedRepository>(p)),
Repository(n, RepositoryCapabilities::create()
- .installed_interface(this)
.sets_interface(this)
.syncable_interface(0)
.use_interface(0)
@@ -86,22 +95,25 @@ InstalledUnpackagedRepository::InstalledUnpackagedRepository(
.e_interface(0)
.hook_interface(0)
.qa_interface(0)
- .manifest_interface(0),
- "installed_unpackaged")
+ .manifest_interface(0)),
+ _imp(PrivateImplementationPattern<InstalledUnpackagedRepository>::_imp)
{
- tr1::shared_ptr<RepositoryInfoSection> config_info(new RepositoryInfoSection("Configuration information"));
-
- config_info->add_kv("location", stringify(_imp->params.location));
- config_info->add_kv("root", stringify(_imp->params.root));
- config_info->add_kv("format", "installed_unpackage");
-
- _info->add_section(config_info);
+ _add_metadata_keys();
}
InstalledUnpackagedRepository::~InstalledUnpackagedRepository()
{
}
+void
+InstalledUnpackagedRepository::_add_metadata_keys() const
+{
+ clear_metadata_keys();
+ add_metadata_key(_imp->location_key);
+ add_metadata_key(_imp->root_key);
+ add_metadata_key(_imp->format_key);
+}
+
tr1::shared_ptr<const PackageIDSequence>
InstalledUnpackagedRepository::package_ids(const QualifiedPackageName & q) const
{
@@ -114,7 +126,7 @@ InstalledUnpackagedRepository::package_ids(const QualifiedPackageName & q) const
Lock l(*e->mutex);
if (! e->package_id)
e->package_id.reset(new InstalledUnpackagedID(_imp->params.environment, e->name, e->version,
- e->slot, name(), e->fs_location, e->magic, root(), &_imp->ndbam));
+ e->slot, name(), e->fs_location, e->magic, installed_root_key()->value(), &_imp->ndbam));
result->push_back(e->package_id);
}
@@ -291,7 +303,7 @@ InstalledUnpackagedRepository::merge(const MergeOptions & m)
NDBAMMergerOptions::create()
.environment(_imp->params.environment)
.image(m.image_dir)
- .root(root())
+ .root(installed_root_key()->value())
.contents_file(target_ver_dir / "contents")
.config_protect(getenv_with_default("CONFIG_PROTECT", ""))
.config_protect_mask(getenv_with_default("CONFIG_PROTECT_MASK", ""))
@@ -320,14 +332,14 @@ InstalledUnpackagedRepository::merge(const MergeOptions & m)
bool
InstalledUnpackagedRepository::is_suitable_destination_for(const PackageID & e) const
{
- std::string f(e.repository()->format());
+ std::string f(e.repository()->format_key() ? e.repository()->format_key()->value() : "");
return f == "unpackaged";
}
bool
InstalledUnpackagedRepository::is_default_destination() const
{
- return _imp->params.environment->root() == root();
+ return _imp->params.environment->root() == installed_root_key()->value();
}
bool
@@ -336,16 +348,11 @@ InstalledUnpackagedRepository::want_pre_post_phases() const
return true;
}
-FSEntry
-InstalledUnpackagedRepository::root() const
-{
- return _imp->params.root;
-}
-
void
InstalledUnpackagedRepository::invalidate()
{
_imp.reset(new Implementation<InstalledUnpackagedRepository>(_imp->params));
+ _add_metadata_keys();
}
void
@@ -404,3 +411,21 @@ InstalledUnpackagedRepository::sets_list() const
return result;
}
+void
+InstalledUnpackagedRepository::need_keys_added() const
+{
+}
+
+const tr1::shared_ptr<const MetadataStringKey>
+InstalledUnpackagedRepository::format_key() const
+{
+ return _imp->format_key;
+}
+
+const tr1::shared_ptr<const MetadataFSEntryKey>
+InstalledUnpackagedRepository::installed_root_key() const
+{
+ return _imp->root_key;
+}
+
+
diff --git a/paludis/repositories/unpackaged/installed_repository.hh b/paludis/repositories/unpackaged/installed_repository.hh
index fc7e722..0b9bff6 100644
--- a/paludis/repositories/unpackaged/installed_repository.hh
+++ b/paludis/repositories/unpackaged/installed_repository.hh
@@ -35,9 +35,15 @@ namespace paludis
private PrivateImplementationPattern<InstalledUnpackagedRepository>,
public Repository,
public RepositoryDestinationInterface,
- public RepositoryInstalledInterface,
public RepositorySetsInterface
{
+ private:
+ PrivateImplementationPattern<InstalledUnpackagedRepository>::ImpPtr & _imp;
+ void _add_metadata_keys() const;
+
+ protected:
+ virtual void need_keys_added() const;
+
public:
InstalledUnpackagedRepository(
const RepositoryName &,
@@ -59,9 +65,6 @@ namespace paludis
virtual void merge(const MergeOptions &);
- virtual FSEntry root() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
void deindex(const QualifiedPackageName &) const;
virtual tr1::shared_ptr<const SetNameSet> sets_list() const
@@ -92,6 +95,11 @@ namespace paludis
virtual tr1::shared_ptr<SetSpecTree::ConstItem> package_set(const SetName & id) const
PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ /* 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/unpackaged/unpackaged_id.cc b/paludis/repositories/unpackaged/unpackaged_id.cc
index 237592a..98924c7 100644
--- a/paludis/repositories/unpackaged/unpackaged_id.cc
+++ b/paludis/repositories/unpackaged/unpackaged_id.cc
@@ -32,6 +32,7 @@
#include <paludis/environment.hh>
#include <paludis/metadata_key.hh>
#include <paludis/action.hh>
+#include <paludis/literal_metadata_key.hh>
#include <paludis/hashed_containers.hh>
using namespace paludis;
@@ -48,7 +49,7 @@ namespace paludis
const SlotName slot;
const RepositoryName repository_name;
- const tr1::shared_ptr<UnpackagedFSEntryKey> fs_location_key;
+ const tr1::shared_ptr<LiteralMetadataFSEntryKey> fs_location_key;
const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > build_dependencies_key;
const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > run_dependencies_key;
const tr1::shared_ptr<const MetadataStringKey> description_key;
@@ -67,10 +68,10 @@ namespace paludis
version(v),
slot(s),
repository_name(n),
- fs_location_key(new UnpackagedFSEntryKey("location", "Location", mkt_normal, l)),
+ fs_location_key(new LiteralMetadataFSEntryKey("location", "Location", mkt_normal, l)),
build_dependencies_key(new UnpackagedDependencyKey(env, "build_dependencies", "Build dependencies", mkt_dependencies, b)),
run_dependencies_key(new UnpackagedDependencyKey(env, "run_dependencies", "Run dependencies", mkt_dependencies, r)),
- description_key(new UnpackagedStringKey("description", "Description", mkt_significant, d))
+ description_key(new LiteralMetadataStringKey("description", "Description", mkt_significant, d))
{
}
};
@@ -80,7 +81,7 @@ UnpackagedID::UnpackagedID(const Environment * const e, const QualifiedPackageNa
const VersionSpec & v, const SlotName & s, const RepositoryName & n, const FSEntry & l,
const std::string & b, const std::string & r, const std::string & d) :
PrivateImplementationPattern<UnpackagedID>(new Implementation<UnpackagedID>(e, q, v, s, n, l, b, r, d)),
- _imp(PrivateImplementationPattern<UnpackagedID>::_imp.get())
+ _imp(PrivateImplementationPattern<UnpackagedID>::_imp)
{
add_metadata_key(_imp->fs_location_key);
add_metadata_key(_imp->build_dependencies_key);
diff --git a/paludis/repositories/unpackaged/unpackaged_id.hh b/paludis/repositories/unpackaged/unpackaged_id.hh
index 47dda1f..196bfb8 100644
--- a/paludis/repositories/unpackaged/unpackaged_id.hh
+++ b/paludis/repositories/unpackaged/unpackaged_id.hh
@@ -36,7 +36,7 @@ namespace paludis
public tr1::enable_shared_from_this<UnpackagedID>
{
private:
- Implementation<UnpackagedID> * const _imp;
+ PrivateImplementationPattern<UnpackagedID>::ImpPtr & _imp;
protected:
void need_keys_added() const;
diff --git a/paludis/repositories/unpackaged/unpackaged_key.cc b/paludis/repositories/unpackaged/unpackaged_key.cc
index 1c107ca..921186c 100644
--- a/paludis/repositories/unpackaged/unpackaged_key.cc
+++ b/paludis/repositories/unpackaged/unpackaged_key.cc
@@ -29,70 +29,6 @@ using namespace paludis::unpackaged_repositories;
namespace paludis
{
template <>
- struct Implementation<UnpackagedFSEntryKey>
- {
- const FSEntry value;
-
- Implementation(const FSEntry & v) :
- value(v)
- {
- }
- };
-}
-
-UnpackagedFSEntryKey::UnpackagedFSEntryKey(const std::string & r, const std::string & h, const MetadataKeyType t,
- const FSEntry & v) :
- MetadataFSEntryKey(r, h, t),
- PrivateImplementationPattern<UnpackagedFSEntryKey>(new Implementation<UnpackagedFSEntryKey>(v)),
- _imp(PrivateImplementationPattern<UnpackagedFSEntryKey>::_imp.get())
-{
-}
-
-UnpackagedFSEntryKey::~UnpackagedFSEntryKey()
-{
-}
-
-const FSEntry
-UnpackagedFSEntryKey::value() const
-{
- return _imp->value;
-}
-
-namespace paludis
-{
- template <>
- struct Implementation<UnpackagedStringKey>
- {
- const std::string value;
-
- Implementation(const std::string & v) :
- value(v)
- {
- }
- };
-}
-
-UnpackagedStringKey::UnpackagedStringKey(const std::string & r, const std::string & h, const MetadataKeyType t,
- const std::string & v) :
- MetadataStringKey(r, h, t),
- PrivateImplementationPattern<UnpackagedStringKey>(new Implementation<UnpackagedStringKey>(v)),
- _imp(PrivateImplementationPattern<UnpackagedStringKey>::_imp.get())
-{
-}
-
-UnpackagedStringKey::~UnpackagedStringKey()
-{
-}
-
-const std::string
-UnpackagedStringKey::value() const
-{
- return _imp->value;
-}
-
-namespace paludis
-{
- template <>
struct Implementation<UnpackagedDependencyKey>
{
const Environment * const env;
@@ -111,7 +47,7 @@ UnpackagedDependencyKey::UnpackagedDependencyKey(const Environment * const env,
const std::string & v) :
MetadataSpecTreeKey<DependencySpecTree>(r, h, t),
PrivateImplementationPattern<UnpackagedDependencyKey>(new Implementation<UnpackagedDependencyKey>(env, v)),
- _imp(PrivateImplementationPattern<UnpackagedDependencyKey>::_imp.get())
+ _imp(PrivateImplementationPattern<UnpackagedDependencyKey>::_imp)
{
}
diff --git a/paludis/repositories/unpackaged/unpackaged_key.hh b/paludis/repositories/unpackaged/unpackaged_key.hh
index 8d4e506..65c2c9d 100644
--- a/paludis/repositories/unpackaged/unpackaged_key.hh
+++ b/paludis/repositories/unpackaged/unpackaged_key.hh
@@ -27,40 +27,12 @@ namespace paludis
{
namespace unpackaged_repositories
{
- class UnpackagedFSEntryKey :
- public MetadataFSEntryKey,
- private PrivateImplementationPattern<UnpackagedFSEntryKey>
- {
- private:
- Implementation<UnpackagedFSEntryKey> * const _imp;
-
- public:
- UnpackagedFSEntryKey(const std::string &, const std::string &, const MetadataKeyType, const FSEntry & l);
- ~UnpackagedFSEntryKey();
-
- const FSEntry value() const;
- };
-
- class UnpackagedStringKey :
- public MetadataStringKey,
- private PrivateImplementationPattern<UnpackagedStringKey>
- {
- private:
- Implementation<UnpackagedStringKey> * const _imp;
-
- public:
- UnpackagedStringKey(const std::string & r, const std::string & h, const MetadataKeyType t, const std::string & v);
- ~UnpackagedStringKey();
-
- const std::string value() const;
- };
-
class UnpackagedDependencyKey :
public MetadataSpecTreeKey<DependencySpecTree>,
private PrivateImplementationPattern<UnpackagedDependencyKey>
{
private:
- Implementation<UnpackagedDependencyKey> * const _imp;
+ PrivateImplementationPattern<UnpackagedDependencyKey>::ImpPtr & _imp;
public:
UnpackagedDependencyKey(const Environment * const env,
diff --git a/paludis/repositories/unpackaged/unpackaged_repository.cc b/paludis/repositories/unpackaged/unpackaged_repository.cc
index 21c97e5..5c33119 100644
--- a/paludis/repositories/unpackaged/unpackaged_repository.cc
+++ b/paludis/repositories/unpackaged/unpackaged_repository.cc
@@ -25,8 +25,9 @@
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/stringify.hh>
#include <paludis/package_id.hh>
-#include <paludis/repository_info.hh>
+#include <paludis/metadata_key.hh>
#include <paludis/action.hh>
+#include <paludis/literal_metadata_key.hh>
using namespace paludis;
using namespace paludis::unpackaged_repositories;
@@ -44,6 +45,14 @@ namespace paludis
tr1::shared_ptr<QualifiedPackageNameSet> package_names;
tr1::shared_ptr<CategoryNamePartSet> category_names;
+ tr1::shared_ptr<const MetadataFSEntryKey> location_key;
+ tr1::shared_ptr<const MetadataStringKey> name_key;
+ tr1::shared_ptr<const MetadataStringKey> slot_key;
+ tr1::shared_ptr<const MetadataStringKey> format_key;
+ tr1::shared_ptr<const MetadataStringKey> build_dependencies_key;
+ tr1::shared_ptr<const MetadataStringKey> run_dependencies_key;
+ tr1::shared_ptr<const MetadataStringKey> description_key;
+
Implementation(const RepositoryName & n,
const UnpackagedRepositoryParams & p) :
params(p),
@@ -51,7 +60,21 @@ namespace paludis
params.build_dependencies, params.run_dependencies, params.description)),
ids(new PackageIDSequence),
package_names(new QualifiedPackageNameSet),
- category_names(new CategoryNamePartSet)
+ category_names(new CategoryNamePartSet),
+ location_key(new LiteralMetadataFSEntryKey("location", "location",
+ mkt_significant, params.location)),
+ name_key(new LiteralMetadataStringKey("name", "name",
+ mkt_normal, stringify(params.name))),
+ slot_key(new LiteralMetadataStringKey("slot", "slot",
+ mkt_normal, stringify(params.slot))),
+ format_key(new LiteralMetadataStringKey(
+ "format", "format", mkt_significant, "unpackaged")),
+ build_dependencies_key(new LiteralMetadataStringKey(
+ "build_dependencies", "build_dependencies", mkt_normal, params.build_dependencies)),
+ run_dependencies_key(new LiteralMetadataStringKey(
+ "run_dependencies", "run_dependencies", mkt_normal, params.run_dependencies)),
+ description_key(new LiteralMetadataStringKey(
+ "description", "description", mkt_normal, params.description))
{
ids->push_back(id);
package_names->insert(id->name());
@@ -64,7 +87,6 @@ UnpackagedRepository::UnpackagedRepository(const RepositoryName & n,
const UnpackagedRepositoryParams & params) :
PrivateImplementationPattern<UnpackagedRepository>(new Implementation<UnpackagedRepository>(n, params)),
Repository(n, RepositoryCapabilities::create()
- .installed_interface(0)
.sets_interface(0)
.syncable_interface(0)
.use_interface(0)
@@ -78,27 +100,29 @@ UnpackagedRepository::UnpackagedRepository(const RepositoryName & n,
.e_interface(0)
.hook_interface(0)
.qa_interface(0)
- .manifest_interface(0),
- "unpackaged")
+ .manifest_interface(0)),
+ _imp(PrivateImplementationPattern<UnpackagedRepository>::_imp)
{
- tr1::shared_ptr<RepositoryInfoSection> config_info(new RepositoryInfoSection("Configuration information"));
-
- config_info->add_kv("location", stringify(_imp->params.location));
- config_info->add_kv("name", stringify(_imp->params.name));
- config_info->add_kv("version", stringify(_imp->params.version));
- config_info->add_kv("slot", stringify(_imp->params.slot));
- config_info->add_kv("format", "unpackaged");
- config_info->add_kv("build_dependencies", _imp->params.build_dependencies);
- config_info->add_kv("run_dependencies", _imp->params.run_dependencies);
- config_info->add_kv("description", _imp->params.description);
-
- _info->add_section(config_info);
+ _add_metadata_keys();
}
UnpackagedRepository::~UnpackagedRepository()
{
}
+void
+UnpackagedRepository::_add_metadata_keys() const
+{
+ clear_metadata_keys();
+ add_metadata_key(_imp->location_key);
+ add_metadata_key(_imp->name_key);
+ add_metadata_key(_imp->slot_key);
+ add_metadata_key(_imp->format_key);
+ add_metadata_key(_imp->build_dependencies_key);
+ add_metadata_key(_imp->run_dependencies_key);
+ add_metadata_key(_imp->description_key);
+}
+
tr1::shared_ptr<const PackageIDSequence>
UnpackagedRepository::package_ids(const QualifiedPackageName & n) const
{
@@ -145,6 +169,7 @@ void
UnpackagedRepository::invalidate()
{
_imp.reset(new Implementation<UnpackagedRepository>(name(), _imp->params));
+ _add_metadata_keys();
}
void
@@ -152,3 +177,20 @@ UnpackagedRepository::invalidate_masks()
{
}
+void
+UnpackagedRepository::need_keys_added() const
+{
+}
+
+const tr1::shared_ptr<const MetadataStringKey>
+UnpackagedRepository::format_key() const
+{
+ return _imp->format_key;
+}
+
+const tr1::shared_ptr<const MetadataFSEntryKey>
+UnpackagedRepository::installed_root_key() const
+{
+ return tr1::shared_ptr<const MetadataFSEntryKey>();
+}
+
diff --git a/paludis/repositories/unpackaged/unpackaged_repository.hh b/paludis/repositories/unpackaged/unpackaged_repository.hh
index 8ff1639..e1ebd6e 100644
--- a/paludis/repositories/unpackaged/unpackaged_repository.hh
+++ b/paludis/repositories/unpackaged/unpackaged_repository.hh
@@ -35,6 +35,13 @@ namespace paludis
private PrivateImplementationPattern<UnpackagedRepository>,
public Repository
{
+ private:
+ PrivateImplementationPattern<UnpackagedRepository>::ImpPtr & _imp;
+ void _add_metadata_keys() const;
+
+ protected:
+ virtual void need_keys_added() const;
+
public:
UnpackagedRepository(
const RepositoryName &,
@@ -67,6 +74,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/virtuals/installed_virtuals_repository.cc b/paludis/repositories/virtuals/installed_virtuals_repository.cc
index aaadd75..1f76d09 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.cc
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.cc
@@ -24,8 +24,8 @@
#include <paludis/hashed_containers.hh>
#include <paludis/hook.hh>
#include <paludis/package_database.hh>
+#include <paludis/literal_metadata_key.hh>
#include <paludis/action.hh>
-#include <paludis/repository_info.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
@@ -55,11 +55,18 @@ namespace paludis
mutable IDMap ids;
mutable bool has_ids;
+ tr1::shared_ptr<const MetadataFSEntryKey> root_key;
+ tr1::shared_ptr<const MetadataStringKey> format_key;
+
Implementation(const Environment * const e, const FSEntry & r, tr1::shared_ptr<Mutex> m = make_shared_ptr(new Mutex)) :
env(e),
root(r),
ids_mutex(m),
- has_ids(false)
+ has_ids(false),
+ root_key(new LiteralMetadataFSEntryKey(
+ "root", "root", mkt_normal, root)),
+ format_key(new LiteralMetadataStringKey(
+ "format", "format", mkt_significant, "installed_virtuals"))
{
}
};
@@ -100,7 +107,6 @@ namespace
InstalledVirtualsRepository::InstalledVirtualsRepository(const Environment * const env,
const FSEntry & r) :
Repository(RepositoryName(make_name(r)), RepositoryCapabilities::create()
- .installed_interface(this)
.use_interface(0)
.sets_interface(0)
.syncable_interface(0)
@@ -114,14 +120,13 @@ InstalledVirtualsRepository::InstalledVirtualsRepository(const Environment * con
.make_virtuals_interface(0)
.qa_interface(0)
.hook_interface(this)
- .manifest_interface(0),
- "installed_virtuals"),
+ .manifest_interface(0)),
PrivateImplementationPattern<InstalledVirtualsRepository>(
- new Implementation<InstalledVirtualsRepository>(env, r))
+ new Implementation<InstalledVirtualsRepository>(env, r)),
+ _imp(PrivateImplementationPattern<InstalledVirtualsRepository>::_imp)
{
- tr1::shared_ptr<RepositoryInfoSection> config_info(new RepositoryInfoSection("Configuration information"));
- config_info->add_kv("format", "installed_virtuals");
- _info->add_section(config_info);
+ add_metadata_key(_imp->root_key);
+ add_metadata_key(_imp->format_key);
}
InstalledVirtualsRepository::~InstalledVirtualsRepository()
@@ -246,12 +251,6 @@ InstalledVirtualsRepository::invalidate_masks()
{
}
-FSEntry
-InstalledVirtualsRepository::root() const
-{
- return _imp->root;
-}
-
HookResult
InstalledVirtualsRepository::perform_hook(const Hook & hook) const
{
@@ -325,3 +324,21 @@ InstalledVirtualsRepository::unimportant_category_names() const
result->insert(CategoryNamePart("virtual"));
return result;
}
+
+const tr1::shared_ptr<const MetadataStringKey>
+InstalledVirtualsRepository::format_key() const
+{
+ return _imp->format_key;
+}
+
+const tr1::shared_ptr<const MetadataFSEntryKey>
+InstalledVirtualsRepository::installed_root_key() const
+{
+ return _imp->root_key;
+}
+
+void
+InstalledVirtualsRepository::need_keys_added() const
+{
+}
+
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.hh b/paludis/repositories/virtuals/installed_virtuals_repository.hh
index 917a420..8ab949b 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.hh
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.hh
@@ -34,14 +34,18 @@ namespace paludis
*/
class PALUDIS_VISIBLE InstalledVirtualsRepository :
public Repository,
- public RepositoryInstalledInterface,
public RepositoryHookInterface,
public tr1::enable_shared_from_this<InstalledVirtualsRepository>,
private PrivateImplementationPattern<InstalledVirtualsRepository>
{
private:
+ PrivateImplementationPattern<InstalledVirtualsRepository>::ImpPtr & _imp;
+
void need_ids() const;
+ protected:
+ virtual void need_keys_added() const;
+
public:
///\name Basic operations
//\{
@@ -68,8 +72,6 @@ namespace paludis
virtual bool can_be_favourite_repository() const;
- virtual FSEntry root() const;
-
HookResult perform_hook(const Hook &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -94,6 +96,10 @@ 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/virtuals/package_id.cc b/paludis/repositories/virtuals/package_id.cc
index 9cdd227..9e14535 100644
--- a/paludis/repositories/virtuals/package_id.cc
+++ b/paludis/repositories/virtuals/package_id.cc
@@ -37,6 +37,7 @@
#include <paludis/mask.hh>
#include <paludis/package_database.hh>
#include <paludis/query.hh>
+#include <paludis/literal_metadata_key.hh>
using namespace paludis;
using namespace paludis::virtuals;
@@ -44,17 +45,6 @@ using namespace paludis::virtuals;
namespace paludis
{
template <>
- struct Implementation<VirtualsPackageIDKey>
- {
- const tr1::shared_ptr<const PackageID> value;
-
- Implementation(const tr1::shared_ptr<const PackageID> & v) :
- value(v)
- {
- }
- };
-
- template <>
struct Implementation<VirtualsDepKey>
{
const Environment * const env;
@@ -82,28 +72,11 @@ namespace paludis
};
}
-VirtualsPackageIDKey::VirtualsPackageIDKey(const tr1::shared_ptr<const PackageID> & v) :
- MetadataPackageIDKey("VIRTUAL_FOR", "Virtual for", mkt_normal),
- PrivateImplementationPattern<VirtualsPackageIDKey>(new Implementation<VirtualsPackageIDKey>(v)),
- _imp(PrivateImplementationPattern<VirtualsPackageIDKey>::_imp.get())
-{
-}
-
-VirtualsPackageIDKey::~VirtualsPackageIDKey()
-{
-}
-
-const tr1::shared_ptr<const PackageID>
-VirtualsPackageIDKey::value() const
-{
- return _imp->value;
-}
-
VirtualsDepKey::VirtualsDepKey(const Environment * const e, const std::string & r, const std::string & h,
const tr1::shared_ptr<const PackageID> & v, const bool exact) :
MetadataSpecTreeKey<DependencySpecTree>(r, h, mkt_dependencies),
PrivateImplementationPattern<VirtualsDepKey>(new Implementation<VirtualsDepKey>(e, v, exact)),
- _imp(PrivateImplementationPattern<VirtualsDepKey>::_imp.get())
+ _imp(PrivateImplementationPattern<VirtualsDepKey>::_imp)
{
}
@@ -178,7 +151,7 @@ namespace paludis
repository(o),
name(n),
version(p->version()),
- virtual_for(new virtuals::VirtualsPackageIDKey(p)),
+ virtual_for(new LiteralMetadataPackageIDKey("VIRTUAL_FOR", "Virtual for", mkt_normal, p)),
bdep(new virtuals::VirtualsDepKey(e, "DEPEND", "Build dependencies", p, b)),
rdep(new virtuals::VirtualsDepKey(e, "RDEPEND", "Run dependencies", p, b)),
has_masks(false)
@@ -195,7 +168,7 @@ VirtualsPackageID::VirtualsPackageID(
const bool exact) :
PrivateImplementationPattern<VirtualsPackageID>(
new Implementation<VirtualsPackageID>(e, owner, virtual_name, virtual_for, exact)),
- _imp(PrivateImplementationPattern<VirtualsPackageID>::_imp.get())
+ _imp(PrivateImplementationPattern<VirtualsPackageID>::_imp)
{
add_metadata_key(_imp->virtual_for);
add_metadata_key(_imp->bdep);
diff --git a/paludis/repositories/virtuals/package_id.hh b/paludis/repositories/virtuals/package_id.hh
index e20c6e0..f9bca57 100644
--- a/paludis/repositories/virtuals/package_id.hh
+++ b/paludis/repositories/virtuals/package_id.hh
@@ -28,27 +28,12 @@ namespace paludis
{
namespace virtuals
{
- class VirtualsPackageIDKey :
- public MetadataPackageIDKey,
- private PrivateImplementationPattern<VirtualsPackageIDKey>
- {
- private:
- Implementation<VirtualsPackageIDKey> * const _imp;
-
- public:
- VirtualsPackageIDKey(const tr1::shared_ptr<const PackageID> &);
- ~VirtualsPackageIDKey();
-
- virtual const tr1::shared_ptr<const PackageID> value() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
class VirtualsDepKey :
public MetadataSpecTreeKey<DependencySpecTree>,
private PrivateImplementationPattern<VirtualsDepKey>
{
private:
- Implementation<VirtualsDepKey> * const _imp;
+ PrivateImplementationPattern<VirtualsDepKey>::ImpPtr & _imp;
public:
VirtualsDepKey(const Environment * const, const std::string &, const std::string &,
@@ -70,7 +55,7 @@ namespace paludis
public PackageID
{
private:
- Implementation<VirtualsPackageID> * const _imp;
+ PrivateImplementationPattern<VirtualsPackageID>::ImpPtr & _imp;
protected:
virtual void need_keys_added() const;
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index 21a0cdc..6ac8efa 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -25,8 +25,8 @@
#include <paludis/match_package.hh>
#include <paludis/package_database.hh>
#include <paludis/query.hh>
-#include <paludis/repository_info.hh>
#include <paludis/action.hh>
+#include <paludis/literal_metadata_key.hh>
#include <paludis/util/log.hh>
#include <paludis/util/make_shared_ptr.hh>
@@ -61,11 +61,15 @@ namespace paludis
mutable IDMap ids;
mutable bool has_ids;
+ tr1::shared_ptr<const MetadataStringKey> format_key;
+
Implementation(const Environment * const e, tr1::shared_ptr<Mutex> m = make_shared_ptr(new Mutex)) :
env(e),
big_nasty_mutex(m),
has_names(false),
- has_ids(false)
+ has_ids(false),
+ format_key(new LiteralMetadataStringKey(
+ "format", "format", mkt_significant, "virtuals"))
{
}
};
@@ -110,7 +114,6 @@ namespace
VirtualsRepository::VirtualsRepository(const Environment * const env) :
Repository(RepositoryName("virtuals"), RepositoryCapabilities::create()
- .installed_interface(0)
.use_interface(0)
.sets_interface(0)
.syncable_interface(0)
@@ -124,14 +127,12 @@ VirtualsRepository::VirtualsRepository(const Environment * const env) :
.make_virtuals_interface(this)
.qa_interface(0)
.hook_interface(0)
- .manifest_interface(0),
- "virtuals"),
+ .manifest_interface(0)),
PrivateImplementationPattern<VirtualsRepository>(
- new Implementation<VirtualsRepository>(env))
+ new Implementation<VirtualsRepository>(env)),
+ _imp(PrivateImplementationPattern<VirtualsRepository>::_imp)
{
- tr1::shared_ptr<RepositoryInfoSection> config_info(new RepositoryInfoSection("Configuration information"));
- config_info->add_kv("format", "virtuals");
- _info->add_section(config_info);
+ add_metadata_key(_imp->format_key);
}
VirtualsRepository::~VirtualsRepository()
@@ -319,7 +320,6 @@ void
VirtualsRepository::invalidate()
{
Lock l(*_imp->big_nasty_mutex);
-
_imp.reset(new Implementation<VirtualsRepository>(_imp->env, _imp->big_nasty_mutex));
}
@@ -410,3 +410,20 @@ VirtualsRepository::unimportant_category_names() const
return result;
}
+const tr1::shared_ptr<const MetadataStringKey>
+VirtualsRepository::format_key() const
+{
+ return _imp->format_key;
+}
+
+const tr1::shared_ptr<const MetadataFSEntryKey>
+VirtualsRepository::installed_root_key() const
+{
+ return tr1::shared_ptr<const MetadataFSEntryKey>();
+}
+
+void
+VirtualsRepository::need_keys_added() const
+{
+}
+
diff --git a/paludis/repositories/virtuals/virtuals_repository.hh b/paludis/repositories/virtuals/virtuals_repository.hh
index 4a7ca33..9c99710 100644
--- a/paludis/repositories/virtuals/virtuals_repository.hh
+++ b/paludis/repositories/virtuals/virtuals_repository.hh
@@ -38,9 +38,14 @@ namespace paludis
public tr1::enable_shared_from_this<VirtualsRepository>
{
private:
+ PrivateImplementationPattern<VirtualsRepository>::ImpPtr & _imp;
+
void need_names() const;
void need_ids() const;
+ protected:
+ virtual void need_keys_added() const;
+
public:
///\name Basic operations
///\{
@@ -93,6 +98,10 @@ namespace paludis
const QualifiedPackageName & virtual_name, const tr1::shared_ptr<const PackageID> & provider) const
PALUDIS_ATTRIBUTE((warn_unused_result));
+ /* 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/repository-fwd.hh b/paludis/repository-fwd.hh
index cee6ced..e4b0a28 100644
--- a/paludis/repository-fwd.hh
+++ b/paludis/repository-fwd.hh
@@ -41,7 +41,6 @@ namespace paludis
class HookResult;
class Repository;
- class RepositoryInstalledInterface;
class RepositorySetsInterface;
class RepositorySyncableInterface;
class RepositoryUseInterface;
diff --git a/paludis/repository.cc b/paludis/repository.cc
index 85ef0b5..862cc9d 100644
--- a/paludis/repository.cc
+++ b/paludis/repository.cc
@@ -18,7 +18,6 @@
*/
#include <paludis/repository.hh>
-#include <paludis/repository_info.hh>
#include <paludis/util/log.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/instantiation_policy-impl.hh>
@@ -31,6 +30,8 @@
#include <paludis/util/set-impl.hh>
#include <paludis/util/config_file.hh>
#include <paludis/util/wrapped_forward_iterator-impl.hh>
+#include <paludis/util/tr1_functional.hh>
+#include <paludis/metadata_key.hh>
#include <map>
#include <list>
#include <utility>
@@ -93,19 +94,31 @@ namespace
};
}
+namespace paludis
+{
+ template <>
+ struct Implementation<Repository>
+ {
+ mutable std::list<tr1::shared_ptr<const MetadataKey> > keys;
+ const RepositoryName name;
+
+ Implementation(const RepositoryName & n) :
+ name(n)
+ {
+ }
+ };
+}
+
Repository::Repository(
const RepositoryName & our_name,
- const RepositoryCapabilities & caps,
- const std::string & f) :
- RepositoryCapabilities(caps),
- _name(our_name),
- _format(f),
- _info(new RepositoryInfo)
+ const RepositoryCapabilities & caps) :
+ PrivateImplementationPattern<Repository>(new Implementation<Repository>(our_name)),
+ RepositoryCapabilities(caps)
{
std::map<std::string, std::string>::const_iterator i(
- RepositoryBlacklist::get_instance()->items.find(stringify(_name)));
+ RepositoryBlacklist::get_instance()->items.find(stringify(name())));
if (RepositoryBlacklist::get_instance()->items.end() != i)
- Log::get_instance()->message(ll_warning, lc_no_context, "Repository '" + stringify(_name) +
+ Log::get_instance()->message(ll_warning, lc_no_context, "Repository '" + stringify(name()) +
"' is blacklisted with reason '" + i->second + "'. Consult the FAQ for more details.");
}
@@ -113,16 +126,52 @@ Repository::~Repository()
{
}
-const RepositoryName &
+const RepositoryName
Repository::name() const
{
- return _name;
+ return _imp->name;
}
-tr1::shared_ptr<const RepositoryInfo>
-Repository::info(bool) const
+void
+Repository::add_metadata_key(const tr1::shared_ptr<const MetadataKey> & k) const
+{
+ using namespace tr1::placeholders;
+
+ if (_imp->keys.end() != std::find_if(_imp->keys.begin(), _imp->keys.end(),
+ tr1::bind(std::equal_to<std::string>(), k->raw_name(), tr1::bind(tr1::mem_fn(&MetadataKey::raw_name), _1))))
+ throw ConfigurationError("Tried to add duplicate key '" + k->raw_name() + "' to Repository '" + stringify(name()) + "'");
+
+ _imp->keys.push_back(k);
+}
+
+void
+Repository::clear_metadata_keys() const
{
- return _info;
+ _imp->keys.clear();
+}
+
+Repository::MetadataConstIterator
+Repository::begin_metadata() const
+{
+ need_keys_added();
+ return MetadataConstIterator(_imp->keys.begin());
+}
+
+Repository::MetadataConstIterator
+Repository::end_metadata() const
+{
+ need_keys_added();
+ return MetadataConstIterator(_imp->keys.end());
+}
+
+Repository::MetadataConstIterator
+Repository::find_metadata(const std::string & s) const
+{
+ using namespace tr1::placeholders;
+
+ need_keys_added();
+ return std::find_if(begin_metadata(), end_metadata(),
+ tr1::bind(std::equal_to<std::string>(), s, tr1::bind(tr1::mem_fn(&MetadataKey::raw_name), _1)));
}
tr1::shared_ptr<const CategoryNamePartSet>
@@ -145,16 +194,6 @@ Repository::regenerate_cache() const
{
}
-std::string
-Repository::format() const
-{
- return _format;
-}
-
-RepositoryInstalledInterface::~RepositoryInstalledInterface()
-{
-}
-
RepositorySetsInterface::~RepositorySetsInterface()
{
}
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 6d3c899..d553630 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -22,7 +22,6 @@
#include <paludis/action-fwd.hh>
#include <paludis/repository-fwd.hh>
-#include <paludis/repository_info-fwd.hh>
#include <paludis/dep_spec-fwd.hh>
#include <paludis/dep_tree.hh>
#include <paludis/name.hh>
@@ -35,6 +34,7 @@
#include <paludis/util/virtual_constructor.hh>
#include <paludis/util/wrapped_forward_iterator-fwd.hh>
#include <paludis/version_spec.hh>
+#include <paludis/metadata_key-fwd.hh>
#include <string>
/** \file
@@ -129,30 +129,34 @@ namespace paludis
*/
class PALUDIS_VISIBLE Repository :
private InstantiationPolicy<Repository, instantiation_method::NonCopyableTag>,
+ private PrivateImplementationPattern<Repository>,
public RepositoryCapabilities
{
- private:
- const RepositoryName _name;
- std::string _format;
-
protected:
- ///\name Implementation data
+ ///\name Basic operations
///\{
- /**
- * Our information.
- */
- mutable tr1::shared_ptr<RepositoryInfo> _info;
+ Repository(const RepositoryName &, const RepositoryCapabilities &);
///\}
- ///\name Basic operations
- ///\{
+ /**
+ * Add a new MetadataKey, which must not use the same raw name as
+ * any previous MetadataKey added to this repository.
+ */
+ virtual void add_metadata_key(const tr1::shared_ptr<const MetadataKey> &) const;
- Repository(const RepositoryName &, const RepositoryCapabilities &,
- const std::string & our_format);
+ /**
+ * Clear all MetadataKey instances added using add_metadata_key.
+ */
+ virtual void clear_metadata_keys() const;
- ///\}
+ /**
+ * This method will be called before any of the metadata key
+ * iteration methods does its work. It can be used by subclasses to
+ * implement as-needed loading of keys.
+ */
+ virtual void need_keys_added() const = 0;
public:
///\name Basic operations
@@ -166,27 +170,48 @@ namespace paludis
///\{
/**
- * Fetch information about the repository.
+ * Return our name.
*/
- virtual tr1::shared_ptr<const RepositoryInfo> info(bool verbose) const
+ const RepositoryName name() const PALUDIS_ATTRIBUTE((nothrow))
PALUDIS_ATTRIBUTE((warn_unused_result));
/**
- * Return our name.
+ * Are we allowed to be favourite repository?
*/
- const RepositoryName & name() const PALUDIS_ATTRIBUTE((nothrow))
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual bool can_be_favourite_repository() const;
+
+ ///\}
+
+ ///\name Specific metadata keys
+ ///\{
/**
- * Return our format.
+ * The format_key, if non-zero, holds our repository's format. Repository
+ * implementations should not return zero here, but clients should still
+ * check.
*/
- std::string format() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const tr1::shared_ptr<const MetadataStringKey> format_key() const = 0;
/**
- * Are we allowed to be favourite repository?
+ * The installed_root_key, if non-zero, specifies that we contain installed
+ * packages at the specified root.
+ *
+ * This key is currently used in various places to determine whether a repository is
+ * an 'installed' repository or not.
*/
- virtual bool can_be_favourite_repository() const;
+ virtual const tr1::shared_ptr<const MetadataFSEntryKey> installed_root_key() const = 0;
+
+ ///\}
+
+ ///\name Finding and iterating over metadata keys
+ ///\{
+
+ struct MetadataConstIteratorTag;
+ typedef WrappedForwardIterator<MetadataConstIteratorTag, tr1::shared_ptr<const MetadataKey> > MetadataConstIterator;
+
+ MetadataConstIterator begin_metadata() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ MetadataConstIterator end_metadata() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ MetadataConstIterator find_metadata(const std::string &) const PALUDIS_ATTRIBUTE((warn_unused_result));
///\}
@@ -322,30 +347,6 @@ namespace paludis
};
/**
- * Interface for handling actions for installed repositories.
- *
- * \see Repository
- * \ingroup g_repository
- * \nosubgrouping
- */
- class PALUDIS_VISIBLE RepositoryInstalledInterface
- {
- public:
- ///\name Installed content queries
- ///\{
-
- /**
- * What is our filesystem root?
- */
- virtual FSEntry root() const
- PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
-
- ///\}
-
- virtual ~RepositoryInstalledInterface();
- };
-
- /**
* Interface for package sets for repositories.
*
* \see Repository
diff --git a/paludis/repository.sr b/paludis/repository.sr
index a5a4e73..bc93ed4 100644
--- a/paludis/repository.sr
+++ b/paludis/repository.sr
@@ -5,7 +5,6 @@ make_class_RepositoryCapabilities()
{
visible
- key installed_interface "RepositoryInstalledInterface *"
key sets_interface "RepositorySetsInterface *"
key syncable_interface "RepositorySyncableInterface *"
key use_interface "RepositoryUseInterface *"
diff --git a/paludis/repository_info.cc b/paludis/repository_info.cc
deleted file mode 100644
index c8abbc6..0000000
--- a/paludis/repository_info.cc
+++ /dev/null
@@ -1,135 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/name.hh>
-#include <paludis/repository.hh>
-#include <paludis/repository_info.hh>
-#include <paludis/util/private_implementation_pattern-impl.hh>
-#include <paludis/util/instantiation_policy-impl.hh>
-#include <paludis/util/wrapped_forward_iterator-impl.hh>
-#include <paludis/util/stringify.hh>
-#include <list>
-#include <map>
-#include <utility>
-
-using namespace paludis;
-
-template class WrappedForwardIterator<RepositoryInfoSection::KeyValueConstIteratorTag,
- const std::pair<const std::string, std::string> >;
-template class WrappedForwardIterator<RepositoryInfo::SectionConstIteratorTag,
- const tr1::shared_ptr<const RepositoryInfoSection> >;
-
-namespace paludis
-{
- template<>
- struct Implementation<RepositoryInfoSection>
- {
- std::string heading;
- std::map<std::string, std::string> kvs;
- };
-
- template<>
- struct Implementation<RepositoryInfo>
- {
- std::list<tr1::shared_ptr<const RepositoryInfoSection> > sections;
- };
-}
-
-RepositoryInfo &
-RepositoryInfo::add_section(tr1::shared_ptr<const RepositoryInfoSection> s)
-{
- _imp->sections.push_back(s);
- return *this;
-}
-
-RepositoryInfoSection::RepositoryInfoSection(const std::string & our_heading) :
- PrivateImplementationPattern<RepositoryInfoSection>(new Implementation<RepositoryInfoSection>)
-{
- _imp->heading = our_heading;
-}
-
-RepositoryInfoSection::~RepositoryInfoSection()
-{
-}
-
-std::string
-RepositoryInfoSection::heading() const
-{
- return _imp->heading;
-}
-
-RepositoryInfoSection::KeyValueConstIterator
-RepositoryInfoSection::begin_kvs() const
-{
- return KeyValueConstIterator(_imp->kvs.begin());
-}
-
-RepositoryInfoSection::KeyValueConstIterator
-RepositoryInfoSection::end_kvs() const
-{
- return KeyValueConstIterator(_imp->kvs.end());
-}
-
-RepositoryInfoSection &
-RepositoryInfoSection::add_kv(const std::string & k, const std::string & v)
-{
- _imp->kvs.insert(std::make_pair(k, v));
- return *this;
-}
-
-std::string
-RepositoryInfoSection::get_key_with_default(const std::string & k, const std::string & d) const
-{
- std::map<std::string, std::string>::const_iterator p(_imp->kvs.find(k));
- if (p != _imp->kvs.end())
- return p->second;
- else
- return d;
-}
-
-RepositoryInfo::RepositoryInfo() :
- PrivateImplementationPattern<RepositoryInfo>(new Implementation<RepositoryInfo>)
-{
-}
-
-RepositoryInfo::~RepositoryInfo()
-{
-}
-
-RepositoryInfo::SectionConstIterator
-RepositoryInfo::begin_sections() const
-{
- return SectionConstIterator(_imp->sections.begin());
-}
-
-RepositoryInfo::SectionConstIterator
-RepositoryInfo::end_sections() const
-{
- return SectionConstIterator(_imp->sections.end());
-}
-
-std::string
-RepositoryInfo::get_key_with_default(const std::string & k, const std::string & d) const
-{
- std::string result(d);
- for (SectionConstIterator i(begin_sections()), i_end(end_sections()) ; i != i_end ; ++i)
- result = (*i)->get_key_with_default(k, result);
- return result;
-}
-
diff --git a/paludis/repository_info.hh b/paludis/repository_info.hh
deleted file mode 100644
index 984d476..0000000
--- a/paludis/repository_info.hh
+++ /dev/null
@@ -1,125 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORY_INFO_HH
-#define PALUDIS_GUARD_PALUDIS_REPOSITORY_INFO_HH 1
-
-#include <paludis/repository_info-fwd.hh>
-#include <paludis/util/wrapped_forward_iterator-fwd.hh>
-
-/** \file
- * Declarations for RepositoryInfo classes.
- *
- * \ingroup g_repository
- *
- * \section Examples
- *
- * - \ref example_repository.cc "example_repository.cc"
- */
-
-namespace paludis
-{
- /**
- * A section of information about a Repository.
- *
- * \see RepositoryInfo
- * \ingroup g_repository
- * \nosubgrouping
- */
- class PALUDIS_VISIBLE RepositoryInfoSection :
- private PrivateImplementationPattern<RepositoryInfoSection>
- {
- public:
- ///\name Basic operations
- ///\{
-
- RepositoryInfoSection(const std::string & heading);
-
- ~RepositoryInfoSection();
-
- ///\}
-
- /// Our heading.
- std::string heading() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- ///\name Iterate over our key/values
- ///\{
-
- struct KeyValueConstIteratorTag;
- typedef WrappedForwardIterator<KeyValueConstIteratorTag,
- const std::pair<const std::string, std::string> > KeyValueConstIterator;
-
- KeyValueConstIterator begin_kvs() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- KeyValueConstIterator end_kvs() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- ///\}
-
- /// Add a key/value pair.
- RepositoryInfoSection & add_kv(const std::string &, const std::string &);
-
- /// Fetch a value, with default.
- std::string get_key_with_default(const std::string &, const std::string &) const;
- };
-
- /**
- * Information about a Repository, for the end user.
- *
- * \ingroup g_repository
- * \nosubgrouping
- */
- class PALUDIS_VISIBLE RepositoryInfo :
- private PrivateImplementationPattern<RepositoryInfo>
- {
- public:
- ///\name Basic operations
- ///\{
-
- RepositoryInfo();
- ~RepositoryInfo();
-
- ///\}
-
- ///\name ConstIterator over our sections
- ///\{
-
- struct SectionConstIteratorTag;
- typedef WrappedForwardIterator<SectionConstIteratorTag,
- const tr1::shared_ptr<const RepositoryInfoSection> > SectionConstIterator;
-
- SectionConstIterator begin_sections() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- SectionConstIterator end_sections() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- ///\}
-
- /// Add a section.
- RepositoryInfo & add_section(tr1::shared_ptr<const RepositoryInfoSection>);
-
- /// Fetch a value from any of our sections, with default.
- std::string get_key_with_default(const std::string &, const std::string &) const;
- };
-}
-
-#endif
diff --git a/paludis/stringify_formatter-impl.hh b/paludis/stringify_formatter-impl.hh
index de34207..1886c00 100644
--- a/paludis/stringify_formatter-impl.hh
+++ b/paludis/stringify_formatter-impl.hh
@@ -56,6 +56,8 @@ namespace paludis
const CanFormat<PlainTextDepSpec> * const f_plain;
const CanFormat<UseDepSpec> * const f_use_dep;
const CanFormat<NamedSetDepSpec> * const f_named;
+ const CanFormat<FSEntry> * const f_fsentry;
+ const CanFormat<PackageID> * const f_package_id;
const CanSpace * const f_space;
Implementation(
@@ -73,6 +75,8 @@ namespace paludis
const CanFormat<PlainTextDepSpec> * const f_plain_v,
const CanFormat<UseDepSpec> * const f_use_dep_v,
const CanFormat<NamedSetDepSpec> * const f_named_v,
+ const CanFormat<FSEntry> * const f_fsentry_v,
+ const CanFormat<PackageID> * const f_package_id_v,
const CanSpace * const f_space_v
) :
f_str(f_str_v),
@@ -89,6 +93,8 @@ namespace paludis
f_plain(f_plain_v),
f_use_dep(f_use_dep_v),
f_named(f_named_v),
+ f_fsentry(f_fsentry_v),
+ f_package_id(f_package_id_v),
f_space(f_space_v)
{
}
@@ -203,6 +209,8 @@ namespace paludis
PlainTextDepSpec>::get(&t),
StringifyFormatterGetForwarder<tr1::is_convertible<T_ *, CanFormat<UseDepSpec> *>::value, UseDepSpec>::get(&t),
StringifyFormatterGetForwarder<tr1::is_convertible<T_ *, CanFormat<NamedSetDepSpec> *>::value, NamedSetDepSpec>::get(&t),
+ StringifyFormatterGetForwarder<tr1::is_convertible<T_ *, CanFormat<FSEntry> *>::value, FSEntry>::get(&t),
+ StringifyFormatterGetForwarder<tr1::is_convertible<T_ *, CanFormat<PackageID> *>::value, PackageID>::get(&t),
StringifyFormatterGetSpaceForwarder<tr1::is_convertible<T_ *, CanSpace *>::value>::get(&t)
)),
CanSpace()
diff --git a/paludis/stringify_formatter.cc b/paludis/stringify_formatter.cc
index 3f3bb64..6d5c3bf 100644
--- a/paludis/stringify_formatter.cc
+++ b/paludis/stringify_formatter.cc
@@ -28,7 +28,7 @@ using namespace paludis;
StringifyFormatter::StringifyFormatter() :
PrivateImplementationPattern<StringifyFormatter>(new Implementation<StringifyFormatter>(
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
{
}
@@ -189,6 +189,30 @@ StringifyFormatter::format(const PackageDepSpec & s, const format::Installable &
}
std::string
+StringifyFormatter::format(const PackageID & s, const format::Plain & k) const
+{
+ if (_imp->f_package_id)
+ return _imp->f_package_id->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const PackageID & s, const format::Installed & k) const
+{
+ if (_imp->f_package_id)
+ return _imp->f_package_id->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const PackageID & s, const format::Installable & k) const
+{
+ if (_imp->f_package_id)
+ return _imp->f_package_id->format(s, k);
+ return stringify(s);
+}
+
+std::string
StringifyFormatter::format(const BlockDepSpec & s, const format::Plain & k) const
{
if (_imp->f_block)
@@ -293,6 +317,14 @@ StringifyFormatter::format(const UseDepSpec & s, const format::Masked & k) const
}
std::string
+StringifyFormatter::format(const FSEntry & s, const format::Plain & k) const
+{
+ if (_imp->f_fsentry)
+ return _imp->f_fsentry->format(s, k);
+ return stringify(s);
+}
+
+std::string
StringifyFormatter::format(const UseDepSpec & s, const format::Plain & k) const
{
if (_imp->f_use_dep)
diff --git a/paludis/stringify_formatter.hh b/paludis/stringify_formatter.hh
index 4b3c778..22649fb 100644
--- a/paludis/stringify_formatter.hh
+++ b/paludis/stringify_formatter.hh
@@ -25,6 +25,7 @@
#include <paludis/name.hh>
#include <paludis/dep_spec-fwd.hh>
#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/fs_entry-fwd.hh>
/** \file
* Declarations for the StringifyFormatter class.
@@ -72,6 +73,8 @@ namespace paludis
public CanFormat<LicenseDepSpec>,
public CanFormat<UseDepSpec>,
public CanFormat<NamedSetDepSpec>,
+ public CanFormat<FSEntry>,
+ public CanFormat<PackageID>,
public CanSpace
{
private:
@@ -141,6 +144,12 @@ namespace paludis
virtual std::string format(const UseDepSpec &, const format::Masked &) const;
virtual std::string format(const UseDepSpec &, const format::Plain &) const;
+ virtual std::string format(const FSEntry &, const format::Plain &) const;
+
+ virtual std::string format(const PackageID &, const format::Plain &) const;
+ virtual std::string format(const PackageID &, const format::Installed &) const;
+ virtual std::string format(const PackageID &, const format::Installable &) const;
+
virtual std::string newline() const;
virtual std::string indent(const int) const;
};
diff --git a/paludis/uninstall_list.cc b/paludis/uninstall_list.cc
index 3b41b01..f6cf46c 100644
--- a/paludis/uninstall_list.cc
+++ b/paludis/uninstall_list.cc
@@ -226,7 +226,7 @@ UninstallList::collect_all_installed() const
for (PackageDatabase::RepositoryConstIterator i(_imp->env->package_database()->begin_repositories()),
i_end(_imp->env->package_database()->end_repositories()) ; i != i_end ; ++i)
{
- if (! (*i)->installed_interface)
+ if (! (*i)->installed_root_key())
continue;
tr1::shared_ptr<const CategoryNamePartSet> cats((*i)->category_names());
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index 514823f..69aaba9 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -42,6 +42,7 @@ add(`pipe', `hh', `cc')
add(`private_implementation_pattern', `hh', `impl')
add(`pstream', `hh', `cc', `test')
add(`random', `hh', `cc', `test')
+add(`remove_shared_ptr', `hh')
add(`rmd160', `hh', `cc', `test')
add(`save', `hh', `test')
add(`sequence', `hh', `fwd', `impl')
diff --git a/paludis/util/mutex.cc b/paludis/util/mutex.cc
index 40a3ffc..d57d12a 100644
--- a/paludis/util/mutex.cc
+++ b/paludis/util/mutex.cc
@@ -18,6 +18,9 @@
*/
#include <paludis/util/mutex.hh>
+#include <paludis/util/exception.hh>
+#include <paludis/util/stringify.hh>
+#include <cstring>
using namespace paludis;
@@ -34,7 +37,9 @@ Mutex::Mutex() :
Mutex::~Mutex()
{
- pthread_mutex_destroy(_mutex);
+ int r(0);
+ if (0 != ((r = pthread_mutex_destroy(_mutex))))
+ throw InternalError(PALUDIS_HERE, "mutex destory failed: " + stringify(strerror(r)));
pthread_mutexattr_destroy(_attr);
delete _mutex;
@@ -50,19 +55,26 @@ Mutex::posix_mutex()
Lock::Lock(Mutex & m) :
_mutex(&m)
{
- pthread_mutex_lock(_mutex->posix_mutex());
+ int r(0);
+ if (0 != ((r = pthread_mutex_lock(_mutex->posix_mutex()))))
+ throw InternalError(PALUDIS_HERE, "mutex lock failed: " + stringify(strerror(r)));
}
Lock::~Lock()
{
- pthread_mutex_unlock(_mutex->posix_mutex());
+ int r(0);
+ if (0 != ((r = pthread_mutex_unlock(_mutex->posix_mutex()))))
+ throw InternalError(PALUDIS_HERE, "mutex unlock failed: " + stringify(strerror(r)));
}
void
Lock::acquire_then_release_old(Mutex & m)
{
- pthread_mutex_lock(m.posix_mutex());
- pthread_mutex_unlock(_mutex->posix_mutex());
+ int r(0);
+ if (0 != ((r = pthread_mutex_lock(m.posix_mutex()))))
+ throw InternalError(PALUDIS_HERE, "mutex lock failed: " + stringify(strerror(r)));
+ if (0 != ((r = pthread_mutex_unlock(_mutex->posix_mutex()))))
+ throw InternalError(PALUDIS_HERE, "mutex unlock failed: " + stringify(strerror(r)));
_mutex = &m;
}
@@ -75,8 +87,10 @@ TryLock::TryLock(Mutex & m) :
TryLock::~TryLock()
{
+ int r(0);
if (_mutex)
- pthread_mutex_unlock(_mutex->posix_mutex());
+ if (0 != ((r = pthread_mutex_unlock(_mutex->posix_mutex()))))
+ throw InternalError(PALUDIS_HERE, "mutex unlock failed: " + stringify(strerror(r)));
}
bool
diff --git a/paludis/repository_info-fwd.hh b/paludis/util/remove_shared_ptr.hh
index 48b2ac1..f6829a5 100644
--- a/paludis/repository_info-fwd.hh
+++ b/paludis/util/remove_shared_ptr.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2007 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -17,19 +17,40 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORY_INFO_FWD_HH
-#define PALUDIS_GUARD_PALUDIS_REPOSITORY_INFO_FWD_HH 1
-
-/** \file
- * Forward declarations for paludis/repository_info.hh .
- *
- * \ingroup g_package_database
- */
+#ifndef PALUDIS_GUARD_PALUDIS_UTIL_REMOVE_SHARED_PTR_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_REMOVE_SHARED_PTR_HH 1
namespace paludis
{
- class RepositoryInfo;
- class RepositoryInfoSection;
+ template <typename T_>
+ struct RemoveSharedPtr
+ {
+ typedef T_ Type;
+ };
+
+ template <typename T_>
+ struct RemoveSharedPtr<tr1::shared_ptr<T_> >
+ {
+ typedef T_ Type;
+ };
+
+ template <typename T_>
+ struct RemoveSharedPtr<tr1::shared_ptr<const T_> >
+ {
+ typedef const T_ Type;
+ };
+
+ template <typename T_>
+ struct RemoveSharedPtr<const T_>
+ {
+ typedef const typename RemoveSharedPtr<T_>::Type Type;
+ };
+
+ template <typename T_>
+ struct RemoveSharedPtr<T_ &>
+ {
+ typedef typename RemoveSharedPtr<T_>::Type Type;
+ };
}
#endif
diff --git a/python/mask_TEST.py b/python/mask_TEST.py
index 1a079bf..fdc6575 100755
--- a/python/mask_TEST.py
+++ b/python/mask_TEST.py
@@ -68,11 +68,7 @@ class TestCase_01_Masks(unittest.TestCase):
self.assertEquals(m.key(), "R")
self.assertEquals(m.description(), "repository")
- for section in self.db.fetch_repository("testrepo").info(False).sections:
- for k, v in section.kvs:
- if k == "location":
- location = v
- package_mask_path = os.path.join(location, "profiles/package.mask")
+ package_mask_path = os.path.join(os.getcwd(), "mask_TEST_dir/testrepo/profiles/package.mask")
self.assertEquals(m.mask_key().value().mask_file, package_mask_path)
self.assert_(isinstance(m.mask_key().value().comment, StringIterable))
diff --git a/python/metadata_key.cc b/python/metadata_key.cc
index b5e866d..59a7869 100644
--- a/python/metadata_key.cc
+++ b/python/metadata_key.cc
@@ -99,6 +99,11 @@ class MetadataKeySptrToPythonVisitor :
obj = bp::object(tr1::static_pointer_cast<const MetadataSetKey<Set<std::string> > >(_m_ptr));
}
+ void visit(const MetadataSetKey<FSEntrySequence> & k)
+ {
+ obj = bp::object(tr1::static_pointer_cast<const MetadataSetKey<FSEntrySequence> >(_m_ptr));
+ }
+
void visit(const MetadataSpecTreeKey<LicenseSpecTree> & k)
{
obj = bp::object(tr1::static_pointer_cast<const MetadataSpecTreeKey<LicenseSpecTree> >(_m_ptr));
@@ -918,6 +923,7 @@ void expose_metadata_key()
class_set_key<UseFlagNameSet>("UseFlagNameIterable");
class_set_key<IUseFlagSet>("IUseFlagIterable");
class_set_key<Set<std::string> >("StringIterable");
+ class_set_key<FSEntrySequence>("FSEntryIterable");
/**
* MetadataSpecTreeKeys
diff --git a/python/repository.cc b/python/repository.cc
index adcfbe9..f6f98e4 100644
--- a/python/repository.cc
+++ b/python/repository.cc
@@ -21,7 +21,6 @@
#include <python/iterable.hh>
#include <paludis/repository.hh>
-#include <paludis/repository_info.hh>
#include <paludis/repositories/e/e_repository.hh>
#include <paludis/repositories/fake/fake_repository.hh>
#include <paludis/repositories/fake/fake_package_id.hh>
@@ -40,20 +39,6 @@ struct RepositoryWrapper :
Repository,
bp::wrapper<Repository>
{
- tr1::shared_ptr<const RepositoryInfo>
- info(bool verbose) const
- {
- if (bp::override info = this->get_override("info"))
- return info(verbose);
- return Repository::info(verbose);
- }
-
- tr1::shared_ptr<const RepositoryInfo>
- default_info(bool verbose) const
- {
- return Repository::info(verbose);
- }
-
static RepositorySetsInterface *
get_sets_interface(const Repository & self)
{
@@ -179,44 +164,6 @@ void expose_repository()
);
/**
- * RepositoryInfoSection
- */
- bp::to_python_converter<std::pair<const std::string, std::string>,
- pair_to_tuple<const std::string, std::string> >();
- register_shared_ptrs_to_python<RepositoryInfoSection>();
- bp::class_<RepositoryInfoSection, boost::noncopyable>
- (
- "RepositoryInfoSection",
- "A section of information about a Repository.",
- bp::init<const std::string &>()
- )
- .add_property("heading", &RepositoryInfoSection::heading,
- "[ro] string\n"
- "Heading."
- )
-
- .add_property("kvs", bp::range(&RepositoryInfoSection::begin_kvs, &RepositoryInfoSection::end_kvs),
- "[ro] Iterable of tuples\n"
- "Key-value pairs."
- )
- ;
-
- /**
- * RepositoryInfo
- */
- register_shared_ptrs_to_python<RepositoryInfo>();
- bp::class_<RepositoryInfo, boost::noncopyable>
- (
- "RepositoryInfo",
- "Information about a Repository, for the end user.",
- bp::no_init
- )
- .add_property("sections", bp::range(&RepositoryInfo::begin_sections, &RepositoryInfo::end_sections),
- "[ro] Iterable of RepositoryInfoSection."
- )
- ;
-
- /**
* Repository
*/
register_shared_ptrs_to_python<Repository>(rsp_const);
@@ -226,22 +173,12 @@ void expose_repository()
"A Repository provides a representation of a physical repository to a PackageDatabase.",
bp::no_init
)
- .def("info", &Repository::info, &RepositoryWrapper::default_info,
- "info() -> RepositoryInfo\n"
- "Fetch information about the repository."
- )
- .add_property("name", bp::make_function(&Repository::name,
- bp::return_value_policy<bp::copy_const_reference>()),
+ .add_property("name", &Repository::name,
"[ro] RepositoryName\n"
"Our name."
)
- .add_property("format", &Repository::format,
- "[ro] string\n"
- "Our format."
- )
-
.def("has_category_named", &Repository::has_category_named,
"has_category_named(CategoryNamePart) -> bool\n"
"Do we have a category with the given name?"
@@ -382,20 +319,6 @@ void expose_repository()
;
/**
- * RepositoryInstalledInterface
- */
- bp::class_<RepositoryInstalledInterface, boost::noncopyable>
- (
- "RepositoryInstalledInterface",
- "Interface for handling actions for installed repositories.",
- bp::no_init
- )
- .def("root", bp::pure_virtual(&RepositoryInstalledInterface::root),
- "What is our filesystem root?"
- )
- ;
-
- /**
* RepositorySetsInterface
*/
bp::class_<RepositorySetsInterface, boost::noncopyable>
diff --git a/python/repository_TEST.py b/python/repository_TEST.py
index e6144a6..ed4d68c 100755
--- a/python/repository_TEST.py
+++ b/python/repository_TEST.py
@@ -52,10 +52,6 @@ class TestCase_01_Repository(unittest.TestCase):
self.assertEquals(str(repo.name), "testrepo")
self.assertEquals(str(irepo.name), "installed")
- def test_04_format(self):
- self.assertEquals(str(repo.format), "ebuild")
- self.assertEquals(str(irepo.format), "vdb")
-
def test_05_has_category_named(self):
self.assert_(repo.has_category_named("foo"))
self.assert_(not repo.has_category_named("bar"))
@@ -83,26 +79,6 @@ class TestCase_01_Repository(unittest.TestCase):
self.assertEquals(i, 0)
self.assertEquals(str(qpn), "foo/bar")
- def test_11_repository_info(self):
- self.assert_(isinstance(repo.info(True), RepositoryInfo))
- self.assert_(isinstance(repo.info(False), RepositoryInfo))
-
- for (i, section) in enumerate(repo.info(False).sections):
- self.assert_(isinstance(section, RepositoryInfoSection))
- if i == 0:
- self.assertEquals(section.heading, "Configuration information")
- for (k, v) in section.kvs:
- if k == "format":
- self.assertEquals(v, "ebuild")
-
- for (i, section) in enumerate(irepo.info(False).sections):
- self.assert_(isinstance(section, RepositoryInfoSection))
- if i == 0:
- self.assertEquals(section.heading, "Configuration information")
- for (k, v) in section.kvs:
- if k == "format":
- self.assertEquals(v, "vdb")
-
class TestCase_02_RepositoryInterfaces(unittest.TestCase):
def setUp(self):
global e, nce, db, repo, irepo
diff --git a/ruby/metadata_key.cc b/ruby/metadata_key.cc
index 5171b5d..4456729 100644
--- a/ruby/metadata_key.cc
+++ b/ruby/metadata_key.cc
@@ -45,6 +45,7 @@ namespace
static VALUE c_metadata_iuse_flag_set_key;
static VALUE c_metadata_string_set_key;
static VALUE c_metadata_package_id_sequence_key;
+ static VALUE c_metadata_fsentry_sequence_key;
static VALUE c_metadata_key_type;
static VALUE c_metadata_provide_spec_tree_key;
static VALUE c_metadata_license_spec_tree_key;
@@ -158,6 +159,13 @@ namespace
tr1::static_pointer_cast<const MetadataSetKey<Set<std::string> > >(mm)));
}
+ void visit(const MetadataSetKey<FSEntrySequence> &)
+ {
+ value = Data_Wrap_Struct(c_metadata_fsentry_sequence_key, 0, &Common<tr1::shared_ptr<const FSEntrySequence> >::free,
+ new tr1::shared_ptr<const MetadataSetKey<FSEntrySequence> >(
+ tr1::static_pointer_cast<const MetadataSetKey<FSEntrySequence> >(mm)));
+ }
+
void visit(const MetadataSetKey<PackageIDSequence> &)
{
value = Data_Wrap_Struct(c_metadata_package_id_sequence_key, 0, &Common<tr1::shared_ptr<const MetadataSetKey<PackageIDSequence> > >::free,
@@ -396,12 +404,20 @@ namespace
/*
* Document-class: Paludis::MetadataPackageIDSequenceKey
*
- * Metadata class for Use flag names
+ * Metadata class for package IDs
*/
c_metadata_package_id_sequence_key = rb_define_class_under(paludis_module(), "MetadataPackageIDSequenceKey", c_metadata_key);
rb_define_method(c_metadata_package_id_sequence_key, "value", RUBY_FUNC_CAST((&SetValue<PackageIDSequence>::fetch)), 0);
/*
+ * Document-class: Paludis::MetadataPackageIDSequenceKey
+ *
+ * Metadata class for filesystem sequences
+ */
+ c_metadata_fsentry_sequence_key = rb_define_class_under(paludis_module(), "MetadataFSEntrySequenceKey", c_metadata_key);
+ rb_define_method(c_metadata_fsentry_sequence_key, "value", RUBY_FUNC_CAST((&SetValue<FSEntrySequence>::fetch)), 0);
+
+ /*
* Document-class: Paludis::MetadataIUseFlagSetKey
*
* Metadata class for IUse flags
diff --git a/ruby/repository.cc b/ruby/repository.cc
index 898ed25..0b733a7 100644
--- a/ruby/repository.cc
+++ b/ruby/repository.cc
@@ -21,7 +21,6 @@
#include <paludis_ruby.hh>
#include <paludis/repository.hh>
-#include <paludis/repository_info.hh>
#include <paludis/util/options.hh>
#include <paludis/repositories/fake/fake_repository.hh>
#include <paludis/repositories/fake/fake_package_id.hh>
@@ -39,8 +38,6 @@ using namespace paludis::ruby;
namespace
{
static VALUE c_repository;
- static VALUE c_repository_info;
- static VALUE c_repository_info_section;
static VALUE c_profiles_desc_line;
static VALUE c_fake_repository_base;
static VALUE c_fake_repository;
@@ -90,27 +87,6 @@ namespace
/*
* call-seq:
- * format -> String
- *
- * Returns our format.
- */
- VALUE
- repository_format(VALUE self)
- {
- try
- {
- tr1::shared_ptr<Repository> * self_ptr;
- Data_Get_Struct(self, tr1::shared_ptr<Repository>, self_ptr);
- return rb_str_new2(stringify((*self_ptr)->format()).c_str());
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
* has_category_named?(category_name) -> true or false
*
* Do we have a category with the given name?
@@ -436,91 +412,6 @@ namespace
}
/*
- * call-seq:
- * info(verbose) -> RepositoryInfo
- *
- * Fetch our RepositoryInfo
- */
- VALUE
- repository_info(VALUE self, VALUE verbose)
- {
- tr1::shared_ptr<Repository> * self_ptr;
- Data_Get_Struct(self, tr1::shared_ptr<Repository>, self_ptr);
-
- tr1::shared_ptr<const RepositoryInfo> * p = new tr1::shared_ptr<const RepositoryInfo>((*self_ptr)->info(Qfalse != verbose));
- return Data_Wrap_Struct(c_repository_info, 0, &Common<tr1::shared_ptr<const RepositoryInfo> >::free, p);
- }
-
- /*
- * call-seq:
- * info_sections -> Array
- *
- * Fetch an array of our sections.
- */
- VALUE
- repository_info_sections(VALUE self)
- {
- try
- {
- tr1::shared_ptr<const RepositoryInfo> * self_ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const RepositoryInfo>, self_ptr);
-
- VALUE result(rb_ary_new());
- for (RepositoryInfo::SectionConstIterator i((*self_ptr)->begin_sections()),
- i_end((*self_ptr)->end_sections()) ; i != i_end ; ++i)
- {
- tr1::shared_ptr<const RepositoryInfoSection> * s(new tr1::shared_ptr<const RepositoryInfoSection>(*i));
- rb_ary_push(result, Data_Wrap_Struct(c_repository_info_section, 0, &Common<tr1::shared_ptr<const RepositoryInfo> >::free, s));
- }
- return result;
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * kvs -> Hash
- *
- * Returns the key/value pairs within the section.
- */
- VALUE
- repository_info_section_kvs(VALUE self)
- {
- try
- {
- tr1::shared_ptr<const RepositoryInfoSection> * self_ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const RepositoryInfoSection>, self_ptr);
-
- VALUE result(rb_hash_new());
- for (RepositoryInfoSection::KeyValueConstIterator i((*self_ptr)->begin_kvs()),
- i_end((*self_ptr)->end_kvs()) ; i != i_end ; ++i)
- rb_hash_aset(result, rb_str_new2(i->first.c_str()), rb_str_new2(i->second.c_str()));
- return result;
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * header -> String
- *
- * Our heading
- */
- VALUE
- repository_info_section_header(VALUE self)
- {
- tr1::shared_ptr<const RepositoryInfoSection> * self_ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const RepositoryInfoSection>, self_ptr);
- return rb_str_new2((*self_ptr)->heading().c_str());
- }
-
- /*
* Document-method: query_use
*
* call-seq:
@@ -970,7 +861,6 @@ namespace
c_repository = rb_define_class_under(paludis_module(), "Repository", rb_cObject);
rb_funcall(c_repository, rb_intern("private_class_method"), 1, rb_str_new2("new"));
rb_define_method(c_repository, "name", RUBY_FUNC_CAST(&repository_name), 0);
- rb_define_method(c_repository, "format", RUBY_FUNC_CAST(&repository_format), 0);
rb_define_method(c_repository, "has_category_named?", RUBY_FUNC_CAST(&repository_has_category_named), 1);
rb_define_method(c_repository, "has_package_named?", RUBY_FUNC_CAST(&repository_has_package_named), 1);
@@ -981,8 +871,6 @@ namespace
rb_define_method(c_repository, "package_names", RUBY_FUNC_CAST(&repository_package_names), 1);
rb_define_method(c_repository, "package_ids", RUBY_FUNC_CAST(&repository_package_ids), 1);
- rb_define_method(c_repository, "installed_interface", RUBY_FUNC_CAST((&Interface<RepositoryInstalledInterface,
- &Repository::installed_interface>::fetch)), 0);
rb_define_method(c_repository, "sets_interface", RUBY_FUNC_CAST((&Interface<RepositorySetsInterface,
&Repository::sets_interface>::fetch)), 0);
rb_define_method(c_repository, "syncable_interface", RUBY_FUNC_CAST((&Interface<RepositorySyncableInterface,
@@ -1006,7 +894,6 @@ namespace
rb_define_method(c_repository, "some_ids_might_support_action", RUBY_FUNC_CAST(&repository_some_ids_might_support_action), 1);
- rb_define_method(c_repository, "info", RUBY_FUNC_CAST(&repository_info), 1);
rb_define_method(c_repository, "query_use", RUBY_FUNC_CAST((&QueryUse<UseFlagState, use_enabled, use_disabled, &RepositoryUseInterface::query_use>::query)), -1);
rb_define_method(c_repository, "query_use_mask", RUBY_FUNC_CAST((&QueryUse<bool, true, false, &RepositoryUseInterface::query_use_mask>::query)), -1);
rb_define_method(c_repository, "query_use_force", RUBY_FUNC_CAST((&QueryUse<bool, true, false, &RepositoryUseInterface::query_use_force>::query)), -1);
@@ -1021,31 +908,12 @@ namespace
rb_define_method(c_repository, "check_qa", RUBY_FUNC_CAST(&repository_check_qa),5);
/*
- * Document-class: Paludis::RepositoryInfo
- *
- * Information about a Repository, for the end user.
- */
- c_repository_info = rb_define_class_under(paludis_module(), "RepositoryInfo", rb_cObject);
- rb_funcall(c_repository_info, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_repository_info, "sections", RUBY_FUNC_CAST(&repository_info_sections), 0);
-
- /*
- * Document-class: Paludis::RepositoryInfoSection
- *
- * A section of information about a Repository.
- */
- c_repository_info_section = rb_define_class_under(paludis_module(), "RepositoryInfoSection", rb_cObject);
- rb_funcall(c_repository_info_section, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_repository_info_section, "kvs", RUBY_FUNC_CAST(&repository_info_section_kvs), 0);
- rb_define_method(c_repository_info_section, "header", RUBY_FUNC_CAST(&repository_info_section_header), 0);
-
- /*
* Document-class: Paludis::ProfilesDescLine
*
*
*/
c_profiles_desc_line = rb_define_class_under(paludis_module(), "ProfilesDescLine", rb_cObject);
- rb_funcall(c_repository_info, rb_intern("private_class_method"), 1, rb_str_new2("new"));
+ rb_funcall(c_profiles_desc_line, rb_intern("private_class_method"), 1, rb_str_new2("new"));
rb_define_method(c_profiles_desc_line, "path",
RUBY_FUNC_CAST((&DescLineValue<FSEntry,&RepositoryEInterface::ProfilesDescLine::path>::fetch)), 0);
rb_define_method(c_profiles_desc_line, "arch",
diff --git a/ruby/repository_TEST.rb b/ruby/repository_TEST.rb
index 3401cf3..4676086 100644
--- a/ruby/repository_TEST.rb
+++ b/ruby/repository_TEST.rb
@@ -73,11 +73,6 @@ module Paludis
assert_equal "installed", installed_repo.name
assert_equal "testrepo", repo.name
end
-
- def test_format
- assert_equal "vdb", installed_repo.format
- assert_equal "ebuild", repo.format
- end
end
class TestCase_RepositoryHasCategoryNamed < Test::Unit::TestCase
@@ -173,7 +168,7 @@ module Paludis
def test_responds
repo = no_config_testrepo.main_repository
- [:installed_interface, :sets_interface, :syncable_interface, :use_interface,
+ [:sets_interface, :syncable_interface, :use_interface,
:world_interface, :mirrors_interface, :environment_variable_interface,
:provides_interface, :virtuals_interface, :e_interface,
:qa_interface].each do |sym|
@@ -183,8 +178,6 @@ module Paludis
def test_interfaces
assert_equal repo.name, repo.use_interface.name
- assert_nil repo.installed_interface
-
assert_equal installed_repo.name, installed_repo.provides_interface.name
assert_nil installed_repo.syncable_interface
end
@@ -387,31 +380,6 @@ module Paludis
end
end
- class TestCase_RepositoryInfo < Test::Unit::TestCase
- include RepositoryTestCase
-
- def test_info
- assert_kind_of RepositoryInfo, repo.info(false)
- assert_kind_of RepositoryInfo, repo.info(true)
- end
-
- def test_sections
- assert_kind_of Array, repo.info(false).sections
- assert_equal 1, repo.info(false).sections.length
- end
-
- def test_section_header
- assert_kind_of String, repo.info(false).sections.first.header
- assert_equal 'Configuration information', repo.info(false).sections.first.header
- end
-
- def test_section_kvs
- assert_kind_of Hash, repo.info(false).sections.first.kvs
- assert_equal 'ebuild', repo.info(false).sections.first.kvs['format']
- assert_equal 'vdb', installed_repo.info(false).sections.first.kvs['format']
- end
- end
-
class TestCase_RepositoryPortageInterface < Test::Unit::TestCase
include RepositoryTestCase
diff --git a/src/clients/gtkpaludis/libgtkpaludis/markup_formatter.cc b/src/clients/gtkpaludis/libgtkpaludis/markup_formatter.cc
index 1bf6d88..b0ede92 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/markup_formatter.cc
+++ b/src/clients/gtkpaludis/libgtkpaludis/markup_formatter.cc
@@ -215,21 +215,27 @@ MarkupFormatter::format(const BlockDepSpec & f, const format::Plain &) const
}
std::string
-MarkupFormatter::format(const tr1::shared_ptr<const PackageID> & f, const format::Plain &) const
+MarkupFormatter::format(const FSEntry & f, const format::Plain &) const
{
- return markup_escape(stringify(*f));
+ return markup_escape(stringify(f));
+}
+
+std::string
+MarkupFormatter::format(const PackageID & f, const format::Plain &) const
+{
+ return markup_escape(stringify(f));
}
std::string
-MarkupFormatter::format(const tr1::shared_ptr<const PackageID> & f, const format::Installed &) const
+MarkupFormatter::format(const PackageID & f, const format::Installed &) const
{
- return markup_foreground("blue", markup_escape(stringify(*f)));
+ return markup_foreground("blue", markup_escape(stringify(f)));
}
std::string
-MarkupFormatter::format(const tr1::shared_ptr<const PackageID> & f, const format::Installable &) const
+MarkupFormatter::format(const PackageID & f, const format::Installable &) const
{
- return markup_foreground("darkblue", markup_escape(stringify(*f)));
+ return markup_foreground("darkblue", markup_escape(stringify(f)));
}
std::string
diff --git a/src/clients/gtkpaludis/libgtkpaludis/markup_formatter.hh b/src/clients/gtkpaludis/libgtkpaludis/markup_formatter.hh
index 57cfc6b..d5e0fcc 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/markup_formatter.hh
+++ b/src/clients/gtkpaludis/libgtkpaludis/markup_formatter.hh
@@ -6,6 +6,7 @@
#include <paludis/formatter.hh>
#include <paludis/name-fwd.hh>
#include <paludis/dep_spec-fwd.hh>
+#include <paludis/util/fs_entry-fwd.hh>
namespace gtkpaludis
{
@@ -23,7 +24,8 @@ namespace gtkpaludis
public paludis::CanFormat<paludis::FetchableURIDepSpec>,
public paludis::CanFormat<paludis::LicenseDepSpec>,
public paludis::CanFormat<paludis::NamedSetDepSpec>,
- public paludis::CanFormat<paludis::tr1::shared_ptr<const paludis::PackageID> >,
+ public paludis::CanFormat<paludis::PackageID>,
+ public paludis::CanFormat<paludis::FSEntry>,
public paludis::CanFormat<std::string>,
public paludis::CanSpace
{
@@ -76,9 +78,11 @@ namespace gtkpaludis
std::string format(const paludis::BlockDepSpec &, const paludis::format::Plain &) const;
- std::string format(const paludis::tr1::shared_ptr<const paludis::PackageID> &, const paludis::format::Plain &) const;
- std::string format(const paludis::tr1::shared_ptr<const paludis::PackageID> &, const paludis::format::Installed &) const;
- std::string format(const paludis::tr1::shared_ptr<const paludis::PackageID> &, const paludis::format::Installable &) const;
+ std::string format(const paludis::PackageID &, const paludis::format::Plain &) const;
+ std::string format(const paludis::PackageID &, const paludis::format::Installed &) const;
+ std::string format(const paludis::PackageID &, const paludis::format::Installable &) const;
+
+ std::string format(const paludis::FSEntry &, const paludis::format::Plain &) const;
std::string newline() const;
std::string indent(const int) const;
diff --git a/src/clients/gtkpaludis/libgtkpaludis/repository_info_model.cc b/src/clients/gtkpaludis/libgtkpaludis/repository_info_model.cc
index 727a890..3d6a75d 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/repository_info_model.cc
+++ b/src/clients/gtkpaludis/libgtkpaludis/repository_info_model.cc
@@ -5,7 +5,6 @@
#include <paludis/repository.hh>
#include <paludis/environment.hh>
#include <paludis/package_database.hh>
-#include <paludis/repository_info.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/indirect_iterator-impl.hh>
@@ -39,13 +38,16 @@ RepositoryInfoModel::~RepositoryInfoModel()
}
void
-RepositoryInfoModel::set_repository(const RepositoryName & name)
+RepositoryInfoModel::set_repository(const RepositoryName &)
{
+#if 0
_imp->main_window->paludis_thread_action(
sigc::bind(sigc::mem_fun(this, &RepositoryInfoModel::set_repository_in_paludis_thread), name),
"Populating repository information model");
+#endif
}
+#if 0
void
RepositoryInfoModel::set_repository_in_paludis_thread(const RepositoryName & name)
{
@@ -76,6 +78,7 @@ RepositoryInfoModel::set_repository_in_gui_thread(tr1::shared_ptr<const Reposito
}
}
}
+#endif
RepositoryInfoModel::Columns::Columns()
{
diff --git a/src/clients/gtkpaludis/libgtkpaludis/repository_info_model.hh b/src/clients/gtkpaludis/libgtkpaludis/repository_info_model.hh
index 2f77bba..6243503 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/repository_info_model.hh
+++ b/src/clients/gtkpaludis/libgtkpaludis/repository_info_model.hh
@@ -22,8 +22,10 @@ namespace gtkpaludis
public Gtk::TreeStore
{
private:
+#if 0
void set_repository_in_paludis_thread(const paludis::RepositoryName &);
void set_repository_in_gui_thread(paludis::tr1::shared_ptr<const paludis::RepositoryInfo>);
+#endif
public:
RepositoryInfoModel(MainWindow * const);
diff --git a/src/clients/gtkpaludis/libgtkpaludis/version_info_model.cc b/src/clients/gtkpaludis/libgtkpaludis/version_info_model.cc
index 0a08f6c..331f141 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/version_info_model.cc
+++ b/src/clients/gtkpaludis/libgtkpaludis/version_info_model.cc
@@ -114,6 +114,11 @@ namespace gtkpaludis
got_key(k, k.pretty_print_flat(formatter));
}
+ void visit(const MetadataSetKey<FSEntrySequence> & k)
+ {
+ got_key(k, k.pretty_print_flat(formatter));
+ }
+
void visit(const MetadataSetKey<UseFlagNameSet> & k)
{
got_key(k, k.pretty_print_flat(formatter));
diff --git a/src/clients/importare/importare.cc b/src/clients/importare/importare.cc
index 7125dea..404c181 100644
--- a/src/clients/importare/importare.cc
+++ b/src/clients/importare/importare.cc
@@ -135,7 +135,9 @@ main(int argc, char *argv[])
for (PackageIDSequence::ConstIterator i(old_ids->begin()), i_end(old_ids->end()) ;
i != i_end ; ++i)
{
- if ((*i)->repository()->format() != "installed_unpackaged")
+ if (! (*i)->repository()->format_key())
+ continue;
+ if ((*i)->repository()->format_key()->value() != "installed_unpackaged")
continue;
old_id = *i;
break;
diff --git a/src/clients/inquisitio/do_search.cc b/src/clients/inquisitio/do_search.cc
index 2e6fdb3..aac97c7 100644
--- a/src/clients/inquisitio/do_search.cc
+++ b/src/clients/inquisitio/do_search.cc
@@ -30,6 +30,7 @@
#include <paludis/package_database.hh>
#include <paludis/action.hh>
#include <paludis/package_id.hh>
+#include <paludis/metadata_key.hh>
#include <paludis/util/set.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/make_shared_ptr.hh>
@@ -208,7 +209,7 @@ do_search(const Environment & env)
if (CommandLine::get_instance()->a_repository_format.end_args() ==
std::find_if(CommandLine::get_instance()->a_repository_format.begin_args(),
CommandLine::get_instance()->a_repository_format.end_args(),
- tr1::bind(std::equal_to<std::string>(), _1, stringify((*r)->format()))))
+ tr1::bind(std::equal_to<std::string>(), _1, (*r)->format_key() ? (*r)->format_key()->value() : "?")))
continue;
if (CommandLine::get_instance()->a_kind.argument() == "installable")
diff --git a/src/clients/inquisitio/key_extractor.cc b/src/clients/inquisitio/key_extractor.cc
index 7f384ef..2c7b04c 100644
--- a/src/clients/inquisitio/key_extractor.cc
+++ b/src/clients/inquisitio/key_extractor.cc
@@ -269,6 +269,17 @@ namespace
tr1::bind(&Matcher::operator(), tr1::cref(_m), _1));
}
+ void visit(const MetadataSetKey<FSEntrySequence> & s)
+ {
+ using namespace tr1::placeholders;
+
+ if (_flatten)
+ result = _m(join(s.value()->begin(), s.value()->end(), " "));
+ else
+ result = s.value()->end() != std::find_if(s.value()->begin(), s.value()->end(),
+ tr1::bind(&Matcher::operator(), tr1::cref(_m), tr1::bind(&stringify<FSEntry>, _1)));
+ }
+
void visit(const MetadataSetKey<PackageIDSequence> & s)
{
using namespace tr1::placeholders;
diff --git a/src/clients/instruo/instruo.cc b/src/clients/instruo/instruo.cc
index 015a37b..1baadb8 100644
--- a/src/clients/instruo/instruo.cc
+++ b/src/clients/instruo/instruo.cc
@@ -120,6 +120,11 @@ namespace
const tr1::shared_ptr<const Set<std::string> > & PALUDIS_ATTRIBUTE((unused)) s(k.value());
}
+ void visit(const MetadataSetKey<FSEntrySequence> & k)
+ {
+ const tr1::shared_ptr<const FSEntrySequence> & PALUDIS_ATTRIBUTE((unused)) s(k.value());
+ }
+
void visit(const MetadataSetKey<KeywordNameSet> & k)
{
const tr1::shared_ptr<const KeywordNameSet> & PALUDIS_ATTRIBUTE((unused)) s(k.value());
diff --git a/src/clients/paludis/applets.cc b/src/clients/paludis/applets.cc
index de4afa6..d4d4fe1 100644
--- a/src/clients/paludis/applets.cc
+++ b/src/clients/paludis/applets.cc
@@ -40,6 +40,130 @@
using namespace paludis;
+namespace
+{
+ struct ValuePrinter :
+ ConstVisitor<MetadataKeyVisitorTypes>
+ {
+ int return_code;
+
+ ValuePrinter() :
+ return_code(0)
+ {
+ }
+
+ void visit(const MetadataStringKey & k)
+ {
+ std::cout << k.value() << std::endl;
+ }
+
+ void visit(const MetadataFSEntryKey & k)
+ {
+ std::cout << k.value() << std::endl;
+ }
+
+ void visit(const MetadataRepositoryMaskInfoKey &)
+ {
+ std::cout << "(unprintable)" << std::endl;
+ return_code |= 1;
+ }
+
+ void visit(const MetadataSectionKey &)
+ {
+ std::cout << "(unprintable)" << std::endl;
+ return_code |= 1;
+ }
+
+ void visit(const MetadataContentsKey &)
+ {
+ std::cout << "(unprintable)" << std::endl;
+ return_code |= 1;
+ }
+
+ void visit(const MetadataSpecTreeKey<RestrictSpecTree> & k)
+ {
+ StringifyFormatter f;
+ std::cout << k.pretty_print_flat(f) << std::endl;
+ }
+
+ void visit(const MetadataSpecTreeKey<ProvideSpecTree> & k)
+ {
+ StringifyFormatter f;
+ std::cout << k.pretty_print_flat(f) << std::endl;
+ }
+
+ void visit(const MetadataSpecTreeKey<FetchableURISpecTree> & k)
+ {
+ StringifyFormatter f;
+ std::cout << k.pretty_print_flat(f) << std::endl;
+ }
+
+ void visit(const MetadataSpecTreeKey<DependencySpecTree> & k)
+ {
+ StringifyFormatter f;
+ std::cout << k.pretty_print_flat(f) << std::endl;
+ }
+
+ void visit(const MetadataSpecTreeKey<SimpleURISpecTree> & k)
+ {
+ StringifyFormatter f;
+ std::cout << k.pretty_print_flat(f) << std::endl;
+ }
+
+ void visit(const MetadataSpecTreeKey<LicenseSpecTree> & k)
+ {
+ StringifyFormatter f;
+ std::cout << k.pretty_print_flat(f) << std::endl;
+ }
+
+ void visit(const MetadataSetKey<FSEntrySequence> & k)
+ {
+ StringifyFormatter f;
+ std::cout << k.pretty_print_flat(f) << std::endl;
+ }
+
+ void visit(const MetadataSetKey<PackageIDSequence> & k)
+ {
+ StringifyFormatter f;
+ std::cout << k.pretty_print_flat(f) << std::endl;
+ }
+
+ void visit(const MetadataSetKey<KeywordNameSet> & k)
+ {
+ StringifyFormatter f;
+ std::cout << k.pretty_print_flat(f) << std::endl;
+ }
+
+ void visit(const MetadataSetKey<IUseFlagSet> & k)
+ {
+ StringifyFormatter f;
+ std::cout << k.pretty_print_flat(f) << std::endl;
+ }
+
+ void visit(const MetadataSetKey<UseFlagNameSet> & k)
+ {
+ StringifyFormatter f;
+ std::cout << k.pretty_print_flat(f) << std::endl;
+ }
+
+ void visit(const MetadataSetKey<Set<std::string> > & k)
+ {
+ StringifyFormatter f;
+ std::cout << k.pretty_print_flat(f) << std::endl;
+ }
+
+ void visit(const MetadataPackageIDKey & k)
+ {
+ std::cout << *k.value() << std::endl;
+ }
+
+ void visit(const MetadataTimeKey & k)
+ {
+ std::cout << k.value() << std::endl;
+ }
+ };
+}
+
int do_has_version(tr1::shared_ptr<Environment> env)
{
int return_code(0);
@@ -174,29 +298,21 @@ int do_environment_variable(tr1::shared_ptr<Environment> env)
int do_configuration_variable(tr1::shared_ptr<Environment> env)
{
- int return_code(0);
-
Context context("When performing configuration-variable action from command line:");
std::string repo_str(*CommandLine::get_instance()->begin_parameters());
std::string var_str(* next(CommandLine::get_instance()->begin_parameters()));
- tr1::shared_ptr<const RepositoryInfo> info(env->package_database()->fetch_repository(
- RepositoryName(repo_str))->info(false));
-
- return_code = 1;
- for (RepositoryInfo::SectionConstIterator s(info->begin_sections()),
- s_end(info->end_sections()) ; s != s_end ; ++s)
- for (RepositoryInfoSection::KeyValueConstIterator k((*s)->begin_kvs()),
- k_end((*s)->end_kvs()) ; k != k_end ; ++k)
- if (var_str == k->first)
- {
- std::cout << k->second << std::endl;
- return_code = 0;
- break;
- }
-
- return return_code;
+ const tr1::shared_ptr<const Repository> repo(env->package_database()->fetch_repository(RepositoryName(repo_str)));
+ Repository::MetadataConstIterator i(repo->find_metadata(var_str));
+ if (i == repo->end_metadata())
+ return 1;
+ else
+ {
+ ValuePrinter v;
+ (*i)->accept(v);
+ return v.return_code;
+ }
}
int do_list_repository_formats()
@@ -303,8 +419,18 @@ int do_regenerate_cache(tr1::shared_ptr<Environment> env, bool installed)
for (PackageDatabase::RepositoryConstIterator r(env->package_database()->begin_repositories()),
r_end(env->package_database()->end_repositories()) ; r != r_end ; ++r)
{
- if (installed != (0 != (*r)->installed_interface))
- continue;
+ if (installed)
+ {
+ SupportsActionTest<InstalledAction> action_test;
+ if (! (*r)->some_ids_might_support_action(action_test))
+ continue;
+ }
+ else
+ {
+ SupportsActionTest<InstallAction> action_test;
+ if (! (*r)->some_ids_might_support_action(action_test))
+ continue;
+ }
std::cout << "Regenerating cache for " << (*r)->name() << "..." << std::endl;
(*r)->regenerate_cache();
diff --git a/src/clients/paludis/info.cc b/src/clients/paludis/info.cc
index cd6c8f0..70590c1 100644
--- a/src/clients/paludis/info.cc
+++ b/src/clients/paludis/info.cc
@@ -20,15 +20,16 @@
#include "info.hh"
#include "command_line.hh"
#include "src/output/colour.hh"
+#include "src/output/colour_formatter.hh"
#include <paludis/about.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/package_database.hh>
#include <paludis/environment.hh>
-#include <paludis/repository_info.hh>
#include <paludis/query.hh>
#include <paludis/package_id.hh>
#include <paludis/action.hh>
+#include <paludis/metadata_key.hh>
#include <iostream>
#include <iomanip>
#include <sys/types.h>
@@ -39,6 +40,135 @@ using namespace paludis;
using std::endl;
using std::cout;
+namespace
+{
+ struct InfoDisplayer :
+ ConstVisitor<MetadataKeyVisitorTypes>
+ {
+ std::string indent;
+
+ InfoDisplayer(const std::string & i) :
+ indent(i)
+ {
+ }
+
+ void visit(const MetadataSectionKey & k)
+ {
+ cout << endl;
+ cout << indent << colour(cl_heading, k.human_name() + ":") << endl;
+ InfoDisplayer i(indent + " ");
+ std::for_each(indirect_iterator(k.begin_metadata()), indirect_iterator(k.end_metadata()), accept_visitor(i));
+ }
+
+ void visit(const MetadataStringKey & k)
+ {
+ cout << std::setw(30) << (indent + k.human_name() + ":") << " " << k.value() << endl;
+ }
+
+ void visit(const MetadataFSEntryKey & k)
+ {
+ cout << std::setw(30) << (indent + k.human_name() + ":") << " " << k.value() << endl;
+ }
+
+ void visit(const MetadataPackageIDKey & k)
+ {
+ cout << std::setw(30) << (indent + k.human_name() + ":") << " " << *k.value() << endl;
+ }
+
+ void visit(const MetadataRepositoryMaskInfoKey & k)
+ {
+ cout << std::setw(30) << (indent + k.human_name() + ":") << " " << endl;
+ }
+
+ void visit(const MetadataContentsKey & k)
+ {
+ cout << std::setw(30) << (indent + k.human_name() + ":") << " " << endl;
+ }
+
+ void visit(const MetadataTimeKey & k)
+ {
+ time_t t(k.value());
+ char buf[255];
+ if (! strftime(buf, 254, "%c", gmtime(&t)))
+ buf[0] = '\0';
+
+ cout << std::setw(30) << (indent + k.human_name() + ":") << " " << stringify(buf) << endl;
+ }
+
+ void visit(const MetadataSpecTreeKey<RestrictSpecTree> & k)
+ {
+ ColourFormatter f;
+ cout << std::setw(30) << (indent + k.human_name() + ":") << " " << k.pretty_print_flat(f) << endl;
+ }
+
+ void visit(const MetadataSpecTreeKey<LicenseSpecTree> & k)
+ {
+ ColourFormatter f;
+ cout << std::setw(30) << (indent + k.human_name() + ":") << " " << k.pretty_print_flat(f) << endl;
+ }
+
+ void visit(const MetadataSpecTreeKey<FetchableURISpecTree> & k)
+ {
+ ColourFormatter f;
+ cout << std::setw(30) << (indent + k.human_name() + ":") << " " << k.pretty_print_flat(f) << endl;
+ }
+
+ void visit(const MetadataSpecTreeKey<SimpleURISpecTree> & k)
+ {
+ ColourFormatter f;
+ cout << std::setw(30) << (indent + k.human_name() + ":") << " " << k.pretty_print_flat(f) << endl;
+ }
+
+ void visit(const MetadataSpecTreeKey<DependencySpecTree> & k)
+ {
+ ColourFormatter f;
+ cout << std::setw(30) << (indent + k.human_name() + ":") << " " << k.pretty_print_flat(f) << endl;
+ }
+
+ void visit(const MetadataSpecTreeKey<ProvideSpecTree> & k)
+ {
+ ColourFormatter f;
+ cout << std::setw(30) << (indent + k.human_name() + ":") << " " << k.pretty_print_flat(f) << endl;
+ }
+
+ void visit(const MetadataSetKey<FSEntrySequence> & k)
+ {
+ ColourFormatter f;
+ cout << std::setw(30) << (indent + k.human_name() + ":") << " " << k.pretty_print_flat(f) << endl;
+ }
+
+ void visit(const MetadataSetKey<PackageIDSequence> & k)
+ {
+ ColourFormatter f;
+ cout << std::setw(30) << (indent + k.human_name() + ":") << " " << k.pretty_print_flat(f) << endl;
+ }
+
+ void visit(const MetadataSetKey<KeywordNameSet> & k)
+ {
+ ColourFormatter f;
+ cout << std::setw(30) << (indent + k.human_name() + ":") << " " << k.pretty_print_flat(f) << endl;
+ }
+
+ void visit(const MetadataSetKey<IUseFlagSet> & k)
+ {
+ ColourFormatter f;
+ cout << std::setw(30) << (indent + k.human_name() + ":") << " " << k.pretty_print_flat(f) << endl;
+ }
+
+ void visit(const MetadataSetKey<UseFlagNameSet> & k)
+ {
+ ColourFormatter f;
+ cout << std::setw(30) << (indent + k.human_name() + ":") << " " << k.pretty_print_flat(f) << endl;
+ }
+
+ void visit(const MetadataSetKey<Set<std::string> > & k)
+ {
+ ColourFormatter f;
+ cout << std::setw(30) << (indent + k.human_name() + ":") << " " << k.pretty_print_flat(f) << endl;
+ }
+ };
+}
+
int do_one_info(
const tr1::shared_ptr<const Environment> & env,
const std::string & q)
@@ -150,18 +280,9 @@ do_info(const tr1::shared_ptr<const Environment> & env)
r != r_end ; ++r)
{
cout << "Repository " << colour(cl_repository_name, r->name()) << ":" << endl;
-
- tr1::shared_ptr<const RepositoryInfo> ii(r->info(true));
- for (RepositoryInfo::SectionConstIterator i(ii->begin_sections()),
- i_end(ii->end_sections()) ; i != i_end ; ++i)
- {
- cout << " " << colour(cl_heading, (*i)->heading() + ":") << endl;
- for (RepositoryInfoSection::KeyValueConstIterator k((*i)->begin_kvs()),
- k_end((*i)->end_kvs()) ; k != k_end ; ++k)
- cout << " " << std::setw(22) << std::left << (stringify(k->first) + ":")
- << std::setw(0) << " " << k->second << endl;
- cout << endl;
- }
+ InfoDisplayer i(" ");
+ std::for_each(indirect_iterator(r->begin_metadata()), indirect_iterator(r->end_metadata()), accept_visitor(i));
+ cout << endl;
}
if (CommandLine::get_instance()->empty())
diff --git a/src/clients/paludis/list.cc b/src/clients/paludis/list.cc
index 3820121..a0a3473 100644
--- a/src/clients/paludis/list.cc
+++ b/src/clients/paludis/list.cc
@@ -22,11 +22,11 @@
#include <paludis/environment.hh>
#include <paludis/package_database.hh>
-#include <paludis/repository_info.hh>
#include <paludis/util/log.hh>
#include <paludis/util/visitor.hh>
#include <paludis/util/set.hh>
#include <paludis/util/indirect_iterator-impl.hh>
+#include <paludis/metadata_key.hh>
#include <src/output/colour.hh>
#include <paludis/util/tr1_memory.hh>
@@ -59,24 +59,12 @@ do_list_repositories(tr1::shared_ptr<Environment> env)
if (CommandLine::get_instance()->a_repository_format.end_args() == std::find(
CommandLine::get_instance()->a_repository_format.begin_args(),
CommandLine::get_instance()->a_repository_format.end_args(),
- r->format()))
+ r->format_key() ? r->format_key()->value() : "?"))
continue;
ret_code = 0;
std::cout << "* " << colour(cl_repository_name, r->name()) << std::endl;
-
- tr1::shared_ptr<const RepositoryInfo> ii(r->info(false));
- for (RepositoryInfo::SectionConstIterator i(ii->begin_sections()),
- i_end(ii->end_sections()) ; i != i_end ; ++i)
- {
- std::cout << " " << colour(cl_heading, (*i)->heading() + ":") << std::endl;
- for (RepositoryInfoSection::KeyValueConstIterator k((*i)->begin_kvs()),
- k_end((*i)->end_kvs()) ; k != k_end ; ++k)
- std::cout << " " << std::setw(22) << std::left << (stringify(k->first) + ":")
- << std::setw(0) << " " << k->second << std::endl;
- std::cout << std::endl;
- }
}
return ret_code;
@@ -105,7 +93,7 @@ do_list_categories(tr1::shared_ptr<Environment> env)
if (CommandLine::get_instance()->a_repository_format.end_args() == std::find(
CommandLine::get_instance()->a_repository_format.begin_args(),
CommandLine::get_instance()->a_repository_format.end_args(),
- r->format()))
+ r->format_key() ? r->format_key()->value() : "?"))
continue;
tr1::shared_ptr<const CategoryNamePartSet> cat_names(r->category_names());
@@ -158,7 +146,7 @@ do_list_packages(tr1::shared_ptr<Environment> env)
if (CommandLine::get_instance()->a_repository_format.end_args() == std::find(
CommandLine::get_instance()->a_repository_format.begin_args(),
CommandLine::get_instance()->a_repository_format.end_args(),
- r->format()))
+ r->format_key() ? r->format_key()->value() : "?"))
continue;
tr1::shared_ptr<const CategoryNamePartSet> cat_names(r->category_names());
@@ -226,7 +214,7 @@ do_list_sets(tr1::shared_ptr<Environment> env)
if (CommandLine::get_instance()->a_repository_format.end_args() == std::find(
CommandLine::get_instance()->a_repository_format.begin_args(),
CommandLine::get_instance()->a_repository_format.end_args(),
- r->format()))
+ r->format_key() ? r->format_key()->value() : "?"))
continue;
tr1::shared_ptr<const SetNameSet> set_names(r->sets_interface->sets_list());
diff --git a/src/clients/paludis/owner.cc b/src/clients/paludis/owner.cc
index 765fff2..a8c263a 100644
--- a/src/clients/paludis/owner.cc
+++ b/src/clients/paludis/owner.cc
@@ -98,7 +98,8 @@ do_one_owner(
for (PackageDatabase::RepositoryConstIterator r(env->package_database()->begin_repositories()),
r_end(env->package_database()->end_repositories()) ; r != r_end ; ++r)
{
- if (! (*r)->installed_interface)
+ SupportsActionTest<InstalledAction> action_test;
+ if (! (*r)->some_ids_might_support_action(action_test))
continue;
tr1::shared_ptr<const CategoryNamePartSet> cats((*r)->category_names());
diff --git a/src/clients/qualudis/qualudis.cc b/src/clients/qualudis/qualudis.cc
index ab2496b..2691cd7 100644
--- a/src/clients/qualudis/qualudis.cc
+++ b/src/clients/qualudis/qualudis.cc
@@ -69,6 +69,11 @@ namespace
stream << k.raw_name() << ": " << join(k.value()->begin(), k.value()->end(), " ") << "\n";
}
+ void visit(const MetadataSetKey<FSEntrySequence> & k)
+ {
+ stream << k.raw_name() << ": " << join(k.value()->begin(), k.value()->end(), " ") << "\n";
+ }
+
void visit(const MetadataSetKey<UseFlagNameSet> & k)
{
stream << k.raw_name() << ": " << join(k.value()->begin(), k.value()->end(), " ") << "\n";
@@ -151,10 +156,7 @@ namespace
void visit(const MetadataSectionKey & k)
{
- if (k.title_key())
- stream << k.raw_name() << ": " << k.title_key()->value() << "\n";
- else
- stream << k.raw_name() << "\n";
+ stream << k.raw_name() << "\n";
}
};
diff --git a/src/output/colour_formatter.cc b/src/output/colour_formatter.cc
index 43de8aa..7e64d52 100644
--- a/src/output/colour_formatter.cc
+++ b/src/output/colour_formatter.cc
@@ -387,21 +387,27 @@ ColourFormatter::format(const BlockDepSpec & f, const format::Plain &) const
}
std::string
-ColourFormatter::format(const tr1::shared_ptr<const PackageID> & f, const format::Plain &) const
+ColourFormatter::format(const PackageID & f, const format::Plain &) const
{
- return stringify(*f);
+ return stringify(f);
+}
+
+std::string
+ColourFormatter::format(const PackageID & f, const format::Installed &) const
+{
+ return colour(cl_package_name, f);
}
std::string
-ColourFormatter::format(const tr1::shared_ptr<const PackageID> & f, const format::Installed &) const
+ColourFormatter::format(const PackageID & f, const format::Installable &) const
{
- return colour(cl_package_name, *f);
+ return colour(cl_installable_package_name, f);
}
std::string
-ColourFormatter::format(const tr1::shared_ptr<const PackageID> & f, const format::Installable &) const
+ColourFormatter::format(const FSEntry & f, const format::Plain &) const
{
- return colour(cl_installable_package_name, *f);
+ return stringify(f);
}
std::string
diff --git a/src/output/colour_formatter.hh b/src/output/colour_formatter.hh
index 74a4465..0f9b9e5 100644
--- a/src/output/colour_formatter.hh
+++ b/src/output/colour_formatter.hh
@@ -24,6 +24,7 @@
#include <paludis/name-fwd.hh>
#include <paludis/dep_spec-fwd.hh>
#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/fs_entry-fwd.hh>
class ColourFormatter :
public paludis::CanFormat<paludis::UseFlagName>,
@@ -39,7 +40,8 @@ class ColourFormatter :
public paludis::CanFormat<paludis::FetchableURIDepSpec>,
public paludis::CanFormat<paludis::LicenseDepSpec>,
public paludis::CanFormat<paludis::NamedSetDepSpec>,
- public paludis::CanFormat<paludis::tr1::shared_ptr<const paludis::PackageID> >,
+ public paludis::CanFormat<paludis::FSEntry>,
+ public paludis::CanFormat<paludis::PackageID>,
public paludis::CanFormat<std::string>,
public paludis::CanSpace,
private paludis::PrivateImplementationPattern<ColourFormatter>
@@ -101,9 +103,11 @@ class ColourFormatter :
std::string format(const paludis::BlockDepSpec &, const paludis::format::Plain &) const;
- std::string format(const paludis::tr1::shared_ptr<const paludis::PackageID> &, const paludis::format::Plain &) const;
- std::string format(const paludis::tr1::shared_ptr<const paludis::PackageID> &, const paludis::format::Installed &) const;
- std::string format(const paludis::tr1::shared_ptr<const paludis::PackageID> &, const paludis::format::Installable &) const;
+ std::string format(const paludis::FSEntry &, const paludis::format::Plain &) const;
+
+ std::string format(const paludis::PackageID &, const paludis::format::Plain &) const;
+ std::string format(const paludis::PackageID &, const paludis::format::Installed &) const;
+ std::string format(const paludis::PackageID &, const paludis::format::Installable &) const;
std::string newline() const;
std::string indent(const int) const;
diff --git a/src/output/console_query_task.cc b/src/output/console_query_task.cc
index f5719a0..6cdef71 100644
--- a/src/output/console_query_task.cc
+++ b/src/output/console_query_task.cc
@@ -274,6 +274,24 @@ namespace
}
}
+ void visit(const MetadataSetKey<FSEntrySequence> & k)
+ {
+ if (k.type() == type)
+ {
+ ColourFormatter formatter;
+ if (task->want_raw())
+ {
+ task->output_left_column(k.raw_name() + ":", in);
+ task->output_right_column(k.pretty_print_flat(formatter));
+ }
+ else
+ {
+ task->output_left_column(k.human_name() + ":", in);
+ task->output_right_column(k.pretty_print_flat(formatter));
+ }
+ }
+ }
+
void visit(const MetadataSetKey<Set<std::string> > & k)
{
if (k.type() == type)
@@ -514,15 +532,13 @@ namespace
}
else
{
- task->output_left_column((k.title_key() ? k.title_key()->value() : k.human_name()) + ":", in);
+ task->output_left_column(k.human_name() + ":", in);
task->output_right_column("");
}
Displayer v(task, env, id, type, in + 4);
- for (MetadataSectionKey::MetadataConstIterator kk(k.begin_metadata()), kk_end(k.end_metadata()) ;
- kk != kk_end ; ++kk)
- if (*kk != k.title_key())
- (*kk)->accept(v);
+ std::for_each(indirect_iterator(k.begin_metadata()), indirect_iterator(k.end_metadata()),
+ accept_visitor(v));
}
}
diff --git a/src/output/mask_displayer.cc b/src/output/mask_displayer.cc
index 5d664e2..ea15114 100644
--- a/src/output/mask_displayer.cc
+++ b/src/output/mask_displayer.cc
@@ -71,29 +71,23 @@ namespace
void visit(const MetadataSectionKey & k)
{
- if (k.title_key())
- s << k.title_key()->value() << ": ";
s << "(";
bool need_comma(false);
for (MetadataSectionKey::MetadataConstIterator m(k.begin_metadata()), m_end(k.end_metadata()) ;
m != m_end ; ++m)
- if ((*m) != k.title_key())
- {
- if (need_comma)
- s << ", ";
- else
- s << " ";
-
- KeyPrettyPrinter p;
- (*m)->accept(p);
- s << p.s.str();
- need_comma = true;
- }
+ {
+ if (need_comma)
+ s << ", ";
+ else
+ s << " ";
+
+ KeyPrettyPrinter p;
+ (*m)->accept(p);
+ s << p.s.str();
+ need_comma = true;
+ }
s << " )";
-
- std::for_each(indirect_iterator(k.begin_metadata()),
- indirect_iterator(k.end_metadata()), accept_visitor(*this));
}
void visit(const MetadataTimeKey & k)
@@ -138,6 +132,12 @@ namespace
s << k.pretty_print_flat(formatter);
}
+ void visit(const MetadataSetKey<FSEntrySequence> & k)
+ {
+ ColourFormatter formatter;
+ s << k.pretty_print_flat(formatter);
+ }
+
void visit(const MetadataSetKey<PackageIDSequence> & k)
{
ColourFormatter formatter;