libzypp  17.3.0
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  {
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
std::unordered_map< IdString, PoolItem > Container
Definition: PoolItemBest.h:62
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
const Container & container() const
Definition: PoolItemBest.cc:50
std::ostream & dumpRange(std::ostream &str, TIterator begin, TIterator end, const std::string &intro="{", const std::string &pfx="\ ", const std::string &sep="\ ", const std::string &sfx="\, const std::string &extro="}")
Print range defined by iterators (multiline style).
Definition: LogTools.h:91
String related utilities and Regular expression matching.
Access to the sat-pools string space.
Definition: IdString.h:41
Impl * clone() const
clone for RWCOW_pointer
Definition: PoolItemBest.cc:36
iterator begin() const
Pointer to the first PoolItem.
Definition: PoolItemBest.h:114
Find the best candidates e.g.
Definition: PoolItemBest.h:60
size_type size() const
Number of PoolItems collected.
Definition: PoolItemBest.h:112
PoolItemBest implementation.
Definition: PoolItemBest.cc:29
RWCOW_pointer< Impl > & pimpl()
Pointer to implementation.
Definition: PoolItemBest.h:141
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:50
iterator end() const
Pointer behind the last PoolItem.
Definition: PoolItemBest.h:116
void add(sat::Solvable slv_r)
Feed one sat::Solvable.
Definition: PoolItemBest.h:92
std::ostream & operator<<(std::ostream &str, const PoolItemBest &obj)
Definition: PoolItemBest.cc:73
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57
IdString ident() const
The identifier.
Definition: Solvable.cc:265
PoolItem find(IdString ident_r) const
Return the collected PoolItem with sat::Solvable::ident ident_r.
Definition: PoolItemBest.cc:61
Oder on AvailableItemSet.