Add 'identical' test whether two Solvables/PoolItems have the same content.
authorMichael Andres <ma@suse.de>
Thu, 29 Oct 2009 13:29:47 +0000 (14:29 +0100)
committerMichael Andres <ma@suse.de>
Thu, 29 Oct 2009 13:29:47 +0000 (14:29 +0100)
Basically same name, edition, arch, vendor and buildtime.

zypp/PoolItem.h
zypp/sat/Solvable.cc
zypp/sat/Solvable.h

index 1d8c60e..d8854da 100644 (file)
@@ -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
index c7bdaf9..7595687 100644 (file)
@@ -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
index 4a3dda9..8de8d9d 100644 (file)
@@ -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
     { /////////////////////////////////////////////////////////////////