libzypp  11.13.5
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 
18 using std::endl;
19 
21 namespace zypp
22 {
23 
25  //
26  // CLASS NAME : PoolItemBest::Impl
27  //
30  {
32 
33  private:
34  friend Impl * rwcowClone<Impl>( const Impl * rhs );
36  Impl * clone() const
37  { return new Impl( *this ); }
38  };
40 
42  //
43  // CLASS NAME : PoolItemBest
44  //
46 
49 
51  { return pimpl()->_container; }
52 
53  void PoolItemBest::add( const PoolItem & pi_r )
54  {
55  Container & container( pimpl()->_container );
56  PoolItem & ccand( container[pi_r.satSolvable().ident()] );
57  if ( ! ccand || ui::SelectableTraits::AVOrder()( pi_r, ccand ) )
58  ccand = pi_r;
59  }
60 
62  {
63  const Container & container( pimpl()->_container );
64  Container::const_iterator it( container.find( ident_r ) );
65  return it != container.end() ? it->second : PoolItem();
66  }
67 
68  /******************************************************************
69  **
70  ** FUNCTION NAME : operator<<
71  ** FUNCTION TYPE : std::ostream &
72  */
73  std::ostream & operator<<( std::ostream & str, const PoolItemBest & obj )
74  {
75  return dumpRange( str << "(" << obj.size() << ") ", obj.begin(), obj.end() );
76  }
77 
79 } // namespace zypp