ref: refs/heads/ma-misc
commit 70909e234beffad3b08af5fb7c04537208785754
Author: Michael Andres
Date: Thu Oct 29 14:38:57 2009 +0100
Selectable: Add identicalInstalled tests whether items with same content are already installed.
---
zypp/ui/Selectable.cc | 3 +++
zypp/ui/Selectable.h | 18 ++++++++++++++++++
zypp/ui/SelectableImpl.h | 16 ++++++++++++++++
3 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/zypp/ui/Selectable.cc b/zypp/ui/Selectable.cc
index d6e8858..1c16d94 100644
--- a/zypp/ui/Selectable.cc
+++ b/zypp/ui/Selectable.cc
@@ -79,6 +79,9 @@ namespace zypp
PoolItem Selectable::updateCandidateObj() const
{ return _pimpl->updateCandidateObj(); }
+ bool Selectable::identicalInstalled( const PoolItem & rhs ) const
+ { return _pimpl->identicalInstalled( rhs ); }
+
PoolItem Selectable::setCandidate( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r )
{ return _pimpl->setCandidate( newCandidate_r, causer_r ); }
diff --git a/zypp/ui/Selectable.h b/zypp/ui/Selectable.h
index 92b0bf5..65b2faf 100644
--- a/zypp/ui/Selectable.h
+++ b/zypp/ui/Selectable.h
@@ -140,6 +140,24 @@ namespace zypp
*/
PoolItem updateCandidateObj() const;
+ /** \c True if \a rhs has the same content as an installed one.
+ * Basically the same name, edition, arch, vendor and buildtime.
+ * \see \ref sat::Solvable::identical
+ */
+ bool identicalInstalled( const PoolItem & rhs ) const;
+
+ /** \c True if the \ref candidateObj is installed (same content).
+ * \see \ref identicalInstalled.
+ */
+ bool identicalInstalledCandidate() const
+ { return identicalInstalled( candidateObj() ); }
+
+ /** \c True if the \ref updateCandidateObj is installed (same content).
+ * \see \ref identicalInstalled.
+ */
+ bool identicalInstalledUpdateCandidate() const
+ { return identicalInstalled( updateCandidateObj() ); }
+
/** Return the \ref installedObj resolvable casted to a specific kind.
* \code
diff --git a/zypp/ui/SelectableImpl.h b/zypp/ui/SelectableImpl.h
index c74ed90..7d211b4 100644
--- a/zypp/ui/SelectableImpl.h
+++ b/zypp/ui/SelectableImpl.h
@@ -165,6 +165,22 @@ namespace zypp
return _defaultCandidate;
}
+ /** \c True if \a rhs has the same content as an installed one.
+ * \see \ref sat::Solvable::identical
+ */
+ bool identicalInstalled( const PoolItem & rhs ) const
+ {
+ if ( !installedEmpty() && rhs )
+ {
+ for_( it, _installedItems.begin(), _installedItems.end() )
+ {
+ if ( identical( *it, rhs ) )
+ return true;
+ }
+ }
+ return false;
+ }
+
/** Best among all objects. */
PoolItem theObj() const
{
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org