He's not dead, he's resting
New Paludis Query Interface (Part II)
Environment::operator takes a
Selection instance. Currently available selections are:
selection::AllVersionsSorted, which is like the old
selection::AllVersionsUnsorted, which is like the old
qo_whatever(although fetching all versions is no longer necessary if you don’t need them).
selection::AllVersionsGroupedBySlot, which is like the old
qo_group_by_slot. This one is quite expensive.
selection::BestVersionOnly, which is like the old
qo_best_version_only, but cheaper.
selection::BestVersionInEachSlot, which is like
selection::RequireExactlyOne, which is like
selection::SomeArbitraryVersion, which is new.
All of the above take a
FilteredGenerator as their single parameter. A
FilteredGenerator isn’t something you create by hand, though — it’s the underlying type that you get by combining a
Generator with a
You’ll always need a
Generator. Your choices are:
generator::All. Matches everything, which is generally slow.
generator::Matches(PackageDepSpec). Anything matching the spec.
generator::Package(QualifiedPackageName). Anything with that name.
generator::Repository(RepositoryName). Anything in the named repository.
generator::Category(CategoryNamePart). Anything in the named category.
Generators can be combined to produce a new generator using
operator &. In this case, the set intersection of the two generators’ results is used.
Filters are optional. To allow you to pass a
Generator straight to a
Generator can automatically convert to a
FilteredGenerator can have filters added to it using
operator| with the new filter on the right. By way of the automatic conversion, a
Generator can be used on the left rather than a
Available filters are:
filter::All. Lets everything through. This is more useful for
PackageDatabase::fetch_unique_qualified_package_name, which takes a
Filterparameter. It’s also used internally to avoid having to special-case a generator with no filter.
filter::NotMasked. Doesn’t let masked packages through.
filter::InstalledAtRoot(FSEntry). Lets things that are installed at a given root through.
filter::SupportsAction<ActionClass>. Lets things through that support the given
Putting this together, we get these patterns:
env[SomeSelection(SomeGenerator())] env[SomeSelection(SomeGenerator() & AnotherGenerator())] env[SomeSelection(SomeGenerator() | SomeFilter())] env[SomeSelection(SomeGenerator() | SomeFilter() | AnotherFilter())] env[SomeSelection(SomeGenerator() & AnotherGenerator() | SomeFilter())] env[SomeSelection(SomeGenerator() & AnotherGenerator() | SomeFilter() | AnotherFilter())]
and so on.
In Part III we’ll see how the solving is done.