typedef SelectableTraits::PickList PickList;
public:
- template <class _Iterator>
- Impl( const ResObject::Kind & kind_r,
+ template <class TIterator>
+ Impl( const ResKind & kind_r,
const std::string & name_r,
- _Iterator begin_r,
- _Iterator end_r )
+ TIterator begin_r,
+ TIterator end_r )
: _ident( sat::Solvable::SplitIdent( kind_r, name_r ).ident() )
, _kind( kind_r )
, _name( name_r )
{ return _ident; }
/** */
- ResObject::Kind kind() const
+ ResKind kind() const
{ return _kind; }
/** */
PoolItem candidateObj() const
{
PoolItem ret( transactingCandidate() );
- if ( ret )
- return ret;
- return _candidate ? _candidate : defaultCandidate();
+ if ( ! ret )
+ ret = _candidate ? _candidate : defaultCandidate();
+ return ret;
}
/** Set a userCandidate (out of available objects).
*/
PoolItem candidateObjFrom( Repository repo_r ) const
{
- for_( it, availableBegin(), availableEnd() )
+ for ( const PoolItem & pi : available() )
{
- if ( (*it)->repository() == repo_r )
- return *it;
+ if ( pi.isRetracted() )
+ continue;
+ if ( pi.repository() == repo_r )
+ return pi;
}
return PoolItem();
}
// multiversionInstall: This returns the candidate for the last
// instance installed. Actually we'd need a list here.
- if ( installedEmpty() || ! defaultCand )
+ if ( ! defaultCand || defaultCand.isRetracted() )
+ return PoolItem();
+
+ if ( installedEmpty() )
return defaultCand;
// Here: installed and defaultCand are non NULL and it's not a
// multiversion install.
PoolItem highestAvailableVersionObj() const
{
PoolItem ret;
- for_( it, availableBegin(), availableEnd() )
+ bool retractedOk = false;
+ for ( const PoolItem & pi : available() )
{
- if ( !ret || (*it).satSolvable().edition() > ret.satSolvable().edition() )
- ret = *it;
+ if ( !retractedOk && pi.isRetracted() )
+ {
+ if ( ret )
+ break; // prefer a not retracted candidate
+ retractedOk = true;
+ }
+ if ( !ret || pi.edition() > ret.edition() )
+ ret = pi;
}
return ret;
}
+ /** \copydoc Selectable::identIsAutoInstalled()const */
+ bool identIsAutoInstalled() const
+ { return sat::Solvable::identIsAutoInstalled( ident() ); }
+
/** \copydoc Selectable::identicalAvailable( const PoolItem & )const */
bool identicalAvailable( const PoolItem & rhs ) const
{ return bool(identicalAvailableObj( rhs )); }
available_size_type availableSize() const
{ return _availableItems.size(); }
- available_const_iterator availableBegin() const
+ available_iterator availableBegin() const
{ return _availableItems.begin(); }
- available_const_iterator availableEnd() const
+ available_iterator availableEnd() const
{ return _availableItems.end(); }
+ inline Iterable<available_iterator> available() const
+ { return makeIterable( availableBegin(), availableEnd() ); }
+
////////////////////////////////////////////////////////////////////////
bool installedEmpty() const
installed_iterator installedEnd() const
{ return _installedItems.end(); }
+ inline Iterable<installed_iterator> installed() const
+ { return makeIterable( installedBegin(), installedEnd() ); }
+
////////////////////////////////////////////////////////////////////////
const PickList & picklist() const
{
_picklistPtr.reset( new PickList );
// installed without identical avaialble first:
- for_( it, _installedItems.begin(), _installedItems.end() )
+ for ( const PoolItem & pi : installed() )
{
- if ( ! identicalAvailable( *it ) )
- _picklistPtr->push_back( *it );
+ if ( ! identicalAvailable( pi ) )
+ _picklistPtr->push_back( pi );
}
_picklistPtr->insert( _picklistPtr->end(), availableBegin(), availableEnd() );
}
////////////////////////////////////////////////////////////////////////
+ bool hasRetracted() const
+ { return !_availableItems.empty() && _availableItems.rbegin()->isRetracted(); }
+
+ bool hasRetractedInstalled() const
+ {
+ bool ret = false;
+ if ( hasRetracted() )
+ {
+ for ( const PoolItem & ipi : installed() )
+ {
+ PoolItem pi { identicalAvailableObj( ipi ) };
+ if ( pi && pi.isRetracted() )
+ {
+ ret = true;
+ break;
+ }
+ }
+ }
+ return ret;
+// later if pool index is available:
+// for ( const PoolItem & pi : installed() )
+// if ( pi.isRetracted() )
+// return true;
+// return false;
+ }
+
bool isUnmaintained() const
{ return availableEmpty(); }
bool multiversionInstall() const
- { return sat::Pool::instance().isMultiversion( ident() ); }
+ {
+ for ( const PoolItem & pi : picklist() )
+ {
+ if ( pi.multiversionInstall() )
+ return true;
+ }
+ return false;
+ }
bool pickInstall( const PoolItem & pi_r, ResStatus::TransactByValue causer_r, bool yesno_r );
/** \copydoc Selectable::hasLocks()const */
bool hasLocks() const
{
- for_( it, availableBegin(), availableEnd() )
+ for ( const PoolItem & pi : available() )
{
- const PoolItem & pi( *it );
if ( pi.status().isLocked() )
return true;
}
- for_( it, installedBegin(), installedEnd() )
+ for ( const PoolItem & pi : installed() )
{
- const PoolItem & pi( *it );
if ( pi.status().isLocked() )
return true;
}
private:
PoolItem transactingInstalled() const
{
- for_( it, installedBegin(), installedEnd() )
+ for ( const PoolItem & pi : installed() )
{
- if ( (*it).status().transacts() )
- return (*it);
+ if ( pi.status().transacts() )
+ return pi;
}
return PoolItem();
}
PoolItem transactingCandidate() const
{
- for_( it, availableBegin(), availableEnd() )
+ for ( const PoolItem & pi : available() )
{
- if ( (*it).status().transacts() )
- return (*it);
+ if ( pi.status().transacts() )
+ return pi;
}
return PoolItem();
}
{
// prefer the installed objects arch and vendor
bool solver_allowVendorChange( ResPool::instance().resolver().allowVendorChange() );
- for ( installed_const_iterator iit = installedBegin();
- iit != installedEnd(); ++iit )
+ for ( const PoolItem & ipi : installed() )
{
PoolItem sameArch; // in case there's no same vendor at least stay with same arch.
- for ( available_const_iterator it = availableBegin();
- it != availableEnd(); ++it )
+ for ( const PoolItem & api : available() )
{
// 'same arch' includes allowed changes to/from noarch.
- if ( (*iit)->arch() == (*it)->arch() || (*iit)->arch() == Arch_noarch || (*it)->arch() == Arch_noarch )
+ if ( ipi.arch() == api.arch() || ipi.arch() == Arch_noarch || api.arch() == Arch_noarch )
{
if ( ! solver_allowVendorChange )
{
- if ( VendorAttr::instance().equivalent( (*iit), (*it) ) )
- return *it;
+ if ( VendorAttr::instance().equivalent( ipi, api ) )
+ return api;
else if ( ! sameArch ) // remember best same arch in case no same vendor found
- sameArch = *it;
+ sameArch = api;
}
else // same arch is sufficient
- return *it;
+ return api;
}
}
if ( sameArch )
bool allCandidatesLocked() const
{
- for ( available_const_iterator it = availableBegin();
- it != availableEnd(); ++it )
+ for ( const PoolItem & pi : available() )
{
- if ( ! (*it).status().isLocked() )
+ if ( ! pi.status().isLocked() )
return false;
}
return( ! _availableItems.empty() );
bool allInstalledLocked() const
{
- for ( installed_const_iterator it = installedBegin();
- it != installedEnd(); ++it )
+ for ( const PoolItem & pi : installed() )
{
- if ( ! (*it).status().isLocked() )
+ if ( ! pi.status().isLocked() )
return false;
}
return( ! _installedItems.empty() );
private:
const IdString _ident;
- const ResObject::Kind _kind;
+ const ResKind _kind;
const std::string _name;
InstalledItemSet _installedItems;
AvailableItemSet _availableItems;
{
PoolItem icand( obj.installedObj() );
str << " (I " << obj.installedSize() << ") {" << endl;
- for_( it, obj.installedBegin(), obj.installedEnd() )
+ for ( const PoolItem & pi : obj.installed() )
{
char t = ' ';
- if ( *it == icand )
+ if ( pi == icand )
{
t = 'i';
}
- str << " " << t << " " << *it << endl;
+ str << " " << t << " " << pi << endl;
}
str << "} ";
}
PoolItem cand( obj.candidateObj() );
PoolItem up( obj.updateCandidateObj() );
str << "(A " << obj.availableSize() << ") {" << endl;
- for_( it, obj.availableBegin(), obj.availableEnd() )
+ for ( const PoolItem & pi : obj.available() )
{
char t = ' ';
- if ( *it == cand )
+ if ( pi == cand )
{
- t = *it == up ? 'C' : 'c';
+ t = pi == up ? 'C' : 'c';
}
- else if ( *it == up )
+ else if ( pi == up )
{
t = 'u';
}
- str << " " << t << " " << *it << endl;
+ str << " " << t << " " << pi << endl;
}
str << "} ";
}
PoolItem cand( obj.candidateObj() );
PoolItem up( obj.updateCandidateObj() );
str << "(P " << obj.picklistSize() << ") {" << endl;
- for_( it, obj.picklistBegin(), obj.picklistEnd() )
+ for ( const PoolItem & pi : obj.picklist() )
{
char t = ' ';
- if ( *it == cand )
+ if ( pi == cand )
{
- t = *it == up ? 'C' : 'c';
+ t = pi == up ? 'C' : 'c';
}
- else if ( *it == up )
+ else if ( pi == up )
{
t = 'u';
}
- str << " " << t << " " << *it << "\t" << obj.pickStatus( *it ) << endl;
+ str << " " << t << " " << pi << "\t" << obj.pickStatus( pi ) << endl;
}
str << "} ";
}