Author: mlandres
Date: Fri Feb 8 18:46:51 2008
New Revision: 8580
URL: http://svn.opensuse.org/viewcvs/zypp?rev=8580&view=rev
Log:
avoid map in PoolImpl
Modified:
branches/tmp/ma/jump_sat/libzypp/zypp/PoolItem.h
branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.cc
branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.h
branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolImpl.cc
branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolImpl.h
branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolTraits.h
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/PoolItem.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/PoolItem.h?rev=8580&r1=8579&r2=8580&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/PoolItem.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/PoolItem.h Fri Feb 8 18:46:51 2008
@@ -64,9 +64,9 @@
/** Returns the current status. */
ResStatus & status() const;
- /** Reset status (applies autoprotection). */
+ /** Reset status. */
ResStatus & statusReset() const;
-
+
/** Returns the ResObject::constPtr.
* \see \ref operator->
*/
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.cc?rev=8580&r1=8579&r2=8580&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.cc Fri Feb 8 18:46:51 2008
@@ -16,6 +16,7 @@
#include "zypp/ResPool.h"
#include "zypp/pool/PoolImpl.h"
+#include "zypp/pool/PoolStats.h"
using std::endl;
@@ -61,12 +62,6 @@
ResPool::size_type ResPool::size() const
{ return _pimpl->size(); }
- ResPool::const_iterator ResPool::begin() const
- { return _pimpl->begin(); }
-
- ResPool::const_iterator ResPool::end() const
- { return _pimpl->end(); }
-
PoolItem ResPool::find( const sat::Solvable & slv_r ) const
{ return _pimpl->find( slv_r ); }
@@ -103,6 +98,9 @@
ResPool::AdditionalCapabilities & ResPool::additionaProvide() const
{ return _pimpl->additionaProvide(); }
+ const pool::PoolTraits::ItemContainerT & ResPool::store() const
+ { return _pimpl->store(); }
+
/******************************************************************
**
** FUNCTION NAME : operator<<
@@ -110,7 +108,8 @@
*/
std::ostream & operator<<( std::ostream & str, const ResPool & obj )
{
- return str << *obj._pimpl;
+ dumpPoolStats( str << "ResPool " << sat::Pool::instance() << endl << " ",
+ obj.begin(), obj.end() );
}
/////////////////////////////////////////////////////////////////
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.h?rev=8580&r1=8579&r2=8580&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.h Fri Feb 8 18:46:51 2008
@@ -28,6 +28,8 @@
class SerialNumber;
class ResPoolProxy;
+
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : ResPool
@@ -46,175 +48,192 @@
{
friend std::ostream & operator<<( std::ostream & str, const ResPool & obj );
- public:
- /** \ref PoolItem */
- typedef PoolItem value_type;
- typedef pool::PoolTraits::size_type size_type;
- typedef pool::PoolTraits::const_iterator const_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();
-
- /** preliminary */
- ResPoolProxy proxy() const;
-
- public:
- /** The pools serial number. Changing whenever the
- * whenever the content changes. (Resolvables or
- * Dependencies).
- */
- const SerialNumber & serial() const;
-
- public:
- /** */
- bool empty() const;
- /** */
- size_type size() const;
-
- /** \name Iterate through all ResObjects (all kinds). */
- //@{
- /** */
- const_iterator begin() const;
- /** */
- const_iterator end() 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_iterator;
-
- 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 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 ); }
- //@}
-
- public:
- /** \name Iterate through all ResObjects with a certain name (all kinds). */
- //@{
- typedef zypp::resfilter::ByName ByName;
- typedef filter_iterator byName_iterator;
-
- 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:
- /** \name Iterate through all ResObjects which have at least
- * one Capability with index \a index_r in dependency \a depType_r.
- */
- //@{
- byCapabilityIndex_iterator byCapabilityIndexBegin( const std::string & index_r, Dep depType_r ) const;
-
- byCapabilityIndex_iterator byCapabilityIndexEnd( const std::string & index_r, Dep depType_r ) const;
- //@}
-
- public:
- /** \name Iterate through all Repositories that contribute ResObjects.
- */
- //@{
- size_type knownRepositoriesSize() const;
-
- repository_iterator knownRepositoriesBegin() const;
-
- repository_iterator knownRepositoriesEnd() const;
- //@}
-
- public:
- /** \name Handling addition capabilities in the pool in order for solving it in
- * a solver run. This is used for tasks like needing a package with the name "foo".
- * The solver has to evaluate a proper package by his own.
- *
- * CAUTION: This has another semantic in the solver. The required resolvable has
- * been set for installation (in the pool) only AFTER a solver run.
- */
-
- /**
- * Handling additional requirement. E.G. need package "foo" and package
- * "foo1" which has a greater version than 1.0:
- *
- * \code
- * Capabilities capset;
- * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
- * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo1 > 1.0"));
- *
- * // The user is setting this capablility
- * ResPool::AdditionalCapabilities aCapabilities;
- * aCapabilities[ResStatus::USER] = capset;
- *
- * setAdditionalRequire( aCapabilities );
- * \endcode
- */
- void setAdditionalRequire( const AdditionalCapabilities & capset ) const;
- AdditionalCapabilities & additionalRequire() const;
-
- /**
- * Handling additional conflicts. E.G. do not install anything which provides "foo":
- *
- * \code75
- * Capabilities capset;
- * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
- *
- * // The user is setting this capablility
- * ResPool::AdditionalCapabilities aCapabilities;
- * aCapabilities[ResStatus::USER] = capset;
- *
- * setAdditionalConflict( aCapabilities );
- * \endcode
- */
- void setAdditionalConflict( const AdditionalCapabilities & capset ) const;
- AdditionalCapabilities & additionaConflict() const;
-
- /**
- * Handling additional provides. This is used for ignoring a requirement.
- * e.G. Do ignore the requirement "foo":
- *
- * \code
- * Capabilities capset;
- * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
- *
- * // The user is setting this capablility
- * ResPool::AdditionalCapabilities aCapabilities;
- * aCapabilities[ResStatus::USER] = capset;
- *
- * setAdditionalProvide( aCapabilities );
- * \endcode
- */
- void setAdditionalProvide( const AdditionalCapabilities & capset ) const;
- AdditionalCapabilities & additionaProvide() const;
-
- private:
- /** Ctor */
- ResPool( pool::PoolTraits::Impl_constPtr impl_r );
- /** Const access to implementation. */
- pool::PoolTraits::Impl_constPtr _pimpl;
+ public:
+ /** \ref PoolItem */
+ typedef PoolItem value_type;
+ typedef pool::PoolTraits::size_type size_type;
+ typedef pool::PoolTraits::const_iterator const_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();
+
+ /** preliminary */
+ ResPoolProxy proxy() const;
+
+ public:
+ /** The pools serial number. Changing whenever the
+ * whenever the content changes. (Resolvables or
+ * Dependencies).
+ */
+ const SerialNumber & serial() const;
+
+ public:
+ /** */
+ bool empty() const;
+ /** */
+ size_type size() const;
+
+ /** \name Iterate through all ResObjects (all kinds). */
+ //@{
+ /** */
+ const_iterator begin() const
+ { return make_filter_begin( pool::ByPoolItem(), store() ); }
+ /** */
+ const_iterator end() const
+ { return make_filter_end( pool::ByPoolItem(), store() ); }
+ //@}
+
+ 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 name and kind. */
+ //@{
+ template<class _Filter>
+ filter_iterator<_Filter,const_iterator> filterBegin( const _Filter & filter_r ) const
+ { return make_filter_begin( filter_r, *this ); }
+
+ template<class _Filter>
+ filter_iterator<_Filter,const_iterator> filterEnd( const _Filter & filter_r ) const
+ { return make_filter_end( filter_r, *this ); }
+ //@}
+
+ public:
+ /** \name Iterate through all ResObjects of a certain kind. */
+ //@{
+ typedef zypp::resfilter::ByKind ByKind;
+ typedef filter_iterator byKind_iterator;
+
+ 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 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 ); }
+ //@}
+
+ public:
+ /** \name Iterate through all ResObjects with a certain name (all kinds). */
+ //@{
+ typedef zypp::resfilter::ByName ByName;
+ typedef filter_iterator byName_iterator;
+
+ 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:
+ /** \name Iterate through all ResObjects which have at least
+ * one Capability with index \a index_r in dependency \a depType_r.
+ */
+ //@{
+ byCapabilityIndex_iterator byCapabilityIndexBegin( const std::string & index_r, Dep depType_r ) const;
+
+ byCapabilityIndex_iterator byCapabilityIndexEnd( const std::string & index_r, Dep depType_r ) const;
+ //@}
+
+ public:
+ /** \name Iterate through all Repositories that contribute ResObjects.
+ */
+ //@{
+ size_type knownRepositoriesSize() const;
+
+ repository_iterator knownRepositoriesBegin() const;
+
+ repository_iterator knownRepositoriesEnd() const;
+ //@}
+
+ public:
+ /** \name Handling addition capabilities in the pool in order for solving it in
+ * a solver run. This is used for tasks like needing a package with the name "foo".
+ * The solver has to evaluate a proper package by his own.
+ *
+ * CAUTION: This has another semantic in the solver. The required resolvable has
+ * been set for installation (in the pool) only AFTER a solver run.
+ */
+
+ /**
+ * Handling additional requirement. E.G. need package "foo" and package
+ * "foo1" which has a greater version than 1.0:
+ *
+ * \code
+ * Capabilities capset;
+ * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
+ * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo1 > 1.0"));
+ *
+ * // The user is setting this capablility
+ * ResPool::AdditionalCapabilities aCapabilities;
+ * aCapabilities[ResStatus::USER] = capset;
+ *
+ * setAdditionalRequire( aCapabilities );
+ * \endcode
+ */
+ void setAdditionalRequire( const AdditionalCapabilities & capset ) const;
+ AdditionalCapabilities & additionalRequire() const;
+
+ /**
+ * Handling additional conflicts. E.G. do not install anything which provides "foo":
+ *
+ * \code75
+ * Capabilities capset;
+ * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
+ *
+ * // The user is setting this capablility
+ * ResPool::AdditionalCapabilities aCapabilities;
+ * aCapabilities[ResStatus::USER] = capset;
+ *
+ * setAdditionalConflict( aCapabilities );
+ * \endcode
+ */
+ void setAdditionalConflict( const AdditionalCapabilities & capset ) const;
+ AdditionalCapabilities & additionaConflict() const;
+
+ /**
+ * Handling additional provides. This is used for ignoring a requirement.
+ * e.G. Do ignore the requirement "foo":
+ *
+ * \code
+ * Capabilities capset;
+ * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
+ *
+ * // The user is setting this capablility
+ * ResPool::AdditionalCapabilities aCapabilities;
+ * aCapabilities[ResStatus::USER] = capset;
+ *
+ * setAdditionalProvide( aCapabilities );
+ * \endcode
+ */
+ void setAdditionalProvide( const AdditionalCapabilities & capset ) const;
+ AdditionalCapabilities & additionaProvide() const;
+
+ private:
+ const pool::PoolTraits::ItemContainerT & store() const;
+
+ private:
+ /** Ctor */
+ ResPool( pool::PoolTraits::Impl_constPtr impl_r );
+ /** Const access to implementation. */
+ pool::PoolTraits::Impl_constPtr _pimpl;
};
///////////////////////////////////////////////////////////////////
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolImpl.cc?rev=8580&r1=8579&r2=8580&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolImpl.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolImpl.cc Fri Feb 8 18:46:51 2008
@@ -13,7 +13,6 @@
#include "zypp/base/LogTools.h"
#include "zypp/pool/PoolImpl.h"
-#include "zypp/pool/PoolStats.h"
#include "zypp/Package.h"
#include "zypp/VendorAttr.h"
@@ -57,17 +56,6 @@
PoolImpl::~PoolImpl()
{}
- /******************************************************************
- **
- ** FUNCTION NAME : operator<<
- ** FUNCTION TYPE : std::ostream &
- */
- std::ostream & operator<<( std::ostream & str, const PoolImpl & obj )
- {
- return dumpPoolStats( str << "ResPool " << obj.satpool() << endl << " ",
- obj.begin(), obj.end() );
- }
-
/////////////////////////////////////////////////////////////////
} // namespace pool
///////////////////////////////////////////////////////////////////
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolImpl.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolImpl.h?rev=8580&r1=8579&r2=8580&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolImpl.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolImpl.h Fri Feb 8 18:46:51 2008
@@ -24,6 +24,8 @@
#include "zypp/sat/Pool.h"
+using std::endl;
+
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
@@ -78,14 +80,6 @@
size_type size() const
{ return satpool().solvablesSize(); }
- /** */
- const_iterator begin() const
- { return make_map_value_begin( store() ); }
-
- /** */
- const_iterator end() const
- { return make_map_value_end( store() ); }
-
public:
/** Return the corresponding \ref PoolItem.
* Pool and sat pool should be in sync. Returns an empty
@@ -94,11 +88,7 @@
*/
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();
+ return store()[slv_r.id()];
}
///////////////////////////////////////////////////////////////////
@@ -180,13 +170,11 @@
if ( ! _knownRepositoriesPtr )
{
_knownRepositoriesPtr.reset( new KnownRepositories );
- const ContainerT & c( store() );
- for_( it, c.begin(), c.end() )
+
+ sat::Pool pool( satpool() );
+ for_( it, pool.reposBegin(), pool.reposEnd() )
{
- if ( (*it).second->repository() != Repository::noRepository )
- {
- _knownRepositoriesPtr->insert( (*it).second->repository() );
- }
+ _knownRepositoriesPtr->push_back( Repository( it->info() ) );
}
}
return *_knownRepositoriesPtr;
@@ -195,12 +183,32 @@
///////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////
- private:
+ public:
const ContainerT & store() const
{
checkSerial();
if ( _storeDirty )
{
+ sat::Pool pool( satpool() );
+
+ if ( pool.capacity() != _store.capacity() )
+ {
+ _store.resize( pool.capacity() );
+ }
+
+ if ( pool.capacity() )
+ {
+ for ( sat::detail::SolvableIdType i = pool.capacity()-1; i != 0; --i )
+ {
+ sat::Solvable s( i );
+ PoolItem & pi( _store[i] );
+ if ( ! s && pi )
+ pi = PoolItem();
+ else if ( s && ! pi )
+ pi = PoolItem( s );
+ }
+ }
+#if 0
// pass 1: delete no longer existing solvables
for ( ContainerT::iterator it = _store.begin(); it != _store.end(); /**/ )
{
@@ -223,7 +231,7 @@
}
}
}
-
+#endif
_storeDirty = false;
}
return _store;
@@ -266,9 +274,6 @@
};
///////////////////////////////////////////////////////////////////
- /** \relates PoolImpl Stream output */
- std::ostream & operator<<( std::ostream & str, const PoolImpl & obj );
-
/////////////////////////////////////////////////////////////////
} // namespace pool
///////////////////////////////////////////////////////////////////
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolTraits.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolTraits.h?rev=8580&r1=8579&r2=8580&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolTraits.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolTraits.h Fri Feb 8 18:46:51 2008
@@ -33,6 +33,12 @@
class PoolImpl;
+ struct ByPoolItem
+ {
+ bool operator()( const PoolItem & pi ) const
+ { return pi; }
+ };
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : PoolTraits
@@ -43,9 +49,15 @@
public:
typedef sat::detail::SolvableIdType SolvableIdType;
/** pure items */
- typedef std::mapsat::Solvable,PoolItem ItemContainerT;
- typedef MapKVIteratorTraits<ItemContainerT>::Value_const_iterator
- const_iterator;
+#if 0
+ typedef std::mapsat::Solvable,PoolItem ItemContainerT;
+ typedef MapKVIteratorTraits<ItemContainerT>::Value_const_iterator
+ const_iterator;
+#endif
+ typedef std::vector<PoolItem> ItemContainerT;
+ typedef ItemContainerT::const_iterator item_iterator;
+ typedef filter_iterator
+ const_iterator;
typedef ItemContainerT::size_type size_type;
// internal organization
@@ -60,7 +72,7 @@
typedef const_capitemiterator byCapabilityIndex_iterator;
/* list of known Repositories */
- typedef std::set<Repository> RepoContainerT;
+ typedef std::list<Repository> RepoContainerT;
typedef RepoContainerT::const_iterator repository_iterator;
typedef PoolImpl Impl;
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org