libzypp  17.3.0
zypp::PoolItemBest Class Reference

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

#include <PoolItemBest.h>

Classes

struct  Impl
 PoolItemBest implementation. More...
 

Public Types

typedef boost::function< bool(const PoolItem &lhs, const PoolItem &rhs)> Predicate
 Predicate returning True if lhs is a better choice. More...
 
typedef Container::size_type size_type
 
typedef Container::value_type value_type
 
typedef MapKVIteratorTraits< Container >::Value_const_iterator iterator
 
typedef MapKVIteratorTraits< Container >::Key_const_iterator ident_iterator
 

Public Member Functions

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

Private Types

typedef std::unordered_map< IdString, PoolItemContainer
 

Private Member Functions

void _ctor_init ()
 
const Containercontainer () const
 
RWCOW_pointer< Impl > & pimpl ()
 Pointer to implementation. More...
 
const RWCOW_pointer< Impl > & pimpl () const
 Pointer to implementation. More...
 

Private Attributes

shared_ptr< void > _dont_use_this_use_pimpl
 Avoid need to include Impl definition when inlined ctors (due to tepmlate) are provided. More...
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &str, const PoolItemBest &obj)
 

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.

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 );
}
}
Todo:
Support arbitrary Predicates.

Definition at line 60 of file PoolItemBest.h.

Member Typedef Documentation

◆ Container

typedef std::unordered_map<IdString,PoolItem> zypp::PoolItemBest::Container
private

Definition at line 62 of file PoolItemBest.h.

◆ Predicate

typedef boost::function<bool ( const PoolItem & lhs, const PoolItem & rhs )> zypp::PoolItemBest::Predicate

Predicate returning True if lhs is a better choice.

Definition at line 65 of file PoolItemBest.h.

◆ size_type

typedef Container::size_type zypp::PoolItemBest::size_type

Definition at line 67 of file PoolItemBest.h.

◆ value_type

typedef Container::value_type zypp::PoolItemBest::value_type

Definition at line 68 of file PoolItemBest.h.

◆ iterator

Definition at line 69 of file PoolItemBest.h.

◆ ident_iterator

Definition at line 70 of file PoolItemBest.h.

Constructor & Destructor Documentation

◆ PoolItemBest() [1/4]

zypp::PoolItemBest::PoolItemBest ( )
inline

Default ctor.

Definition at line 74 of file PoolItemBest.h.

◆ PoolItemBest() [2/4]

zypp::PoolItemBest::PoolItemBest ( sat::Solvable  slv_r)
inline

Ctor feeding a sat::Solvable.

Definition at line 78 of file PoolItemBest.h.

◆ PoolItemBest() [3/4]

zypp::PoolItemBest::PoolItemBest ( const PoolItem pi_r)
inline

Ctor feeding a PoolItem.

Definition at line 82 of file PoolItemBest.h.

◆ PoolItemBest() [4/4]

template<class TIterator >
zypp::PoolItemBest::PoolItemBest ( TIterator  begin_r,
TIterator  end_r 
)
inline

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

Definition at line 87 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 92 of file PoolItemBest.h.

◆ add() [2/3]

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

Feed one PoolItem.

Definition at line 53 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 100 of file PoolItemBest.h.

◆ empty()

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

Whether PoolItems were collected.

Definition at line 110 of file PoolItemBest.h.

◆ size()

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

Number of PoolItems collected.

Definition at line 112 of file PoolItemBest.h.

◆ begin()

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

Pointer to the first PoolItem.

Definition at line 114 of file PoolItemBest.h.

◆ end()

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

Pointer behind the last PoolItem.

Definition at line 116 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 61 of file PoolItemBest.cc.

◆ find() [2/3]

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 121 of file PoolItemBest.h.

◆ find() [3/3]

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 123 of file PoolItemBest.h.

◆ identBegin()

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

Pointer to the first item.

Definition at line 129 of file PoolItemBest.h.

◆ identEnd()

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

Pointer behind the last item.

Definition at line 131 of file PoolItemBest.h.

◆ _ctor_init()

void zypp::PoolItemBest::_ctor_init ( )
private

Definition at line 47 of file PoolItemBest.cc.

◆ container()

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

Definition at line 50 of file PoolItemBest.cc.

◆ pimpl() [1/2]

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

Pointer to implementation.

Definition at line 141 of file PoolItemBest.h.

◆ pimpl() [2/2]

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

Pointer to implementation.

Definition at line 143 of file PoolItemBest.h.

Friends And Related Function Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream &  str,
const PoolItemBest obj 
)
related

Stream output

Definition at line 73 of file PoolItemBest.cc.

Member Data Documentation

◆ _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 145 of file PoolItemBest.h.


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