1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/PoolItemBest.cc
13 #include "zypp/base/LogTools.h"
15 #include "zypp/PoolItemBest.h"
16 #include "zypp/ui/SelectableTraits.h"
20 ///////////////////////////////////////////////////////////////////
22 { /////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////
26 // CLASS NAME : PoolItemBest::Impl
28 /** PoolItemBest implementation. */
29 struct PoolItemBest::Impl
34 friend Impl * rwcowClone<Impl>( const Impl * rhs );
35 /** clone for RWCOW_pointer */
37 { return new Impl( *this ); }
39 ///////////////////////////////////////////////////////////////////
41 ///////////////////////////////////////////////////////////////////
43 // CLASS NAME : PoolItemBest
45 ///////////////////////////////////////////////////////////////////
47 void PoolItemBest::_ctor_init()
48 { _dont_use_this_use_pimpl.reset( new RWCOW_pointer<Impl>(new Impl) ); }
50 const PoolItemBest::Container & PoolItemBest::container() const
51 { return pimpl()->_container; }
53 void PoolItemBest::add( const PoolItem & pi_r )
55 Container & container( pimpl()->_container );
56 PoolItem & ccand( container[pi_r.satSolvable().ident()] );
57 if ( ! ccand || ui::SelectableTraits::AVOrder()( pi_r, ccand ) )
61 PoolItem PoolItemBest::find( IdString ident_r ) const
63 const Container & container( pimpl()->_container );
64 Container::const_iterator it( container.find( ident_r ) );
65 return it != container.end() ? it->second : PoolItem();
68 /******************************************************************
70 ** FUNCTION NAME : operator<<
71 ** FUNCTION TYPE : std::ostream &
73 std::ostream & operator<<( std::ostream & str, const PoolItemBest & obj )
75 return dumpRange( str << "(" << obj.size() << ") ", obj.begin(), obj.end() );
78 /////////////////////////////////////////////////////////////////
80 ///////////////////////////////////////////////////////////////////