libzypp  13.10.6
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
IdString ident() const
The identifier.
Definition: Solvable.cc:165
shared_ptr< void > _dont_use_this_use_pimpl
Avoid need to include Impl definition when inlined ctors (due to tepmlate) are provided.
Definition: PoolItemBest.h:145
iterator begin() const
Pointer to the first PoolItem.
Definition: PoolItemBest.h:114
size_type size() const
Number of PoolItems collected.
Definition: PoolItemBest.h:112
Access to the sat-pools string space.
Definition: IdString.h:39
std::tr1::unordered_map< IdString, PoolItem > Container
Definition: PoolItemBest.h:62
PoolItem find(IdString ident_r) const
Return the collected PoolItem with sat::Solvable::ident ident_r.
Definition: PoolItemBest.cc:61
std::ostream & dumpRange(std::ostream &str, _Iterator begin, _Iterator 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:91
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:120
Find the best candidates e.g.
Definition: PoolItemBest.h:60
const Container & container() const
Definition: PoolItemBest.cc:50
sat::Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: PoolItem.h:114
PoolItemBest implementation.
Definition: PoolItemBest.cc:29
RWCOW_pointer< Impl > & pimpl()
Pointer to implementation.
Definition: PoolItemBest.h:141
Reference to a PoolItem connecting ResObject and ResStatus.
Definition: PoolItem.h:50
void add(sat::Solvable slv_r)
Feed one sat::Solvable.
Definition: PoolItemBest.h:92
iterator end() const
Pointer behind the last PoolItem.
Definition: PoolItemBest.h:116
RW_pointer supporting &#39;copy on write&#39; functionality.
Definition: PtrTypes.h:438
Impl * clone() const
clone for RWCOW_pointer
Definition: PoolItemBest.cc:36
Oder on AvailableItemSet.