libzypp 17.38.6
zyppng::sat::SolvableSpec Class Reference

A pure data container describing a set of solvables by ident and/or provides. More...

#include <zypp/ng/sat/solvablespec.h>

Public Member Functions

 SolvableSpec ()=default
 ~SolvableSpec ()=default
 SolvableSpec (const SolvableSpec &)=default
 SolvableSpec (SolvableSpec &&)=default
SolvableSpecoperator= (const SolvableSpec &)=default
SolvableSpecoperator= (SolvableSpec &&)=default
bool empty () const
 Whether the spec has no idents and no provides tokens.
void clear ()
 Reset to empty state.
Ident-based matching

A solvable matches by ident when its ident() IdString is in this set.

void addIdent (IdString ident_r)
 Add ident_r to the ident set.
const IdStringSetidents () const
bool containsIdent (const IdString &ident_r) const
 Whether ident_r has been added to the spec (for introspection/tests).
Provides-based matching

A solvable matches by provides when its provides list contains a capability that matches one of these tokens.

Callers use pool_whatprovides() to expand these tokens into a solvable set.

void addProvides (Capability cap_r)
 Add cap_r to the provides set.
const CapabilitySetprovides () const
bool containsProvides (const Capability &cap_r) const
 Whether cap_r has been added to the spec (for introspection/tests).

Text-format parser

Each entry is either:

Empty strings and strings beginning with '#' are silently ignored.

IdStringSet _idents
CapabilitySet _provides
void parse (std::string_view spec_r)
 Parse and add a single spec entry.
void parseFrom (const zypp::InputStream &istr_r)
 Parse and add specs from istr_r (one per line; #-comments and empty lines are skipped automatically).
template<class TIterator>
void parseFrom (TIterator begin, TIterator end)
 Parse and add specs from an iterator range of string-like values.
void splitParseFrom (std::string_view multispec_r)
 Split multispec_r on ',', ' ', '\t' and parse each token.
bool contains (Pool &pool_r, const Solvable &solv_r) const
 Test whether a single Solvable matches this spec.

Detailed Description

A pure data container describing a set of solvables by ident and/or provides.

Design
This is the NG reimplementation of the legacy zypp::sat::SolvableSpec. It is intentionally a pure data container: it stores sets of IdString idents and Capability provides tokens, but it holds no pool reference, no cache, and no lazy-evaluation state.

Evaluation (i.e., resolving which concrete Solvable objects match) is done externally by callers who supply an explicit Pool& reference. This makes SolvableSpec safe to copy, store, and pass across component boundaries without pool-lifetime concerns.

Contrast with legacy
The legacy zypp::sat::SolvableSpec stores a lazy shared_ptr<WhatProvides> cache and calls setDirty() to invalidate it. That design couples the spec to a specific pool instance. Here the spec is stateless; the PackagePolicyComponent owns the cache and rebuilds it in prepare().
Note
This type does not inherit PoolMember. It must never call pool() or touch any global pool state.

Definition at line 54 of file solvablespec.h.

Constructor & Destructor Documentation

◆ SolvableSpec() [1/3]

zyppng::sat::SolvableSpec::SolvableSpec ( )
default

◆ ~SolvableSpec()

zyppng::sat::SolvableSpec::~SolvableSpec ( )
default

◆ SolvableSpec() [2/3]

zyppng::sat::SolvableSpec::SolvableSpec ( const SolvableSpec & )
default

◆ SolvableSpec() [3/3]

zyppng::sat::SolvableSpec::SolvableSpec ( SolvableSpec && )
default

Member Function Documentation

◆ operator=() [1/2]

SolvableSpec & zyppng::sat::SolvableSpec::operator= ( const SolvableSpec & )
default

◆ operator=() [2/2]

SolvableSpec & zyppng::sat::SolvableSpec::operator= ( SolvableSpec && )
default

◆ empty()

bool zyppng::sat::SolvableSpec::empty ( ) const
inline

Whether the spec has no idents and no provides tokens.

Definition at line 66 of file solvablespec.h.

◆ clear()

void zyppng::sat::SolvableSpec::clear ( )
inline

Reset to empty state.

Definition at line 70 of file solvablespec.h.

◆ addIdent()

void zyppng::sat::SolvableSpec::addIdent ( IdString ident_r)
inline

Add ident_r to the ident set.

No-op if ident_r is empty.

Definition at line 79 of file solvablespec.h.

◆ idents()

const IdStringSet & zyppng::sat::SolvableSpec::idents ( ) const
inline

Definition at line 82 of file solvablespec.h.

◆ containsIdent()

bool zyppng::sat::SolvableSpec::containsIdent ( const IdString & ident_r) const
inline

Whether ident_r has been added to the spec (for introspection/tests).

Definition at line 86 of file solvablespec.h.

◆ addProvides()

void zyppng::sat::SolvableSpec::addProvides ( Capability cap_r)
inline

Add cap_r to the provides set.

No-op if cap_r is empty.

Definition at line 98 of file solvablespec.h.

◆ provides()

const CapabilitySet & zyppng::sat::SolvableSpec::provides ( ) const
inline

Definition at line 101 of file solvablespec.h.

◆ containsProvides()

bool zyppng::sat::SolvableSpec::containsProvides ( const Capability & cap_r) const
inline

Whether cap_r has been added to the spec (for introspection/tests).

Definition at line 105 of file solvablespec.h.

◆ parse()

void SolvableSpec::parse ( std::string_view spec_r)

Parse and add a single spec entry.

Definition at line 52 of file solvablespec.cc.

◆ parseFrom() [1/2]

void SolvableSpec::parseFrom ( const zypp::InputStream & istr_r)

Parse and add specs from istr_r (one per line; #-comments and empty lines are skipped automatically).

Definition at line 63 of file solvablespec.cc.

◆ parseFrom() [2/2]

template<class TIterator>
void zyppng::sat::SolvableSpec::parseFrom ( TIterator begin,
TIterator end )
inline

Parse and add specs from an iterator range of string-like values.

Definition at line 127 of file solvablespec.h.

◆ splitParseFrom()

void SolvableSpec::splitParseFrom ( std::string_view multispec_r)

Split multispec_r on ',', ' ', '\t' and parse each token.

Definition at line 72 of file solvablespec.cc.

◆ contains()

bool SolvableSpec::contains ( Pool & pool_r,
const Solvable & solv_r ) const

Test whether a single Solvable matches this spec.

A solvable matches if its ident is in idents(), or if it provides at least one of the capabilities in provides().

Parameters
pool_rThe Pool owning solv_r (used to expand provides tokens via whatprovides).
solv_rThe solvable to test.

Definition at line 25 of file solvablespec.cc.

Member Data Documentation

◆ _idents

IdStringSet zyppng::sat::SolvableSpec::_idents
private

Definition at line 147 of file solvablespec.h.

◆ _provides

CapabilitySet zyppng::sat::SolvableSpec::_provides
private

Definition at line 148 of file solvablespec.h.


The documentation for this class was generated from the following files: