const Capability & lhs_r,
function<bool(const CapAndItem &)> action_r )
{
-#warning FIX BROKEN BROKEN POOL byCapabilityIndex
- return -1;
-#if 0
std::string index( lhs_r.index() );
return invokeOnEach( pool_r.byCapabilityIndexBegin( index, dep_r ),
pool_r.byCapabilityIndexEnd( index, dep_r ),
MatchesCapability( lhs_r ), // filter
action_r );
-#endif
}
{}
Impl( ResObject::constPtr res_r,
- const ResStatus & status_r = ResStatus() )
+ const ResStatus & status_r )
: _status( status_r )
, _resolvable( res_r )
{
// METHOD NAME : PoolItem::PoolItem
// METHOD TYPE : Ctor
//
- PoolItem::PoolItem( ResObject::constPtr res_r )
- : _pimpl( new Impl( res_r ) )
- {}
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : PoolItem::PoolItem
- // METHOD TYPE : Ctor
- //
- PoolItem::PoolItem( ResObject::constPtr res_r, const ResStatus & status_r )
- : _pimpl( new Impl( res_r, status_r ) )
+ PoolItem::PoolItem( const sat::Solvable & solvable_r )
+ : _pimpl( new Impl( makeResObject( solvable_r ), solvable_r.isSystem() ) )
{}
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
+ namespace pool
+ {
+ class PoolImpl;
+ }
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : PoolItem
{
friend std::ostream & operator<<( std::ostream & str, const PoolItem & obj );
- public:
- /** Implementation */
- class Impl;
-
- public:
- /** Default ctor for use in std::container. */
- PoolItem();
-
- /** Ctor */
- explicit
- PoolItem( ResObject::constPtr res_r );
-
- /** Ctor */
- PoolItem( ResObject::constPtr res_r, const ResStatus & status_r );
-
- /** Dtor */
- ~PoolItem();
-
- public:
- /** Returns the current status. */
- ResStatus & status() const;
-
- /** Returns the ResObject::constPtr.
- * \see \ref operator->
- */
- ResObject::constPtr resolvable() const;
-
- public:
- /** Implicit conversion into ResObject::constPtr to
- * support query filters operating on ResObject.
- */
- operator ResObject::constPtr() const
- { return resolvable(); }
-
- /** Forward \c -> access to ResObject. */
- ResObject::constPtr operator->() const
- { return resolvable(); }
-
- /** Conversion to bool to allow pointer style tests
- * for nonNULL \ref resolvable. */
- operator ResObject::constPtr::unspecified_bool_type() const
- { return resolvable(); }
-
- private:
- /** Pointer to implementation */
- RW_pointer<Impl> _pimpl;
-
- private:
- /** \name tmp hack for save/restore state. */
- /** \todo get rid of it. */
- //@{
- friend class PoolItemSaver;
- void saveState() const;
- void restoreState() const;
- bool sameState() const;
- //@}
+ public:
+ /** Implementation */
+ class Impl;
+
+ public:
+ /** Default ctor for use in std::container. */
+ PoolItem();
+
+ /** Dtor */
+ ~PoolItem();
+
+ public:
+ /** Returns the current status. */
+ ResStatus & status() const;
+
+ /** Returns the ResObject::constPtr.
+ * \see \ref operator->
+ */
+ ResObject::constPtr resolvable() const;
+
+ sat::Solvable satSolvable() const
+ { return resolvable() ? resolvable()->satSolvable() : sat::Solvable::nosolvable; }
+
+ public:
+ /** Implicit conversion into ResObject::constPtr to
+ * support query filters operating on ResObject.
+ */
+ operator ResObject::constPtr() const
+ { return resolvable(); }
+
+ /** Forward \c -> access to ResObject. */
+ ResObject::constPtr operator->() const
+ { return resolvable(); }
+
+ /** Conversion to bool to allow pointer style tests
+ * for nonNULL \ref resolvable. */
+ operator ResObject::constPtr::unspecified_bool_type() const
+ { return resolvable(); }
+
+ private:
+ friend class pool::PoolImpl;
+ /** ctor */
+ explicit PoolItem( const sat::Solvable & solvable_r );
+ /** Pointer to implementation */
+ RW_pointer<Impl> _pimpl;
+
+ private:
+ /** \name tmp hack for save/restore state. */
+ /** \todo get rid of it. */
+ //@{
+ friend class PoolItemSaver;
+ void saveState() const;
+ void restoreState() const;
+ bool sameState() const;
+ //@}
};
///////////////////////////////////////////////////////////////////
- /** \relates PoolItem \todo remove deprecated typedef. */
- typedef PoolItem ZYPP_DEPRECATED PoolItem_Ref;
-
/** \relates PoolItem Stream output */
std::ostream & operator<<( std::ostream & str, const PoolItem & obj );
namespace zypp
{ /////////////////////////////////////////////////////////////////
- namespace
- {
- /** the empty pool used by ResPool::ResPool() */
- pool::PoolTraits::Impl_constPtr noPool()
- {
- static pool::PoolTraits::Impl_constPtr _noPool( new pool::PoolImpl );
- return _noPool;
- }
- }
-
///////////////////////////////////////////////////////////////////
//
- // METHOD NAME : ResPool::ResPool
- // METHOD TYPE : Ctor
+ // METHOD NAME : ResPool::instance
+ // METHOD TYPE : ResPool
//
- ResPool::ResPool()
- : _pimpl( noPool() )
- {}
+ ResPool ResPool::instance()
+ {
+ static ResPool _val( pool::PoolTraits::Impl_constPtr( new pool::PoolImpl ) );
+ return _val;
+ }
///////////////////////////////////////////////////////////////////
//
ResPoolProxy ResPool::proxy() const
{ return _pimpl->proxy( *this ); }
+ const SerialNumber & ResPool::serial() const
+ { return _pimpl->serial(); }
+
bool ResPool::empty() const
{ return _pimpl->empty(); }
- PoolItem ResPool::find( const sat::Solvable & slv_r ) const
- { return _pimpl->find( slv_r ); }
-
ResPool::size_type ResPool::size() const
{ return _pimpl->size(); }
ResPool::const_iterator ResPool::end() const
{ return _pimpl->end(); }
- ResPool::byName_iterator ResPool::byNameBegin( const std::string & name_r ) const
- { return _pimpl->_namehash.begin( name_r ); }
- ResPool::byName_iterator ResPool::byNameEnd( const std::string & name_r ) const
- { return _pimpl->_namehash.end( name_r ); }
+ PoolItem ResPool::find( const sat::Solvable & slv_r ) const
+ { return _pimpl->find( slv_r ); }
ResPool::byCapabilityIndex_iterator ResPool::byCapabilityIndexBegin( const std::string & index_r, Dep depType_r ) const
- { return _pimpl->_caphash.begin( index_r, depType_r ); }
+ { return _pimpl->_caphashfake.begin(); }
ResPool::byCapabilityIndex_iterator ResPool::byCapabilityIndexEnd( const std::string & index_r, Dep depType_r ) const
- { return _pimpl->_caphash.end( index_r, depType_r ); }
+ { return _pimpl->_caphashfake.end(); }
+
ResPool::size_type ResPool::knownRepositoriesSize() const
{ return _pimpl->knownRepositories().size(); }
ResPool::repository_iterator ResPool::knownRepositoriesEnd() const
{ return _pimpl->knownRepositories().end(); }
+
void ResPool::setAdditionalRequire( const AdditionalCapabilities & capset ) const
{ _pimpl->setAdditionalRequire( capset ); }
ResPool::AdditionalCapabilities & ResPool::additionalRequire() const
ResPool::AdditionalCapabilities & ResPool::additionaProvide() const
{ return _pimpl->additionaProvide(); }
- const SerialNumber & ResPool::serial() const
- { return _pimpl->serial(); }
-
/******************************************************************
**
** FUNCTION NAME : operator<<
#include "zypp/base/Iterator.h"
#include "zypp/pool/PoolTraits.h"
+#include "zypp/PoolItem.h"
#include "zypp/ResFilters.h"
///////////////////////////////////////////////////////////////////
friend std::ostream & operator<<( std::ostream & str, const ResPool & obj );
public:
- /** \ref zypp::pool::PoolItem */
- typedef pool::PoolTraits::Item Item;
+ /** \ref PoolItem */
+ typedef PoolItem value_type;
typedef pool::PoolTraits::size_type size_type;
typedef pool::PoolTraits::const_iterator const_iterator;
- typedef pool::PoolTraits::byName_iterator byName_iterator;
+
typedef pool::PoolTraits::byCapabilityIndex_iterator byCapabilityIndex_iterator;
typedef pool::PoolTraits::AdditionalCapabilities AdditionalCapabilities;
typedef pool::PoolTraits::repository_iterator repository_iterator;
public:
/** Singleton ctor. */
- static ResPool instance()
- { return ResPool(); }
+ static ResPool instance();
/** preliminary */
ResPoolProxy proxy() const;
*/
const SerialNumber & serial() const;
- /** Return the corresponding \ref PoolItem.
- * Pool and sat pool should be in sync. Returns an empty
- * \ref PoolItem if there is no corresponding \ref PoolItem.
- * \see \ref PoolItem::satSolvable.
- */
- PoolItem find( const sat::Solvable & slv_r ) const;
-
public:
/** */
bool empty() const;
//@}
public:
+ /** Return the corresponding \ref PoolItem.
+ * Pool and sat pool should be in sync. Returns an empty
+ * \ref PoolItem if there is no corresponding \ref PoolItem.
+ * \see \ref PoolItem::satSolvable.
+ */
+ PoolItem find( const sat::Solvable & slv_r ) const;
+
+ public:
/** \name Iterate through all ResObjects of a certain kind. */
//@{
typedef zypp::resfilter::ByKind ByKind;
typedef filter_iterator<ByKind,const_iterator> byKind_iterator;
- byKind_iterator byKindBegin( const ResObject::Kind & kind_r ) const
+ byKind_iterator byKindBegin( const ResKind & kind_r ) const
{ return make_filter_begin( ByKind(kind_r), *this ); }
template<class _Res>
- byKind_iterator byKindBegin() const
- { return make_filter_begin( resfilter::byKind<_Res>(), *this ); }
-
+ byKind_iterator byKindBegin() const
+ { return make_filter_begin( resfilter::byKind<_Res>(), *this ); }
- byKind_iterator byKindEnd( const ResObject::Kind & kind_r ) const
+ byKind_iterator byKindEnd( const ResKind & kind_r ) const
{ return make_filter_end( ByKind(kind_r), *this ); }
template<class _Res>
- byKind_iterator byKindEnd() const
- { return make_filter_end( resfilter::byKind<_Res>(), *this ); }
+ byKind_iterator byKindEnd() const
+ { return make_filter_end( resfilter::byKind<_Res>(), *this ); }
//@}
public:
/** \name Iterate through all ResObjects with a certain name (all kinds). */
//@{
- byName_iterator byNameBegin( const std::string & name_r ) const;
+ typedef zypp::resfilter::ByName ByName;
+ typedef filter_iterator<ByName,const_iterator> byName_iterator;
- byName_iterator byNameEnd( const std::string & name_r ) const;
+ byName_iterator byNameBegin( const std::string & name_r ) const
+ { return make_filter_begin( ByName(name_r), *this ); }
+
+ byName_iterator byNameEnd( const std::string & name_r ) const
+ { return make_filter_end( ByName(name_r), *this ); }
//@}
public:
private:
/** Ctor */
ResPool( pool::PoolTraits::Impl_constPtr impl_r );
- /** Default ctor */
- ResPool();
- private:
/** Const access to implementation. */
pool::PoolTraits::Impl_constPtr _pimpl;
};
///////////////////////////////////////////////////////////////////
- /** \relates ResPool \todo remove deprecated typedef. */
- typedef ResPool ZYPP_DEPRECATED ResPool_Ref;
-
- ///////////////////////////////////////////////////////////////////
-
/** \relates ResPool Stream output */
std::ostream & operator<<( std::ostream & str, const ResPool & obj );
struct SelPoolHelper
{
- typedef std::set<ResPool::Item> ItemC;
+ typedef std::set<PoolItem> ItemC;
struct SelC
{
- void add( ResPool::Item it )
+ void add( PoolItem it )
{
if ( it.status().isInstalled() )
installed.insert( it );
KindC _kinds;
/** collect from a pool */
- void operator()( ResPool::Item it )
+ void operator()( PoolItem it )
{
_kinds[it->kind()][it->name()].add( it );
}
{
SelPoolHelper collect;
std::for_each( _pool.begin(), _pool.end(),
- functor::functorRef<void,ResPool::Item>( collect ) );
+ functor::functorRef<void,PoolItem>( collect ) );
collect.feed( _selPool );
}
//
// CLASS NAME : ResPoolProxy
//
- /**
+ /** ResPool::instance().proxy();
* \todo integrate it into ResPool
*/
class ResPoolProxy
typedef ResPool::repository_iterator repository_iterator;
public:
- /** Default ctor: no pool */
+
+ /** Default ctor: no pool
+ * Nonempty proxies are provided by \ref ResPool.
+ * \see \ref ResPool::proxy
+ * \code
+ * ResPoolProxy p( ResPool::instance().proxy() );
+ * \endcode
+ */
ResPoolProxy();
- /** Ctor */
- ResPoolProxy( ResPool pool_r ) ZYPP_DEPRECATED;
+
/** Dtor */
~ResPoolProxy();
return make_end( _Filter(), kind_r );
}
-
+ private:
+ friend class pool::PoolImpl;
+ /** Ctor */
+ ResPoolProxy( ResPool pool_r );
/** Pointer to implementation */
RW_pointer<Impl> _pimpl;
};
* MapTypeKey_const_iterator keyBegin( make_map_key_begin( mymap ) );
* MapTypeKey_const_iterator keyEnd ( make_map_key_end( mymap ) );
*
- * MapTypeKey_const_iterator valBegin( make_map_value_begin( mymap ) );
- * MapTypeKey_const_iterator valEnd ( make_map_value_end( mymap ) );
+ * MapTypeValue_const_iterator valBegin( make_map_value_begin( mymap ) );
+ * MapTypeValue_const_iterator valEnd ( make_map_value_end( mymap ) );
*
* std::for_each( keyBegin, keyEnd, DoSomething() );
* std::for_each( valBegin, valEnd, DoSomething() );
namespace pool
{ /////////////////////////////////////////////////////////////////
- void pi2sat( const PoolItem & pi_r, sat::Solvable & slv_r );
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : NameHash::NameHash
- // METHOD TYPE : Ctor
- //
- NameHash::NameHash()
- {}
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : NameHash::~NameHash
- // METHOD TYPE : Dtor
- //
- NameHash::~NameHash()
- {}
-
- void
- NameHash::insert( const PoolItem & item_r )
- {
- _store[item_r->name()].insert( item_r );
- }
-
- void
- NameHash::erase( const PoolItem & item_r )
- {
- PoolTraits::ItemContainerT & items = _store[item_r->name()];
- for ( PoolTraits::iterator nit = items.begin(); nit != items.end(); /**/ )
- {
- if ( *nit == item_r )
- items.erase( nit++ ); // postfix! Incrementing before erase
- else
- ++nit;
- }
- }
-
- NameHash::ItemContainerT & NameHash::getItemContainer( const std::string & tag_r )
- { ContainerT::iterator it = _store.find( tag_r );
- if (it == _store.end()) {
-//XXX << "item container for " << tag_r << " not found" << endl;
- return _empty;
- }
-//XXX << "item container for " << tag_r << " contains " << it->second.size() << " items" << endl;
- return it->second;
- }
-
- const NameHash::ItemContainerT & NameHash::getConstItemContainer( const std::string & tag_r ) const
- { ContainerT::const_iterator it = _store.find( tag_r );
- if (it == _store.end()) {
-//XXX << "const item container for " << tag_r << " not found" << endl;
- return _empty;
- }
-//XXX << "const item container for " << tag_r << " contains " << it->second.size() << " items" << endl;
- return it->second;
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : CapHash::CapHash
- // METHOD TYPE : Ctor
- //
- CapHash::CapHash()
- {}
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : CapHash::~CapHash
- // METHOD TYPE : Dtor
- //
- CapHash::~CapHash()
- {}
-
- static void
- storeInsert( CapHash::ContainerT & store_r, const PoolItem & item_r, Dep cap_r )
- {
- Capabilities caps = item_r->dep( cap_r );
- for (Capabilities::const_iterator ic = caps.begin(); ic != caps.end(); ++ic) {
- store_r[cap_r][ic->index()].push_back( CapAndItem( *ic, item_r ) );
- }
- }
-
- void CapHash::insert( const PoolItem & item_r )
- {
- storeInsert( _store, item_r, Dep::PROVIDES );
- storeInsert( _store, item_r, Dep::REQUIRES );
- storeInsert( _store, item_r, Dep::CONFLICTS );
- storeInsert( _store, item_r, Dep::OBSOLETES );
- storeInsert( _store, item_r, Dep::RECOMMENDS );
- storeInsert( _store, item_r, Dep::SUGGESTS );
- storeInsert( _store, item_r, Dep::FRESHENS );
- storeInsert( _store, item_r, Dep::ENHANCES );
- storeInsert( _store, item_r, Dep::SUPPLEMENTS );
- }
-
- static void
- storeDelete( PoolTraits::DepCapItemContainerT & store_r, const PoolItem & item_r, Dep cap_r )
- {
- Capabilities caps = item_r->dep( cap_r );
-//XXX << "storeDelete(" << item_r << ")" << endl;
- for ( Capabilities::const_iterator ic = caps.begin(); ic != caps.end(); ++ic )
- {
- PoolTraits::CapItemContainerT & capitems = store_r[cap_r][ic->index()];
- for ( PoolTraits::CapItemContainerT::iterator pos = capitems.begin(); pos != capitems.end(); /**/ )
- {
- if ( pos->item == item_r )
- capitems.erase( pos++ ); // postfix! Incrementing before erase
- else
- ++pos;
- }
- }
- }
-
- void CapHash::erase( const PoolItem & item_r )
- {
-//XXX << "CapHash::erase(" << item_r << ")" << endl;
- storeDelete( _store, item_r, Dep::PROVIDES );
- storeDelete( _store, item_r, Dep::REQUIRES );
- storeDelete( _store, item_r, Dep::CONFLICTS );
- storeDelete( _store, item_r, Dep::OBSOLETES );
- storeDelete( _store, item_r, Dep::RECOMMENDS );
- storeDelete( _store, item_r, Dep::SUGGESTS );
- storeDelete( _store, item_r, Dep::FRESHENS );
- storeDelete( _store, item_r, Dep::ENHANCES );
- storeDelete( _store, item_r, Dep::SUPPLEMENTS );
- }
-
- const CapHash::CapItemStoreT & CapHash::capItemStore ( Dep cap_r ) const
- { static CapItemStoreT capitemstore;
- ContainerT::const_iterator it = store().find( cap_r );
- if (it == store().end()) {
-//XXX << "CapItemStoreT for " << cap_r << " not found" << endl;
- return capitemstore;
- }
-//XXX << "CapItemStoreT for " << cap_r << " contains " << it->second.size() << " items" << endl;
- return it->second;
- }
-
- // CapItemStoreT, index -> CapItemContainerT
- const CapHash::CapItemContainerT & CapHash::capItemContainer( const CapItemStoreT & cis, const std::string & tag_r ) const
- { static CapItemContainerT captemcontainer;
- CapItemStoreT::const_iterator it = cis.find( tag_r );
- if (it == cis.end()) {
-//XXX << "CapItemContainerT for " << tag_r << " not found" << endl;
- return captemcontainer;
- }
-//XXX << "CapItemContainerT for " << tag_r << " contains " << it->second.size() << " items" << endl;
-//for (CapItemContainerT::const_iterator cai = it->second.begin(); cai != it->second.end(); ++cai) XXX << *cai << endl;
- return it->second;
- }
-
///////////////////////////////////////////////////////////////////
//
// Class PoolImpl::PoolImpl
PoolImpl::~PoolImpl()
{}
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : PoolImpl::find
- // METHOD TYPE : PoolItem
- //
- PoolItem PoolImpl::find( const sat::Solvable & slv_r ) const
- {
- if ( slv_r )
- {
- for_( it, begin(), end() )
- {
- if ( (*it)->satSolvable() == slv_r )
- return *it;
- }
- }
- return PoolItem();
- }
-
/******************************************************************
**
** FUNCTION NAME : operator<<
obj.begin(), obj.end() );
}
- /******************************************************************
- **
- ** FUNCTION NAME : PoolImplInserter::operator()
- ** FUNCTION TYPE : void
- */
- /** Bottleneck inserting ResObjects in to the pool.
- * Filters arch incomatible available(!) objects.
- */
- void PoolImplInserter::operator()( ResObject::constPtr ptr_r )
- {
- /* -------------------------------------------------------------------------------
- * 1.) Filter unwanted items
- * ------------------------------------------------------------------------------- */
- if ( ! ptr_r )
- return;
-
- if ( isKind<SrcPackage>( ptr_r ) )
- return;
-
- if ( ! _installed )
- {
- // filter arch incomatible available(!) non-atoms
- // atoms are allowed since patches are multi-arch and require atoms of all archs
- // the atoms themselves will 'filter' the arch via their frehen dependencies
- if ( ptr_r->kind() != ResTraits<Atom>::kind ) {
- if ( ! ptr_r->arch().compatibleWith( _poolImpl.targetArch() ) )
- return;
- }
- }
-
- /* -------------------------------------------------------------------------------
- * 2.) Create ResStatus object
- * ------------------------------------------------------------------------------- */
- PoolImpl::Item item( ptr_r, ResStatus (_installed) );
-
- /* -------------------------------------------------------------------------------
- * 3.) Status adjustments
- * ------------------------------------------------------------------------------- */
- // Foreign vendor protection handled in PoolItem ctor.
-
- /* -------------------------------------------------------------------------------
- * 3.) Feed
- * ------------------------------------------------------------------------------- */
- if ( _poolImpl._store.insert( item ).second )
- {
- _poolImpl._namehash.insert( item );
- _poolImpl._caphash.insert( item );
- // don't miss to invalidate ResPoolProxy
- _poolImpl.invalidateProxy();
- }
- }
-
- /******************************************************************
- **
- ** FUNCTION NAME : PoolImplDeleter::operator()
- ** FUNCTION TYPE : void
- */
- void PoolImplDeleter::operator()( ResObject::constPtr ptr_r )
- {
- PoolImpl::Item item( ptr_r );
- _poolImpl._store.erase( item );
- _poolImpl._namehash.erase( item );
- _poolImpl._caphash.erase( item );
-
- // don't miss to invalidate ResPoolProxy
- _poolImpl.invalidateProxy();
- }
-
/////////////////////////////////////////////////////////////////
} // namespace pool
///////////////////////////////////////////////////////////////////
#include "zypp/pool/PoolTraits.h"
#include "zypp/ResPoolProxy.h"
-#include "zypp/ZYppFactory.h"
+
+#include "zypp/sat/Pool.h"
///////////////////////////////////////////////////////////////////
namespace zypp
///////////////////////////////////////////////////////////////////
//
- // CLASS NAME : NameHash
+ // CLASS NAME : PoolImpl
//
/** */
- class ZYPP_DEPRECATED NameHash
+ class PoolImpl
{
- public:
- /** Default ctor */
- NameHash() ZYPP_DEPRECATED;
- /** Dtor */
- ~NameHash();
+ friend std::ostream & operator<<( std::ostream & str, const PoolImpl & obj );
public:
+ /** */
+ typedef PoolTraits::ItemContainerT ContainerT;
+ typedef PoolTraits::size_type size_type;
+ typedef PoolTraits::const_iterator const_iterator;
- typedef PoolTraits::ItemContainerT ItemContainerT;
- typedef PoolTraits::NameItemContainerT ContainerT;
- typedef PoolTraits::size_type size_type;
- typedef PoolTraits::iterator iterator;
- typedef PoolTraits::const_iterator const_iterator;
+ typedef sat::detail::SolvableIdType SolvableIdType;
- private:
- ItemContainerT & getItemContainer( const std::string & tag_r );
- const ItemContainerT & getConstItemContainer( const std::string & tag_r ) const;
+ typedef PoolTraits::AdditionalCapabilities AdditionalCapabilities;
+ typedef PoolTraits::RepoContainerT KnownRepositories;
public:
- /** */
- ContainerT & store()
- { return _store; }
- /** */
- const ContainerT & store() const
- { return _store; }
-
- /** */
- bool empty() const
- { return _store.empty(); }
- /** */
- size_type size() const
- { return _store.size(); }
-
- /** */
- iterator begin( const std::string & tag_r )
- { return getItemContainer( tag_r ).begin(); }
- /** */
- const_iterator begin( const std::string & tag_r ) const
- { return getConstItemContainer( tag_r ).begin(); }
-
- /** */
- iterator end( const std::string & tag_r )
- { return getItemContainer( tag_r ).end(); }
- /** */
- const_iterator end( const std::string & tag_r ) const
- { return getConstItemContainer( tag_r ).end(); }
-
- /** */
- void clear()
- { _store.clear(); }
-
- /** */
- void insert( const PoolItem & item_r );
- /** */
- void erase( const PoolItem & item_r );
+ /** Default ctor */
+ PoolImpl();
+ /** Dtor */
+ ~PoolImpl();
- private:
- ContainerT _store;
- ItemContainerT _empty; // for begin(), end() if tag_r can't be found
- };
+ public:
+ /** convenience. */
+ const sat::Pool satpool() const
+ { return sat::Pool::instance(); }
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : CapHash
- //
- /** */
- class CapHash
- {
- public:
- /** Default ctor */
- CapHash() ZYPP_DEPRECATED;
- /** Dtor */
- ~CapHash();
+ /** Housekeeping data serial number. */
+ const SerialNumber & serial() const
+ { return satpool().serial(); }
+ ///////////////////////////////////////////////////////////////////
+ //
+ ///////////////////////////////////////////////////////////////////
public:
+ /** */
+ bool empty() const
+ { return satpool().solvablesEmpty(); }
- typedef PoolTraits::DepCapItemContainerT ContainerT;
- typedef PoolTraits::capitemsize_type size_type;
- typedef PoolTraits::capitemiterator iterator;
- typedef PoolTraits::const_capitemiterator const_iterator;
+ /** */
+ size_type size() const
+ { return satpool().solvablesSize(); }
- private:
+ /** */
+ const_iterator begin() const
+ { return make_map_value_begin( store() ); }
- typedef PoolTraits::CapItemStoreT CapItemStoreT;
- typedef PoolTraits::CapItemContainerT CapItemContainerT;
+ /** */
+ const_iterator end() const
+ { return make_map_value_end( store() ); }
- // Dep -> CapItemStoreT
- const CapItemStoreT & capItemStore ( Dep cap_r ) const;
+ public:
+ /** Return the corresponding \ref PoolItem.
+ * Pool and sat pool should be in sync. Returns an empty
+ * \ref PoolItem if there is no corresponding \ref PoolItem.
+ * \see \ref PoolItem::satSolvable.
+ */
+ PoolItem find( const sat::Solvable & slv_r ) const
+ {
+ const ContainerT & c( store() );
+ ContainerT::const_iterator it( c.find( slv_r ) );
+ if ( it != c.end() )
+ return it->second;
+ return PoolItem();
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ ///////////////////////////////////////////////////////////////////
+ public:
+ /** \name Save and restore state. */
+ //@{
+ void SaveState( const ResObject::Kind & kind_r );
- // CapItemStoreT, index -> CapItemContainerT
- const CapItemContainerT & capItemContainer( const CapItemStoreT & cis, const std::string & tag_r ) const;
+ void RestoreState( const ResObject::Kind & kind_r );
+ //@}
+ ///////////////////////////////////////////////////////////////////
+ //
+ ///////////////////////////////////////////////////////////////////
public:
+ /**
+ * Handling additional requirement. E.G. need package "foo" and package
+ * "foo1" which has a greater version than 1.0:
+ *
+ * Capset capset;
+ * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
+ * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo1 > 1.0"));
+ *
+ * setAdditionalRequire( capset );
+ */
+ void setAdditionalRequire( const AdditionalCapabilities & capset ) const
+ { _additionalRequire = capset; }
+ AdditionalCapabilities & additionalRequire() const
+ { return _additionalRequire; }
+
+ /**
+ * Handling additional conflicts. E.G. do not install anything which provides "foo":
+ *
+ * Capset capset;
+ * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
+ *
+ * setAdditionalConflict( capset );
+ */
+ void setAdditionalConflict( const AdditionalCapabilities & capset ) const
+ { _additionaConflict = capset; }
+ AdditionalCapabilities & additionaConflict() const
+ { return _additionaConflict; }
- /** */
- ContainerT & store()
- { return _store; }
- /** */
- const ContainerT & store() const
- { return _store; }
-
- /** */
- bool empty() const
- { return _store.empty(); }
- /** */
- size_type size() const
- { return _store.size(); }
-
- /** */
- iterator begin( const std::string & tag_r, Dep cap_r )
- { return _store[cap_r][tag_r].begin(); }
- /** */
- const_iterator begin( const std::string & tag_r, Dep cap_r ) const
- { const CapItemStoreT & capitemstore = capItemStore( cap_r );
- const CapItemContainerT & capcontainer = capItemContainer ( capitemstore, tag_r );
- return capcontainer.begin(); }
-
- /** */
- iterator end( const std::string & tag_r, Dep cap_r )
- { return _store[cap_r][tag_r].begin(); }
- /** */
- const_iterator end( const std::string & tag_r, Dep cap_r ) const
- { const CapItemStoreT & capitemstore = capItemStore( cap_r );
- const CapItemContainerT & capcontainer = capItemContainer ( capitemstore, tag_r );
- return capcontainer.end(); }
-
- /** */
- void clear()
- { _store.clear(); }
-
- /** */
- void insert( const PoolItem & item_r );
- /** */
- void erase( const PoolItem & item_r );
+ /**
+ * Handling additional provides. This is used for ignoring a requirement.
+ * e.G. Do ignore the requirement "foo":
+ *
+ * Capset capset;
+ * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
+ *
+ * setAdditionalProvide( cap );
+ */
+ void setAdditionalProvide( const AdditionalCapabilities & capset ) const
+ { _additionaProvide = capset; }
+ AdditionalCapabilities & additionaProvide() const
+ { return _additionaProvide; }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ ///////////////////////////////////////////////////////////////////
+ public:
+ ResPoolProxy proxy( ResPool self ) const
+ {
+ checkSerial();
+ if ( !_poolProxy )
+ _poolProxy.reset( new ResPoolProxy( self ) );
+ return *_poolProxy;
+ }
+ public:
+ /** Access list of Repositories that contribute ResObjects.
+ * Built on demand.
+ */
+ const KnownRepositories & knownRepositories() const
+ {
+ checkSerial();
+ if ( ! _knownRepositoriesPtr )
+ {
+ _knownRepositoriesPtr.reset( new KnownRepositories );
+ const ContainerT & c( store() );
+ for_( it, c.begin(), c.end() )
+ {
+ if ( (*it).second->repository() != Repository::noRepository )
+ {
+ _knownRepositoriesPtr->insert( (*it).second->repository() );
+ }
+ }
+ }
+ return *_knownRepositoriesPtr;
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ ///////////////////////////////////////////////////////////////////
private:
- PoolTraits::DepCapItemContainerT _store;
- };
+ const ContainerT & store() const
+ {
+ checkSerial();
+ if ( _storeDirty )
+ {
+ // pass 1: delete no longer existing solvables
+ for ( ContainerT::iterator it = _store.begin(); it != _store.end(); /**/ )
+ {
+ if ( ! it->first ) // solvable became invalid
+ _store.erase( it++ ); // postfix! Incrementing before erase
+ else
+ ++it;
+ }
+
+ // pass 2: add new solvables
+ sat::Pool pool( satpool() );
+ if ( _store.size() != pool.solvablesSize() )
+ {
+ for_( it, pool.solvablesBegin(), pool.solvablesEnd() )
+ {
+ PoolItem & pi( _store[*it] );
+ if ( ! pi ) // newly created
+ {
+ pi = PoolItem( *it );
+ }
+ }
+ }
+ }
+ return _store;
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ ///////////////////////////////////////////////////////////////////
+ private:
+ void checkSerial() const
+ {
+ if ( _watcher.remember( serial() ) )
+ invalidate();
+ }
+
+ void invalidate() const
+ {
+ _storeDirty = true;
+ _poolProxy.reset();
+ _knownRepositoriesPtr.reset();
+ }
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : PoolImpl
- //
- /** */
- class PoolImpl
- {
- friend std::ostream & operator<<( std::ostream & str, const PoolImpl & obj );
+ private:
+ /** Watch sat pools serial number. */
+ SerialNumberWatcher _watcher;
+ mutable ContainerT _store;
+ mutable DefaultIntegral<bool,true> _storeDirty;
- public:
- /** */
- typedef PoolTraits::Item Item;
- typedef PoolTraits::ItemContainerT ContainerT;
- typedef PoolTraits::iterator iterator;
- typedef PoolTraits::const_iterator const_iterator;
- typedef PoolTraits::size_type size_type;
- typedef PoolTraits::Inserter Inserter;
- typedef PoolTraits::Deleter Deleter;
- typedef PoolTraits::AdditionalCapabilities AdditionalCapabilities;
- typedef PoolTraits::RepoContainerT KnownRepositories;
-
- public:
- /** Default ctor */
- PoolImpl();
- /** Dtor */
- ~PoolImpl();
-
- /** \todo no poll, but make ZYpp distribute it. */
- Arch targetArch() const
- { return getZYpp()->architecture(); }
-
- public:
- /** */
- ContainerT & store()
- { return _store; }
- /** */
- const ContainerT & store() const
- { return _store; }
-
- /** */
- bool empty() const
- { return _store.empty(); }
- /** */
- size_type size() const
- { return _store.size(); }
-
- /** */
- iterator begin()
- { return _store.begin(); }
- /** */
- const_iterator begin() const
- { return _store.begin(); }
-
- /** */
- iterator end()
- { return _store.end(); }
- /** */
- const_iterator end() const
- { return _store.end(); }
-
- /**
- * Handling additional requirement. E.G. need package "foo" and package
- * "foo1" which has a greater version than 1.0:
- *
- * Capset capset;
- * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
- * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo1 > 1.0"));
- *
- * setAdditionalRequire( capset );
- */
- void setAdditionalRequire( const AdditionalCapabilities & capset ) const
- { _additionalRequire = capset; }
- AdditionalCapabilities & additionalRequire() const
- { return _additionalRequire; }
-
- /**
- * Handling additional conflicts. E.G. do not install anything which provides "foo":
- *
- * Capset capset;
- * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
- *
- * setAdditionalConflict( capset );
- */
- void setAdditionalConflict( const AdditionalCapabilities & capset ) const
- { _additionaConflict = capset; }
- AdditionalCapabilities & additionaConflict() const
- { return _additionaConflict; }
+ private:
+ mutable AdditionalCapabilities _additionalRequire;
+ mutable AdditionalCapabilities _additionaConflict;
+ mutable AdditionalCapabilities _additionaProvide;
- /**
- * Handling additional provides. This is used for ignoring a requirement.
- * e.G. Do ignore the requirement "foo":
- *
- * Capset capset;
- * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
- *
- * setAdditionalProvide( cap );
- */
- void setAdditionalProvide( const AdditionalCapabilities & capset ) const
- { _additionaProvide = capset; }
- AdditionalCapabilities & additionaProvide() const
- { return _additionaProvide; }
-
- /** */
- void clear()
- {
- _store.clear();
- _caphash.clear();
- _namehash.clear();
- _additionalRequire.clear();
- _additionaConflict.clear();
- _additionaProvide.clear();
- // don't miss to invalidate ResPoolProxy
- invalidateProxy();
- return;
- }
-
- /** erase all resolvables coming from the target */
- void eraseInstalled() const;
-
- public:
- /** Access list of Repositories that contribute ResObjects.
- * Built on demand.
- */
- const KnownRepositories & knownRepositories() const
- {
- if ( ! _knownRepositoriesPtr )
- {
- _knownRepositoriesPtr.reset( new KnownRepositories );
- for_( it, _store.begin(), _store.end() )
- {
- if ( (*it)->repository() != Repository::noRepository )
- {
- _knownRepositoriesPtr->insert( (*it)->repository() );
- }
- }
- }
-
- return *_knownRepositoriesPtr;
- }
-
- public:
- /** \name Save and restore state. */
- //@{
- void SaveState( const ResObject::Kind & kind_r );
-
- void RestoreState( const ResObject::Kind & kind_r );
- //@}
-
- public:
- /** Serial number changing whenever the content
- * (Resolvables or Dependencies) changes. */
- const SerialNumber & serial() const
- { return _serial; }
-
- /** Return the corresponding \ref PoolItem.
- * Pool and sat pool should be in sync. Returns an empty
- * \ref PoolItem if there is no corresponding \ref PoolItem.
- * \see \ref PoolItem::satSolvable.
- */
- PoolItem find( const sat::Solvable & slv_r ) const;
-
- private:
- /** Serial number. */
- SerialNumber _serial;
-
- public:
- ContainerT _store;
- NameHash _namehash;
- CapHash _caphash;
- mutable AdditionalCapabilities _additionalRequire;
- mutable AdditionalCapabilities _additionaConflict;
- mutable AdditionalCapabilities _additionaProvide;
-
- public:
- ResPoolProxy proxy( ResPool self ) const
- {
- if ( !_poolProxy )
- _poolProxy.reset( new ResPoolProxy( self ) );
- return *_poolProxy;
- }
-
- /** Invalidate all data we build on demand.
- * To be called whenever the pools content changes
- */
- void invalidateProxy()
- {
- _serial.setDirty();
- _poolProxy.reset();
- _knownRepositoriesPtr.reset();
- }
-
- mutable shared_ptr<ResPoolProxy> _poolProxy;
-
- private:
- /** Set of known repositories built on demand.
- * Invalidated on any Pool content change. Rebuilt on next access.
- */
- mutable scoped_ptr<KnownRepositories> _knownRepositoriesPtr;
+ mutable shared_ptr<ResPoolProxy> _poolProxy;
+ mutable scoped_ptr<KnownRepositories> _knownRepositoriesPtr;
+
+ public:
+ /** \bug FAKE capindex */
+ const PoolTraits::CapItemContainerT _caphashfake;
};
///////////////////////////////////////////////////////////////////
#include <set>
#include <map>
+#include "zypp/base/Iterator.h"
+
#include "zypp/PoolItem.h"
+#include "zypp/sat/Pool.h"
///////////////////////////////////////////////////////////////////
namespace zypp
class PoolImpl;
- /** */
- struct PoolImplInserter
- {
- void operator()( ResObject::constPtr ptr_r );
-
- PoolImplInserter( PoolImpl & poolImpl_r, bool installed_r )
- : _poolImpl( poolImpl_r )
- , _installed( installed_r )
- {}
- PoolImpl & _poolImpl;
- bool _installed;
- };
-
- /** */
- struct PoolImplDeleter
- {
- void operator()( ResObject::constPtr ptr_r );
-
- PoolImplDeleter( PoolImpl & poolImpl_r )
- : _poolImpl( poolImpl_r )
- {}
- PoolImpl & _poolImpl;
- };
-
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : PoolTraits
struct PoolTraits
{
public:
- /** */
- typedef PoolItem Item;
-
+ typedef sat::detail::SolvableIdType SolvableIdType;
/** pure items */
- typedef std::set<Item> ItemContainerT;
- typedef ItemContainerT::iterator iterator;
- typedef ItemContainerT::const_iterator const_iterator;
+ typedef std::map<sat::Solvable,PoolItem> ItemContainerT;
+ typedef MapKVIteratorTraits<ItemContainerT>::Value_const_iterator
+ const_iterator;
typedef ItemContainerT::size_type size_type;
// internal organization
- typedef std::map<std::string,ItemContainerT> NameItemContainerT;
- /** hashed by name */
- typedef ItemContainerT::const_iterator byName_iterator;
-
- // internal organization
typedef std::list<zypp::CapAndItem> CapItemContainerT; // (why,who) pairs
typedef std::map<std::string,CapItemContainerT> CapItemStoreT; // capability.index -> (why,who) pairs
typedef std::map<Dep,CapItemStoreT> DepCapItemContainerT; // Dep -> (capability.index -> (why,who) pairs)
typedef PoolImpl Impl;
typedef shared_ptr<PoolImpl> Impl_Ptr;
typedef shared_ptr<const PoolImpl> Impl_constPtr;
- typedef PoolImplInserter Inserter;
- typedef PoolImplDeleter Deleter;
/** Map of Capabilities and "who" has set it*/
typedef std::map<ResStatus::TransactByValue,Capabilities> AdditionalCapabilities;