libzypp: zypp::PoolItemBest Class Reference

libzypp 17.38.14

zypp::PoolItemBest Class Reference

Find the best candidates e.g. More...

`#include <zypp/PoolItemBest.h>`

## Classes
struct | Impl
| PoolItemBest implementation. More...

## Public Types
using | Predicate = boost::function<bool (const PoolItem &, const PoolItem &)>
| Predicate returning `True` if lhs is a better choice.
using | size_type = Container::size_type
using | value_type = Container::value_type
using | iterator = MapKVIteratorTraits<Container>::Value_const_iterator
using | ident_iterator = MapKVIteratorTraits<Container>::Key_const_iterator

## Public Member Functions
| PoolItemBest (bool preferNotLocked_r=false)
| Default ctor.
| PoolItemBest (sat::Solvable slv_r, bool preferNotLocked_r=false)
| Ctor feeding a sat::Solvable.
| PoolItemBest (const PoolItem &pi_r, bool preferNotLocked_r=false)
| Ctor feeding a PoolItem.
template<class TIterator>
| PoolItemBest (TIterator begin_r, TIterator end_r, bool preferNotLocked_r=false)
| Ctor feeding a range of sat::Solvable or PoolItem.
void | add (sat::Solvable slv_r)
| Feed one sat::Solvable.
void | add (const PoolItem &pi_r)
| Feed one PoolItem.
template<class TIterator>
void | add (TIterator begin_r, TIterator end_r)
| Feed a range of sat::Solvable or PoolItem.
Iterate the collected PoolItems.
bool | empty () const
| Whether PoolItems were collected.
size_type | size () const
| Number of PoolItems collected.
iterator | begin () const
| Pointer to the first PoolItem.
iterator | end () const
| Pointer behind the last PoolItem.
PoolItem | find (IdString ident_r) const
| Return the collected PoolItem with sat::Solvable::ident ident_r.
PoolItem | find (sat::Solvable slv_r) const
PoolItem | find (const PoolItem &pi_r) const

## Static Public Attributes
static constexpr bool | preferNotLocked = true
| Indicator argument for ctor: consider locked packages less than not locked packages.

## Private Types
using | Container = std::unordered_map<IdString, PoolItem>

## Iterate the collected PoolItems ident strings.
shared_ptr< void > | _dont_use_this_use_pimpl
| Avoid need to include Impl definition when inlined ctors (due to tepmlate) are provided.
ident_iterator | identBegin () const
| Pointer to the first item.
ident_iterator | identEnd () const
| Pointer behind the last item.
void | _ctor_init (bool preferNotLocked_r)
void | _ctor_init ()
| bin.compat legacy
const Container & | container () const
RWCOW_pointer< Impl > & | pimpl ()
| Pointer to implementation.
const RWCOW_pointer< Impl > & | pimpl () const
| Pointer to implementation.

## Detailed Description

Find the best candidates e.g.

in a PoolQuery result.

The class basically maintains a `map<IdString,PoolItem>` and remembers for each `ident` (sat::Solvable::ident) the best PoolItem that was added.

The default Predicate to determine the best choice is the same that sorts the ui::Selectable list of available objects, thus follows the same rules the resolver will apply.

Ctor argument preferNotLocked causes locked packages to be considered less than not locked packages.

PoolQuery q;
q.addAttribute(sat::SolvAttr::name, "lib*");
q.setMatchGlob();
// get the best matches and tag them for installation:
PoolItemBest bestMatches( q.begin(), q.end() );
if ( ! bestMatches.empty() )
{
for_( it, bestMatches.begin(), bestMatches.end() )
{
ui::asSelectable()( *it )->setOnSystem( *it, ResStatus::USER );
}
}
for_
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition Easy.h:27
zypp::PoolItemBest::PoolItemBest
PoolItemBest(bool preferNotLocked_r=false)
Default ctor.
Definition PoolItemBest.h:81
zypp::PoolQuery
Meta-data query API.
Definition PoolQuery.h:91
zypp::PoolQuery::addAttribute
void addAttribute(const sat::SolvAttr &attr, const std::string &value="")
Filter by the value of the specified attr attribute.
Definition PoolQuery.cc:885
zypp::PoolQuery::end
const_iterator end() const
An iterator pointing to the end of the query result.
Definition PoolQuery.h:621
zypp::PoolQuery::begin
const_iterator begin() const
Query result accessers.
Definition PoolQuery.cc:1855
zypp::PoolQuery::setMatchGlob
void setMatchGlob()
Set to match globs.
Definition PoolQuery.cc:966
zypp::ResStatus::USER
@ USER
Definition ResStatus.h:112
zypp::sat::SolvAttr::name
static const SolvAttr name
Definition SolvAttr.h:52
zypp::ui::asSelectable
Solvable to Selectable transform functor.
Definition Selectable.h:587

Todo
  Support arbitrary Predicates.

Definition at line 63 of file PoolItemBest.h.

## Member Typedef Documentation

## ◆ Container

using zypp::PoolItemBest::Container = std::unordered_map<IdString, PoolItem>
| private

Definition at line 65 of file PoolItemBest.h.

## ◆ Predicate

using zypp::PoolItemBest::Predicate = boost::function<bool (const PoolItem &, const PoolItem &)>

Predicate returning `True` if lhs is a better choice.

Definition at line 68 of file PoolItemBest.h.

## ◆ size_type

using zypp::PoolItemBest::size_type = Container::size_type

Definition at line 70 of file PoolItemBest.h.

## ◆ value_type

using zypp::PoolItemBest::value_type = Container::value_type

Definition at line 71 of file PoolItemBest.h.

## ◆ iterator

using zypp::PoolItemBest::iterator = MapKVIteratorTraits<Container>::Value_const_iterator

Definition at line 72 of file PoolItemBest.h.

## ◆ ident_iterator

using zypp::PoolItemBest::ident_iterator = MapKVIteratorTraits<Container>::Key_const_iterator

Definition at line 73 of file PoolItemBest.h.

## Constructor & Destructor Documentation

## ◆ PoolItemBest() [1/4]

zypp::PoolItemBest::PoolItemBest | ( | bool | preferNotLocked_r = false | ) |
| inline

Default ctor.

Definition at line 81 of file PoolItemBest.h.

## ◆ PoolItemBest() [2/4]

zypp::PoolItemBest::PoolItemBest | ( | sat::Solvable | slv_r,
|  | bool | preferNotLocked_r = false )
| inline

Ctor feeding a sat::Solvable.

Definition at line 85 of file PoolItemBest.h.

## ◆ PoolItemBest() [3/4]

zypp::PoolItemBest::PoolItemBest | ( | const PoolItem & | pi_r,
|  | bool | preferNotLocked_r = false )
| inline

Ctor feeding a PoolItem.

Definition at line 89 of file PoolItemBest.h.

## ◆ PoolItemBest() [4/4]

template<class TIterator>

zypp::PoolItemBest::PoolItemBest | ( | TIterator | begin_r,
|  | TIterator | end_r,
|  | bool | preferNotLocked_r = false )
| inline

Ctor feeding a range of sat::Solvable or PoolItem.

Definition at line 94 of file PoolItemBest.h.

## Member Function Documentation

## ◆ add() [1/3]

void zypp::PoolItemBest::add | ( | sat::Solvable | slv_r | ) |
| inline

Feed one sat::Solvable.

Definition at line 99 of file PoolItemBest.h.

## ◆ add() [2/3]

void zypp::PoolItemBest::add | ( | const PoolItem & | pi_r | ) |

Feed one PoolItem.

Definition at line 61 of file PoolItemBest.cc.

## ◆ add() [3/3]

template<class TIterator>

void zypp::PoolItemBest::add | ( | TIterator | begin_r,
|  | TIterator | end_r )
| inline

Feed a range of sat::Solvable or PoolItem.

Definition at line 107 of file PoolItemBest.h.

## ◆ empty()

bool zypp::PoolItemBest::empty | ( |  | ) | const
| inline

Whether PoolItems were collected.

Definition at line 117 of file PoolItemBest.h.

## ◆ size()

size_type zypp::PoolItemBest::size | ( |  | ) | const
| inline

Number of PoolItems collected.

Definition at line 119 of file PoolItemBest.h.

## ◆ begin()

iterator zypp::PoolItemBest::begin | ( |  | ) | const
| inline

Pointer to the first PoolItem.

Definition at line 121 of file PoolItemBest.h.

## ◆ end()

iterator zypp::PoolItemBest::end | ( |  | ) | const
| inline

Pointer behind the last PoolItem.

Definition at line 123 of file PoolItemBest.h.

## ◆ find() [1/3]

PoolItem zypp::PoolItemBest::find | ( | IdString | ident_r | ) | const

Return the collected PoolItem with sat::Solvable::ident ident_r.

Definition at line 85 of file PoolItemBest.cc.

## ◆ find() [2/3]

PoolItem zypp::PoolItemBest::find | ( | sat::Solvable | slv_r | ) | const
| inline

Definition at line 128 of file PoolItemBest.h.

## ◆ find() [3/3]

PoolItem zypp::PoolItemBest::find | ( | const PoolItem & | pi_r | ) | const
| inline

Definition at line 130 of file PoolItemBest.h.

## ◆ identBegin()

ident_iterator zypp::PoolItemBest::identBegin | ( |  | ) | const
| inline

Pointer to the first item.

Definition at line 136 of file PoolItemBest.h.

## ◆ identEnd()

ident_iterator zypp::PoolItemBest::identEnd | ( |  | ) | const
| inline

Pointer behind the last item.

Definition at line 138 of file PoolItemBest.h.

## ◆ _ctor_init() [1/2]

void zypp::PoolItemBest::_ctor_init | ( | bool | preferNotLocked_r | ) |
| private

Definition at line 52 of file PoolItemBest.cc.

## ◆ _ctor_init() [2/2]

void zypp::PoolItemBest::_ctor_init | ( |  | ) |
| private

bin.compat legacy

Definition at line 55 of file PoolItemBest.cc.

## ◆ container()

const PoolItemBest::Container & zypp::PoolItemBest::container | ( |  | ) | const
| private

Definition at line 58 of file PoolItemBest.cc.

## ◆ pimpl() [1/2]

RWCOW_pointer< Impl > & zypp::PoolItemBest::pimpl | ( |  | ) |
| inlineprivate

Pointer to implementation.

Definition at line 149 of file PoolItemBest.h.

## ◆ pimpl() [2/2]

const RWCOW_pointer< Impl > & zypp::PoolItemBest::pimpl | ( |  | ) | const
| inlineprivate

Pointer to implementation.

Definition at line 151 of file PoolItemBest.h.

## Member Data Documentation

## ◆ preferNotLocked

bool zypp::PoolItemBest::preferNotLocked = true
| staticconstexpr

Indicator argument for ctor: consider locked packages less than not locked packages.

Definition at line 77 of file PoolItemBest.h.

## ◆ _dont_use_this_use_pimpl

shared_ptr<void> zypp::PoolItemBest::_dont_use_this_use_pimpl
| private

Avoid need to include Impl definition when inlined ctors (due to tepmlate) are provided.

Definition at line 153 of file PoolItemBest.h.

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

- zypp/PoolItemBest.h
- zypp/PoolItemBest.cc