aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-11-26 21:17:18 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-11-27 21:55:32 +0000
commitc310a907025aab85593fee774626c6b30135b5fa (patch)
treea9167090af92cd33382625f177372b764e08dae8
parent8c38f206f44258bc6d0e30829a869fc474bdcb8f (diff)
downloadpaludis-c310a907025aab85593fee774626c6b30135b5fa.tar.gz
paludis-c310a907025aab85593fee774626c6b30135b5fa.tar.xz
Slightly nicer virtuals interface
-rw-r--r--paludis/repositories/e/e_repository.cc7
-rw-r--r--paludis/repositories/e/profile.cc6
-rw-r--r--paludis/repositories/e/profile.hh10
-rw-r--r--paludis/repositories/e/traditional_profile.cc39
-rw-r--r--paludis/repositories/e/traditional_profile.hh5
5 files changed, 27 insertions, 40 deletions
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index ac1d314..731c4f7 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -77,6 +77,7 @@
#include <paludis/util/log.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/make_shared_copy.hh>
#include <paludis/util/map.hh>
#include <paludis/util/mutex.hh>
#include <paludis/util/options.hh>
@@ -891,10 +892,10 @@ ERepository::virtual_packages() const
std::tr1::shared_ptr<VirtualsSequence> result(new VirtualsSequence);
- for (erepository::Profile::VirtualsConstIterator i(_imp->profile_ptr->begin_virtuals()),
- i_end(_imp->profile_ptr->end_virtuals()) ; i != i_end ; ++i)
+ for (Map<QualifiedPackageName, PackageDepSpec>::ConstIterator i(_imp->profile_ptr->virtuals()->begin()),
+ i_end(_imp->profile_ptr->virtuals()->end()) ; i != i_end ; ++i)
result->push_back(make_named_values<RepositoryVirtualsEntry>(
- value_for<n::provided_by_spec>(i->second),
+ value_for<n::provided_by_spec>(make_shared_copy(i->second)),
value_for<n::virtual_name>(i->first)
));
diff --git a/paludis/repositories/e/profile.cc b/paludis/repositories/e/profile.cc
index dfde049..0971d43 100644
--- a/paludis/repositories/e/profile.cc
+++ b/paludis/repositories/e/profile.cc
@@ -18,6 +18,10 @@
*/
#include <paludis/repositories/e/profile.hh>
+#include <paludis/util/wrapped_forward_iterator-impl.hh>
+#include <paludis/util/map-impl.hh>
+#include <paludis/name.hh>
+#include <paludis/dep_spec.hh>
using namespace paludis;
using namespace paludis::erepository;
@@ -26,3 +30,5 @@ Profile::~Profile()
{
}
+template class Map<QualifiedPackageName, PackageDepSpec>;
+
diff --git a/paludis/repositories/e/profile.hh b/paludis/repositories/e/profile.hh
index 465266c..024f2f9 100644
--- a/paludis/repositories/e/profile.hh
+++ b/paludis/repositories/e/profile.hh
@@ -31,6 +31,7 @@
#include <paludis/util/fs_entry-fwd.hh>
#include <paludis/util/tribool.hh>
#include <paludis/util/wrapped_forward_iterator-fwd.hh>
+#include <paludis/util/map-fwd.hh>
#include <paludis/repositories/e/e_repository_id.hh>
#include <string>
@@ -89,13 +90,8 @@ namespace paludis
virtual const std::tr1::shared_ptr<const SetSpecTree> system_packages() const = 0;
- struct VirtualsConstIteratorTag;
- typedef WrappedForwardIterator<VirtualsConstIteratorTag,
- const std::pair<const QualifiedPackageName, std::tr1::shared_ptr<const PackageDepSpec> > > VirtualsConstIterator;
-
- virtual VirtualsConstIterator begin_virtuals() const = 0;
- virtual VirtualsConstIterator end_virtuals() const = 0;
- virtual VirtualsConstIterator find_virtual(const QualifiedPackageName &) const = 0;
+ virtual const std::tr1::shared_ptr<const Map<QualifiedPackageName, PackageDepSpec> >
+ virtuals() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
};
}
}
diff --git a/paludis/repositories/e/traditional_profile.cc b/paludis/repositories/e/traditional_profile.cc
index 48a79b1..4ae36bb 100644
--- a/paludis/repositories/e/traditional_profile.cc
+++ b/paludis/repositories/e/traditional_profile.cc
@@ -29,7 +29,7 @@
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/save.hh>
#include <paludis/util/system.hh>
-#include <paludis/util/wrapped_forward_iterator-impl.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/wrapped_output_iterator.hh>
#include <paludis/util/join.hh>
#include <paludis/util/sequence.hh>
@@ -41,6 +41,7 @@
#include <paludis/util/hashes.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/mutex.hh>
+#include <paludis/util/map.hh>
#include <paludis/choice.hh>
#include <paludis/dep_tag.hh>
#include <paludis/environment.hh>
@@ -62,15 +63,11 @@
using namespace paludis;
using namespace paludis::erepository;
-template class WrappedForwardIterator<TraditionalProfile::VirtualsConstIteratorTag,
- const std::pair<const QualifiedPackageName, std::tr1::shared_ptr<const PackageDepSpec> > >;
-
typedef std::tr1::unordered_map<std::string, std::tr1::shared_ptr<Set<UnprefixedChoiceName> > > KnownMap;
namespace
{
typedef std::tr1::unordered_map<std::string, std::string, Hash<std::string> > EnvironmentVariablesMap;
- typedef std::tr1::unordered_map<QualifiedPackageName, std::tr1::shared_ptr<const PackageDepSpec>, Hash<QualifiedPackageName> > VirtualsMap;
typedef std::tr1::unordered_map<QualifiedPackageName,
std::list<std::pair<std::tr1::shared_ptr<const PackageDepSpec>, std::tr1::shared_ptr<const RepositoryMaskInfo> > >,
Hash<QualifiedPackageName> > PackageMaskMap;
@@ -156,7 +153,7 @@ namespace paludis
///\name Virtuals
///\{
- VirtualsMap virtuals;
+ std::tr1::shared_ptr<Map<QualifiedPackageName, PackageDepSpec> > virtuals;
///\}
@@ -197,6 +194,7 @@ namespace paludis
repository(p),
system_packages(new SetSpecTree(make_shared_ptr(new AllDepSpec))),
system_tag(new GeneralSetDepTag(SetName("system"), stringify(name))),
+ virtuals(new Map<QualifiedPackageName, PackageDepSpec>),
use_expand(new Set<std::string>),
use_expand_hidden(new Set<std::string>),
use_expand_unprefixed(new Set<std::string>),
@@ -607,12 +605,11 @@ Implementation<TraditionalProfile>::make_vars_from_file_vars()
continue;
QualifiedPackageName v(tokens[0]);
- virtuals.erase(v);
- virtuals.insert(std::make_pair(v, std::tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(
- parse_elike_package_dep_spec(tokens[1],
- line->first->supported()->package_dep_spec_parse_options(),
- line->first->supported()->version_spec_options(),
- std::tr1::shared_ptr<const PackageID>())))));
+ virtuals->erase(v);
+ virtuals->insert(v, parse_elike_package_dep_spec(tokens[1],
+ line->first->supported()->package_dep_spec_parse_options(),
+ line->first->supported()->version_spec_options(),
+ std::tr1::shared_ptr<const PackageID>()));
}
}
catch (const InternalError &)
@@ -1023,22 +1020,10 @@ TraditionalProfile::system_packages() const
return _imp->system_packages;
}
-TraditionalProfile::VirtualsConstIterator
-TraditionalProfile::begin_virtuals() const
-{
- return VirtualsConstIterator(_imp->virtuals.begin());
-}
-
-TraditionalProfile::VirtualsConstIterator
-TraditionalProfile::find_virtual(const QualifiedPackageName & n) const
-{
- return VirtualsConstIterator(_imp->virtuals.find(n));
-}
-
-TraditionalProfile::VirtualsConstIterator
-TraditionalProfile::end_virtuals() const
+const std::tr1::shared_ptr<const Map<QualifiedPackageName, PackageDepSpec> >
+TraditionalProfile::virtuals() const
{
- return VirtualsConstIterator(_imp->virtuals.end());
+ return _imp->virtuals;
}
const std::tr1::shared_ptr<const RepositoryMaskInfo>
diff --git a/paludis/repositories/e/traditional_profile.hh b/paludis/repositories/e/traditional_profile.hh
index 67e3a21..db2cab0 100644
--- a/paludis/repositories/e/traditional_profile.hh
+++ b/paludis/repositories/e/traditional_profile.hh
@@ -88,9 +88,8 @@ namespace paludis
virtual const std::tr1::shared_ptr<const SetSpecTree> system_packages() const;
- virtual VirtualsConstIterator begin_virtuals() const;
- virtual VirtualsConstIterator end_virtuals() const;
- virtual VirtualsConstIterator find_virtual(const QualifiedPackageName &) const;
+ virtual const std::tr1::shared_ptr<const Map<QualifiedPackageName, PackageDepSpec> >
+ virtuals() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
}