Author: mlandres
Date: Fri Apr 11 12:51:59 2008
New Revision: 9531
URL: http://svn.opensuse.org/viewcvs/zypp?rev=9531&view=rev
Log:
- Fix SolvIterMixin to avioid multiple visits of the same Selectable.
- Add Resolvable::poolItem() providing access to the corresponding
PoolItem. API to query isRelevant/isSatisfied/isBroken was moved
to PoolItem.
Modified:
trunk/libzypp/zypp/PoolItem.cc
trunk/libzypp/zypp/PoolItem.h
trunk/libzypp/zypp/Resolvable.cc
trunk/libzypp/zypp/Resolvable.h
trunk/libzypp/zypp/sat/SolvIterMixin.cc
trunk/libzypp/zypp/sat/SolvIterMixin.h
trunk/libzypp/zypp/sat/Solvable.cc
trunk/libzypp/zypp/sat/Solvable.h
Modified: trunk/libzypp/zypp/PoolItem.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PoolItem.cc?rev=9531&r1=9530&r2=9531&view=diff
==============================================================================
--- trunk/libzypp/zypp/PoolItem.cc (original)
+++ trunk/libzypp/zypp/PoolItem.cc Fri Apr 11 12:51:59 2008
@@ -54,20 +54,20 @@
public:
- bool isSatisfied() const
+ bool isRelevant() const
{
- return _resolvable->isSatisfied();
+ return true;
}
- bool isRelevant() const
+ bool isSatisfied() const
{
- return _resolvable->isRelevant();
+ return true;
}
- bool validate() const
+ bool isBroken() const
{
- return _resolvable->validate();
- }
+ return true;
+ }
private:
mutable ResStatus _status;
@@ -194,11 +194,14 @@
ResStatus & PoolItem::statusReset() const
{ return _pimpl->statusReset(); }
+ bool PoolItem::isRelevant() const
+ { return _pimpl->isSatisfied(); }
+
bool PoolItem::isSatisfied() const
{ return _pimpl->isSatisfied(); }
- ResObject::constPtr PoolItem::resolvable() const
- { return _pimpl->resolvable(); }
+ bool PoolItem::isBroken() const
+ { return _pimpl->isSatisfied(); }
void PoolItem::saveState() const
{ _pimpl->saveState(); }
@@ -209,6 +212,9 @@
bool PoolItem::sameState() const
{ return _pimpl->sameState(); }
+ ResObject::constPtr PoolItem::resolvable() const
+ { return _pimpl->resolvable(); }
+
/******************************************************************
**
** FUNCTION NAME : operator<<
Modified: trunk/libzypp/zypp/PoolItem.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PoolItem.h?rev=9531&r1=9530&r2=9531&view=diff
==============================================================================
--- trunk/libzypp/zypp/PoolItem.h (original)
+++ trunk/libzypp/zypp/PoolItem.h Fri Apr 11 12:51:59 2008
@@ -69,30 +69,32 @@
~PoolItem();
public:
+ /** \name Status related methods. */
+ //@{
/** Returns the current status. */
ResStatus & status() const;
/** Reset status. */
ResStatus & statusReset() const;
- /** Whether the items requirements are met. */
- bool isSatisfied() const;
-
- /** Whether the items requirements are broken. */
- bool isBroken() const
- { return ! isSatisfied(); }
- /** Returns true if the solvable is relevant which means e.G. for patches
+ /** \name Status validation.
+ *
+ */
+ //@{
+ /** Returns true if the solvable is relevant which means e.g. for patches
* that at least one package of the patch is installed.
*/
bool isRelevant() const;
- /** Check if the solvable is satisfied,broken or not relevant
- * (not important, so it can be ignored)
- * \return BROKEN, SATISFIED, NOTRELEVANT
- */
- ValidValue validate() const;
+ /** Whether a relevant items requirements are met. */
+ bool isSatisfied() const;
+ /** Whether a relevant items requirements are broken. */
+ bool isBroken() const;
+ //@}
+
+ //@}
public:
/** Return the \ref ResPool the item belongs to. */
ResPool pool() const;
Modified: trunk/libzypp/zypp/Resolvable.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Resolvable.cc?rev=9531&r1=9530&r2=9531&view=diff
==============================================================================
--- trunk/libzypp/zypp/Resolvable.cc (original)
+++ trunk/libzypp/zypp/Resolvable.cc Fri Apr 11 12:51:59 2008
@@ -11,7 +11,8 @@
*/
#include "zypp/Resolvable.h"
#include "zypp/ResObject.h"
-
+#include "zypp/PoolItem.h"
+
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
@@ -37,6 +38,14 @@
///////////////////////////////////////////////////////////////////
//
+ // METHOD NAME : Resolvable::poolItem
+ // METHOD TYPE : PoolItem
+ //
+ PoolItem Resolvable::poolItem() const
+ { return PoolItem( *this ); }
+
+ ///////////////////////////////////////////////////////////////////
+ //
// METHOD NAME : Resolvable::dumpOn
// METHOD TYPE : std::ostream &
//
Modified: trunk/libzypp/zypp/Resolvable.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Resolvable.h?rev=9531&r1=9530&r2=9531&view=diff
==============================================================================
--- trunk/libzypp/zypp/Resolvable.h (original)
+++ trunk/libzypp/zypp/Resolvable.h Fri Apr 11 12:51:59 2008
@@ -30,6 +30,7 @@
{ /////////////////////////////////////////////////////////////////
struct NVRAD;
+ class PoolItem;
///////////////////////////////////////////////////////////////////
//
@@ -82,26 +83,12 @@
//@}
public:
- /** Returns true if the solvable is satisfied */
- using sat::Solvable::isSatisfied;
-
- /** Returns true if the solvable is satisfied */
- using sat::Solvable::isBroken;
-
- /** Returns true if the solvable is relevant which means e.G. for patches
- * that at least one package of the patch is installed.
- */
- using sat::Solvable::isRelevant;
-
- /** Check if the solvable is satisfied,broken or not relevant
- * (not important, so it can be ignored)
- * \return BROKEN, SATISFIED, NOTRELEVANT
- */
- using sat::Solvable::validate;
-
- public:
+ /** Access the corresponding \ref sat:::Solvable. */
const sat::Solvable & satSolvable() const { return *this; }
+ /** Access the corresponding \ref PoolItem. */
+ PoolItem poolItem() const;
+
protected:
/** Ctor */
Resolvable( const sat::Solvable & solvable_r );
Modified: trunk/libzypp/zypp/sat/SolvIterMixin.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/SolvIterMixin.cc?rev=9531&r1=9530&r2=9531&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/SolvIterMixin.cc (original)
+++ trunk/libzypp/zypp/sat/SolvIterMixin.cc Fri Apr 11 12:51:59 2008
@@ -13,6 +13,7 @@
//#include "zypp/base/Logger.h"
#include "zypp/sat/SolvIterMixin.h"
+#include "zypp/sat/Solvable.h"
#include "zypp/ResPoolProxy.h"
using std::endl;
@@ -21,13 +22,29 @@
namespace zypp
{ /////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
- namespace ui
+ namespace sat
{ /////////////////////////////////////////////////////////////////
- Selectable_Ptr asSelectable::operator()( const sat::Solvable & sov_r ) const
+ namespace solvitermixin_detail
+ {
+ bool UnifyByIdent::operator()( const Solvable & solv_r ) const
{
- return ResPool::instance().proxy().lookup( sov_r );
+ return( solv_r && _uset->insert( solv_r.ident().id() ).second );
}
+ }
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace sat
+ ///////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ namespace ui
+ { /////////////////////////////////////////////////////////////////
+
+ Selectable_Ptr asSelectable::operator()( const sat::Solvable & sov_r ) const
+ {
+ return ResPool::instance().proxy().lookup( sov_r );
+ }
/////////////////////////////////////////////////////////////////
} // namespace ui
Modified: trunk/libzypp/zypp/sat/SolvIterMixin.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/SolvIterMixin.h?rev=9531&r1=9530&r2=9531&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/SolvIterMixin.h (original)
+++ trunk/libzypp/zypp/sat/SolvIterMixin.h Fri Apr 11 12:51:59 2008
@@ -16,6 +16,7 @@
#include "zypp/base/PtrTypes.h"
#include "zypp/base/Iterator.h"
+#include "zypp/base/Tr1hash.h"
///////////////////////////////////////////////////////////////////
namespace zypp
@@ -34,6 +35,26 @@
class Solvable;
+ namespace solvitermixin_detail
+ {
+ /** Unify by \c ident \c (kind:name).
+ * Return true on the 1st appearance of a new \c ident. This is
+ * used in \ref SolvIterMixin when mapping a Solvable iterator
+ * to a Selectable iterator.
+ */
+ struct UnifyByIdent
+ {
+ bool operator()( const Solvable & solv_r ) const;
+
+ typedef std::tr1::unordered_set<unsigned> Uset;
+ UnifyByIdent()
+ : _uset( new Uset )
+ {}
+ shared_ptr<Uset> _uset;
+ };
+ } // namespace solvitermixin_detail
+
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : SolvIterMixin