libzypp  10.5.0
PoolItemBest.cc
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #include <iostream>
00013 #include "zypp/base/LogTools.h"
00014 
00015 #include "zypp/PoolItemBest.h"
00016 #include "zypp/ui/SelectableTraits.h"
00017 
00018 using std::endl;
00019 
00021 namespace zypp
00022 { 
00023 
00025   //
00026   //    CLASS NAME : PoolItemBest::Impl
00027   //
00029   struct PoolItemBest::Impl
00030   {
00031     Container _container;
00032 
00033     private:
00034       friend Impl * rwcowClone<Impl>( const Impl * rhs );
00036       Impl * clone() const
00037       { return new Impl( *this ); }
00038   };
00040 
00042   //
00043   //    CLASS NAME : PoolItemBest
00044   //
00046 
00047   void PoolItemBest::_ctor_init()
00048   { _dont_use_this_use_pimpl.reset( new RWCOW_pointer<Impl>(new Impl) ); }
00049 
00050   const PoolItemBest::Container & PoolItemBest::container() const
00051   { return pimpl()->_container; }
00052 
00053   void PoolItemBest::add( const PoolItem & pi_r )
00054   {
00055     Container & container( pimpl()->_container );
00056     PoolItem & ccand( container[pi_r.satSolvable().ident()] );
00057     if ( ! ccand || ui::SelectableTraits::AVOrder()( pi_r, ccand ) )
00058       ccand = pi_r;
00059   }
00060 
00061   PoolItem PoolItemBest::find( IdString ident_r ) const
00062   {
00063     const Container & container( pimpl()->_container );
00064     Container::const_iterator it( container.find( ident_r ) );
00065     return it != container.end() ? it->second : PoolItem();
00066   }
00067 
00068   /******************************************************************
00069   **
00070   **    FUNCTION NAME : operator<<
00071   **    FUNCTION TYPE : std::ostream &
00072   */
00073   std::ostream & operator<<( std::ostream & str, const PoolItemBest & obj )
00074   {
00075     return dumpRange( str << "(" << obj.size() << ") ", obj.begin(), obj.end() );
00076   }
00077 
00079 } // namespace zypp