libzypp  17.38.7
SolvIterMixin.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 //#include <iostream>
13 //#include <zypp-core/base/Logger.h>
14 
15 #include <zypp/sat/SolvIterMixin.h>
16 #include <zypp/sat/Solvable.h>
17 #include <zypp/ResPoolProxy.h>
18 #include <zypp/pool/PoolTraits.h>
19 
20 using std::endl;
21 
23 namespace zypp
24 {
25  namespace sat
27  {
28 
29  namespace solvitermixin_detail
30  {
31  bool UnifyByIdent2::operator()( const Solvable & solv_r ) const
32  {
33  bool ret = false;
34  if ( solv_r ) {
35  // Need to use pool::ByIdent because packages and srcpackages have the same ident() id!
36  sat::detail::IdType myident = pool::ByIdent( solv_r ).get();
37  sat::detail::SolvableIdType myid = solv_r.id();
38  auto inmapiter = _umap->insert( std::make_pair( myident, myid ) ).first;
39  if ( inmapiter->second == myid )
40  ret = true; // solv_r represents it's ident
41  }
42  return ret;
43  }
44 
45 #if LEGACY(1735)
46  // It's flawed because the representing solvable (the 1st one that stored it's
47  // ident id) can not be visited twice. Furthermore a UnifyByIdent instance is
48  // shared among iterator copies. So no iterator is able to visit an item
49  // that has been visited by itself or by another iterator copy before.
50  bool UnifyByIdent::operator()( const Solvable & solv_r ) const
51  {
52  // Need to use pool::ByIdent because packages and srcpackages have the same id.
53  return( solv_r && _uset->insert( pool::ByIdent( solv_r ).get() ).second );
54  }
55 #endif
56  }
57 
59  // asSolvable
62  {
63  return pi_r.satSolvable();
64  }
65 
66  Solvable asSolvable::operator()( const ResObject_constPtr & res_r ) const
67  {
68  return res_r ? res_r->satSolvable() : Solvable();
69  }
70 
72  } // namespace sat
74 
76  namespace ui
77  {
78 
79  Selectable_Ptr asSelectable::operator()( const sat::Solvable & sov_r ) const
80  {
81  return ResPool::instance().proxy().lookup( sov_r );
82  }
83 
85  } // namespace ui
88 } // namespace zypp
sat::detail::IdType get() const
Definition: ByIdent.h:90
A Solvable object within the sat Pool.
Definition: Solvable.h:53
ResPoolProxy proxy() const
preliminary
Definition: ResPool.cc:59
IdType id() const
Expert backdoor.
Definition: Solvable.h:464
bool operator()(const Solvable &solv_r) const
int IdType
Generic Id type.
Definition: PoolDefines.h:42
Selectable_Ptr operator()(const sat::Solvable &solv_r) const
unsigned int SolvableIdType
Id type to connect Solvable and sat-solvable.
Definition: PoolDefines.h:63
Solvable operator()(const Solvable &solv_r) const
Definition: Solvable.h:601
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:50
ui::Selectable::Ptr lookup(const pool::ByIdent &ident_r) const
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
Main filter selecting PoolItems by name and kind.
Definition: ByIdent.h:28
static ResPool instance()
Singleton ctor.
Definition: ResPool.cc:38