aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-09-04 21:34:18 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-09-04 21:34:18 +0100
commitc90d4dec7920a8d70949d8e2e71e704d2800d2c1 (patch)
treeb27391f20de3e33d4bfe074e6a5f9592d4fb3465
parent9a153e42f9703672b5a9de6d24d6a35697b05531 (diff)
downloadpaludis-c90d4dec7920a8d70949d8e2e71e704d2800d2c1.tar.gz
paludis-c90d4dec7920a8d70949d8e2e71e704d2800d2c1.tar.xz
PackageID::contents
-rw-r--r--paludis/package_id.hh10
-rw-r--r--paludis/repositories/accounts/accounts_id.cc6
-rw-r--r--paludis/repositories/accounts/accounts_id.hh2
-rw-r--r--paludis/repositories/accounts/installed_accounts_id.cc6
-rw-r--r--paludis/repositories/accounts/installed_accounts_id.hh2
-rw-r--r--paludis/repositories/e/e_installed_repository_id.cc6
-rw-r--r--paludis/repositories/e/e_installed_repository_id.hh2
-rw-r--r--paludis/repositories/e/ebuild_id.cc6
-rw-r--r--paludis/repositories/e/ebuild_id.hh2
-rw-r--r--paludis/repositories/fake/fake_package_id.cc7
-rw-r--r--paludis/repositories/fake/fake_package_id.hh2
-rw-r--r--paludis/repositories/gemcutter/gemcutter_id.cc7
-rw-r--r--paludis/repositories/gemcutter/gemcutter_id.hh2
-rw-r--r--paludis/repositories/repository/repository_id.cc7
-rw-r--r--paludis/repositories/repository/repository_id.hh2
-rw-r--r--paludis/repositories/unavailable/unavailable_package_id.cc7
-rw-r--r--paludis/repositories/unavailable/unavailable_package_id.hh2
-rw-r--r--paludis/repositories/unavailable/unavailable_repository_id.cc7
-rw-r--r--paludis/repositories/unavailable/unavailable_repository_id.hh2
-rw-r--r--paludis/repositories/unpackaged/installed_id.cc6
-rw-r--r--paludis/repositories/unpackaged/installed_id.hh2
-rw-r--r--paludis/repositories/unpackaged/unpackaged_id.cc6
-rw-r--r--paludis/repositories/unpackaged/unpackaged_id.hh2
-rw-r--r--paludis/repositories/unwritten/unwritten_id.cc7
-rw-r--r--paludis/repositories/unwritten/unwritten_id.hh2
-rw-r--r--python/package_id.cc8
-rw-r--r--ruby/package_id.cc30
-rw-r--r--ruby/package_id_TEST.rb5
28 files changed, 151 insertions, 4 deletions
diff --git a/paludis/package_id.hh b/paludis/package_id.hh
index d035f0a..d1a43d5 100644
--- a/paludis/package_id.hh
+++ b/paludis/package_id.hh
@@ -318,6 +318,16 @@ namespace paludis
*/
virtual void perform_action(Action &) const = 0;
+ /**
+ * The contents, if non-zero, contains the contents of a
+ * package. For installed packages, this means the files installed;
+ * for installable packages, this means the files that will be
+ * installed (if known, which it may be for some binary packages).
+ *
+ * \since 0.66
+ */
+ virtual const std::shared_ptr<const Contents> contents() const = 0;
+
///\}
///\name Masks
diff --git a/paludis/repositories/accounts/accounts_id.cc b/paludis/repositories/accounts/accounts_id.cc
index cd0db56..88a80af 100644
--- a/paludis/repositories/accounts/accounts_id.cc
+++ b/paludis/repositories/accounts/accounts_id.cc
@@ -553,3 +553,9 @@ AccountsID::perform_action(Action & action) const
output_manager->succeeded();
}
+const std::shared_ptr<const Contents>
+AccountsID::contents() const
+{
+ return make_null_shared_ptr();
+}
+
diff --git a/paludis/repositories/accounts/accounts_id.hh b/paludis/repositories/accounts/accounts_id.hh
index 32cfa69..a310b05 100644
--- a/paludis/repositories/accounts/accounts_id.hh
+++ b/paludis/repositories/accounts/accounts_id.hh
@@ -86,6 +86,8 @@ namespace paludis
virtual bool supports_action(const SupportsActionTestBase &) const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void perform_action(Action &) const;
+ virtual const std::shared_ptr<const Contents> contents() const;
+
///\}
virtual std::shared_ptr<const Set<std::string> > breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result));
diff --git a/paludis/repositories/accounts/installed_accounts_id.cc b/paludis/repositories/accounts/installed_accounts_id.cc
index 482eb11..50580c4 100644
--- a/paludis/repositories/accounts/installed_accounts_id.cc
+++ b/paludis/repositories/accounts/installed_accounts_id.cc
@@ -354,3 +354,9 @@ InstalledAccountsID::perform_action(Action & action) const
throw ActionFailedError("Unsupported action: " + action.simple_name());
}
+const std::shared_ptr<const Contents>
+InstalledAccountsID::contents() const
+{
+ return make_null_shared_ptr();
+}
+
diff --git a/paludis/repositories/accounts/installed_accounts_id.hh b/paludis/repositories/accounts/installed_accounts_id.hh
index 89f4ae5..5328c26 100644
--- a/paludis/repositories/accounts/installed_accounts_id.hh
+++ b/paludis/repositories/accounts/installed_accounts_id.hh
@@ -84,6 +84,8 @@ namespace paludis
virtual bool supports_action(const SupportsActionTestBase &) const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void perform_action(Action &) const PALUDIS_ATTRIBUTE((noreturn));
+ virtual const std::shared_ptr<const Contents> contents() const;
+
///\}
virtual std::shared_ptr<const Set<std::string> > breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result));
diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc
index 62fb0de..16bcea2 100644
--- a/paludis/repositories/e/e_installed_repository_id.cc
+++ b/paludis/repositories/e/e_installed_repository_id.cc
@@ -867,6 +867,12 @@ EInstalledRepositoryID::contents_key() const
return _imp->keys->contents;
}
+const std::shared_ptr<const Contents>
+EInstalledRepositoryID::contents() const
+{
+ return contents_key()->parse_value();
+}
+
const std::shared_ptr<const MetadataTimeKey>
EInstalledRepositoryID::installed_time_key() const
{
diff --git a/paludis/repositories/e/e_installed_repository_id.hh b/paludis/repositories/e/e_installed_repository_id.hh
index b4b091d..8fa93bc 100644
--- a/paludis/repositories/e/e_installed_repository_id.hh
+++ b/paludis/repositories/e/e_installed_repository_id.hh
@@ -112,6 +112,8 @@ namespace paludis
virtual void can_drop_in_memory_cache() const;
virtual void set_scm_revision(const std::string &) const PALUDIS_ATTRIBUTE((noreturn));
+
+ virtual const std::shared_ptr<const Contents> contents() const;
};
}
}
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index 135be59..0a34b57 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -1715,3 +1715,9 @@ EbuildID::set_scm_revision(const std::string & s) const
}
}
+const std::shared_ptr<const Contents>
+EbuildID::contents() const
+{
+ return make_null_shared_ptr();
+}
+
diff --git a/paludis/repositories/e/ebuild_id.hh b/paludis/repositories/e/ebuild_id.hh
index db04dab..db76271 100644
--- a/paludis/repositories/e/ebuild_id.hh
+++ b/paludis/repositories/e/ebuild_id.hh
@@ -170,6 +170,8 @@ namespace paludis
bool might_be_binary() const;
virtual void set_scm_revision(const std::string &) const;
+
+ virtual const std::shared_ptr<const Contents> contents() const;
};
}
}
diff --git a/paludis/repositories/fake/fake_package_id.cc b/paludis/repositories/fake/fake_package_id.cc
index 6191bf6..5fbc7aa 100644
--- a/paludis/repositories/fake/fake_package_id.cc
+++ b/paludis/repositories/fake/fake_package_id.cc
@@ -1191,6 +1191,12 @@ FakePackageID::behaviours_set()
return _imp->behaviours_set;
}
+const std::shared_ptr<const Contents>
+FakePackageID::contents() const
+{
+ return make_null_shared_ptr();
+}
+
namespace paludis
{
template class FakeMetadataSpecTreeKey<LicenseSpecTree>;
@@ -1203,3 +1209,4 @@ namespace paludis
template class FakeMetadataCollectionKey<KeywordNameSet>;
}
+
diff --git a/paludis/repositories/fake/fake_package_id.hh b/paludis/repositories/fake/fake_package_id.hh
index 3ba726f..59d5b9d 100644
--- a/paludis/repositories/fake/fake_package_id.hh
+++ b/paludis/repositories/fake/fake_package_id.hh
@@ -287,6 +287,8 @@ namespace paludis
virtual std::shared_ptr<const Set<std::string> > breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::shared_ptr<const Contents> contents() const;
+
};
}
diff --git a/paludis/repositories/gemcutter/gemcutter_id.cc b/paludis/repositories/gemcutter/gemcutter_id.cc
index eab00a5..ef426b0 100644
--- a/paludis/repositories/gemcutter/gemcutter_id.cc
+++ b/paludis/repositories/gemcutter/gemcutter_id.cc
@@ -413,7 +413,14 @@ GemcutterID::slot_key() const
return _imp->slot_key;
}
+const std::shared_ptr<const Contents>
+GemcutterID::contents() const
+{
+ return make_null_shared_ptr();
+}
+
namespace paludis
{
template class Pimp<GemcutterID>;
}
+
diff --git a/paludis/repositories/gemcutter/gemcutter_id.hh b/paludis/repositories/gemcutter/gemcutter_id.hh
index 4c5e7c6..495b787 100644
--- a/paludis/repositories/gemcutter/gemcutter_id.hh
+++ b/paludis/repositories/gemcutter/gemcutter_id.hh
@@ -98,6 +98,8 @@ namespace paludis
PALUDIS_ATTRIBUTE((warn_unused_result));
std::size_t extra_hash_value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::shared_ptr<const Contents> contents() const;
};
}
diff --git a/paludis/repositories/repository/repository_id.cc b/paludis/repositories/repository/repository_id.cc
index def3dab..2e27893 100644
--- a/paludis/repositories/repository/repository_id.cc
+++ b/paludis/repositories/repository/repository_id.cc
@@ -276,7 +276,14 @@ RepositoryID::slot_key() const
return make_null_shared_ptr();
}
+const std::shared_ptr<const Contents>
+RepositoryID::contents() const
+{
+ return make_null_shared_ptr();
+}
+
namespace paludis
{
template class Pimp<RepositoryID>;
}
+
diff --git a/paludis/repositories/repository/repository_id.hh b/paludis/repositories/repository/repository_id.hh
index f66a985..71f4393 100644
--- a/paludis/repositories/repository/repository_id.hh
+++ b/paludis/repositories/repository/repository_id.hh
@@ -96,6 +96,8 @@ namespace paludis
PALUDIS_ATTRIBUTE((warn_unused_result));
std::size_t extra_hash_value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::shared_ptr<const Contents> contents() const;
};
}
}
diff --git a/paludis/repositories/unavailable/unavailable_package_id.cc b/paludis/repositories/unavailable/unavailable_package_id.cc
index fec87c4..6552c90 100644
--- a/paludis/repositories/unavailable/unavailable_package_id.cc
+++ b/paludis/repositories/unavailable/unavailable_package_id.cc
@@ -300,7 +300,14 @@ UnavailablePackageID::slot_key() const
return _imp->slot_key;
}
+const std::shared_ptr<const Contents>
+UnavailablePackageID::contents() const
+{
+ return make_null_shared_ptr();
+}
+
namespace paludis
{
template class Pimp<UnavailablePackageID>;
}
+
diff --git a/paludis/repositories/unavailable/unavailable_package_id.hh b/paludis/repositories/unavailable/unavailable_package_id.hh
index 06cf4c9..c99c0ee 100644
--- a/paludis/repositories/unavailable/unavailable_package_id.hh
+++ b/paludis/repositories/unavailable/unavailable_package_id.hh
@@ -110,6 +110,8 @@ namespace paludis
PALUDIS_ATTRIBUTE((warn_unused_result));
std::size_t extra_hash_value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::shared_ptr<const Contents> contents() const;
};
}
}
diff --git a/paludis/repositories/unavailable/unavailable_repository_id.cc b/paludis/repositories/unavailable/unavailable_repository_id.cc
index 9e054ea..a3f0c2f 100644
--- a/paludis/repositories/unavailable/unavailable_repository_id.cc
+++ b/paludis/repositories/unavailable/unavailable_repository_id.cc
@@ -409,7 +409,14 @@ UnavailableRepositoryID::slot_key() const
return make_null_shared_ptr();
}
+const std::shared_ptr<const Contents>
+UnavailableRepositoryID::contents() const
+{
+ return make_null_shared_ptr();
+}
+
namespace paludis
{
template class Pimp<UnavailableRepositoryID>;
}
+
diff --git a/paludis/repositories/unavailable/unavailable_repository_id.hh b/paludis/repositories/unavailable/unavailable_repository_id.hh
index b958a14..7791d83 100644
--- a/paludis/repositories/unavailable/unavailable_repository_id.hh
+++ b/paludis/repositories/unavailable/unavailable_repository_id.hh
@@ -110,6 +110,8 @@ namespace paludis
PALUDIS_ATTRIBUTE((warn_unused_result));
std::size_t extra_hash_value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::shared_ptr<const Contents> contents() const;
};
}
}
diff --git a/paludis/repositories/unpackaged/installed_id.cc b/paludis/repositories/unpackaged/installed_id.cc
index 5b44d77..79ebe9a 100644
--- a/paludis/repositories/unpackaged/installed_id.cc
+++ b/paludis/repositories/unpackaged/installed_id.cc
@@ -604,6 +604,12 @@ InstalledUnpackagedID::contents_key() const
return _imp->contents_key;
}
+const std::shared_ptr<const Contents>
+InstalledUnpackagedID::contents() const
+{
+ return contents_key()->parse_value();
+}
+
const std::shared_ptr<const MetadataTimeKey>
InstalledUnpackagedID::installed_time_key() const
{
diff --git a/paludis/repositories/unpackaged/installed_id.hh b/paludis/repositories/unpackaged/installed_id.hh
index 8d26fc4..fbb36a1 100644
--- a/paludis/repositories/unpackaged/installed_id.hh
+++ b/paludis/repositories/unpackaged/installed_id.hh
@@ -86,6 +86,8 @@ namespace paludis
const bool replace,
const std::shared_ptr<const PackageID> & if_for_install_id,
const std::shared_ptr<OutputManager> & output_manager) const;
+
+ virtual const std::shared_ptr<const Contents> contents() const;
};
}
}
diff --git a/paludis/repositories/unpackaged/unpackaged_id.cc b/paludis/repositories/unpackaged/unpackaged_id.cc
index 9c72cf5..65ec5d2 100644
--- a/paludis/repositories/unpackaged/unpackaged_id.cc
+++ b/paludis/repositories/unpackaged/unpackaged_id.cc
@@ -511,3 +511,9 @@ UnpackagedID::choices_key() const
return _imp->choices_key;
}
+const std::shared_ptr<const Contents>
+UnpackagedID::contents() const
+{
+ return make_null_shared_ptr();
+}
+
diff --git a/paludis/repositories/unpackaged/unpackaged_id.hh b/paludis/repositories/unpackaged/unpackaged_id.hh
index 415bd7e..71e948e 100644
--- a/paludis/repositories/unpackaged/unpackaged_id.hh
+++ b/paludis/repositories/unpackaged/unpackaged_id.hh
@@ -83,6 +83,8 @@ namespace paludis
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual std::size_t extra_hash_value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::shared_ptr<const Contents> contents() const;
};
}
}
diff --git a/paludis/repositories/unwritten/unwritten_id.cc b/paludis/repositories/unwritten/unwritten_id.cc
index 068f552..83e22f5 100644
--- a/paludis/repositories/unwritten/unwritten_id.cc
+++ b/paludis/repositories/unwritten/unwritten_id.cc
@@ -300,7 +300,14 @@ UnwrittenID::choices_key() const
return _imp->choices_key;
}
+const std::shared_ptr<const Contents>
+UnwrittenID::contents() const
+{
+ return make_null_shared_ptr();
+}
+
namespace paludis
{
template class Pimp<UnwrittenID>;
}
+
diff --git a/paludis/repositories/unwritten/unwritten_id.hh b/paludis/repositories/unwritten/unwritten_id.hh
index 9855361..a4a4f92 100644
--- a/paludis/repositories/unwritten/unwritten_id.hh
+++ b/paludis/repositories/unwritten/unwritten_id.hh
@@ -122,6 +122,8 @@ namespace paludis
PALUDIS_ATTRIBUTE((warn_unused_result));
std::size_t extra_hash_value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::shared_ptr<const Contents> contents() const;
};
}
}
diff --git a/python/package_id.cc b/python/package_id.cc
index 88ac8f9..9f84efd 100644
--- a/python/package_id.cc
+++ b/python/package_id.cc
@@ -155,7 +155,6 @@ void expose_package_id()
"installed (if known, which it may be for some binary packages)."
)
-
.def("installed_time_key", &PackageID::installed_time_key,
"The installed_time_key, if not None, contains the time a package\n"
"was installed. It affects dependency resolution if DepList is\n"
@@ -187,6 +186,13 @@ void expose_package_id()
"PackageDepSpec by using parse_user_package_dep_spec."
)
+ .def("contents", &PackageID::contents,
+ "The contents, if not None, contains the contents of a\n"
+ "package. For installed packages, this means the files installed;\n"
+ "for installable packages, this means the files that will be\n"
+ "installed (if known, which it may be for some binary packages)."
+ )
+
.def("__eq__", &py_eq<PackageID>)
.def("__ne__", &py_ne<PackageID>)
diff --git a/ruby/package_id.cc b/ruby/package_id.cc
index d661866..10d9fa1 100644
--- a/ruby/package_id.cc
+++ b/ruby/package_id.cc
@@ -342,6 +342,35 @@ namespace
}
/*
+ * Document-method: contents
+ *
+ * call-seq:
+ * contents -> Contents
+ *
+ * Our Contents
+ */
+ VALUE
+ package_id_contents(VALUE self)
+ {
+ std::shared_ptr<const PackageID> * self_ptr;
+ Data_Get_Struct(self, std::shared_ptr<const PackageID>, self_ptr);
+ try
+ {
+ auto contents((*self_ptr)->contents());
+ if (! contents)
+ return Qnil;
+ else
+ return contents_to_value(contents);
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+
+ return Qnil;
+ }
+
+ /*
* Document-method: masked?
*
* call-seq:
@@ -558,6 +587,7 @@ namespace
rb_define_method(c_package_id, "behaviours_key", RUBY_FUNC_CAST((
&KeyValue<MetadataCollectionKey<Set<std::string> >, &PackageID::behaviours_key>::fetch)), 0);
rb_define_method(c_package_id, "uniquely_identifying_spec", RUBY_FUNC_CAST(&package_id_uniquely_identifying_spec), 0);
+ rb_define_method(c_package_id, "contents", RUBY_FUNC_CAST(&package_id_contents), 0);
/*
* Document-module: Paludis::PackageIDCanonicalForm
diff --git a/ruby/package_id_TEST.rb b/ruby/package_id_TEST.rb
index d287c24..4921baa 100644
--- a/ruby/package_id_TEST.rb
+++ b/ruby/package_id_TEST.rb
@@ -302,9 +302,8 @@ module Paludis
assert_nil pid_installed.long_description_key
end
- def test_contents_key
- assert_kind_of MetadataContentsKey, pid_installed.contents_key
- assert_kind_of Contents, pid_installed.contents_key.parse_value
+ def test_contents
+ assert_kind_of Contents, pid_installed.contents
end
def test_installed_time_key