1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/pool/PoolImpl.cc
13 //#include "zypp/base/Logger.h"
15 #include "zypp/pool/PoolImpl.h"
16 #include "zypp/CapSet.h"
20 ///////////////////////////////////////////////////////////////////
22 { /////////////////////////////////////////////////////////////////
23 ///////////////////////////////////////////////////////////////////
25 { /////////////////////////////////////////////////////////////////
27 ///////////////////////////////////////////////////////////////////
29 // METHOD NAME : PoolImpl::PoolImpl
35 ///////////////////////////////////////////////////////////////////
37 // METHOD NAME : PoolImpl::~PoolImpl
43 /******************************************************************
45 ** FUNCTION NAME : operator<<
46 ** FUNCTION TYPE : std::ostream &
48 std::ostream & operator<<( std::ostream & str, const PoolImpl & obj )
50 return str << "PoolImpl " << obj.size();
53 void PoolImplInserter::operator()( ResObject::constPtr ptr_r )
55 PoolImpl::Item item ( ptr_r, ResStatus (_installed) );
56 _poolImpl.store().insert( item );
57 _poolImpl.namestore().insert( PoolImpl::NameContainerT::value_type (item->name(), item ) );
58 CapSet provides = item->dep( Dep::PROVIDES );
59 for (CapSet::iterator ic = provides.begin(); ic != provides.end(); ++ic) {
60 _poolImpl.providesstore().insert( PoolImpl::IndexContainerT::value_type (ic->index(), std::make_pair( *ic, item ) ) );
62 CapSet requires = item->dep( Dep::REQUIRES );
63 for (CapSet::iterator ic = requires.begin(); ic != requires.end(); ++ic) {
64 _poolImpl.requiresstore().insert( PoolImpl::IndexContainerT::value_type (ic->index(), std::make_pair( *ic, item ) ) );
66 CapSet conflicts = item->dep( Dep::CONFLICTS );
67 for (CapSet::iterator ic = conflicts.begin(); ic != conflicts.end(); ++ic) {
68 _poolImpl.conflictsstore().insert( PoolImpl::IndexContainerT::value_type (ic->index(), std::make_pair( *ic, item ) ) );
71 // don't miss to invalidate ResPoolProxy
72 _poolImpl.invalidateProxy();
75 void PoolImplDeleter::operator()( ResObject::constPtr ptr_r )
77 PoolImpl::Item item( ptr_r );
78 _poolImpl.store().erase( item );
79 for (PoolImpl::nameiterator nit = _poolImpl.namestore().lower_bound (item->name());
80 nit != _poolImpl.namestore().upper_bound (item->name()); ++nit)
82 if (nit->second == item)
83 _poolImpl.namestore().erase( nit );
85 CapSet provides = ptr_r->dep( Dep::PROVIDES );
86 for (CapSet::iterator ic = provides.begin(); ic != provides.end(); ++ic) {
87 for (PoolImpl::indexiterator iit = _poolImpl.providesstore().lower_bound (ic->index());
88 iit != _poolImpl.providesstore().upper_bound (ic->index()); ++iit)
90 if (iit->second.second == item)
91 _poolImpl.providesstore().erase( iit );
94 CapSet requires = ptr_r->dep( Dep::REQUIRES );
95 for (CapSet::iterator ic = requires.begin(); ic != requires.end(); ++ic) {
96 for (PoolImpl::indexiterator iit = _poolImpl.requiresstore().lower_bound (ic->index());
97 iit != _poolImpl.requiresstore().upper_bound (ic->index()); ++iit)
99 if (iit->second.second == item)
100 _poolImpl.requiresstore().erase( iit );
103 CapSet conflicts = ptr_r->dep( Dep::CONFLICTS );
104 for (CapSet::iterator ic = conflicts.begin(); ic != conflicts.end(); ++ic) {
105 for (PoolImpl::indexiterator iit = _poolImpl.conflictsstore().lower_bound (ic->index());
106 iit != _poolImpl.conflictsstore().upper_bound (ic->index()); ++iit)
108 if (iit->second.second == item)
109 _poolImpl.conflictsstore().erase( iit );
113 // don't miss to invalidate ResPoolProxy
114 _poolImpl.invalidateProxy();
117 /////////////////////////////////////////////////////////////////
119 ///////////////////////////////////////////////////////////////////
120 /////////////////////////////////////////////////////////////////
122 ///////////////////////////////////////////////////////////////////