ref: refs/heads/ma-misc
commit 1606b996f1f82bb9d1da6b0fd341c9058305dfe2
Author: Michael Andres
Date: Thu Oct 29 14:29:47 2009 +0100
Add 'identical' test whether two Solvables/PoolItems have the same content.
Basically same name, edition, arch, vendor and buildtime.
---
zypp/PoolItem.h | 14 ++++++++++++++
zypp/sat/Solvable.cc | 6 ++++++
zypp/sat/Solvable.h | 10 ++++++++++
3 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/zypp/PoolItem.h b/zypp/PoolItem.h
index 1d8c60e..d8854da 100644
--- a/zypp/PoolItem.h
+++ b/zypp/PoolItem.h
@@ -184,6 +184,20 @@ namespace zypp
inline bool operator!=( const ResObject::constPtr & lhs, const PoolItem & rhs )
{ return ! (lhs==rhs); }
+
+ /** \relates PoolItem Test for same content. */
+ inline bool identical( const PoolItem & lhs, const PoolItem & rhs )
+ { return lhs.satSolvable().identical( rhs.satSolvable() ); }
+
+ /** \relates PoolItem Test for same content. */
+ inline bool identical( const PoolItem & lhs, sat::Solvable rhs )
+ { return lhs.satSolvable().identical( rhs ); }
+
+ /** \relates PoolItem Test for same content. */
+ inline bool identical( sat::Solvable lhs, const PoolItem & rhs )
+ { return lhs.identical( rhs.satSolvable() ); }
+
+
/** Solvable to PoolItem transform functor.
* \relates PoolItem
* \relates sat::SolvIterMixin
diff --git a/zypp/sat/Solvable.cc b/zypp/sat/Solvable.cc
index c7bdaf9..7595687 100644
--- a/zypp/sat/Solvable.cc
+++ b/zypp/sat/Solvable.cc
@@ -483,6 +483,12 @@ namespace zypp
IdString( _solvable->arch ).c_str() );
}
+ bool Solvable::identical( Solvable rhs ) const
+ {
+ NO_SOLVABLE_RETURN( ! rhs.get() );
+ ::_Solvable * rhssolvable( rhs.get() );
+ return rhssolvable && ::solvable_identical( _solvable, rhssolvable );
+ }
///////////////////////////////////////////////////////////////////
namespace
diff --git a/zypp/sat/Solvable.h b/zypp/sat/Solvable.h
index 4a3dda9..8de8d9d 100644
--- a/zypp/sat/Solvable.h
+++ b/zypp/sat/Solvable.h
@@ -180,6 +180,11 @@ namespace zypp
*/
std::string asString() const;
+ /** Test whether two Solvables have the same content.
+ * Basically the same name, edition, arch, vendor and buildtime.
+ */
+ bool identical( Solvable rhs ) const;
+
public:
/** \name Access to the \ref Solvable dependencies.
@@ -291,6 +296,11 @@ namespace zypp
inline bool operator<( const Solvable & lhs, const Solvable & rhs )
{ return lhs.get() < rhs.get(); }
+ /** \relates Solvable Test for same content. */
+ inline bool identical( Solvable lhs, Solvable rhs )
+ { return lhs.identical( rhs ); }
+
+
///////////////////////////////////////////////////////////////////
namespace detail
{ /////////////////////////////////////////////////////////////////
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org