libzypp 17.35.9
PoolItemBest.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#include <iostream>
13#include <zypp/base/LogTools.h>
14
15#include <zypp/PoolItemBest.h>
17
18using std::endl;
19
21namespace zypp
22{
23
25 //
26 // CLASS NAME : PoolItemBest::Impl
27 //
30 {
34
37
38 private:
39 friend Impl * rwcowClone<Impl>( const Impl * rhs );
41 Impl * clone() const
42 { return new Impl( *this ); }
43 };
45
47 //
48 // CLASS NAME : PoolItemBest
49 //
51
54
56 { _ctor_init( /*preferNotLocked*/false ); }
57
59 { return pimpl()->_container; }
60
62 {
63 Container & container( pimpl()->_container );
64
65 PoolItem & ccand( container[pi_r.satSolvable().ident()] );
66 if ( ! ccand )
67 ccand = pi_r;
68 else if ( pimpl()->_preferNotLocked )
69 {
70 if ( ! pi_r.status().isLocked() )
71 {
72 if ( ccand.status().isLocked() || ui::SelectableTraits::AVOrder()( pi_r, ccand ) )
73 ccand = pi_r;
74 }
75 else if ( ccand.status().isLocked() )
76 {
78 ccand = pi_r;
79 }
80 }
82 ccand = pi_r;
83 }
84
86 {
87 const Container & container( pimpl()->_container );
88 Container::const_iterator it( container.find( ident_r ) );
89 return it != container.end() ? it->second : PoolItem();
90 }
91
92 /******************************************************************
93 **
94 ** FUNCTION NAME : operator<<
95 ** FUNCTION TYPE : std::ostream &
96 */
97 std::ostream & operator<<( std::ostream & str, const PoolItemBest & obj )
98 {
99 return dumpRange( str << "(" << obj.size() << ") ", obj.begin(), obj.end() );
100 }
101
103} // namespace zypp
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition AutoDispose.h:95
Access to the sat-pools string space.
Definition IdString.h:44
Find the best candidates e.g.
RWCOW_pointer< Impl > & pimpl()
Pointer to implementation.
shared_ptr< void > _dont_use_this_use_pimpl
Avoid need to include Impl definition when inlined ctors (due to tepmlate) are provided.
const Container & container() const
PoolItem find(IdString ident_r) const
Return the collected PoolItem with sat::Solvable::ident ident_r.
void _ctor_init()
bin.compat legacy
void add(sat::Solvable slv_r)
Feed one sat::Solvable.
std::unordered_map< IdString, PoolItem > Container
Combining sat::Solvable and ResStatus.
Definition PoolItem.h:51
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & dumpRange(std::ostream &str, TIterator begin, TIterator end, const std::string &intro="{", const std::string &pfx="\n ", const std::string &sep="\n ", const std::string &sfx="\n", const std::string &extro="}")
Print range defined by iterators (multiline style).
Definition LogTools.h:120
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
PoolItemBest implementation.
Impl(bool preferNotLocked_r)
Impl * clone() const
clone for RWCOW_pointer