aboutsummaryrefslogtreecommitdiff
path: root/paludis/use_requirements.cc
diff options
context:
space:
mode:
Diffstat (limited to 'paludis/use_requirements.cc')
-rw-r--r--paludis/use_requirements.cc116
1 files changed, 89 insertions, 27 deletions
diff --git a/paludis/use_requirements.cc b/paludis/use_requirements.cc
index 891e98c..fe36355 100644
--- a/paludis/use_requirements.cc
+++ b/paludis/use_requirements.cc
@@ -18,6 +18,7 @@
*/
#include <paludis/use_requirements.hh>
+#include <paludis/environment.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/tr1_memory.hh>
#include <paludis/util/wrapped_forward_iterator-impl.hh>
@@ -97,12 +98,17 @@ UseRequirements::empty() const
return _imp->reqs.empty();
}
+UseRequirement::UseRequirement(const UseFlagName & n) :
+ _name(n)
+{
+}
+
UseRequirement::~UseRequirement()
{
}
EnabledUseRequirement::EnabledUseRequirement(const UseFlagName & n) :
- _name(n)
+ UseRequirement(n)
{
}
@@ -110,14 +116,14 @@ EnabledUseRequirement::~EnabledUseRequirement()
{
}
-const UseFlagName
-EnabledUseRequirement::flag() const
+bool
+EnabledUseRequirement::satisfied_by(const Environment * const env, const PackageID & pkg) const
{
- return _name;
+ return env->query_use(flag(), pkg);
}
DisabledUseRequirement::DisabledUseRequirement(const UseFlagName & n) :
- _name(n)
+ UseRequirement(n)
{
}
@@ -125,53 +131,109 @@ DisabledUseRequirement::~DisabledUseRequirement()
{
}
-const UseFlagName
-DisabledUseRequirement::flag() const
+bool
+DisabledUseRequirement::satisfied_by(const Environment * const env, const PackageID & pkg) const
{
- return _name;
+ return ! env->query_use(flag(), pkg);
}
-EqualUseRequirement::EqualUseRequirement(const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
- _name(n),
+ConditionalUseRequirement::ConditionalUseRequirement(const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
+ UseRequirement(n),
_id(i)
{
}
-EqualUseRequirement::~EqualUseRequirement()
+ConditionalUseRequirement::~ConditionalUseRequirement()
{
}
-const UseFlagName
-EqualUseRequirement::flag() const
+IfMineThenUseRequirement::IfMineThenUseRequirement(const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
+ ConditionalUseRequirement(n, i)
{
- return _name;
}
-const tr1::shared_ptr<const PackageID>
-EqualUseRequirement::package_id() const
+IfMineThenUseRequirement::~IfMineThenUseRequirement()
{
- return _id;
}
-NotEqualUseRequirement::NotEqualUseRequirement(const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
- _name(n),
- _id(i)
+bool
+IfMineThenUseRequirement::satisfied_by(const Environment * const env, const PackageID & pkg) const
{
+ return ! env->query_use(flag(), *package_id()) || env->query_use(flag(), pkg);
}
-NotEqualUseRequirement::~NotEqualUseRequirement()
+IfNotMineThenUseRequirement::IfNotMineThenUseRequirement(const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
+ ConditionalUseRequirement(n, i)
+{
+}
+
+IfNotMineThenUseRequirement::~IfNotMineThenUseRequirement()
+{
+}
+
+bool
+IfNotMineThenUseRequirement::satisfied_by(const Environment * const env, const PackageID & pkg) const
{
+ return env->query_use(flag(), *package_id()) || env->query_use(flag(), pkg);
}
-const UseFlagName
-NotEqualUseRequirement::flag() const
+IfMineThenNotUseRequirement::IfMineThenNotUseRequirement(const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
+ ConditionalUseRequirement(n, i)
{
- return _name;
}
-const tr1::shared_ptr<const PackageID>
-NotEqualUseRequirement::package_id() const
+IfMineThenNotUseRequirement::~IfMineThenNotUseRequirement()
+{
+}
+
+bool
+IfMineThenNotUseRequirement::satisfied_by(const Environment * const env, const PackageID & pkg) const
+{
+ return ! env->query_use(flag(), *package_id()) || ! env->query_use(flag(), pkg);
+}
+
+IfNotMineThenNotUseRequirement::IfNotMineThenNotUseRequirement(const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
+ ConditionalUseRequirement(n, i)
+{
+}
+
+IfNotMineThenNotUseRequirement::~IfNotMineThenNotUseRequirement()
+{
+}
+
+bool
+IfNotMineThenNotUseRequirement::satisfied_by(const Environment * const env, const PackageID & pkg) const
+{
+ return env->query_use(flag(), *package_id()) || ! env->query_use(flag(), pkg);
+}
+
+EqualUseRequirement::EqualUseRequirement(const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
+ ConditionalUseRequirement(n, i)
+{
+}
+
+EqualUseRequirement::~EqualUseRequirement()
+{
+}
+
+bool
+EqualUseRequirement::satisfied_by(const Environment * const env, const PackageID & pkg) const
+{
+ return env->query_use(flag(), pkg) == env->query_use(flag(), *package_id());
+}
+
+NotEqualUseRequirement::NotEqualUseRequirement(const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
+ ConditionalUseRequirement(n, i)
+{
+}
+
+NotEqualUseRequirement::~NotEqualUseRequirement()
+{
+}
+
+bool
+NotEqualUseRequirement::satisfied_by(const Environment * const env, const PackageID & pkg) const
{
- return _id;
+ return env->query_use(flag(), pkg) != env->query_use(flag(), *package_id());
}