ref: refs/heads/master
commit 9ecf8d08d616bff334567649a3782d5916032a6e
Author: Michael Andres
Date: Thu Dec 3 12:05:31 2009 +0100
ui::Selectable: PickList and status interface for multiinstallable items.
---
zypp/ui/Selectable.cc | 16 ++++++++++++++++
zypp/ui/Selectable.h | 43 ++++++++++++++++++++++++++++++++++++++++++-
zypp/ui/SelectableImpl.cc | 7 +++++++
zypp/ui/SelectableImpl.h | 37 ++++++++++++++++++++++++++++++++++++-
zypp/ui/SelectableTraits.h | 6 +++++-
5 files changed, 106 insertions(+), 3 deletions(-)
diff --git a/zypp/ui/Selectable.cc b/zypp/ui/Selectable.cc
index 23e2e19..153c8d4 100644
--- a/zypp/ui/Selectable.cc
+++ b/zypp/ui/Selectable.cc
@@ -132,6 +132,19 @@ namespace zypp
Selectable::installed_iterator Selectable::installedEnd() const
{ return _pimpl->installedEnd(); }
+ ////////////////////////////////////////////////////////////////////////
+
+ bool Selectable::picklistEmpty() const
+ { return _pimpl->picklistEmpty(); }
+
+ Selectable::picklist_size_type Selectable::picklistSize() const
+ { return _pimpl->picklistSize(); }
+
+ Selectable::picklist_iterator Selectable::picklistBegin() const
+ { return _pimpl->picklistBegin(); }
+
+ Selectable::picklist_iterator Selectable::picklistEnd() const
+ { return _pimpl->picklistEnd(); }
////////////////////////////////////////////////////////////////////////
@@ -147,6 +160,9 @@ namespace zypp
bool Selectable::pickDelete( const PoolItem & pi_r, ResStatus::TransactByValue causer_r, bool yesno_r )
{ return _pimpl->pickDelete( pi_r, causer_r, yesno_r ); }
+ Status Selectable::pickStatus( const PoolItem & pi_r ) const
+ { return _pimpl->pickStatus( pi_r ); }
+
////////////////////////////////////////////////////////////////////////
bool Selectable::isUndetermined() const
diff --git a/zypp/ui/Selectable.h b/zypp/ui/Selectable.h
index 9be8a75..4826d7c 100644
--- a/zypp/ui/Selectable.h
+++ b/zypp/ui/Selectable.h
@@ -64,6 +64,9 @@ namespace zypp
typedef SelectableTraits::installed_iterator installed_iterator;
typedef SelectableTraits::installed_size_type installed_size_type;
+ typedef SelectableTraits::picklist_iterator picklist_iterator;
+ typedef SelectableTraits::picklist_size_type picklist_size_type;
+
public:
/** \name Static ctor substitues picking the item from the pool.
* \code
@@ -233,7 +236,7 @@ namespace zypp
////////////////////////////////////////////////////////////////////////
- /** \name Insatlled objects iterators.
+ /** \name Installed objects iterators.
* Ordered by install time. Latest first.
*/
//@{
@@ -245,6 +248,19 @@ namespace zypp
////////////////////////////////////////////////////////////////////////
+ /** \name picklist iterators.
+ * This is basically the available items list prepended by those
+ * installed items, that are nolonger \ref identicalAvailable.
+ */
+ //@{
+ bool picklistEmpty() const;
+ picklist_size_type picklistSize() const;
+ picklist_iterator picklistBegin() const;
+ picklist_iterator picklistEnd() const;
+ //}
+
+ ////////////////////////////////////////////////////////////////////////
+
public:
/** \name Query for objects within this Selectable.
*/
@@ -309,6 +325,31 @@ namespace zypp
*/
bool pickNoDelete( const PoolItem & pi_r, ResStatus::TransactByValue causer_r = ResStatus::USER )
{ return pickDelete( pi_r, causer_r, false ); }
+
+ /** Compute the \ref ui::Status for an individual PoolItem.
+ * This just takes into account the item and any identical
+ * installed (or available) one.
+ * \code
+ * Assume there are 3 identical 'foo-1.1 (vendor A)' items,
+ * one 'foo-2.1 (vendor A)' and one ''foo-1.1 (vendor B)':
+ *
+ * installed: . foo-1.1 (vendor A) -> S_KeepInstalled
+ * available: foo-2.1 (vendor A) (repo 1) -> S_NoInst
+ * . foo-1.1 (vendor A) (repo 1) -> S_KeepInstalled
+ * . foo-1.1 (vendor A) (repo 2) -> S_KeepInstalled
+ * foo-1.1 (vendor B) (repo 3) -> S_NoInst
+ *
+ * After 'foo-1.1 (vendor A) (repo 1)' was selected to be installed:
+ *
+ * installed: . foo-1.1 (vendor A) -> S_Update
+ * available: foo-2.1 (vendor A) (repo 1) -> S_NoInst
+ * I foo-1.1 (vendor A) (repo 1) -> S_Update
+ * . foo-1.1 (vendor A) (repo 2) -> S_KeepInstalled
+ * foo-1.1 (vendor B) (repo 3) -> S_NoInst
+ * \endcode
+ * \see \ref sat::Solvable::identical
+ */
+ Status pickStatus( const PoolItem & pi_r ) const;
//@}
/** \name Classification of available patches (pseudo installed items).
diff --git a/zypp/ui/SelectableImpl.cc b/zypp/ui/SelectableImpl.cc
index ab82c6a..8a118ef 100644
--- a/zypp/ui/SelectableImpl.cc
+++ b/zypp/ui/SelectableImpl.cc
@@ -323,6 +323,7 @@ namespace zypp
return _candidate = newCandidate;
}
+
bool Selectable::Impl::pickInstall( const PoolItem & pi_r, ResStatus::TransactByValue causer_r, bool yesno_r )
{
if ( pi_r.satSolvable().ident() != ident() || pi_r.satSolvable().isSystem() )
@@ -339,6 +340,12 @@ namespace zypp
return pi_r.status().setTransact( yesno_r, causer_r );
}
+ Status Selectable::Impl::pickStatus( const PoolItem & pi_r ) const
+ {
+ return status();
+ }
+
+
ResStatus::TransactByValue Selectable::Impl::modifiedBy() const
{
PoolItem cand( candidateObj() );
diff --git a/zypp/ui/SelectableImpl.h b/zypp/ui/SelectableImpl.h
index 85ec1a3..f8f1fd5 100644
--- a/zypp/ui/SelectableImpl.h
+++ b/zypp/ui/SelectableImpl.h
@@ -52,6 +52,8 @@ namespace zypp
typedef SelectableTraits::installed_const_iterator installed_const_iterator;
typedef SelectableTraits::installed_size_type installed_size_type;
+ typedef SelectableTraits::PickList PickList;
+
public:
template <class _Iterator>
Impl( const ResObject::Kind & kind_r,
@@ -247,6 +249,36 @@ namespace zypp
////////////////////////////////////////////////////////////////////////
+ const PickList & picklist() const
+ {
+ if ( ! _picklistPtr )
+ {
+ _picklistPtr.reset( new PickList( _availableItems.size() ) );
+ // installed without identical avaialble first:
+ for_( it, _installedItems.begin(), _installedItems.end() )
+ {
+ if ( ! identicalAvailable( *it ) )
+ _picklistPtr->push_back( *it );
+ }
+ _picklistPtr->insert( _picklistPtr->end(), availableBegin(), availableEnd() );
+ }
+ return *_picklistPtr;
+ }
+
+ bool picklistEmpty() const
+ { return picklist().empty(); }
+
+ picklist_size_type picklistSize() const
+ { return picklist().size(); }
+
+ picklist_iterator picklistBegin() const
+ { return picklist().begin(); }
+
+ picklist_iterator picklistEnd() const
+ { return picklist().end(); }
+
+ ////////////////////////////////////////////////////////////////////////
+
bool isUnmaintained() const
{ return availableEmpty(); }
@@ -257,6 +289,8 @@ namespace zypp
bool pickDelete( const PoolItem & pi_r, ResStatus::TransactByValue causer_r, bool yesno_r );
+ Status pickStatus( const PoolItem & pi_r ) const;
+
////////////////////////////////////////////////////////////////////////
bool isUndetermined() const
@@ -368,9 +402,10 @@ namespace zypp
AvailableItemSet _availableItems;
//! Best among availabe with restpect to installed.
PoolItem _defaultCandidate;
-
//! The object selected by setCandidateObj() method.
PoolItem _candidate;
+ //! lazy initialized picklist
+ mutable scoped_ptr<PickList> _picklistPtr;
};
///////////////////////////////////////////////////////////////////
diff --git a/zypp/ui/SelectableTraits.h b/zypp/ui/SelectableTraits.h
index 298994f..9ad8102 100644
--- a/zypp/ui/SelectableTraits.h
+++ b/zypp/ui/SelectableTraits.h
@@ -13,6 +13,7 @@
#define ZYPP_UI_SELECTABLETRAITS_H
#include <set>
+#include <vector>
#include "zypp/base/Iterator.h"
#include "zypp/PoolItem.h"
@@ -114,7 +115,10 @@ namespace zypp
typedef AvailableItemSet::const_iterator installed_const_iterator;
typedef AvailableItemSet::size_type installed_size_type;
- };
+ typedef std::vector<PoolItem> PickList;
+ typedef PickList::const_iterator picklist_iterator;
+ typedef PickList::size_type picklist_size_type;
+ };
///////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org