aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-16 22:14:48 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-16 22:14:48 +0000
commit1186146e44a2d7f50f61b466f3fa64e79dab4825 (patch)
treeac83d61844423cc47554ecaa5b9e5e1982e41c5d
parent3f2d61950fda0f253784ec1c3719e75c1e04d2d2 (diff)
downloadpaludis-1186146e44a2d7f50f61b466f3fa64e79dab4825.tar.gz
paludis-1186146e44a2d7f50f61b466f3fa64e79dab4825.tar.xz
Use a smart record for the constructor, allowing named parameters to be provided, rather than passing around huge parameter lists containing lots of things of the same type
-rw-r--r--paludis/portage_repository.cc76
-rw-r--r--paludis/portage_repository.hh41
-rw-r--r--paludis/vdb_repository.cc38
-rw-r--r--paludis/vdb_repository.hh30
4 files changed, 114 insertions, 71 deletions
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index 04cbe99..909770b 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -174,10 +174,7 @@ namespace paludis
mutable AllDepAtom::Pointer system_packages;
/// Constructor.
- Implementation(const Environment * const,
- const PackageDatabase * const d, const FSEntry & l, const FSEntry & p,
- const FSEntry & c, const FSEntry &, const FSEntry &, const std::string &,
- const std::string &, const FSEntry &);
+ Implementation(const PortageRepositoryParams &);
/// Destructor.
~Implementation();
@@ -196,21 +193,17 @@ namespace paludis
};
}
-Implementation<PortageRepository>::Implementation(const Environment * const env,
- const PackageDatabase * const d,
- const FSEntry & l, const FSEntry & p, const FSEntry & c,
- const FSEntry & e, const FSEntry & dd, const std::string & syn,
- const std::string & se, const FSEntry & r) :
- db(d),
- env(env),
- location(l),
- profile(p),
- cache(c),
- eclassdir(e),
- distdir(dd),
- sync(syn),
- sync_exclude(se),
- root(r),
+Implementation<PortageRepository>::Implementation(const PortageRepositoryParams & p) :
+ db(p.get<prpk_package_database>()),
+ env(p.get<prpk_environment>()),
+ location(p.get<prpk_location>()),
+ profile(p.get<prpk_profile>()),
+ cache(p.get<prpk_cache>()),
+ eclassdir(p.get<prpk_eclassdir>()),
+ distdir(p.get<prpk_distdir>()),
+ sync(p.get<prpk_sync>()),
+ sync_exclude(p.get<prpk_sync_exclude>()),
+ root(p.get<prpk_root>()),
has_category_names(false),
has_repo_mask(false),
has_virtuals(false),
@@ -387,27 +380,21 @@ Implementation<PortageRepository>::invalidate() const
system_packages = AllDepAtom::Pointer(0);
}
-PortageRepository::PortageRepository(
- const Environment * const e, const PackageDatabase * const d,
- const FSEntry & location, const FSEntry & profile,
- const FSEntry & cache, const FSEntry & eclassdir,
- const FSEntry & distdir, const std::string & sync,
- const std::string & sync_exclude, const FSEntry & root) :
- Repository(PortageRepository::fetch_repo_name(location)),
- PrivateImplementationPattern<PortageRepository>(new Implementation<PortageRepository>(e,
- d, location, profile, cache, eclassdir, distdir, sync, sync_exclude, root))
+PortageRepository::PortageRepository(const PortageRepositoryParams & p) :
+ Repository(PortageRepository::fetch_repo_name(p.get<prpk_location>())),
+ PrivateImplementationPattern<PortageRepository>(new Implementation<PortageRepository>(p))
{
- _info.insert(std::make_pair(std::string("location"), location));
- _info.insert(std::make_pair(std::string("profile"), profile));
- _info.insert(std::make_pair(std::string("cache"), cache));
- _info.insert(std::make_pair(std::string("eclassdir"), eclassdir));
- _info.insert(std::make_pair(std::string("distdir"), distdir));
+ _info.insert(std::make_pair(std::string("location"), _imp->location));
+ _info.insert(std::make_pair(std::string("profile"), _imp->profile));
+ _info.insert(std::make_pair(std::string("cache"), _imp->cache));
+ _info.insert(std::make_pair(std::string("eclassdir"), _imp->eclassdir));
+ _info.insert(std::make_pair(std::string("distdir"), _imp->distdir));
_info.insert(std::make_pair(std::string("format"), std::string("portage")));
- _info.insert(std::make_pair(std::string("root"), stringify(root)));
- if (! sync.empty())
- _info.insert(std::make_pair(std::string("sync"), sync));
- if (! sync_exclude.empty())
- _info.insert(std::make_pair(std::string("sync_exclude"), sync_exclude));
+ _info.insert(std::make_pair(std::string("root"), stringify(_imp->root)));
+ if (! _imp->sync.empty())
+ _info.insert(std::make_pair(std::string("sync"), _imp->sync));
+ if (! _imp->sync_exclude.empty())
+ _info.insert(std::make_pair(std::string("sync_exclude"), _imp->sync_exclude));
}
@@ -1004,8 +991,17 @@ PortageRepository::make_portage_repository(
if (m.end() == m.find("root") || ((root = m.find("root")->second)).empty())
root = "/";
- return CountedPtr<Repository>(new PortageRepository(env, db, location, profile, cache,
- eclassdir, distdir, sync, sync_exclude, root));
+ return CountedPtr<Repository>(new PortageRepository(PortageRepositoryParams::create((
+ param<prpk_environment>(env),
+ param<prpk_package_database>(db),
+ param<prpk_location>(location),
+ param<prpk_profile>(profile),
+ param<prpk_cache>(cache),
+ param<prpk_eclassdir>(eclassdir),
+ param<prpk_distdir>(distdir),
+ param<prpk_sync>(sync),
+ param<prpk_sync_exclude>(sync_exclude),
+ param<prpk_root>(root)))));
}
PortageRepositoryConfigurationError::PortageRepositoryConfigurationError(
diff --git a/paludis/portage_repository.hh b/paludis/portage_repository.hh
index e067d5d..b130f6d 100644
--- a/paludis/portage_repository.hh
+++ b/paludis/portage_repository.hh
@@ -24,6 +24,7 @@
#include <paludis/repository.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/smart_record.hh>
#include <string>
/** \file
@@ -34,6 +35,39 @@ namespace paludis
{
class PackageDatabase;
+ enum PortageRepositoryParamsKeys
+ {
+ prpk_environment,
+ prpk_package_database,
+ prpk_location,
+ prpk_profile,
+ prpk_cache,
+ prpk_distdir,
+ prpk_eclassdir,
+ prpk_sync,
+ prpk_sync_exclude,
+ prpk_root,
+ last_prpk
+ };
+
+ struct PortageRepositoryParamsTag :
+ SmartRecordTag<comparison_mode::NoComparisonTag, void>,
+ SmartRecordKeys<PortageRepositoryParamsKeys, last_prpk>,
+ SmartRecordKey<prpk_environment, const Environment *>,
+ SmartRecordKey<prpk_package_database, const PackageDatabase *>,
+ SmartRecordKey<prpk_location, const FSEntry>,
+ SmartRecordKey<prpk_profile, const FSEntry>,
+ SmartRecordKey<prpk_cache, const FSEntry>,
+ SmartRecordKey<prpk_distdir, const FSEntry>,
+ SmartRecordKey<prpk_eclassdir, const FSEntry>,
+ SmartRecordKey<prpk_sync, const FSEntry>,
+ SmartRecordKey<prpk_sync_exclude, const std::string>,
+ SmartRecordKey<prpk_root, const FSEntry>
+ {
+ };
+
+ typedef MakeSmartRecord<PortageRepositoryParamsTag>::Type PortageRepositoryParams;
+
/**
* A PortageRepository is a Repository that handles the layout used by
* Portage for the main Gentoo tree.
@@ -104,12 +138,7 @@ namespace paludis
/**
* Constructor.
*/
- PortageRepository(const Environment * const env,
- const PackageDatabase * const db,
- const FSEntry & location, const FSEntry & profile,
- const FSEntry & cache, const FSEntry & distdir,
- const FSEntry & eclassdir, const std::string & sync,
- const std::string & sync_exclude, const FSEntry & root);
+ PortageRepository(const PortageRepositoryParams &);
/**
* Virtual constructor.
diff --git a/paludis/vdb_repository.cc b/paludis/vdb_repository.cc
index e8d08a2..c86b46f 100644
--- a/paludis/vdb_repository.cc
+++ b/paludis/vdb_repository.cc
@@ -166,9 +166,7 @@ namespace paludis
mutable std::map<QualifiedPackageName, QualifiedPackageName> provide_map;
/// Constructor.
- Implementation(const Environment * const,
- const PackageDatabase * const d, const FSEntry & l,
- const FSEntry & r, const FSEntry &);
+ Implementation(const VDBRepositoryParams &);
/// Destructor.
~Implementation();
@@ -178,14 +176,12 @@ namespace paludis
};
}
-Implementation<VDBRepository>::Implementation(const Environment * const env,
- const PackageDatabase * const d,
- const FSEntry & l, const FSEntry & r, const FSEntry & w) :
- db(d),
- env(env),
- location(l),
- root(r),
- world_file(w),
+Implementation<VDBRepository>::Implementation(const VDBRepositoryParams & p) :
+ db(p.get<vdbrpk_package_database>()),
+ env(p.get<vdbrpk_environment>()),
+ location(p.get<vdbrpk_location>()),
+ root(p.get<vdbrpk_root>()),
+ world_file(p.get<vdbrpk_world>()),
entries_valid(false),
has_provide_map(false)
{
@@ -292,17 +288,14 @@ Implementation<VDBRepository>::load_entry(std::vector<VDBEntry>::iterator p) con
p->metadata->set(vmk_slot, slot);
}
-VDBRepository::VDBRepository(
- const Environment * const e, const PackageDatabase * const d,
- const FSEntry & location, const FSEntry & root, const FSEntry & world) :
+VDBRepository::VDBRepository(const VDBRepositoryParams & p) :
Repository(RepositoryName("installed")),
- PrivateImplementationPattern<VDBRepository>(new Implementation<VDBRepository>(e,
- d, location, root, world))
+ PrivateImplementationPattern<VDBRepository>(new Implementation<VDBRepository>(p))
{
- _info.insert(std::make_pair(std::string("location"), location));
- _info.insert(std::make_pair(std::string("root"), root));
+ _info.insert(std::make_pair(std::string("location"), _imp->location));
+ _info.insert(std::make_pair(std::string("root"), _imp->root));
_info.insert(std::make_pair(std::string("format"), std::string("vdb")));
- _info.insert(std::make_pair(std::string("world"), world));
+ _info.insert(std::make_pair(std::string("world"), _imp->world_file));
}
VDBRepository::~VDBRepository()
@@ -481,7 +474,12 @@ VDBRepository::make_vdb_repository(
if (m.end() == m.find("world") || ((world = m.find("world")->second)).empty())
world = location + "/world";
- return CountedPtr<Repository>(new VDBRepository(env, db, location, root, world));
+ return CountedPtr<Repository>(new VDBRepository(VDBRepositoryParams::create((
+ param<vdbrpk_environment>(env),
+ param<vdbrpk_package_database>(db),
+ param<vdbrpk_location>(location),
+ param<vdbrpk_root>(root),
+ param<vdbrpk_world>(world)))));
}
VDBRepositoryConfigurationError::VDBRepositoryConfigurationError(
diff --git a/paludis/vdb_repository.hh b/paludis/vdb_repository.hh
index 730b22c..33e0be3 100644
--- a/paludis/vdb_repository.hh
+++ b/paludis/vdb_repository.hh
@@ -23,9 +23,33 @@
#include <paludis/repository.hh>
#include <paludis/util/attributes.hh>
#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/smart_record.hh>
namespace paludis
{
+ enum VDBRepositoryParamsKeys
+ {
+ vdbrpk_environment,
+ vdbrpk_package_database,
+ vdbrpk_location,
+ vdbrpk_root,
+ vdbrpk_world,
+ last_vdbrpk
+ };
+
+ struct VDBRepositoryParamsTag :
+ SmartRecordTag<comparison_mode::NoComparisonTag, void>,
+ SmartRecordKeys<VDBRepositoryParamsKeys, last_vdbrpk>,
+ SmartRecordKey<vdbrpk_environment, const Environment *>,
+ SmartRecordKey<vdbrpk_package_database, const PackageDatabase *>,
+ SmartRecordKey<vdbrpk_location, const FSEntry>,
+ SmartRecordKey<vdbrpk_root, const FSEntry>,
+ SmartRecordKey<vdbrpk_world, const FSEntry>
+ {
+ };
+
+ typedef MakeSmartRecord<VDBRepositoryParamsTag>::Type VDBRepositoryParams;
+
class VDBRepository :
public Repository,
public PrivateImplementationPattern<VDBRepository>
@@ -83,11 +107,7 @@ namespace paludis
/**
* Constructor.
*/
- VDBRepository(const Environment * const env,
- const PackageDatabase * const db,
- const FSEntry & location,
- const FSEntry & root,
- const FSEntry & world);
+ VDBRepository(const VDBRepositoryParams &);
/**
* Virtual constructor.