From b5280212886a3a31703600c12608c5a5a8be5555 Mon Sep 17 00:00:00 2001 From: Ciaran McCreesh Date: Sun, 4 Sep 2011 22:43:39 +0100 Subject: Refactor --- paludis/repositories/unpackaged/installed_id.cc | 65 ++++--------------------- 1 file changed, 9 insertions(+), 56 deletions(-) diff --git a/paludis/repositories/unpackaged/installed_id.cc b/paludis/repositories/unpackaged/installed_id.cc index 0d6a4bdfb..ddbc8cfa2 100644 --- a/paludis/repositories/unpackaged/installed_id.cc +++ b/paludis/repositories/unpackaged/installed_id.cc @@ -115,54 +115,6 @@ namespace } }; - class InstalledUnpackagedContentsKey : - public MetadataValueKey > - { - private: - const PackageID * const _id; - const NDBAM * const _db; - mutable Mutex _mutex; - mutable std::shared_ptr _v; - - public: - InstalledUnpackagedContentsKey(const PackageID * const i, const NDBAM * const d) : - _id(i), - _db(d) - { - } - - const std::shared_ptr parse_value() const - { - Lock l(_mutex); - if (_v) - return _v; - - using namespace std::placeholders; - _v = std::make_shared(); - _db->parse_contents(*_id, - std::bind(&Contents::add, _v.get(), std::placeholders::_1), - std::bind(&Contents::add, _v.get(), std::placeholders::_1), - std::bind(&Contents::add, _v.get(), std::placeholders::_1) - ); - return _v; - } - - virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)) - { - return "contents"; - } - - virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)) - { - return "Contents"; - } - - virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)) - { - return mkt_internal; - } - }; - class InstalledUnpackagedTimeKey : public MetadataTimeKey { @@ -398,7 +350,6 @@ namespace paludis std::shared_ptr > slot_key; std::shared_ptr fs_location_key; - std::shared_ptr contents_key; std::shared_ptr installed_time_key; std::shared_ptr from_repositories_key; std::shared_ptr description_key; @@ -408,7 +359,7 @@ namespace paludis Imp( const Environment * const e, - const PackageID * const id, + const PackageID * const, const QualifiedPackageName & q, const VersionSpec & v, const SlotName & s, @@ -427,10 +378,7 @@ namespace paludis behaviours_key(InstalledUnpackagedIDData::get_instance()->behaviours_key) { if ((l / "contents").stat().exists()) - { - contents_key = std::make_shared(id, d); installed_time_key = std::make_shared(l / "contents"); - } from_repositories_key = std::make_shared("source_repository", "Source repository", mkt_normal); @@ -462,8 +410,6 @@ InstalledUnpackagedID::InstalledUnpackagedID(const Environment * const e, const { add_metadata_key(_imp->fs_location_key); add_metadata_key(_imp->slot_key); - if (_imp->contents_key) - add_metadata_key(_imp->contents_key); if (_imp->installed_time_key) add_metadata_key(_imp->installed_time_key); if (_imp->from_repositories_key) @@ -601,7 +547,14 @@ InstalledUnpackagedID::long_description_key() const const std::shared_ptr InstalledUnpackagedID::contents() const { - return _imp->contents_key->parse_value(); + using namespace std::placeholders; + auto v(std::make_shared()); + _imp->ndbam->parse_contents(*this, + std::bind(&Contents::add, v.get(), std::placeholders::_1), + std::bind(&Contents::add, v.get(), std::placeholders::_1), + std::bind(&Contents::add, v.get(), std::placeholders::_1) + ); + return v; } const std::shared_ptr -- cgit v1.2.3