aboutsummaryrefslogtreecommitdiff
path: root/paludis
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-29 11:03:54 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-04 08:32:58 +0100
commit5574c81a3c60266d023d18dfc115803da8b12e6b (patch)
tree659da456cb9813045fd32067a3db11d7c7d7ce82 /paludis
parentb7f5d7dbfeff2e406ef24ca471657e1735a4db4f (diff)
downloadpaludis-5574c81a3c60266d023d18dfc115803da8b12e6b.tar.gz
paludis-5574c81a3c60266d023d18dfc115803da8b12e6b.tar.xz
category and package parts to requirements
Diffstat (limited to 'paludis')
-rw-r--r--paludis/dep_spec.cc12
-rw-r--r--paludis/dep_spec.hh14
-rw-r--r--paludis/dep_spec_data.hh19
-rw-r--r--paludis/generator.cc17
-rw-r--r--paludis/match_package.cc4
-rw-r--r--paludis/package_dep_spec_constraint-fwd.hh6
-rw-r--r--paludis/package_dep_spec_constraint.cc39
-rw-r--r--paludis/package_dep_spec_constraint.hh45
-rw-r--r--paludis/package_dep_spec_properties.cc4
-rw-r--r--paludis/partially_made_package_dep_spec.cc24
-rw-r--r--paludis/resolver/match_qpns.cc4
-rw-r--r--paludis/user_dep_spec_TEST.cc12
12 files changed, 150 insertions, 50 deletions
diff --git a/paludis/dep_spec.cc b/paludis/dep_spec.cc
index 8f29957be..dac1df32e 100644
--- a/paludis/dep_spec.cc
+++ b/paludis/dep_spec.cc
@@ -548,16 +548,16 @@ PackageDepSpec::package_name_constraint() const
return _imp->data->package_name_constraint();
}
-std::shared_ptr<const PackageNamePart>
-PackageDepSpec::package_name_part_ptr() const
+const std::shared_ptr<const PackageNamePartConstraint>
+PackageDepSpec::package_name_part_constraint() const
{
- return _imp->data->package_name_part_ptr();
+ return _imp->data->package_name_part_constraint();
}
-std::shared_ptr<const CategoryNamePart>
-PackageDepSpec::category_name_part_ptr() const
+const std::shared_ptr<const CategoryNamePartConstraint>
+PackageDepSpec::category_name_part_constraint() const
{
- return _imp->data->category_name_part_ptr();
+ return _imp->data->category_name_part_constraint();
}
std::shared_ptr<const VersionRequirements>
diff --git a/paludis/dep_spec.hh b/paludis/dep_spec.hh
index 5bf2b6822..881b82607 100644
--- a/paludis/dep_spec.hh
+++ b/paludis/dep_spec.hh
@@ -356,14 +356,20 @@ namespace paludis
const std::shared_ptr<const NameConstraint> package_name_constraint() const PALUDIS_ATTRIBUTE((warn_unused_result));
/**
- * Fetch the package name part, if wildcarded, or a zero pointer otherwise.
+ * Fetch the single PackageNamePartConstraint, if we have one, or
+ * a null pointer otherwise.
+ *
+ * \since 0.61
*/
- std::shared_ptr<const PackageNamePart> package_name_part_ptr() const;
+ const std::shared_ptr<const PackageNamePartConstraint> package_name_part_constraint() const;
/**
- * Fetch the category name part, if wildcarded, or a zero pointer otherwise.
+ * Fetch the single CategoryNamePartConstraint, if we have one, or
+ * a null pointer otherwise.
+ *
+ * \since 0.61
*/
- std::shared_ptr<const CategoryNamePart> category_name_part_ptr() const;
+ const std::shared_ptr<const CategoryNamePartConstraint> category_name_part_constraint() const;
/**
* Fetch the version requirements (may be a zero pointer).
diff --git a/paludis/dep_spec_data.hh b/paludis/dep_spec_data.hh
index 973434ff8..53c1c62d4 100644
--- a/paludis/dep_spec_data.hh
+++ b/paludis/dep_spec_data.hh
@@ -116,17 +116,26 @@ namespace paludis
*
* \since 0.61
*/
- virtual const std::shared_ptr<const NameConstraint> package_name_constraint() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ virtual const std::shared_ptr<const NameConstraint> package_name_constraint() const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
- * Fetch the package name part, if wildcarded, or a zero pointer otherwise.
+ * Fetch the single PackageNamePartConstraint, if we have one, or
+ * a null pointer otherwise.
+ *
+ * \since 0.61
*/
- virtual std::shared_ptr<const PackageNamePart> package_name_part_ptr() const = 0;
+ virtual const std::shared_ptr<const PackageNamePartConstraint> package_name_part_constraint() const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
- * Fetch the category name part, if wildcarded, or a zero pointer otherwise.
+ * Fetch the single CategoryNamePartConstraint, if we have one, or
+ * a null pointer otherwise.
+ *
+ * \since 0.61
*/
- virtual std::shared_ptr<const CategoryNamePart> category_name_part_ptr() const = 0;
+ virtual const std::shared_ptr<const CategoryNamePartConstraint> category_name_part_constraint() const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
* Fetch the version requirements (may be a zero pointer).
diff --git a/paludis/generator.cc b/paludis/generator.cc
index ce85afa5d..5602195e8 100644
--- a/paludis/generator.cc
+++ b/paludis/generator.cc
@@ -367,28 +367,27 @@ namespace
const std::shared_ptr<const RepositoryNameSet> & repos,
const RepositoryContentMayExcludes & x) const
{
- if (spec.category_name_part_ptr())
+ if (spec.category_name_part_constraint())
{
std::shared_ptr<CategoryNamePartSet> result(std::make_shared<CategoryNamePartSet>());
for (RepositoryNameSet::ConstIterator r(repos->begin()), r_end(repos->end()) ;
r != r_end ; ++r)
- if (env->fetch_repository(*r)->has_category_named(*spec.category_name_part_ptr(), x))
+ if (env->fetch_repository(*r)->has_category_named(spec.category_name_part_constraint()->name_part(), x))
{
- result->insert(*spec.category_name_part_ptr());
+ result->insert(spec.category_name_part_constraint()->name_part());
break;
}
return result;
}
- else if (spec.package_name_part_ptr())
+ else if (spec.package_name_part_constraint())
{
std::shared_ptr<CategoryNamePartSet> result(std::make_shared<CategoryNamePartSet>());
for (RepositoryNameSet::ConstIterator r(repos->begin()), r_end(repos->end()) ;
r != r_end ; ++r)
{
std::shared_ptr<const CategoryNamePartSet> cats(
- env->fetch_repository(*r)
- ->category_names_containing_package(*spec.package_name_part_ptr(), x));
+ env->fetch_repository(*r)->category_names_containing_package(spec.package_name_part_constraint()->name_part(), x));
std::copy(cats->begin(), cats->end(), result->inserter());
}
@@ -417,15 +416,15 @@ namespace
const std::shared_ptr<const CategoryNamePartSet> & cats,
const RepositoryContentMayExcludes & x) const
{
- if (spec.package_name_part_ptr())
+ if (spec.package_name_part_constraint())
{
std::shared_ptr<QualifiedPackageNameSet> result(std::make_shared<QualifiedPackageNameSet>());
for (RepositoryNameSet::ConstIterator r(repos->begin()), r_end(repos->end()) ;
r != r_end ; ++r)
for (CategoryNamePartSet::ConstIterator c(cats->begin()), c_end(cats->end()) ;
c != c_end ; ++c)
- if (env->fetch_repository(*r)->has_package_named(*c + *spec.package_name_part_ptr(), x))
- result->insert(*c + *spec.package_name_part_ptr());
+ if (env->fetch_repository(*r)->has_package_named(*c + spec.package_name_part_constraint()->name_part(), x))
+ result->insert(*c + spec.package_name_part_constraint()->name_part());
return result;
}
diff --git a/paludis/match_package.cc b/paludis/match_package.cc
index e50a17e3d..f9eb55eca 100644
--- a/paludis/match_package.cc
+++ b/paludis/match_package.cc
@@ -90,10 +90,10 @@ paludis::match_package_with_maybe_changes(
if (spec.package_name_constraint() && spec.package_name_constraint()->name() != id->name())
return false;
- if (spec.package_name_part_ptr() && *spec.package_name_part_ptr() != id->name().package())
+ if (spec.package_name_part_constraint() && spec.package_name_part_constraint()->name_part() != id->name().package())
return false;
- if (spec.category_name_part_ptr() && *spec.category_name_part_ptr() != id->name().category())
+ if (spec.category_name_part_constraint() && spec.category_name_part_constraint()->name_part() != id->name().category())
return false;
if (spec.version_requirements_ptr())
diff --git a/paludis/package_dep_spec_constraint-fwd.hh b/paludis/package_dep_spec_constraint-fwd.hh
index ebd25ccad..24284f300 100644
--- a/paludis/package_dep_spec_constraint-fwd.hh
+++ b/paludis/package_dep_spec_constraint-fwd.hh
@@ -28,6 +28,12 @@ namespace paludis
class NameConstraint;
typedef Pool<NameConstraint> NameConstraintPool;
+
+ class PackageNamePartConstraint;
+ typedef Pool<PackageNamePartConstraint> PackageNamePartConstraintPool;
+
+ class CategoryNamePartConstraint;
+ typedef Pool<CategoryNamePartConstraint> CategoryNamePartConstraintPool;
}
#endif
diff --git a/paludis/package_dep_spec_constraint.cc b/paludis/package_dep_spec_constraint.cc
index ea35fad10..7ffa90406 100644
--- a/paludis/package_dep_spec_constraint.cc
+++ b/paludis/package_dep_spec_constraint.cc
@@ -41,5 +41,42 @@ NameConstraint::name() const
template class Pool<NameConstraint>;
template class Singleton<Pool<NameConstraint> >;
-template const std::shared_ptr<const NameConstraint> Pool<NameConstraint>::create(const QualifiedPackageName &) const;
+template const std::shared_ptr<const NameConstraint> Pool<NameConstraint>::create(
+ const QualifiedPackageName &) const;
+
+CategoryNamePartConstraint::CategoryNamePartConstraint(const CategoryNamePart & n) :
+ _name_part(n)
+{
+}
+
+CategoryNamePartConstraint::~CategoryNamePartConstraint() = default;
+
+const CategoryNamePart
+CategoryNamePartConstraint::name_part() const
+{
+ return _name_part;
+}
+
+template class Pool<CategoryNamePartConstraint>;
+template class Singleton<Pool<CategoryNamePartConstraint> >;
+template const std::shared_ptr<const CategoryNamePartConstraint> Pool<CategoryNamePartConstraint>::create(
+ const CategoryNamePart &) const;
+
+PackageNamePartConstraint::PackageNamePartConstraint(const PackageNamePart & n) :
+ _name_part(n)
+{
+}
+
+PackageNamePartConstraint::~PackageNamePartConstraint() = default;
+
+const PackageNamePart
+PackageNamePartConstraint::name_part() const
+{
+ return _name_part;
+}
+
+template class Pool<PackageNamePartConstraint>;
+template class Singleton<Pool<PackageNamePartConstraint> >;
+template const std::shared_ptr<const PackageNamePartConstraint> Pool<PackageNamePartConstraint>::create(
+ const PackageNamePart &) const;
diff --git a/paludis/package_dep_spec_constraint.hh b/paludis/package_dep_spec_constraint.hh
index e9dbf16b9..34bf6440a 100644
--- a/paludis/package_dep_spec_constraint.hh
+++ b/paludis/package_dep_spec_constraint.hh
@@ -32,7 +32,10 @@ namespace paludis
{
class PALUDIS_VISIBLE PackageDepSpecConstraint :
public virtual DeclareAbstractAcceptMethods<PackageDepSpecConstraint, MakeTypeList<
- NameConstraint>::Type>
+ NameConstraint,
+ PackageNamePartConstraint,
+ CategoryNamePartConstraint
+ >::Type>
{
public:
virtual ~PackageDepSpecConstraint() = 0;
@@ -57,7 +60,47 @@ namespace paludis
const QualifiedPackageName name() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
+ class PALUDIS_VISIBLE CategoryNamePartConstraint :
+ public PackageDepSpecConstraint,
+ public ImplementAcceptMethods<PackageDepSpecConstraint, CategoryNamePartConstraint>
+ {
+ friend class Pool<CategoryNamePartConstraint>;
+
+ private:
+ CategoryNamePart _name_part;
+
+ CategoryNamePartConstraint(const CategoryNamePart &);
+
+ CategoryNamePartConstraint(const CategoryNamePartConstraint &) = delete;
+
+ public:
+ ~CategoryNamePartConstraint();
+
+ const CategoryNamePart name_part() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class PALUDIS_VISIBLE PackageNamePartConstraint :
+ public PackageDepSpecConstraint,
+ public ImplementAcceptMethods<PackageDepSpecConstraint, PackageNamePartConstraint>
+ {
+ friend class Pool<PackageNamePartConstraint>;
+
+ private:
+ PackageNamePart _name_part;
+
+ PackageNamePartConstraint(const PackageNamePart &);
+
+ PackageNamePartConstraint(const PackageNamePartConstraint &) = delete;
+
+ public:
+ ~PackageNamePartConstraint();
+
+ const PackageNamePart name_part() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
extern template class Pool<NameConstraint>;
+ extern template class Pool<PackageNamePartConstraint>;
+ extern template class Pool<CategoryNamePartConstraint>;
}
#endif
diff --git a/paludis/package_dep_spec_properties.cc b/paludis/package_dep_spec_properties.cc
index 68ee5c6b3..d964df855 100644
--- a/paludis/package_dep_spec_properties.cc
+++ b/paludis/package_dep_spec_properties.cc
@@ -42,14 +42,14 @@ paludis::package_dep_spec_has_properties(const PackageDepSpec & spec, const Pack
bool result(true);
result = result && check(bool(spec.additional_requirements_ptr()) && ! spec.additional_requirements_ptr()->empty(), properties.has_additional_requirements());
- result = result && check(bool(spec.category_name_part_ptr()), properties.has_category_name_part());
+ result = result && check(bool(spec.category_name_part_constraint()), properties.has_category_name_part());
result = result && check(bool(spec.from_repository_ptr()), properties.has_from_repository());
result = result && check(bool(spec.in_repository_ptr()), properties.has_in_repository());
result = result && check(bool(spec.installable_to_path_ptr()), properties.has_installable_to_path());
result = result && check(bool(spec.installable_to_repository_ptr()), properties.has_installable_to_repository());
result = result && check(bool(spec.installed_at_path_ptr()), properties.has_installed_at_path());
result = result && check(bool(spec.package_name_constraint()), properties.has_package());
- result = result && check(bool(spec.package_name_part_ptr()), properties.has_package_name_part());
+ result = result && check(bool(spec.package_name_part_constraint()), properties.has_package_name_part());
result = result && check(bool(spec.slot_requirement_ptr()), properties.has_slot_requirement());
result = result && check(spec.version_requirements_ptr() && ! spec.version_requirements_ptr()->empty(), properties.has_version_requirements());
diff --git a/paludis/partially_made_package_dep_spec.cc b/paludis/partially_made_package_dep_spec.cc
index bd000bd9c..98eca7ca9 100644
--- a/paludis/partially_made_package_dep_spec.cc
+++ b/paludis/partially_made_package_dep_spec.cc
@@ -49,8 +49,8 @@ namespace
PackageDepSpecData
{
std::shared_ptr<const NameConstraint> package;
- std::shared_ptr<const PackageNamePart> package_name_part;
- std::shared_ptr<const CategoryNamePart> category_name_part;
+ std::shared_ptr<const PackageNamePartConstraint> package_name_part;
+ std::shared_ptr<const CategoryNamePartConstraint> category_name_part;
std::shared_ptr<VersionRequirements> version_requirements;
VersionRequirementsMode version_requirements_mode_v;
std::shared_ptr<const SlotRequirement> slot;
@@ -72,8 +72,8 @@ namespace
PartiallyMadePackageDepSpecData(const PackageDepSpecData & other) :
PackageDepSpecData(other),
package(other.package_name_constraint()),
- package_name_part(other.package_name_part_ptr()),
- category_name_part(other.category_name_part_ptr()),
+ package_name_part(other.package_name_part_constraint()),
+ category_name_part(other.category_name_part_constraint()),
version_requirements(other.version_requirements_ptr() ? new VersionRequirements : 0),
version_requirements_mode_v(other.version_requirements_mode()),
slot(other.slot_requirement_ptr()),
@@ -135,15 +135,15 @@ namespace
s << package_name_constraint()->name();
else
{
- if (category_name_part_ptr())
- s << *category_name_part_ptr();
+ if (category_name_part_constraint())
+ s << category_name_part_constraint()->name_part();
else
s << "*";
s << "/";
- if (package_name_part_ptr())
- s << *package_name_part_ptr();
+ if (package_name_part_constraint())
+ s << package_name_part_constraint()->name_part();
else
s << "*";
}
@@ -283,12 +283,12 @@ namespace
return package;
}
- virtual std::shared_ptr<const PackageNamePart> package_name_part_ptr() const
+ virtual const std::shared_ptr<const PackageNamePartConstraint> package_name_part_constraint() const
{
return package_name_part;
}
- virtual std::shared_ptr<const CategoryNamePart> category_name_part_ptr() const
+ virtual const std::shared_ptr<const CategoryNamePartConstraint> category_name_part_constraint() const
{
return category_name_part;
}
@@ -489,7 +489,7 @@ PartiallyMadePackageDepSpec::clear_installable_to_path()
PartiallyMadePackageDepSpec &
PartiallyMadePackageDepSpec::package_name_part(const PackageNamePart & part)
{
- _imp->data->package_name_part = std::make_shared<PackageNamePart>(part);
+ _imp->data->package_name_part = PackageNamePartConstraintPool::get_instance()->create(part);
return *this;
}
@@ -503,7 +503,7 @@ PartiallyMadePackageDepSpec::clear_package_name_part()
PartiallyMadePackageDepSpec &
PartiallyMadePackageDepSpec::category_name_part(const CategoryNamePart & part)
{
- _imp->data->category_name_part = std::make_shared<CategoryNamePart>(part);
+ _imp->data->category_name_part = CategoryNamePartConstraintPool::get_instance()->create(part);
return *this;
}
diff --git a/paludis/resolver/match_qpns.cc b/paludis/resolver/match_qpns.cc
index 91a797347..366429cc5 100644
--- a/paludis/resolver/match_qpns.cc
+++ b/paludis/resolver/match_qpns.cc
@@ -58,9 +58,9 @@ paludis::resolver::match_qpns(
if (spec.package_name_constraint() && spec.package_name_constraint()->name() != package)
return false;
- if (spec.package_name_part_ptr() && *spec.package_name_part_ptr() != package.package())
+ if (spec.package_name_part_constraint() && spec.package_name_part_constraint()->name_part() != package.package())
return false;
- if (spec.category_name_part_ptr() && *spec.category_name_part_ptr() != package.category())
+ if (spec.category_name_part_constraint() && spec.category_name_part_constraint()->name_part() != package.category())
return false;
return true;
diff --git a/paludis/user_dep_spec_TEST.cc b/paludis/user_dep_spec_TEST.cc
index d4d05ddfb..7e325da8a 100644
--- a/paludis/user_dep_spec_TEST.cc
+++ b/paludis/user_dep_spec_TEST.cc
@@ -99,19 +99,19 @@ UserDepSpecTest::check_spec(
}
if (category_name_part.empty())
- EXPECT_TRUE(! spec.category_name_part_ptr());
+ EXPECT_TRUE(! spec.category_name_part_constraint());
else
{
- EXPECT_TRUE(bool(spec.category_name_part_ptr()));
- EXPECT_EQ(category_name_part, stringify(*spec.category_name_part_ptr()));
+ EXPECT_TRUE(bool(spec.category_name_part_constraint()));
+ EXPECT_EQ(category_name_part, stringify(spec.category_name_part_constraint()->name_part()));
}
if (package_name_part.empty())
- EXPECT_TRUE(! spec.package_name_part_ptr());
+ EXPECT_TRUE(! spec.package_name_part_constraint());
else
{
- EXPECT_TRUE(bool(spec.package_name_part_ptr()));
- EXPECT_EQ(package_name_part, stringify(*spec.package_name_part_ptr()));
+ EXPECT_TRUE(bool(spec.package_name_part_constraint()));
+ EXPECT_EQ(package_name_part, stringify(spec.package_name_part_constraint()->name_part()));
}
if (! version_requirement_mode.empty())