# See './mkChangelog -h' for help.
#
SET(LIBZYPP_MAJOR "15")
-SET(LIBZYPP_COMPATMINOR "10")
-SET(LIBZYPP_MINOR "10")
+SET(LIBZYPP_COMPATMINOR "11")
+SET(LIBZYPP_MINOR "11")
SET(LIBZYPP_PATCH "0")
#
-# LAST RELEASED: 15.10.0 (10)
+# LAST RELEASED: 15.11.0 (11)
# (The number in parenthesis is LIBZYPP_COMPATMINOR)
#=======
-------------------------------------------------------------------
+Mon Aug 10 16:22:06 CEST 2015 - ma@suse.de
+
+- Make multiversion an individual solvables property (FATE#318778)
+- SolvableType: common api to access solvable properties
+- Support for MIPS architectures
+- version 15.11.0 (11)
+
+-------------------------------------------------------------------
+Sun Aug 9 01:13:24 CEST 2015 - ma@suse.de
+
+- Update zypp-po.tar.bz2
+
+-------------------------------------------------------------------
+Sun Aug 2 01:13:27 CEST 2015 - ma@suse.de
+
+- Update zypp-po.tar.bz2
+
+-------------------------------------------------------------------
Thu Jul 30 16:13:49 CEST 2015 - ma@suse.de
- Resolver: Track changed requested locales and adjust installed
DEF_BUILTIN( sh4 );
DEF_BUILTIN( sh4a );
- DEF_BUILTIN(m68k);
+ DEF_BUILTIN( m68k );
+
+ DEF_BUILTIN( mips );
+ DEF_BUILTIN( mipsel );
+ DEF_BUILTIN( mips64 );
+ DEF_BUILTIN( mips64el );
#undef DEF_BUILTIN
///////////////////////////////////////////////////////////////////
defCompatibleWith( _sh4(), _noarch() );
defCompatibleWith( _sh4a(), _noarch(),_sh4() );
- defCompatibleWith(_m68k(), _noarch());
+ defCompatibleWith( _m68k(), _noarch() );
+
+ defCompatibleWith( _mips(), _noarch() );
+ defCompatibleWith( _mipsel(), _noarch() );
+ defCompatibleWith( _mips64(), _noarch() );
+ defCompatibleWith( _mips64el(), _noarch() );
//
///////////////////////////////////////////////////////////////////
// dumpOn( USR ) << endl;
/** \relates Arch */
extern const Arch Arch_m68k;
+
+ /** \relates Arch */
+ extern const Arch Arch_mips;
+ /** \relates Arch */
+ extern const Arch Arch_mipsel;
+ /** \relates Arch */
+ extern const Arch Arch_mips64;
+ /** \relates Arch */
+ extern const Arch Arch_mips64el;
//@}
///////////////////////////////////////////////////////////////////
base/Functional.h
base/Gettext.h
base/GzStream.h
+ base/Hash.h
base/IOStream.h
base/InputStream.h
+ base/Iterable.h
base/Iterator.h
base/Json.h
base/LogControl.h
base/StrMatcher.h
base/Regex.h
base/Sysconfig.h
- base/Tr1hash.h
base/TypeTraits.h
base/Unit.h
base/ValueTransform.h
sat/Pool.h
sat/Solvable.h
sat/SolvableSet.h
+ sat/SolvableType.h
sat/SolvIterMixin.h
sat/Map.h
sat/Queue.h
class ByKind
{
public:
+ ByKind()
+ {}
+
ByKind( const ResKind & kind_r )
: _kind( kind_r )
{}
{
void operator()(const PoolQuery& query) const
{
- for_( it,query.begin(),query.end() )
+ for ( const PoolItem & item : query.poolItem() )
{
- PoolItem item(*it);
item.status().setLock(true,ResStatus::USER);
- DBG << "lock "<< item.resolvable()->name();
+ DBG << "lock "<< item.name();
}
}
};
return sat::Solvable( _buddy );
}
- void setBuddy( sat::Solvable solv_r );
+ void setBuddy( const sat::Solvable & solv_r );
ResObject::constPtr resolvable() const
{ return _resolvable; }
return str;
}
- inline void PoolItem::Impl::setBuddy( sat::Solvable solv_r )
+ inline void PoolItem::Impl::setBuddy( const sat::Solvable & solv_r )
{
PoolItem myBuddy( solv_r );
if ( myBuddy )
}
///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : PoolItem
- //
+ // class PoolItem
///////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : PoolItem::PoolItem
- // METHOD TYPE : Ctor
- //
PoolItem::PoolItem()
: _pimpl( Impl::nullimpl() )
{}
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : PoolItem::PoolItem
- // METHOD TYPE : Ctor
- //
PoolItem::PoolItem( const sat::Solvable & solvable_r )
: _pimpl( ResPool::instance().find( solvable_r )._pimpl )
{}
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : PoolItem::PoolItem
- // METHOD TYPE : Ctor
- //
PoolItem::PoolItem( const ResObject::constPtr & resolvable_r )
: _pimpl( ResPool::instance().find( resolvable_r )._pimpl )
{}
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : PoolItem::PoolItem
- // METHOD TYPE : Ctor
- //
PoolItem::PoolItem( Impl * implptr_r )
: _pimpl( implptr_r )
{}
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : PoolItem::makePoolItem
- // METHOD TYPE : PoolItem
- //
PoolItem PoolItem::makePoolItem( const sat::Solvable & solvable_r )
{
return PoolItem( new Impl( makeResObject( solvable_r ), solvable_r.isSystem() ) );
}
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : PoolItem::~PoolItem
- // METHOD TYPE : Dtor
- //
PoolItem::~PoolItem()
{}
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : PoolItem::pool
- // METHOD TYPE : ResPool
- //
ResPool PoolItem::pool() const
{ return ResPool::instance(); }
- ///////////////////////////////////////////////////////////////////
- //
- // Forward to Impl:
- //
- ///////////////////////////////////////////////////////////////////
-
- ResStatus & PoolItem::status() const
- { return _pimpl->status(); }
-
- ResStatus & PoolItem::statusReset() const
- { return _pimpl->statusReset(); }
-
- sat::Solvable PoolItem::buddy() const
- { return _pimpl->buddy(); }
-
- void PoolItem::setBuddy( sat::Solvable solv_r )
- { _pimpl->setBuddy( solv_r ); }
- bool PoolItem::isUndetermined() const
- { return _pimpl->isUndetermined(); }
+ ResStatus & PoolItem::status() const { return _pimpl->status(); }
+ ResStatus & PoolItem::statusReset() const { return _pimpl->statusReset(); }
+ sat::Solvable PoolItem::buddy() const { return _pimpl->buddy(); }
+ void PoolItem::setBuddy( const sat::Solvable & solv_r ) { _pimpl->setBuddy( solv_r ); }
+ bool PoolItem::isUndetermined() const { return _pimpl->isUndetermined(); }
+ bool PoolItem::isRelevant() const { return _pimpl->isRelevant(); }
+ bool PoolItem::isSatisfied() const { return _pimpl->isSatisfied(); }
+ bool PoolItem::isBroken() const { return _pimpl->isBroken(); }
+ bool PoolItem::isNeeded() const { return _pimpl->isNeeded(); }
+ bool PoolItem::isUnwanted() const { return _pimpl->isUnwanted(); }
+ void PoolItem::saveState() const { _pimpl->saveState(); }
+ void PoolItem::restoreState() const { _pimpl->restoreState(); }
+ bool PoolItem::sameState() const { return _pimpl->sameState(); }
+ ResObject::constPtr PoolItem::resolvable() const { return _pimpl->resolvable(); }
- bool PoolItem::isRelevant() const
- { return _pimpl->isRelevant(); }
- bool PoolItem::isSatisfied() const
- { return _pimpl->isSatisfied(); }
-
- bool PoolItem::isBroken() const
- { return _pimpl->isBroken(); }
-
- bool PoolItem::isNeeded() const
- { return _pimpl->isNeeded(); }
-
- bool PoolItem::isUnwanted() const
- { return _pimpl->isUnwanted(); }
-
- void PoolItem::saveState() const
- { _pimpl->saveState(); }
-
- void PoolItem::restoreState() const
- { _pimpl->restoreState(); }
-
- bool PoolItem::sameState() const
- { return _pimpl->sameState(); }
-
- ResObject::constPtr PoolItem::resolvable() const
- { return _pimpl->resolvable(); }
-
- /******************************************************************
- **
- ** FUNCTION NAME : operator<<
- ** FUNCTION TYPE : std::ostream &
- */
std::ostream & operator<<( std::ostream & str, const PoolItem & obj )
- {
- return str << *obj._pimpl;
- }
+ { return str << *obj._pimpl; }
- /////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
#include "zypp/base/PtrTypes.h"
#include "zypp/ResObject.h"
+
+#include "zypp/sat/SolvableType.h"
#include "zypp/ResStatus.h"
///////////////////////////////////////////////////////////////////
namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
+{
class ResPool;
-
namespace pool
{
class PoolImpl;
}
-
///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : PoolItem
- //
- /** Reference to a PoolItem connecting ResObject and ResStatus.
- *
- * The "real" PoolItem is usg. somewhere in the ResPool. This is
- * a reference to it. All copies made will reference (and modify)
- * the same PoolItem. All changes via a PoolItem are immediately
- * visible in all copies (now COW).
- *
- * \note Constness: Like pointer types, a <tt>const PoolItem</tt>
- * does \b not refer to a <tt>const PoolItem</tt>. The reference is
- * \c const, i.e. you can't change the refered PoolItem. The PoolItem
- * (i.e. the status) is always mutable.
- *
- */
- class PoolItem
+ /// \class PoolItem
+ /// \brief Combining \ref sat::Solvable and \ref ResStatus.
+ ///
+ /// The "real" PoolItem is usually somewhere in the ResPool. This is
+ /// a reference to it. All copies made will reference (and modify)
+ /// the same PoolItem. All changes via a PoolItem are immediately
+ /// visible in all copies (now COW).
+ ///
+ /// \note PoolItem is a SolvableType, which provides direct access to
+ /// many of the underlying sat::Solvables properties.
+ /// \see \ref sat::SolvableType
+ ///
+ /// \note Constness: Like pointer types, a <tt>const PoolItem</tt>
+ /// does \b not refer to a <tt>const PoolItem</tt>. The reference is
+ /// \c const, i.e. you can't change the refered PoolItem. The PoolItem
+ /// (i.e. the status) is always mutable.
+ ///////////////////////////////////////////////////////////////////
+ class PoolItem : public sat::SolvableType<PoolItem>
{
friend std::ostream & operator<<( std::ostream & str, const PoolItem & obj );
-
- public:
- /** Implementation */
- class Impl;
-
public:
/** Default ctor for use in std::container. */
PoolItem();
/** Ctor looking up the \ref sat::Solvable in the \ref ResPool. */
explicit PoolItem( const sat::Solvable & solvable_r );
+ /** Ctor looking up the \ref sat::Solvable in the \ref ResPool. */
+ template <class Derived>
+ explicit PoolItem( const SolvableType<Derived> & solvable_r )
+ : PoolItem( solvable_r.satSolvable() )
+ {}
+
/** Ctor looking up the \ref ResObject in the \ref ResPool. */
explicit PoolItem( const ResObject::constPtr & resolvable_r );
/** Return the \ref ResPool the item belongs to. */
ResPool pool() const;
- /** Return the corresponding \ref sat::Solvable. */
- sat::Solvable satSolvable() const
+ /** This is a \ref sat::SolvableType. */
+ explicit operator sat::Solvable() const
{ return resolvable() ? resolvable()->satSolvable() : sat::Solvable::noSolvable; }
/** Return the buddy we share our status object with.
* A \ref Product e.g. may share it's status with an associated reference \ref Package.
- */
+ */
sat::Solvable buddy() const;
public:
ResObject::constPtr operator->() const
{ return resolvable(); }
- /** Conversion to bool to allow pointer style tests
- * for nonNULL \ref resolvable. */
- explicit operator bool() const
- { return bool(resolvable()); }
-
private:
- friend class Impl;
friend class pool::PoolImpl;
/** \ref PoolItem generator for \ref pool::PoolImpl. */
static PoolItem makePoolItem( const sat::Solvable & solvable_r );
/** Buddies are set by \ref pool::PoolImpl.*/
- void setBuddy( sat::Solvable solv_r );
+ void setBuddy( const sat::Solvable & solv_r );
/** internal ctor */
+ public:
+ class Impl; ///< Expose type only
+ private:
explicit PoolItem( Impl * implptr_r );
/** Pointer to implementation */
RW_pointer<Impl> _pimpl;
/** \relates PoolItem Stream output */
std::ostream & operator<<( std::ostream & str, const PoolItem & obj );
- /** \relates PoolItem */
- inline bool operator==( const PoolItem & lhs, const PoolItem & rhs )
- { return lhs.resolvable() == rhs.resolvable(); }
-
- /** \relates PoolItem */
- inline bool operator==( const PoolItem & lhs, const ResObject::constPtr & rhs )
- { return lhs.resolvable() == rhs; }
-
- /** \relates PoolItem */
- inline bool operator==( const ResObject::constPtr & lhs, const PoolItem & rhs )
- { return lhs == rhs.resolvable(); }
-
-
- /** \relates PoolItem */
- inline bool operator!=( const PoolItem & lhs, const PoolItem & rhs )
- { return ! (lhs==rhs); }
-
- /** \relates PoolItem */
- inline bool operator!=( const PoolItem & lhs, const ResObject::constPtr & rhs )
- { return ! (lhs==rhs); }
-
- /** \relates PoolItem */
- 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 == rhs || 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() ); }
-
-
- /** \relates PoolItem Test for same name version release and arch. */
- inline bool sameNVRA( const PoolItem & lhs, const PoolItem & rhs )
- { return lhs == rhs || lhs.satSolvable().sameNVRA( rhs.satSolvable() ); }
-
- /** \relates PoolItem Test for same name version release and arch. */
- inline bool sameNVRA( const PoolItem & lhs, sat::Solvable rhs )
- { return lhs.satSolvable().sameNVRA( rhs ); }
-
- /** \relates PoolItem Test for same name version release and arch. */
- inline bool sameNVRA( sat::Solvable lhs, const PoolItem & rhs )
- { return lhs.sameNVRA( rhs.satSolvable() ); }
-
/** Solvable to PoolItem transform functor.
* \relates PoolItem
* \relates sat::SolvIterMixin
{ return PoolItem( solv_r ); }
};
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-namespace std
-{ /////////////////////////////////////////////////////////////////
-
- /** \relates zypp::PoolItem Order in std::container follows ResObject::constPtr.*/
- template<>
- inline bool less<zypp::PoolItem>::operator()( const zypp::PoolItem & lhs, const zypp::PoolItem & rhs ) const
- { return lhs.resolvable() < rhs.resolvable(); }
-
- /////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
#endif // ZYPP_POOLITEM_H
#define ZYPP_SAT_REPOSITORY_H
#include <iosfwd>
+#include "zypp/base/Iterator.h"
#include "zypp/Pathname.h"
#include "zypp/sat/detail/PoolMember.h"
#include "zypp/sat/LookupAttr.h" // LookupAttrTools.h included at EOF
/** Iterator behind the last \ref Solvable. */
SolvableIterator solvablesEnd() const;
+ /** Iterate the repositories Solvables. */
+ Iterable<SolvableIterator> solvables() const;
+
public:
/** Query class for Repository related products */
*/
ProductInfoIterator compatibleWithProductEnd() const;
+ /** Iterate the repository compatible distros. */
+ Iterable<ProductInfoIterator> compatibleWithProduct() const;
+
+
/**
* Get an iterator to the beginning of distos the repository
* provides upadates for.
*/
ProductInfoIterator updatesProductEnd() const;
+ /** Iterate distos the repository provides upadates for. */
+ Iterable<ProductInfoIterator> updatesProduct() const;
+
public:
/** Return any associated \ref RepoInfo. */
RepoInfo info() const;
};
///////////////////////////////////////////////////////////////////
+ /** Iterate the repository compatible distros. */
+ inline Iterable<Repository::ProductInfoIterator> Repository::compatibleWithProduct() const
+ { return makeIterable( compatibleWithProductBegin(), compatibleWithProductEnd() ); }
+
+ /** Iterate distos the repository provides upadates for. */
+ inline Iterable<Repository::ProductInfoIterator> Repository::updatesProduct() const
+ { return makeIterable( updatesProductBegin(), updatesProductEnd() ); }
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : Repository::EraseFromPool
/////////////////////////////////////////////////////////////////
} // namespace detail
///////////////////////////////////////////////////////////////////
+
+ inline Iterable<Repository::SolvableIterator> Repository::solvables() const
+ { return makeIterable( solvablesBegin(), solvablesEnd() ); }
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
/** Select ResObject by name. */
struct ByName : public ResObjectFilterFunctor
{
+ ByName()
+ {}
+
ByName( const std::string & name_r )
: _name( name_r )
{}
*/
#include "zypp/ResObject.h"
-#include "zypp/sat/SolvAttr.h"
-#include "zypp/sat/Solvable.h"
-#include "zypp/Repository.h"
-#include "zypp/RepoInfo.h"
-#include "zypp/IdString.h"
-
-#include "zypp/ui/Selectable.h"
using namespace zypp;
using namespace std;
///////////////////////////////////////////////////////////////////
namespace zypp
-{ /////////////////////////////////////////////////////////////////
+{
IMPL_PTR_TYPE(ResObject);
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : ResObject::ResObject
- // METHOD TYPE : Ctor
- //
ResObject::ResObject( const sat::Solvable & solvable_r )
: Resolvable( solvable_r )
{}
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : ResObject::~ResObject
- // METHOD TYPE : Dtor
- //
ResObject::~ResObject()
{}
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : ResObject::dumpOn
- // METHOD TYPE : std::ostream &
- //
std::ostream & ResObject::dumpOn( std::ostream & str ) const
{
return Resolvable::dumpOn( str );
}
- ///////////////////////////////////////////////////////////////////
-
- std::string ResObject::summary( const Locale & lang_r ) const
- { return lookupStrAttribute( sat::SolvAttr::summary, lang_r ); }
-
- std::string ResObject::description( const Locale & lang_r ) const
- { return lookupStrAttribute( sat::SolvAttr::description, lang_r ); }
-
- std::string ResObject::insnotify( const Locale & lang_r ) const
- { return lookupStrAttribute( sat::SolvAttr::insnotify, lang_r ); }
-
- std::string ResObject::delnotify( const Locale & lang_r ) const
- { return lookupStrAttribute( sat::SolvAttr::delnotify, lang_r ); }
-
- std::string ResObject::licenseToConfirm( const Locale & lang_r ) const
- {
- std::string ret = lookupStrAttribute( sat::SolvAttr::eula, lang_r );
- if ( ret.empty() && isKind<Product>() )
- {
- const RepoInfo & ri( repoInfo() );
- if ( ri.needToAcceptLicense() || ! ui::Selectable::get( *this )->hasInstalledObj() )
- ret = ri.getLicense( lang_r ); // bnc#908976: suppress informal license upon update
- }
- return ret;
- }
-
- bool ResObject::needToAcceptLicense() const
- {
- if ( isKind<Product>() )
- return repoInfo().needToAcceptLicense( );
- return true;
- }
-
- std::string ResObject::distribution() const
- { return lookupStrAttribute( sat::SolvAttr::distribution ); }
-
- CpeId ResObject::cpeId() const
- { return CpeId( lookupStrAttribute( sat::SolvAttr::cpeid ), CpeId::noThrow ); }
-
- ByteCount ResObject::installSize() const
- { return ByteCount( lookupNumAttribute( sat::SolvAttr::installsize ) ); }
-
- ByteCount ResObject::downloadSize() const
- { return ByteCount( lookupNumAttribute( sat::SolvAttr::downloadsize ) ); }
-
- unsigned ResObject::mediaNr() const
- { return lookupNumAttribute( sat::SolvAttr::medianr ); }
-
- Date ResObject::buildtime() const
- { return Date( lookupNumAttribute( sat::SolvAttr::buildtime ) ); }
-
- Date ResObject::installtime() const
- { return Date( lookupNumAttribute( sat::SolvAttr::installtime ) ); }
-
- /////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
+{
ResObject::Ptr makeResObject( const sat::Solvable & solvable_r )
{
if ( ! solvable_r )
// unknow => return a plain ResObject
return new ResObject( solvable_r );
}
-
- /////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
#include "zypp/APIConfig.h"
#include "zypp/Resolvable.h"
-#include "zypp/Date.h"
-#include "zypp/Locale.h"
#include "zypp/Vendor.h"
-#include "zypp/ByteCount.h"
-#include "zypp/OnMediaLocation.h"
-#include "zypp/Repository.h"
-#include "zypp/CpeId.h"
#include "zypp/sat/LookupAttr.h"
#include "zypp/sat/SolvableSet.h"
///////////////////////////////////////////////////////////////////
namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
+{
+ ///////////////////////////////////////////////////////////////////
+ /// \class ResObject
+ /// \brief Base for resolvable objects
+ ///
+ /// \note \ref Resolvable is a SolvableType, which provides direct
+ /// access to many of the underlying sat::Solvables properties.
+ /// Don't add common properties here, but in \ref sat::Solvable
+ /// and extend \ref sat::SolvableType.
+ ///
+ /// \see \ref makeResObject for how to construct ResObjects.
+ /// \todo Merge with Resolvable
///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : ResObject
- //
- /**
- * Interface base for resolvable objects (common data).
- * That is, all data not needed for solving, but common
- * across all Resolvable kinds.
- *
- * \see \ref makeResObject for how to construct ResObjects.
- */
class ResObject : public Resolvable
{
public:
typedef TraitsType::constPtrType constPtr;
public:
-
/** Convert \c this into a Ptr of a certain Kind.
* This is a convenience to access type specific
* attributes.
inline typename ResTraits<_Res>::PtrType asKind();
public:
- /** \name Locale support.
- * \see \ref sat::Solvable
- */
- //@{
- /** \see \ref sat::Solvable::supportsLocales */
- bool supportsLocales() const
- { return sat::Solvable::supportsLocales(); }
-
- /** \see \ref sat::Solvable::supportsLocale */
- bool supportsLocale( const Locale & locale_r ) const
- { return sat::Solvable::supportsLocale( locale_r ); }
-
- bool supportsLocale( const LocaleSet & locales_r ) const
- { return sat::Solvable::supportsLocale( locales_r ); }
-
- /** \see \ref sat::Solvable::supportsRequestedLocales */
- bool supportsRequestedLocales() const
- { return sat::Solvable::supportsRequestedLocales(); }
-
- /** \see \ref sat::Solvable::getSupportedLocales */
- LocaleSet getSupportedLocales() const
- { return sat::Solvable::getSupportedLocales(); }
- //@}
-
- public:
- /**
- * \short Short text describing the resolvable.
- * This attribute is usually displayed in columns.
- */
- std::string summary( const Locale & lang_r = Locale() ) const;
-
- /**
- * \short Long text describing the resolvable.
- */
- std::string description( const Locale & lang_r = Locale() ) const;
-
- /**
- * \short Installation Notification
- *
- * This text can be used to tell the user some notes
- * When he selects the resovable for installation.
- */
- std::string insnotify( const Locale & lang_r = Locale() ) const;
-
- /**
- * \short De-Installation Notification
- *
- * This text can be used to tell the user some notes
- * When he selects the resovable for deinstall.
- */
- std::string delnotify( const Locale & lang_r = Locale() ) const;
-
- /**
- * \short License or agreement to accept
- *
- * Agreement, warning or license the user should
- * accept before installing the resolvable.
- */
- std::string licenseToConfirm( const Locale & lang_r = Locale() ) const;
-
- /**
- * \short Acceptance of Product License needed?
- *
- * Returns whether a product license has to be accepted
- * (no acceptance is needed for openSUSE)
- */
- bool needToAcceptLicense() const;
-
/**
* \short Vendor
- *
- * For example "Novell Inc."
+ * \deprecated Though typedef'ed to std::string, Vendor is actually an \ref IdString.
*/
Vendor vendor() const
{ return Resolvable::vendor().asString(); }
- /** The distribution string.
- * E.g. \c code-11.
- */
- std::string distribution() const;
-
- /** The Common Platform Enumeration name for this product. */
- CpeId cpeId() const;
-
- /** Installed (unpacked) size.
- * This is just a total number. Many objects provide even more detailed
- * disk usage data. You can use \ref DiskUsageCounter to find out
- * how objects data are distributed across partitions/directories.
- * \code
- * // Load directory set into ducounter
- * DiskUsageCounter ducounter( { "/", "/usr", "/var" } );
- *
- * // see how noch space the packages use
- * for ( const PoolItem & pi : pool )
- * {
- * cout << pi << ducounter.disk_usage( pi ) << endl;
- * // I__s_(7)GeoIP-1.4.8-3.1.2.x86_64(@System) {
- * // dir:[/] [ bs: 0 B ts: 0 B us: 0 B (+-: 1.0 KiB)]
- * // dir:[/usr] [ bs: 0 B ts: 0 B us: 0 B (+-: 133.0 KiB)]
- * // dir:[/var] [ bs: 0 B ts: 0 B us: 0 B (+-: 1.1 MiB)]
- * // }
- * }
- * \endcode
- * \see \ref DiskUsageCounter
- */
- ByteCount installSize() const;
-
- /** Download size. */
- ByteCount downloadSize() const;
-
- /** \see \ref sat::Solvable::repository */
- Repository repository() const
- { return sat::Solvable::repository(); }
-
- /** \ref RepoInfo associated with the repository
- * providing this resolvable.
- */
- RepoInfo repoInfo() const
- { return repository().info(); }
-
- /**
- * Media number where the resolvable is located
- * 0 if no media access is required.
- */
- unsigned mediaNr() const;
-
- /**
- * \short build time of the resolvable
- */
- Date buildtime() const;
-
- /**
- * \short Installation time
- * 0 if the resolvable is not installed.
- */
- Date installtime() const;
-
protected:
friend ResObject::Ptr makeResObject( const sat::Solvable & solvable_r );
/** Ctor */
virtual ~ResObject();
/** Helper for stream output */
virtual std::ostream & dumpOn( std::ostream & str ) const;
+ /** This is a \ref sat::SolvableType (allow implicit conversion in derived classes). */
+ operator sat::Solvable() const
+ { return satSolvable(); }
};
///////////////////////////////////////////////////////////////////
inline typename ResTraits<_Res>::PtrType ResObject::asKind()
{ return dynamic_cast<_Res *>( this ); }
- /////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
#endif // ZYPP_RESOBJECT_H
* an ordinary filter iterator. Do not provide filter iterators
* here, if there is no index table for it.
*
+ * For most (*Begin,*End) iterator-pairs there's also an \ref Iterable
+ * provided, so you can use then in range-based for loops:
+ * \code
+ * // classic:
+ * for_( it, pool.filterBegin(myfilter), pool.filterEnd(myfilter) )
+ * { ... }
+ *
+ * // range based:
+ * for ( const PoolItem & pi : pool.filter(myfilter) )
+ * { ... }
+ * \endcode
+ *
* \include n_ResPool_nomorenameiter
*/
class ResPool
template<class _Filter>
filter_iterator<_Filter,const_iterator> filterEnd( const _Filter & filter_r ) const
{ return make_filter_end( filter_r, *this ); }
+
+ template<class _Filter>
+ Iterable<filter_iterator<_Filter,const_iterator>> filter( const _Filter & filter_r ) const
+ { return makeIterable( filterBegin( filter_r ), filterEnd( filter_r ) ); }
//@}
/** \name Iterate over all PoolItems by status.
filter_iterator<filter::ByStatus,const_iterator> byStatusEnd( const filter::ByStatus & filter_r ) const
{ return make_filter_end( filter_r, *this ); }
+
+ Iterable<filter_iterator<filter::ByStatus,const_iterator>> byStatus( const filter::ByStatus & filter_r ) const
+ { return makeIterable( byStatusBegin( filter_r ), byStatusEnd( filter_r ) ); }
//@}
public:
/** Takes a \ref sat::Solvable::ident string. */
byIdent_iterator byIdentEnd( IdString ident_r ) const
{ return byIdentEnd( ByIdent(ident_r) ); }
+
+
+ Iterable<byIdent_iterator> byIdent( const ByIdent & ident_r ) const
+ { return makeIterable( byIdentBegin( ident_r ), byIdentEnd( ident_r ) ); }
+
+ Iterable<byIdent_iterator> byIdent( ResKind kind_r, IdString name_r ) const
+ { return makeIterable( byIdentBegin( kind_r, name_r ), byIdentEnd( kind_r, name_r ) ); }
+
+ Iterable<byIdent_iterator> byIdent( ResKind kind_r, const C_Str & name_r ) const
+ { return makeIterable( byIdentBegin( kind_r, name_r ), byIdentEnd( kind_r, name_r ) ); }
+
+ template<class _Res>
+ Iterable<byIdent_iterator> byIdent( IdString name_r ) const
+ { return makeIterable( byIdentBegin<_Res>( name_r ), byIdentEnd<_Res>( name_r ) ); }
+
+ template<class _Res>
+ Iterable<byIdent_iterator> byIdent( const C_Str & name_r ) const
+ { return makeIterable( byIdentBegin<_Res>( name_r ), byIdentEnd<_Res>( name_r ) ); }
+
+ Iterable<byIdent_iterator> byIdent( const PoolItem & pi_r ) const
+ { return makeIterable( byIdentBegin( pi_r ), byIdentEnd( pi_r ) ); }
+
+ Iterable<byIdent_iterator> byIdent(sat::Solvable slv_r ) const
+ { return makeIterable( byIdentBegin( slv_r ), byIdentEnd( slv_r ) ); }
+
+ Iterable<byIdent_iterator> byIdent( IdString ident_r ) const
+ { return makeIterable( byIdentBegin( ident_r ), byIdentEnd( ident_r ) ); }
//@}
public:
template<class _Res>
byKind_iterator byKindEnd() const
{ return make_filter_end( resfilter::byKind<_Res>(), *this ); }
+
+ Iterable<byKind_iterator> byKind( const ResKind & kind_r ) const
+ { return makeIterable( byKindBegin( kind_r ), byKindEnd( kind_r ) ); }
+
+ template<class _Res>
+ Iterable<byKind_iterator> byKind() const
+ { return makeIterable( byKindBegin<_Res>(), byKindEnd<_Res>() ); }
//@}
public:
byName_iterator byNameEnd( const std::string & name_r ) const
{ return make_filter_end( ByName(name_r), *this ); }
+
+ Iterable<byName_iterator> byName( const std::string & name_r ) const
+ { return makeIterable( byNameBegin( name_r ), byNameEnd( name_r ) ); }
//@}
public:
* Returns \ref Repository::norepository if there is no such \ref Repository.
*/
Repository reposFind( const std::string & alias_r ) const;
+
+ Iterable<repository_iterator> knownRepositories() const
+ { return makeIterable( knownRepositoriesBegin(), knownRepositoriesEnd() ); }
//@}
public:
hardLockQueries_iterator hardLockQueriesBegin() const;
hardLockQueries_iterator hardLockQueriesEnd() const;
+ Iterable<hardLockQueries_iterator> hardLockQueries() const
+ { return makeIterable( hardLockQueriesBegin(), hardLockQueriesEnd() ); }
+
/** Set a new set of queries.
* The hard-locks of existing PoolItems are adjusted according
* to the queries. (usually called on target load)
///////////////////////////////////////////////////////////////////
namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
+{
IMPL_PTR_TYPE(Resolvable);
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : Resolvable::Resolvable
- // METHOD TYPE : Ctor
- //
Resolvable::Resolvable( const sat::Solvable & solvable_r )
- : sat::Solvable( solvable_r )
+ : _solvable( solvable_r )
{}
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : Resolvable::~Resolvable
- // METHOD TYPE : Dtor
- //
Resolvable::~Resolvable()
{}
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : Resolvable::poolItem
- // METHOD TYPE : PoolItem
- //
PoolItem Resolvable::poolItem() const
{ return PoolItem( *this ); }
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : Resolvable::dumpOn
- // METHOD TYPE : std::ostream &
- //
std::ostream & Resolvable::dumpOn( std::ostream & str ) const
{ return str << satSolvable(); }
- /////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
#include "zypp/base/NonCopyable.h"
#include "zypp/base/PtrTypes.h"
-#include "zypp/sat/Solvable.h"
+#include "zypp/sat/SolvableType.h"
///////////////////////////////////////////////////////////////////
namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
+{
class PoolItem;
-
///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : Resolvable
- //
- /** Interface base for resolvable objects (identification and dependencies).
- * \todo Merge with ResObject
- */
- class Resolvable : protected zypp::sat::Solvable, // Note: gcc bug #52841 prohibits using just sat::Solvable
+ /// \class Resolvable
+ /// \brief Base for resolvable objects
+ ///
+ /// \note \ref Resolvable is a SolvableType, which provides direct
+ /// access to many of the underlying sat::Solvables properties.
+ /// Don't add common properties here, but in \ref sat::Solvable
+ /// and extend \ref sat::SolvableType.
+ ///
+ /// In most cases you want to retrieve the common properties directly
+ /// from a \ref PoolItem or \ref sat::Solvable. Construction from and
+ /// explicit conversion to sat::Solvable are supported. Next goal is
+ /// to get rid of the smart pointer hierarchy. A Resolvable is actually
+ /// an unsigned and derived classes contain no data, so it makes little
+ /// sense to wrap this into ReferenceCounted smart pointer.
+ ///
+ /// \todo Merge with ResObject
+ /// \todo Get rid of refcout/smart_prt bloat, as this type is actually IdBased (i.e. sizeof(unsigned))
+ ///////////////////////////////////////////////////////////////////
+ class Resolvable : public sat::SolvableType<Resolvable>,
public base::ReferenceCounted, private base::NonCopyable
{
friend std::ostream & operator<<( std::ostream & str, const Resolvable & obj );
typedef TraitsType::constPtrType constPtr;
public:
- /** Whether this represents an installed solvable. */
- bool isSystem() const
- { return sat::Solvable::isSystem(); }
-
- /** \copydoc sat::Solvable::onSystemByUser() */
- bool onSystemByUser() const
- { return sat::Solvable::onSystemByUser(); }
-
- IdString ident() const
- { return sat::Solvable::ident(); }
-
- ResKind kind() const
- { return sat::Solvable::kind(); }
-
- bool isKind( const ResKind & kind_r ) const
- { return sat::Solvable::isKind( kind_r ); }
-
- template<class _Res>
- bool isKind() const
- { return sat::Solvable::isKind<_Res>(); }
-
- std::string name() const
- { return sat::Solvable::name(); }
-
- Edition edition() const
- { return sat::Solvable::edition(); }
-
- Arch arch() const
- { return sat::Solvable::arch(); }
-
- /** Whether different versions of this package can be installed at the same time.
- * Per default \c false. \see also \ref ZConfig::multiversion.
- */
- bool multiversionInstall() const
- { return sat::Solvable::multiversionInstall(); }
-
- using sat::Solvable::asString;
- using sat::Solvable::asUserString;
-
- /** \name Dependencies. */
- //@{
- /** Select by Dep. */
- Capabilities dep( Dep which_r ) const
- { return operator[]( which_r ); }
-
- Capabilities operator[]( Dep which_r ) const
- { return sat::Solvable::operator[]( which_r ); }
-
- Capabilities provides() const
- { return sat::Solvable::provides(); }
-
- Capabilities requires() const
- { return sat::Solvable::requires(); }
-
- Capabilities conflicts() const
- { return sat::Solvable::conflicts(); }
-
- Capabilities obsoletes() const
- { return sat::Solvable::obsoletes(); }
-
- Capabilities recommends() const
- { return sat::Solvable::recommends(); }
-
- Capabilities suggests() const
- { return sat::Solvable::suggests(); }
-
- Capabilities enhances() const
- { return sat::Solvable::enhances(); }
-
- Capabilities supplements() const
- { return sat::Solvable::supplements(); }
-
- Capabilities prerequires() const
- { return sat::Solvable::prerequires(); }
-
- CapabilitySet providesNamespace( const std::string & namespace_r ) const
- { return sat::Solvable::providesNamespace( namespace_r ); }
-
- CapabilitySet valuesOfNamespace( const std::string & namespace_r ) const
- { return sat::Solvable::valuesOfNamespace( namespace_r ); }
- //@}
-
- public:
- /** Access the corresponding \ref sat:::Solvable. */
- const sat::Solvable & satSolvable() const { return *this; }
+ /** This is a \ref sat::SolvableType. */
+ explicit operator sat::Solvable() const
+ { return _solvable; }
/** Access the corresponding \ref PoolItem. */
PoolItem poolItem() const;
virtual ~Resolvable();
/** Helper for stream output */
virtual std::ostream & dumpOn( std::ostream & str ) const;
+
+ private:
+ sat::Solvable _solvable;
};
///////////////////////////////////////////////////////////////////
inline std::ostream & dumpOn( std::ostream & str, const Resolvable & obj )
{ return dumpOn( str, obj.satSolvable() ); }
- /** Test whether a Resolvable::Ptr is of a certain Kind.
- * \return \c Ture iff \a p is not \c NULL and points to a Resolvable
- * of the specified Kind.
- * \relates Resolvable
- * \code
- * isKind<Package>(resPtr);
- * \endcode
+ /** Test whether a Resolvable::Ptr is of a certain Kind.
+ * \return \c Ture iff \a p is not \c NULL and points to a Resolvable
+ * of the specified Kind.
+ * \relates Resolvable
+ * \code
+ * isKind<Package>(resPtr);
+ * \endcode
*/
- template<class _Res>
- inline bool isKind( const Resolvable::constPtr & p )
- { return p && p->kind() == ResTraits<_Res>::kind; }
-
- // Specialization for Resolvable: Always true.
- template<>
- inline bool isKind<Resolvable>( const Resolvable::constPtr & p )
- { return !!p; }
-
- // Specialization for ResObject: Always true.
- template<>
- inline bool isKind<ResObject>( const Resolvable::constPtr & p )
- { return !!p; }
-
-
- /** Convert Resolvable::Ptr into Ptr of a certain Kind.
- * \return \c NULL iff \a p is \c NULL or points to a Resolvable
- * not of the specified Kind.
- * \relates Resolvable
- * \code
- * asKind<Package>(resPtr);
- * \endcode
+ template<class _Res>
+ inline bool isKind( const Resolvable::constPtr & p )
+ { return p && p->isKind<_Res>(); }
+
+ // Specialization for Resolvable: Always true.
+ template<>
+ inline bool isKind<Resolvable>( const Resolvable::constPtr & p )
+ { return !!p; }
+
+ // Specialization for ResObject: Always true.
+ template<>
+ inline bool isKind<ResObject>( const Resolvable::constPtr & p )
+ { return !!p; }
+
+
+ /** Convert Resolvable::Ptr into Ptr of a certain Kind.
+ * \return \c NULL iff \a p is \c NULL or points to a Resolvable
+ * not of the specified Kind.
+ * \relates Resolvable
+ * \code
+ * asKind<Package>(resPtr);
+ * \endcode
*/
- template<class _Res>
- inline typename ResTraits<_Res>::PtrType asKind( const Resolvable::Ptr & p )
- { return dynamic_pointer_cast<_Res>(p); }
+ template<class _Res>
+ inline typename ResTraits<_Res>::PtrType asKind( const Resolvable::Ptr & p )
+ { return dynamic_pointer_cast<_Res>(p); }
- template<class _Res>
- inline typename ResTraits<_Res>::constPtrType asKind( const Resolvable::constPtr & p )
- { return dynamic_pointer_cast<const _Res>(p); }
+ template<class _Res>
+ inline typename ResTraits<_Res>::constPtrType asKind( const Resolvable::constPtr & p )
+ { return dynamic_pointer_cast<const _Res>(p); }
///////////////////////////////////////////////////////////////////
- /** \relates Resolvable Compare Resolvable::constPtr according to
- * \a kind and \a name.
- */
- inline int compareByN( const Resolvable::constPtr & lhs,
- const Resolvable::constPtr & rhs )
+ /** \relates Resolvable Compare Resolvable::constPtr according to \a kind and \a name.
+ * \deprecated Get rid of refcout/smart_prt bloat, use
+ */
+ inline int compareByN( const Resolvable::constPtr & lhs, const Resolvable::constPtr & rhs )
{
- if ( lhs == rhs )
- return 0;
- if ( ! (lhs && rhs) )
- return lhs ? 1 : -1;
- int res = 0;
- if ( (res = lhs->kind().compare( rhs->kind() )) )
- return res;
- return lhs->name().compare( rhs->name() );
+ int ret = 0;
+ if ( lhs != rhs )
+ {
+ if ( lhs && rhs )
+ ret = compareByN( *lhs, *rhs );
+ else
+ ret = lhs ? 1 : -1;
+ }
+ return ret;
}
- /** \relates Resolvable Compare Resolvable::constPtr according to
- * \a kind, \a name and \a edition(compare!).
- */
- inline int compareByNVR( const Resolvable::constPtr & lhs,
- const Resolvable::constPtr & rhs )
+ /** \relates Resolvable Compare according to \a kind, \a name and \a edition. */
+ inline int compareByNVR( const Resolvable::constPtr & lhs, const Resolvable::constPtr & rhs )
{
- if ( lhs == rhs )
- return 0;
- if ( ! (lhs && rhs) )
- return lhs ? 1 : -1;
- int res = 0;
- if ( (res = lhs->kind().compare( rhs->kind() )) )
- return res;
- if ( (res = lhs->name().compare( rhs->name() )) )
- return res;
- return lhs->edition().compare( rhs->edition() );
+ int ret = 0;
+ if ( lhs != rhs )
+ {
+ if ( lhs && rhs )
+ ret = compareByNVR( *lhs, *rhs );
+ else
+ ret = lhs ? 1 : -1;
+ }
+ return ret;
}
- /** \relates Resolvable Compare Resolvable::constPtr according to
- * \a kind, \a name, \a edition(compare!) and \a arch.
- */
- inline int compareByNVRA( const Resolvable::constPtr & lhs,
- const Resolvable::constPtr & rhs )
+ /** \relates Resolvable Compare Resolvable::constPtr according to \a kind, \a name, \a edition and \a arch. */
+ inline int compareByNVRA( const Resolvable::constPtr & lhs, const Resolvable::constPtr & rhs )
{
- if ( lhs == rhs )
- return 0;
- if ( ! (lhs && rhs) )
- return lhs ? 1 : -1;
- int res = 0;
- if ( (res = lhs->kind().compare( rhs->kind() )) )
- return res;
- if ( (res = lhs->name().compare( rhs->name() )) )
- return res;
- if ( (res = lhs->edition().compare( rhs->edition() )) )
- return res;
- return lhs->arch().compare( rhs->arch() );
+ int ret = 0;
+ if ( lhs != rhs )
+ {
+ if ( lhs && rhs )
+ ret = compareByNVRA( *lhs, *rhs );
+ else
+ ret = lhs ? 1 : -1;
+ }
+ return ret;
}
-
- /////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
#endif // ZYPP_RESOLVABLE_H
}
else if ( entry == "multiversion" )
{
- str::split( value, inserter( _multiversion, _multiversion.end() ), ", \t" );
+ str::splitEscaped( value, inserter( _multiversion, _multiversion.end() ), ", \t" );
}
else if ( entry == "locksfile.path" )
{
void resetSolverUpgradeRemoveDroppedPackages();
/** \name Packages which can be installed in different versions at the same time.
- * This returns the config file values (\c names or \c provides:...). For the corresponding
- * packages use e.g \ref sat::Pool::multiversionBegin, or \ref sat::Solbale::multiversionInstall
- * (\ref ui::Selectable::multiversionInstall).
+ *
+ * This returns the config file values (\c names or \c provides:...). The
+ * corresponding packages have the \c multiversionInstall property set. Those
+ * packages will be installed using 'rpm -i', so they will not implicitly obsolete
+ * other installed versions.
+ *
+ * \see \ref sat::SolvableType
*/
//@{
const std::set<std::string> & multiversionSpec() const;
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/base/Iterable.h
+ */
+#ifndef ZYPP_BASE_ITERABLE_H
+#define ZYPP_BASE_ITERABLE_H
+
+#include <iterator>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{
+ ///////////////////////////////////////////////////////////////////
+ /// \class Iterable
+ /// \brief
+ /// \code
+ /// struct Foo
+ /// {
+ /// class Iterator;
+ /// typedef Iterable<Iterator> IterableType;
+ ///
+ /// Iterator myBegin();
+ /// Iterator myEnd();
+ ///
+ /// IterableType iterate() { return makeIterable( myBegin(), myEnd() ); }
+ /// };
+ /// \endcode
+ ///////////////////////////////////////////////////////////////////
+ template <class _Iterator>
+ class Iterable
+ {
+ public:
+ typedef size_t size_type;
+ typedef _Iterator iterator_type;
+ typedef typename std::iterator_traits<iterator_type>::value_type value_type;
+ typedef typename std::iterator_traits<iterator_type>::difference_type difference_type;
+ typedef typename std::iterator_traits<iterator_type>::pointer pointer;
+ typedef typename std::iterator_traits<iterator_type>::reference reference;
+ typedef typename std::iterator_traits<iterator_type>::iterator_category iterator_category;
+
+ /** Ctor taking the iterator pair */
+ Iterable()
+ {}
+
+ /** Ctor taking the iterator pair */
+ Iterable( iterator_type begin_r, iterator_type end_r )
+ : _begin( std::move(begin_r) )
+ , _end( std::move(end_r) )
+ {}
+
+ iterator_type begin() const
+ { return _begin; }
+
+ iterator_type end() const
+ { return _end; }
+
+ bool empty() const
+ { return( _begin == _end ); }
+
+ size_type size() const
+ { size_type ret = 0; for ( iterator_type i = _begin; i != _end; ++i ) ++ret; return ret; }
+
+ bool contains( const value_type & val_r ) const
+ { return( find( val_r ) != _end ); }
+
+ iterator_type find( const value_type & val_r ) const
+ { iterator_type ret = _begin; for ( ; ret != _end; ++ret ) if ( *ret == val_r ) break; return ret; }
+
+ private:
+ iterator_type _begin;
+ iterator_type _end;
+ };
+
+ /** \relates Iterable convenient construction. */
+ template <class _Iterator>
+ Iterable<_Iterator> makeIterable( _Iterator && begin_r, _Iterator && end_r )
+ { return Iterable<_Iterator>( std::forward<_Iterator>(begin_r), std::forward<_Iterator>(end_r) ); }
+
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_BASE_ITERABLE_H
#include <boost/iterator/transform_iterator.hpp>
#include <boost/function_output_iterator.hpp>
+#include "zypp/base/Iterable.h"
+
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
bool Pool::isAvailableLocale( const Locale & locale_r ) const
{ return myPool().isAvailableLocale( locale_r ); }
- bool Pool::multiversionEmpty() const { return myPool().multiversionList().empty(); }
- size_t Pool::multiversionSize() const { return myPool().multiversionList().size(); }
- Pool::MultiversionIterator Pool::multiversionBegin() const { return myPool().multiversionList().begin(); }
- Pool::MultiversionIterator Pool::multiversionEnd() const { return myPool().multiversionList().end(); }
- bool Pool::isMultiversion( IdString ident_r ) const { return myPool().isMultiversion( ident_r ); }
+ const Pool::MultiversionList & Pool::multiversion() const
+ { return myPool().multiversionList(); }
Queue Pool::autoInstalled() const { return myPool().autoInstalled(); }
void Pool::setAutoInstalled( const Queue & autoInstalled_r ){ myPool().setAutoInstalled( autoInstalled_r ); }
#include "zypp/sat/detail/PoolMember.h"
#include "zypp/Repository.h"
#include "zypp/sat/WhatProvides.h"
+#include "zypp/sat/SolvableSet.h"
#include "zypp/sat/Queue.h"
///////////////////////////////////////////////////////////////////
/** Iterator behind the last \ref Repository. */
RepositoryIterator reposEnd() const;
+ /** Iterate the repositories. */
+ Iterable<RepositoryIterator> repos() const
+ { return makeIterable( reposBegin(), reposEnd() ); }
+
/** Return a \ref Repository named \c alias_r.
* It a such a \ref Repository does not already exist
* a new empty \ref Repository is created.
/** Iterator behind the last \ref Solvable. */
SolvableIterator solvablesEnd() const;
+ /** Iterate the solvables. */
+ Iterable<SolvableIterator> solvables() const
+ { return makeIterable( solvablesBegin(), solvablesEnd() ); }
+
public:
/** \name Iterate all Solvables matching a \c _Filter. */
//@{
//@}
public:
- /** \name Multiversion install.
- * Ident list of all packages that can be installed in different version
- * at the same time. (\see \ref ZConfig::multiversionSpec)
- */
- //@{
- typedef IdStringSet::const_iterator MultiversionIterator;
-
- bool multiversionEmpty() const;
- size_t multiversionSize() const;
- MultiversionIterator multiversionBegin() const;
- MultiversionIterator multiversionEnd() const;
-
- bool isMultiversion( IdString ident_r ) const;
- //@}
+ /** \name Multiversion install.
+ * Whether the pool contains packages which are multiversion installable.
+ * \see \ref Solvable::multiversionInstall
+ * \see \ref ZConfig::multiversionSpec
+ */
+ //@{
+ typedef SolvableSet MultiversionList;
+ const MultiversionList & multiversion() const;
+ /** \deprecated Legacy, use multiversion().empty() instead. */
+ ZYPP_DEPRECATED bool multiversionEmpty() const { return multiversion().empty(); }
+ //@}
public:
/** \name Autoinstalled */
{ return self().begin(); }
Solvable_iterator solvableEnd() const
{ return self().end(); }
+ Iterable<Solvable_iterator> solvable() const
+ { return makeIterable( solvableBegin(), solvableEnd() ); }
//@}
/** \name Iterate as PoolItem */
{ return make_transform_iterator( solvableBegin(), asPoolItem() ); }
PoolItem_iterator poolItemEnd() const
{ return make_transform_iterator( solvableEnd(), asPoolItem() ); }
+ Iterable<PoolItem_iterator> poolItem() const
+ { return makeIterable( poolItemBegin(), poolItemEnd() ); }
//@}
private:
{ return make_transform_iterator( unifiedSolvableBegin(), ui::asSelectable() ); }
Selectable_iterator selectableEnd() const
{ return make_transform_iterator( unifiedSolvableEnd(), ui::asSelectable() ); }
+ Iterable<Selectable_iterator> selectable() const
+ { return makeIterable( selectableBegin(), selectableEnd() ); }
//@}
private:
UnifiedSolvable_iterator unifiedSolvableBegin() const
{ return make_filter_iterator( solvitermixin_detail::UnifyByIdent(), solvableBegin(), solvableEnd() ); }
UnifiedSolvable_iterator unifiedSolvableEnd() const
- { return make_filter_iterator( solvitermixin_detail::UnifyByIdent(), solvableEnd(), solvableEnd() );; }
+ { return make_filter_iterator( solvitermixin_detail::UnifyByIdent(), solvableEnd(), solvableEnd() ); }
+ Iterable<UnifiedSolvable_iterator> unifiedSolvable() const
+ { return makeIterable( unifiedSolvableBegin(), unifiedSolvableEnd() ); }
//@}
private:
const Derived & self() const
#include "zypp/OnMediaLocation.h"
#include "zypp/ZConfig.h"
+#include "zypp/ui/Selectable.h"
+
using std::endl;
///////////////////////////////////////////////////////////////////
namespace zypp
-{ /////////////////////////////////////////////////////////////////
+{
///////////////////////////////////////////////////////////////////
namespace sat
- { /////////////////////////////////////////////////////////////////
-
+ {
+ ///////////////////////////////////////////////////////////////////
namespace
{
void _doSplit( IdString & _ident, ResKind & _kind, IdString & _name )
}
return;
}
- }
+ } // namespace
+ ///////////////////////////////////////////////////////////////////
Solvable::SplitIdent::SplitIdent( IdString ident_r )
: _ident( ident_r )
{ _doSplit( _ident, _kind, _name ); }
/////////////////////////////////////////////////////////////////
+ // class Solvable
+ /////////////////////////////////////////////////////////////////
const Solvable Solvable::noSolvable;
return noSolvable;
}
- Repository Solvable::repository() const
- {
- NO_SOLVABLE_RETURN( Repository::noRepository );
- return Repository( _solvable->repo );
- }
-
- bool Solvable::isSystem() const
- {
- NO_SOLVABLE_RETURN( _id == detail::systemSolvableId );
- return myPool().isSystemRepo( _solvable->repo );
- }
-
- bool Solvable::onSystemByUser() const
- {
- return isSystem() && myPool().isOnSystemByUser( ident() );
- }
-
- IdString Solvable::ident() const
- {
- NO_SOLVABLE_RETURN( IdString() );
- return IdString( _solvable->name );
- }
-
std::string Solvable::lookupStrAttribute( const SolvAttr & attr ) const
{
NO_SOLVABLE_RETURN( std::string() );
{
inline Pathname lookupDatadirIn( Repository repor_r )
{
- static const sat::SolvAttr susetagsDatadir( "susetags:datadir" );
+ static const SolvAttr susetagsDatadir( "susetags:datadir" );
Pathname ret;
// First look for repo attribute "susetags:datadir". If not found,
// look into the solvables as Code11 libsolv placed it there.
- sat::LookupRepoAttr datadir( susetagsDatadir, repor_r );
+ LookupRepoAttr datadir( susetagsDatadir, repor_r );
if ( ! datadir.empty() )
ret = datadir.begin().asString();
else
{
- sat::LookupAttr datadir( susetagsDatadir, repor_r );
+ LookupAttr datadir( susetagsDatadir, repor_r );
if ( ! datadir.empty() )
ret = datadir.begin().asString();
}
return ret;
}
- }
+ } // namespace
///////////////////////////////////////////////////////////////////
OnMediaLocation Solvable::lookupLocation() const
return ret;
}
- ResKind Solvable::kind() const
+
+ IdString Solvable::ident() const
+ {
+ NO_SOLVABLE_RETURN( IdString() );
+ return IdString( _solvable->name );
+ }
+
+ ResKind Solvable::kind() const
{
NO_SOLVABLE_RETURN( ResKind() );
// detect srcpackages by 'arch'
//return ArchId( _solvable->arch );
}
+ IdString Solvable::vendor() const
+ {
+ NO_SOLVABLE_RETURN( IdString() );
+ return IdString( _solvable->vendor );
+ }
+
+ Repository Solvable::repository() const
+ {
+ NO_SOLVABLE_RETURN( Repository::noRepository );
+ return Repository( _solvable->repo );
+ }
+
+ RepoInfo Solvable::repoInfo() const
+ { return repository().info(); }
+
+
+ bool Solvable::isSystem() const
+ {
+ NO_SOLVABLE_RETURN( _id == detail::systemSolvableId );
+ return myPool().isSystemRepo( _solvable->repo );
+ }
+
+ bool Solvable::onSystemByUser() const
+ {
+ return isSystem() && myPool().isOnSystemByUser( ident() );
+ }
+
bool Solvable::multiversionInstall() const
{
- return myPool().isMultiversion( ident() );
+ NO_SOLVABLE_RETURN( false );
+ return myPool().isMultiversion( *this );
}
- IdString Solvable::vendor() const
+ Date Solvable::buildtime() const
{
- NO_SOLVABLE_RETURN( IdString() );
- return IdString( _solvable->vendor );
+ NO_SOLVABLE_RETURN( Date() );
+ return Date( lookupNumAttribute( SolvAttr::buildtime ) );
}
- Capabilities Solvable::operator[]( Dep which_r ) const
+ Date Solvable::installtime() const
{
- switch( which_r.inSwitch() )
- {
- case Dep::PROVIDES_e: return provides(); break;
- case Dep::REQUIRES_e: return requires(); break;
- case Dep::CONFLICTS_e: return conflicts(); break;
- case Dep::OBSOLETES_e: return obsoletes(); break;
- case Dep::RECOMMENDS_e: return recommends(); break;
- case Dep::SUGGESTS_e: return suggests(); break;
- case Dep::ENHANCES_e: return enhances(); break;
- case Dep::SUPPLEMENTS_e: return supplements(); break;
- case Dep::PREREQUIRES_e: return prerequires(); break;
- }
- return Capabilities();
+ NO_SOLVABLE_RETURN( Date() );
+ return Date( lookupNumAttribute( SolvAttr::installtime ) );
}
- inline Capabilities _getCapabilities( detail::IdType * idarraydata_r, ::Offset offs_r )
+ std::string Solvable::asString() const
{
- return offs_r ? Capabilities( idarraydata_r + offs_r ) : Capabilities();
+ NO_SOLVABLE_RETURN( (_id == detail::systemSolvableId ? "systemSolvable" : "noSolvable") );
+ return str::form( "%s-%s.%s",
+ IdString( _solvable->name ).c_str(),
+ IdString( _solvable->evr ).c_str(),
+ IdString( _solvable->arch ).c_str() );
}
+
+ std::string Solvable::asUserString() const\
+ {
+ NO_SOLVABLE_RETURN( (_id == detail::systemSolvableId ? "systemSolvable" : "noSolvable") );
+ return str::form( "%s-%s.%s(%s)",
+ IdString( _solvable->name ).c_str(),
+ IdString( _solvable->evr ).c_str(),
+ IdString( _solvable->arch ).c_str(),
+ repository().asUserString().c_str() );
+ }
+
+ bool Solvable::identical( const Solvable & rhs ) const
+ {
+ NO_SOLVABLE_RETURN( ! rhs.get() );
+ ::_Solvable * rhssolvable( rhs.get() );
+ return rhssolvable && ( _solvable == rhssolvable || ::solvable_identical( _solvable, rhssolvable ) );
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ namespace
+ {
+ inline Capabilities _getCapabilities( detail::IdType * idarraydata_r, ::Offset offs_r )
+ {
+ return offs_r ? Capabilities( idarraydata_r + offs_r ) : Capabilities();
+ }
+ } // namespace
+ ///////////////////////////////////////////////////////////////////
+
Capabilities Solvable::provides() const
{
NO_SOLVABLE_RETURN( Capabilities() );
ret.insert( *it );
}
return ret;
- }
+ }
CapabilitySet Solvable::valuesOfNamespace( const std::string & namespace_r ) const
{
return ret;
}
-
- std::string Solvable::asString() const
- {
- NO_SOLVABLE_RETURN( (_id == detail::systemSolvableId ? "systemSolvable" : "noSolvable") );
- return str::form( "%s-%s.%s",
- IdString( _solvable->name ).c_str(),
- IdString( _solvable->evr ).c_str(),
- IdString( _solvable->arch ).c_str() );
- }
-
- std::string Solvable::asUserString() const\
- {
- NO_SOLVABLE_RETURN( (_id == detail::systemSolvableId ? "systemSolvable" : "noSolvable") );
- return str::form( "%s-%s.%s(%s)",
- IdString( _solvable->name ).c_str(),
- IdString( _solvable->evr ).c_str(),
- IdString( _solvable->arch ).c_str(),
- repository().asUserString().c_str() );
- }
-
- bool Solvable::identical( Solvable rhs ) const
- {
- NO_SOLVABLE_RETURN( ! rhs.get() );
- ::_Solvable * rhssolvable( rhs.get() );
- return rhssolvable && ( _solvable == rhssolvable || ::solvable_identical( _solvable, rhssolvable ) );
- }
-
///////////////////////////////////////////////////////////////////
namespace
- { /////////////////////////////////////////////////////////////////
+ {
/** Expand \ref Capability and call \c fnc_r for each namescpace:language
* dependency. Return #invocations of fnc_r, negative if fnc_r returned
* false to indicate abort.
* dependency. Return #invocations of fnc_r, negative if fnc_r returned
* false to indicate abort.
*/
- inline int invokeOnEachSupportedLocale( Capabilities cap_r, function<bool (const Locale &)> fnc_r )
+ inline int invokeOnEachSupportedLocale( Capabilities cap_r, function<bool (Locale)> fnc_r )
{
int cnt = 0;
for_( cit, cap_r.begin(), cap_r.end() )
const LocaleSet & _locales;
};
-
- } /////////////////////////////////////////////////////////////////
+ } // namespace
+ ///////////////////////////////////////////////////////////////////
bool Solvable::supportsLocales() const
{
bool Solvable::supportsRequestedLocales() const
{ return supportsLocale( myPool().getRequestedLocales() ); }
- void Solvable::getSupportedLocales( LocaleSet & locales_r ) const
+ LocaleSet Solvable::getSupportedLocales() const
+ {
+ LocaleSet ret;
+ invokeOnEachSupportedLocale( supplements(), functor::Collector( std::inserter( ret, ret.begin() ) ) );
+ return ret;
+ }
+
+ CpeId Solvable::cpeId() const
+ {
+ NO_SOLVABLE_RETURN( CpeId() );
+ return CpeId( lookupStrAttribute( SolvAttr::cpeid ), CpeId::noThrow );
+ }
+
+ unsigned Solvable::mediaNr() const
+ {
+ NO_SOLVABLE_RETURN( 0U );
+ return lookupNumAttribute( SolvAttr::medianr );
+ }
+
+ ByteCount Solvable::installSize() const
+ {
+ NO_SOLVABLE_RETURN( ByteCount() );
+ return ByteCount( lookupNumAttribute( SolvAttr::installsize ) );
+ }
+
+ ByteCount Solvable::downloadSize() const
+ {
+ NO_SOLVABLE_RETURN( ByteCount() );
+ return ByteCount( lookupNumAttribute( SolvAttr::downloadsize ) );
+ }
+
+ std::string Solvable::distribution() const
+ {
+ NO_SOLVABLE_RETURN( std::string() );
+ return lookupStrAttribute( SolvAttr::distribution );
+ }
+
+ std::string Solvable::summary( const Locale & lang_r ) const
{
- invokeOnEachSupportedLocale( supplements(),
- functor::Collector( std::inserter( locales_r, locales_r.begin() ) ) );
+ NO_SOLVABLE_RETURN( std::string() );
+ return lookupStrAttribute( SolvAttr::summary, lang_r );
+ }
+
+ std::string Solvable::description( const Locale & lang_r ) const
+ {
+ NO_SOLVABLE_RETURN( std::string() );
+ return lookupStrAttribute( SolvAttr::description, lang_r );
}
- /******************************************************************
- **
- ** FUNCTION NAME : operator<<
- ** FUNCTION TYPE : std::ostream &
- */
+ std::string Solvable::insnotify( const Locale & lang_r ) const
+ {
+ NO_SOLVABLE_RETURN( std::string() );
+ return lookupStrAttribute( SolvAttr::insnotify, lang_r );
+ }
+
+ std::string Solvable::delnotify( const Locale & lang_r ) const
+ {
+ NO_SOLVABLE_RETURN( std::string() );
+ return lookupStrAttribute( SolvAttr::delnotify, lang_r );
+ }
+
+ std::string Solvable::licenseToConfirm( const Locale & lang_r ) const
+ {
+ NO_SOLVABLE_RETURN( std::string() );
+ std::string ret = lookupStrAttribute( SolvAttr::eula, lang_r );
+ if ( ret.empty() && isKind<Product>() )
+ {
+ const RepoInfo & ri( repoInfo() );
+ if ( ri.needToAcceptLicense() || ! ui::Selectable::get( *this )->hasInstalledObj() )
+ ret = ri.getLicense( lang_r ); // bnc#908976: suppress informal license upon update
+ }
+ return ret;
+ }
+
+ bool Solvable::needToAcceptLicense() const
+ {
+ NO_SOLVABLE_RETURN( false );
+ return ( isKind<Product>() ? repoInfo().needToAcceptLicense() : true );
+ }
+
+
std::ostream & operator<<( std::ostream & str, const Solvable & obj )
{
if ( ! obj )
<< obj.repository().alias() << ")";
}
- /******************************************************************
- **
- ** FUNCTION NAME : dumpOn
- ** FUNCTION TYPE : std::ostream &
- */
std::ostream & dumpOn( std::ostream & str, const Solvable & obj )
{
str << obj;
return str;
}
- /////////////////////////////////////////////////////////////////
} // namespace sat
///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
+{
+ class ByteCount;
class CheckSum;
+ class CpeId;
+ class Date;
class OnMediaLocation;
-
///////////////////////////////////////////////////////////////////
namespace sat
- { /////////////////////////////////////////////////////////////////
-
+ {
+ ///////////////////////////////////////////////////////////////////
+ /// \class Solvable
+ /// \brief A \ref Solvable object within the sat \ref Pool.
+ ///
+ /// \note Unfortunately libsolv combines the objects kind and
+ /// name in a single identifier \c "pattern:kde_multimedia",
+ /// \b except for packages and source packes. They are not prefixed
+ /// by any kind string. Instead the architecture is abused to store
+ /// \c "src" and \c "nosrc" values.
+ ///
+ /// \ref Solvable will hide this inconsistency by treating source
+ /// packages as an own kind of solvable and map their arch to
+ /// \ref Arch_noarch.
///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : Solvable
- //
- /** A \ref Solvable object within the sat \ref Pool.
- *
- * \note Unfortunately libsolv combines the objects kind and
- * name in a single identifier \c "pattern:kde_multimedia",
- * \b except for packages and source packes. They are not prefixed
- * by any kind string. Instead the architecture is abused to store
- * \c "src" and \c "nosrc" values.
- *
- * \ref Solvable will hide this inconsistency by treating source
- * packages as an own kind of solvable and map their arch to
- * \ref Arch_noarch.
- */
class Solvable : protected detail::PoolMember
{
+ public:
+ typedef sat::detail::SolvableIdType IdType;
+
+ public:
+ /** Default ctor creates \ref noSolvable.*/
+ Solvable()
+ : _id( detail::noSolvableId )
+ {}
+
+ /** \ref PoolImpl ctor. */
+ explicit Solvable( IdType id_r )
+ : _id( id_r )
+ {}
+
+ public:
+ /** Represents no \ref Solvable. */
+ static const Solvable noSolvable;
+
+ /** Evaluate \ref Solvable in a boolean context (\c != \c noSolvable). */
+ explicit operator bool() const
+ { return get(); }
+
+ public:
+ /** The identifier.
+ * This is the solvables \ref name, \b except for packages and
+ * source packes, prefixed by it's \ref kind.
+ */
+ IdString ident()const;
+
+ /** The Solvables ResKind. */
+ ResKind kind()const;
+
+ /** Test whether a Solvable is of a certain \ref ResKind.
+ * The test is far cheaper than actually retrieving and
+ * comparing the \ref kind.
+ */
+ bool isKind( const ResKind & kind_r ) const;
+ /** \overload */
+ template<class _Res>
+ bool isKind() const
+ { return isKind( resKind<_Res>() ); }
+ /** \overload Extend the test to a range of \ref ResKind. */
+ template<class _Iterator>
+ bool isKind( _Iterator begin, _Iterator end ) const
+ { for_( it, begin, end ) if ( isKind( *it ) ) return true; return false; }
+
+ /** The name (without any ResKind prefix). */
+ std::string name() const;
+
+ /** The edition (version-release). */
+ Edition edition() const;
+
+ /** The architecture. */
+ Arch arch() const;
+
+ /** The vendor. */
+ IdString vendor() const;
+
+ /** The \ref Repository this \ref Solvable belongs to. */
+ Repository repository() const;
+ /** The repositories \ref RepoInfo. */
+ RepoInfo repoInfo() const;
+
+ /** Return whether this \ref Solvable belongs to the system repo.
+ * \note This includes the otherwise hidden systemSolvable.
+ */
+ bool isSystem() const;
+
+ /** Whether this is known to be installed on behalf of a user request.
+ * \note This is a hint guessed by evaluating an available install history.
+ * Returns \c false for non-system (uninstalled) solvables, or if no history
+ * is available.
+ */
+ bool onSystemByUser() const;
+
+ /** Whether different versions of this package can be installed at the same time.
+ * Per default \c false. \see also \ref ZConfig::multiversion.
+ */
+ bool multiversionInstall() const;
+
+ /** The items build time. */
+ Date buildtime() const;
+
+ /** The items install time (\c false if not installed). */
+ Date installtime() const;
+
+ public:
+ /** String representation <tt>"ident-edition.arch"</tt> or \c "noSolvable"
+ * \code
+ * product:openSUSE-11.1.x86_64
+ * autoyast2-2.16.19-0.1.src
+ * noSolvable
+ * \endcode
+ */
+ std::string asString() const;
+
+ /** String representation <tt>"ident-edition.arch(repo)"</tt> or \c "noSolvable" */
+ std::string asUserString() const;
+
+ /** Test whether two Solvables have the same content.
+ * Basically the same name, edition, arch, vendor and buildtime.
+ */
+ bool identical( const Solvable & rhs ) const;
+
+ /** Test for same name-version-release.arch */
+ bool sameNVRA( const Solvable & rhs ) const
+ { return( get() == rhs.get() || ( ident() == rhs.ident() && edition() == rhs.edition() && arch() == rhs.arch() ) ); }
+
+ public:
+ /** \name Access to the \ref Solvable dependencies.
+ *
+ * \note Prerequires are a subset of requires.
+ */
+ //@{
+ Capabilities provides() const;
+ Capabilities requires() const;
+ Capabilities conflicts() const;
+ Capabilities obsoletes() const;
+ Capabilities recommends() const;
+ Capabilities suggests() const;
+ Capabilities enhances() const;
+ Capabilities supplements() const;
+ Capabilities prerequires() const;
+
+ /** Return \ref Capabilities selected by \ref Dep constant. */
+ Capabilities dep( Dep which_r ) const
+ {
+ switch( which_r.inSwitch() )
+ {
+ case Dep::PROVIDES_e: return provides(); break;
+ case Dep::REQUIRES_e: return requires(); break;
+ case Dep::CONFLICTS_e: return conflicts(); break;
+ case Dep::OBSOLETES_e: return obsoletes(); break;
+ case Dep::RECOMMENDS_e: return recommends(); break;
+ case Dep::SUGGESTS_e: return suggests(); break;
+ case Dep::ENHANCES_e: return enhances(); break;
+ case Dep::SUPPLEMENTS_e: return supplements(); break;
+ case Dep::PREREQUIRES_e: return prerequires(); break;
+ }
+ return Capabilities();
+ }
+ /** \overload operator[] */
+ Capabilities operator[]( Dep which_r ) const
+ { return dep( which_r ); }
+
+
+ /** Return the namespaced provides <tt>'namespace([value])[ op edition]'</tt> of this Solvable. */
+ CapabilitySet providesNamespace( const std::string & namespace_r ) const;
+
+ /** Return <tt>'value[ op edition]'</tt> for namespaced provides <tt>'namespace(value)[ op edition]'</tt>.
+ * Similar to \ref providesNamespace, but the namespace is stripped from the
+ * dependencies. This is convenient if the namespace denotes packages that
+ * should be looked up. E.g. the \c weakremover namespace used in a products
+ * release package denotes the packages that were dropped from the distribution.
+ * \see \ref Product::droplist
+ */
+ CapabilitySet valuesOfNamespace( const std::string & namespace_r ) const;
+ //@}
+
+ public:
+ /** \name Locale support. */
+ //@{
+ /** Whether this \c Solvable claims to support locales. */
+ bool supportsLocales() const;
+ /** Whether this \c Solvable supports a specific \ref Locale. */
+ bool supportsLocale( const Locale & locale_r ) const;
+ /** Whether this \c Solvable supports at least one of the specified locales. */
+ bool supportsLocale( const LocaleSet & locales_r ) const;
+ /** Whether this \c Solvable supports at least one requested locale.
+ * \see \ref Pool::setRequestedLocales
+ */
+ bool supportsRequestedLocales() const;
+ /** Return the supported locales. */
+ LocaleSet getSupportedLocales() const;
+ /** \overload Legacy return via arg \a locales_r */
+ void getSupportedLocales( LocaleSet & locales_r ) const
+ { locales_r = getSupportedLocales(); }
+ //@}
+
+ public:
+ /** The solvables CpeId if available. */
+ CpeId cpeId() const;
+
+ /** Media number the solvable is located on (\c 0 if no media access required). */
+ unsigned mediaNr() const;
+
+ /** Installed (unpacked) size.
+ * This is just a total number. Many objects provide even more detailed
+ * disk usage data. You can use \ref DiskUsageCounter to find out
+ * how objects data are distributed across partitions/directories.
+ * \code
+ * // Load directory set into ducounter
+ * DiskUsageCounter ducounter( { "/", "/usr", "/var" } );
+ *
+ * // see how noch space the packages use
+ * for ( const PoolItem & pi : pool )
+ * {
+ * cout << pi << ducounter.disk_usage( pi ) << endl;
+ * // I__s_(7)GeoIP-1.4.8-3.1.2.x86_64(@System) {
+ * // dir:[/] [ bs: 0 B ts: 0 B us: 0 B (+-: 1.0 KiB)]
+ * // dir:[/usr] [ bs: 0 B ts: 0 B us: 0 B (+-: 133.0 KiB)]
+ * // dir:[/var] [ bs: 0 B ts: 0 B us: 0 B (+-: 1.1 MiB)]
+ * // }
+ * }
+ * \endcode
+ * \see \ref DiskUsageCounter
+ */
+ ByteCount installSize() const;
+
+ /** Download size. */
+ ByteCount downloadSize() const;
+
+ /** The distribution string. */
+ std::string distribution() const;
+
+ /** Short (singleline) text describing the solvable (opt. translated). */
+ std::string summary( const Locale & lang_r = Locale() ) const;
+
+ /** Long (multiline) text describing the solvable (opt. translated). */
+ std::string description( const Locale & lang_r = Locale() ) const;
+
+ /** UI hint text when selecting the solvable for install (opt. translated). */
+ std::string insnotify( const Locale & lang_r = Locale() ) const;
+ /** UI hint text when selecting the solvable for uninstall (opt. translated).*/
+ std::string delnotify( const Locale & lang_r = Locale() ) const;
+
+ /** License or agreement to accept before installing the solvable (opt. translated). */
+ std::string licenseToConfirm( const Locale & lang_r = Locale() ) const;
+ /** \c True except for well known exceptions (i.e show license but no need to accept it). */
+ bool needToAcceptLicense() const;
+
+ public:
+ /** Helper that splits an identifier into kind and name or vice versa.
+ * \note In case \c name_r is preceded by a well known kind spec, the
+ * \c kind_r argument is ignored, and kind is derived from name.
+ * \see \ref ident
+ */
+ class SplitIdent
+ {
public:
- typedef sat::detail::SolvableIdType IdType;
-
- public:
- /** Default ctor creates \ref noSolvable.*/
- Solvable()
- : _id( detail::noSolvableId ) {}
-
- /** \ref PoolImpl ctor. */
- explicit Solvable( IdType id_r )
- : _id( id_r ) {}
-
- public:
- /** Represents no \ref Solvable. */
- static const Solvable noSolvable;
-
- /** Evaluate \ref Solvable in a boolean context (\c != \c noSolvable). */
- explicit operator bool() const
- { return get(); }
-
- /** Return whether this \ref Solvable belongs to the system repo.
- * \note This includes the otherwise hidden systemSolvable.
- */
- bool isSystem() const;
-
- /** Whether this is known to be installed on behalf of a user request.
- * \note This is a hint guessed by evaluating an available install history.
- * Returns \c false for non-system (uninstalled) solvables, or if no history
- * is available.
- */
- bool onSystemByUser() const;
-
- /** The \ref Repository this \ref Solvable belongs to. */
- Repository repository() const;
-
- public:
-
- /** \name Attribute lookup.
- * \see \ref LookupAttr and \ref ArrayAttr providing a general, more
- * query like interface for attribute retrieval.
- */
- //@{
- /**
- * returns the string attribute value for \ref attr
- * or an empty string if it does not exists.
- */
- std::string lookupStrAttribute( const SolvAttr & attr ) const;
- /** \overload Trying to look up a translated string attribute.
- *
- * Returns the translation for \c lang_r.
- *
- * Passing an empty \ref Locale will return the string for the
- * current default locale (\see \ref ZConfig::TextLocale),
- * \b considering all fallback locales.
- *
- * Returns an empty string if no translation is available.
- */
- std::string lookupStrAttribute( const SolvAttr & attr, const Locale & lang_r ) const;
-
- /**
- * returns the numeric attribute value for \ref attr
- * or 0 if it does not exists.
- */
- unsigned long long lookupNumAttribute( const SolvAttr & attr ) const;
-
- /**
- * returns the boolean attribute value for \ref attr
- * or \c false if it does not exists.
- */
- bool lookupBoolAttribute( const SolvAttr & attr ) const;
-
- /**
- * returns the id attribute value for \ref attr
- * or \ref detail::noId if it does not exists.
- */
- detail::IdType lookupIdAttribute( const SolvAttr & attr ) const;
-
- /**
- * returns the CheckSum attribute value for \ref attr
- * or an empty CheckSum if ir does not exist.
- */
- CheckSum lookupCheckSumAttribute( const SolvAttr & attr ) const;
-
- /**
- * returns OnMediaLocation data: This is everything we need to
- * download e.g. an rpm (path, checksum, downloadsize, etc.).
- */
- OnMediaLocation lookupLocation() const;
-
- //@}
- public:
- /** The identifier.
- * This is the solvables \ref name, \b except for packages and
- * source packes, prefixed by it's \ref kind.
- */
- IdString ident() const;
-
- ResKind kind() const;
- /** Test whether a Solvable is of a certain \ref ResKind.
- * The test is far cheaper than actually retriveing and
- * comparing the \ref kind.
- */
- bool isKind( const ResKind & kind_r ) const;
- /** \overload */
- template<class _Res>
- bool isKind() const
- { return isKind( resKind<_Res>() ); }
- /** \overload Extend the test to a range of \ref ResKind. */
- template<class _Iterator>
- bool isKind( _Iterator begin, _Iterator end )
- { for_( it, begin, end ) if ( isKind( *it ) ) return true; return false; }
-
- std::string name() const;
- Edition edition() const;
- Arch arch() const;
-
- IdString vendor() const;
-
- /** Whether different versions of this package can be installed at the same time.
- * Per default \c false. \see also \ref ZConfig::multiversion.
- */
- bool multiversionInstall() const;
-
- /** String representation <tt>"ident-edition.arch"</tt> or \c "noSolvable"
- * \code
- * product:openSUSE-11.1.x86_64
- * autoyast2-2.16.19-0.1.src
- * noSolvable
- * \endcode
- */
- std::string asString() const;
-
- /** String representation <tt>"ident-edition.arch(repo)"</tt> or \c "noSolvable" */
- std::string asUserString() const;
-
- /** Test whether two Solvables have the same content.
- * Basically the same name, edition, arch, vendor and buildtime.
- */
- bool identical( Solvable rhs ) const;
-
- /** Test for same name-version-release.arch */
- bool sameNVRA( Solvable rhs ) const
- { return( ident() == rhs.ident() && edition() == rhs.edition() && arch() == rhs.arch() ); }
-
- public:
-
- /** \name Access to the \ref Solvable dependencies.
- *
- * \note Prerequires are a subset of requires.
- */
- //@{
- Capabilities operator[]( Dep which_r ) const;
-
- Capabilities provides() const;
- Capabilities requires() const;
- Capabilities conflicts() const;
- Capabilities obsoletes() const;
- Capabilities recommends() const;
- Capabilities suggests() const;
- Capabilities enhances() const;
- Capabilities supplements() const;
- Capabilities prerequires() const;
-
- /** Return the namespaced provides <tt>'namespace([value])[ op edition]'</tt> of this Solvable. */
- CapabilitySet providesNamespace( const std::string & namespace_r ) const;
-
- /** Return <tt>'value[ op edition]'</tt> for namespaced provides <tt>'namespace(value)[ op edition]'</tt>.
- * Similar to \ref providesNamespace, but the namespace is stripped from the
- * dependencies. This is convenient if the namespace denotes packages that
- * should be looked up. E.g. the \c weakremover namespace used in a products
- * release package denotes the packages that were dropped from the distribution.
- * \see \ref Product::droplist
- */
- CapabilitySet valuesOfNamespace( const std::string & namespace_r ) const;
- //@}
-
- public:
- /** \name Locale support. */
- //@{
- /** Whether this \c Solvable claims to support locales. */
- bool supportsLocales() const;
- /** Whether this \c Solvable supports a specific \ref Locale. */
- bool supportsLocale( const Locale & locale_r ) const;
- /** Whether this \c Solvable supports at least one of the specified locales. */
- bool supportsLocale( const LocaleSet & locales_r ) const;
- /** Whether this \c Solvable supports at least one requested locale.
- * \see \ref Pool::setRequestedLocales
- */
- bool supportsRequestedLocales() const;
- /** Return the supported locales via locales_r. */
- void getSupportedLocales( LocaleSet & locales_r ) const;
- /** \overload */
- LocaleSet getSupportedLocales() const
- { LocaleSet ret; getSupportedLocales( ret ); return ret; }
- //@}
-
- public:
- /** Return next Solvable in \ref Pool (or \ref noSolvable). */
- Solvable nextInPool() const;
- /** Return next Solvable in \ref Repo (or \ref noSolvable). */
- Solvable nextInRepo() const;
-
- /** Helper that splits an identifier into kind and name or vice versa.
- * \note In case \c name_r is preceded by a well known kind spec, the
- * \c kind_r argument is ignored, and kind is derived from name.
- * \see \ref ident
- */
- class SplitIdent
- {
- public:
- SplitIdent() {}
- SplitIdent( IdString ident_r );
- SplitIdent( const char * ident_r );
- SplitIdent( const std::string & ident_r );
- SplitIdent( ResKind kind_r, IdString name_r );
- SplitIdent( ResKind kind_r, const C_Str & name_r );
-
- IdString ident() const { return _ident; }
- ResKind kind() const { return _kind; }
- IdString name() const { return _name; }
-
- private:
- IdString _ident;
- ResKind _kind;
- IdString _name;
- };
+ SplitIdent() {}
+ SplitIdent( IdString ident_r );
+ SplitIdent( const char * ident_r );
+ SplitIdent( const std::string & ident_r );
+ SplitIdent( ResKind kind_r, IdString name_r );
+ SplitIdent( ResKind kind_r, const C_Str & name_r );
- public:
- /** Expert backdoor. */
- ::_Solvable * get() const;
- /** Expert backdoor. */
- IdType id() const { return _id; }
+ IdString ident() const { return _ident; }
+ ResKind kind() const { return _kind; }
+ IdString name() const { return _name; }
private:
- IdType _id;
+ IdString _ident;
+ ResKind _kind;
+ IdString _name;
+ };
+
+ public:
+ /** \name Attribute lookup.
+ * \see \ref LookupAttr and \ref ArrayAttr providing a general, more
+ * query like interface for attribute retrieval.
+ */
+ //@{
+ /**
+ * returns the string attribute value for \ref attr
+ * or an empty string if it does not exists.
+ */
+ std::string lookupStrAttribute( const SolvAttr & attr ) const;
+ /** \overload Trying to look up a translated string attribute.
+ *
+ * Returns the translation for \c lang_r.
+ *
+ * Passing an empty \ref Locale will return the string for the
+ * current default locale (\see \ref ZConfig::TextLocale),
+ * \b considering all fallback locales.
+ *
+ * Returns an empty string if no translation is available.
+ */
+ std::string lookupStrAttribute( const SolvAttr & attr, const Locale & lang_r ) const;
+
+ /**
+ * returns the numeric attribute value for \ref attr
+ * or 0 if it does not exists.
+ */
+ unsigned long long lookupNumAttribute( const SolvAttr & attr ) const;
+
+ /**
+ * returns the boolean attribute value for \ref attr
+ * or \c false if it does not exists.
+ */
+ bool lookupBoolAttribute( const SolvAttr & attr ) const;
+
+ /**
+ * returns the id attribute value for \ref attr
+ * or \ref detail::noId if it does not exists.
+ */
+ detail::IdType lookupIdAttribute( const SolvAttr & attr ) const;
+
+ /**
+ * returns the CheckSum attribute value for \ref attr
+ * or an empty CheckSum if ir does not exist.
+ */
+ CheckSum lookupCheckSumAttribute( const SolvAttr & attr ) const;
+
+ /**
+ * returns OnMediaLocation data: This is everything we need to
+ * download e.g. an rpm (path, checksum, downloadsize, etc.).
+ */
+ OnMediaLocation lookupLocation() const;
+ //@}
+
+ public:
+ /** Return next Solvable in \ref Pool (or \ref noSolvable). */
+ Solvable nextInPool() const;
+ /** Return next Solvable in \ref Repo (or \ref noSolvable). */
+ Solvable nextInRepo() const;
+ /** Expert backdoor. */
+ ::_Solvable * get() const;
+ /** Expert backdoor. */
+ IdType id() const { return _id; }
+
+ private:
+ IdType _id;
};
///////////////////////////////////////////////////////////////////
inline bool operator<( const Solvable & lhs, const Solvable & rhs )
{ return lhs.get() < rhs.get(); }
+ /** \relates Solvable Test whether a \ref Solvable is of a certain Kind. */
+ template<class _Res>
+ inline bool isKind( const Solvable & solvable_r )
+ { return solvable_r.isKind( ResTraits<_Res>::kind ); }
+
/** \relates Solvable Test for same content. */
- inline bool identical( Solvable lhs, Solvable rhs )
+ inline bool identical( const Solvable & lhs, const Solvable & rhs )
{ return lhs.identical( rhs ); }
/** \relates Solvable Test for same name version release and arch. */
- inline bool sameNVRA( Solvable lhs, Solvable rhs )
+ inline bool sameNVRA( const Solvable & lhs, const Solvable & rhs )
{ return lhs.sameNVRA( rhs ); }
+
+ /** \relates Solvable Compare according to \a kind and \a name. */
+ inline int compareByN( const Solvable & lhs, const Solvable & rhs )
+ {
+ int res = 0;
+ if ( lhs != rhs )
+ {
+ if ( (res = lhs.kind().compare( rhs.kind() )) == 0 )
+ res = lhs.name().compare( rhs.name() );
+ }
+ return res;
+ }
+
+ /** \relates Solvable Compare according to \a kind, \a name and \a edition. */
+ inline int compareByNVR( const Solvable & lhs, const Solvable & rhs )
+ {
+ int res = compareByN( lhs, rhs );
+ if ( res == 0 )
+ res = lhs.edition().compare( rhs.edition() );
+ return res;
+ }
+
+ /** \relates Solvable Compare according to \a kind, \a name, \a edition and \a arch. */
+ inline int compareByNVRA( const Solvable & lhs, const Solvable & rhs )
+ {
+ int res = compareByNVR( lhs, rhs );
+ if ( res == 0 )
+ res = lhs.arch().compare( rhs.arch() );
+ return res;
+ }
+
///////////////////////////////////////////////////////////////////
namespace detail
- { /////////////////////////////////////////////////////////////////
+ {
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : SolvableIterator
Solvable _val;
};
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
} // namespace detail
///////////////////////////////////////////////////////////////////
-
- /////////////////////////////////////////////////////////////////
} // namespace sat
///////////////////////////////////////////////////////////////////
- /** \relates sat::Solvable Test whether a \ref sat::Solvable is of a certain Kind. */
- template<class _Res>
- inline bool isKind( const sat::Solvable & solvable_r )
- { return solvable_r.isKind( ResTraits<_Res>::kind ); }
-
class PoolItem;
///////////////////////////////////////////////////////////////////
namespace sat
- { /////////////////////////////////////////////////////////////////
+ {
/** To Solvable transform functor.
* \relates Solvable
* \relates sat::SolvIterMixin
{
typedef Solvable result_type;
- Solvable operator()( Solvable solv_r ) const
+ Solvable operator()( const Solvable & solv_r ) const
{ return solv_r; }
Solvable operator()( const PoolItem & pi_r ) const;
Solvable operator()( const ResObject_constPtr & res_r ) const;
};
- /////////////////////////////////////////////////////////////////
} // namespace sat
///////////////////////////////////////////////////////////////////
-
- /////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
/** */
template<class _Solv>
bool contains( const _Solv & solv_r ) const
- { return( get().find( asSolvable()( solv_r ) ) != end() ); }
+ { return( get().count( asSolvable()( solv_r ) ) ); }
/** Iterator pointing to the first \ref Solvable. */
const_iterator begin() const
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/sat/SolvableType.h
+ */
+#ifndef ZYPP_SAT_SOLVABLETYPE_H
+#define ZYPP_SAT_SOLVABLETYPE_H
+
+#include <iosfwd>
+
+#include "zypp/sat/Solvable.h"
+#include "zypp/Repository.h"
+#include "zypp/OnMediaLocation.h"
+#include "zypp/ByteCount.h"
+#include "zypp/CheckSum.h"
+#include "zypp/CpeId.h"
+#include "zypp/Date.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{
+ ///////////////////////////////////////////////////////////////////
+ namespace sat
+ {
+ ///////////////////////////////////////////////////////////////////
+ /// \class SolvableType
+ /// \brief Base class for creating \ref Solvable based types.
+ /// \ingroup g_CRTP
+ ///
+ /// Derive from this and offer explicit conversion to \ref Solvable
+ /// to make the \ref Solvable properties directly accessible.
+ ///
+ /// Different SolvableTypes are comparable based on the underlying
+ /// \ref Solvable.
+ ///
+ /// \see \ref Solvable
+ ///
+ /// \code
+ /// class MySolvable : public SolvableType<MySolvable>
+ /// {
+ /// ......
+ /// public:
+ /// explicit operator sat::Solvable() const;
+ ///
+ /// };
+ /// \endcode
+ ///////////////////////////////////////////////////////////////////
+ template <class Derived>
+ struct SolvableType
+ {
+ /** Return the corresponding \ref sat::Solvable. */
+ Solvable satSolvable() const { return Solvable(static_cast<const Derived&>(*this)); }
+
+ explicit operator bool() const { return bool(satSolvable()); }
+
+ IdString ident() const { return satSolvable().ident(); }
+
+ ResKind kind() const { return satSolvable().kind(); }
+ bool isKind( const ResKind & kind_r ) const { return satSolvable().isKind( kind_r ); }
+ template<class _Res>
+ bool isKind() const { return satSolvable().isKind<_Res>(); }
+ template<class _Iterator>
+ bool isKind( _Iterator begin, _Iterator end ) const { return satSolvable().isKind( begin, end ); }
+
+ std::string name() const { return satSolvable().name(); }
+ Edition edition() const { return satSolvable().edition(); }
+ Arch arch() const { return satSolvable().arch(); }
+ IdString vendor() const { return satSolvable().vendor(); }
+
+ Repository repository() const { return satSolvable().repository(); }
+ RepoInfo repoInfo() const { return satSolvable().repoInfo(); }
+
+ bool isSystem() const { return satSolvable().isSystem(); }
+ bool onSystemByUser() const { return satSolvable().onSystemByUser(); }
+ bool multiversionInstall() const { return satSolvable().multiversionInstall(); }
+
+ Date buildtime() const { return satSolvable().buildtime(); }
+ Date installtime() const { return satSolvable().installtime(); }
+
+ std::string asString() const { return satSolvable().asString(); }
+ std::string asUserString() const { return satSolvable().asUserString(); }
+
+ bool identical( const Solvable & rhs ) const { return satSolvable().identical( rhs ); }
+ template <class RDerived>
+ bool identical( const SolvableType<RDerived> & rhs ) const { return satSolvable().identical( rhs.satSolvable() ); }
+
+ bool sameNVRA( const Solvable &rhs ) const { return satSolvable().sameNVRA( rhs ); }
+ template <class RDerived>
+ bool sameNVRA( const SolvableType<RDerived> & rhs ) const { return satSolvable().sameNVRA( rhs.satSolvable() ); }
+
+ Capabilities provides() const { return satSolvable().provides(); }
+ Capabilities requires() const { return satSolvable().requires(); }
+ Capabilities conflicts() const { return satSolvable().conflicts(); }
+ Capabilities obsoletes() const { return satSolvable().obsoletes(); }
+ Capabilities recommends() const { return satSolvable().recommends(); }
+ Capabilities suggests() const { return satSolvable().suggests(); }
+ Capabilities enhances() const { return satSolvable().enhances(); }
+ Capabilities supplements() const { return satSolvable().supplements(); }
+ Capabilities prerequires() const { return satSolvable().prerequires(); }
+ Capabilities dep( Dep which_r ) const { return satSolvable().dep(which_r); }
+ Capabilities operator[]( Dep which_r ) const { return satSolvable()[which_r]; }
+
+ CapabilitySet providesNamespace( const std::string & namespace_r ) const { return satSolvable().providesNamespace( namespace_r ); }
+ CapabilitySet valuesOfNamespace( const std::string & namespace_r ) const { return satSolvable().valuesOfNamespace( namespace_r ); }
+
+ bool supportsLocales() const { return satSolvable().supportsLocales(); }
+ bool supportsLocale( const Locale & locale_r ) const { return satSolvable().supportsLocale( locale_r ); }
+ bool supportsLocale( const LocaleSet & locales_r ) const { return satSolvable().supportsLocale( locales_r ); }
+ bool supportsRequestedLocales() const { return satSolvable().supportsRequestedLocales(); }
+ LocaleSet getSupportedLocales() const { return satSolvable().getSupportedLocales(); }
+
+ CpeId cpeId() const { return satSolvable().cpeId(); }
+ unsigned mediaNr() const { return satSolvable().mediaNr(); }
+ ByteCount installSize() const { return satSolvable().installSize(); }
+ ByteCount downloadSize() const { return satSolvable().downloadSize(); }
+ std::string distribution() const { return satSolvable().distribution(); }
+
+ std::string summary( const Locale & lang_r = Locale() ) const { return satSolvable().summary( lang_r ); }
+ std::string description( const Locale & lang_r = Locale() ) const { return satSolvable().description( lang_r ); }
+ std::string insnotify( const Locale & lang_r = Locale() ) const { return satSolvable().insnotify( lang_r ); }
+ std::string delnotify( const Locale & lang_r = Locale() ) const { return satSolvable().delnotify( lang_r ); }
+ std::string licenseToConfirm( const Locale & lang_r = Locale() ) const { return satSolvable().licenseToConfirm( lang_r ); }
+ bool needToAcceptLicense() const { return satSolvable().needToAcceptLicense(); }
+
+ public:
+ std::string lookupStrAttribute( const SolvAttr & attr ) const { return satSolvable().lookupStrAttribute( attr ); }
+ std::string lookupStrAttribute( const SolvAttr & attr, const Locale & lang_r ) const { return satSolvable().lookupStrAttribute( attr, lang_r ); }
+ bool lookupBoolAttribute( const SolvAttr & attr ) const { return satSolvable().lookupBoolAttribute( attr ); }
+ detail::IdType lookupIdAttribute( const SolvAttr & attr ) const { return satSolvable().lookupIdAttribute( attr ); }
+ unsigned long long lookupNumAttribute( const SolvAttr & attr ) const { return satSolvable().lookupNumAttribute( attr ); }
+ CheckSum lookupCheckSumAttribute( const SolvAttr & attr ) const { return satSolvable().lookupCheckSumAttribute( attr ); }
+ OnMediaLocation lookupLocation() const { return satSolvable().lookupLocation(); }
+ Solvable::IdType id() const { return satSolvable().id(); }
+
+ protected:
+ SolvableType() {}
+ SolvableType( SolvableType && ) {}
+ SolvableType( const SolvableType & ) {}
+ void operator=( SolvableType && ) {}
+ void operator=( const SolvableType & ) {}
+ ~SolvableType() {}
+ };
+
+ /** \relates SolvableType Stream output */
+ template <class Derived>
+ inline std::ostream & operator<<( std::ostream & str, const SolvableType<Derived> & obj )
+ { return str << obj.satSolvable(); }
+
+ /** \relates SolvableType More verbose stream output including dependencies */
+ template <class Derived>
+ inline std::ostream & dumpOn( std::ostream & str, const SolvableType<Derived> & obj )
+ { return dumpOn( str, obj.satSolvable() ); }
+
+ /** \relates SolvableType Equal*/
+ template <class LDerived, class RDerived>
+ inline bool operator==( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
+ { return lhs.satSolvable() == rhs.satSolvable(); }
+ /** \overload */
+ template <class Derived>
+ inline bool operator==( const SolvableType<Derived> & lhs, const Solvable & rhs )
+ { return lhs.satSolvable() == rhs; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator==( const Solvable & lhs, const SolvableType<Derived> & rhs )
+ { return lhs == rhs.satSolvable(); }
+
+ /** \relates SolvableType NotEqual */
+ template <class LDerived, class RDerived>
+ inline bool operator!=( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
+ { return lhs.satSolvable() != rhs.satSolvable(); }
+ /** \overload */
+ template <class Derived>
+ inline bool operator!=( const SolvableType<Derived> & lhs, const Solvable & rhs )
+ { return lhs.satSolvable() != rhs; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator!=( const Solvable & lhs, const SolvableType<Derived> & rhs )
+ { return lhs != rhs.satSolvable(); }
+
+ /** \relates SolvableType Less*/
+ template <class LDerived, class RDerived>
+ inline bool operator<( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
+ { return lhs.satSolvable() < rhs.satSolvable(); }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<( const SolvableType<Derived> & lhs, const Solvable & rhs )
+ { return lhs.satSolvable() < rhs; }
+ /** \overload */
+ template <class Derived>
+ inline bool operator<( const Solvable & lhs, const SolvableType<Derived> & rhs )
+ { return lhs < rhs.satSolvable(); }
+
+ /** \relates SolvableType Test whether the \ref Solvable is of a certain \ref ResKind. */
+ template<class _Res, class Derived>
+ inline bool isKind( const SolvableType<Derived> & solvable_r )
+ { return isKind<_Res>( solvable_r.satSolvable() ); }
+
+ /** \relates SolvableType Test for same content. */
+ template <class LDerived, class RDerived>
+ inline bool identical( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
+ { return identical( lhs.satSolvable(), rhs.satSolvable() ); }
+ /** \overload */
+ template <class Derived>
+ inline bool identical( const SolvableType<Derived> & lhs, const Solvable & rhs )
+ { return identical( lhs.satSolvable(), rhs ); }
+ /** \overload */
+ template <class Derived>
+ inline bool identical( const Solvable & lhs, const SolvableType<Derived> & rhs )
+ { return identical( lhs, rhs.satSolvable() ); }
+
+ /** \relates SolvableType Test for same name version release and arch. */
+ template <class LDerived, class RDerived>
+ inline bool sameNVRA( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
+ { return sameNVRA( lhs.satSolvable(), rhs.satSolvable() ); }
+ /** \overload */
+ template <class Derived>
+ inline bool sameNVRA( const SolvableType<Derived> & lhs, const Solvable & rhs )
+ { return sameNVRA( lhs.satSolvable(), rhs ); }
+ /** \overload */
+ template <class Derived>
+ inline bool sameNVRA( const Solvable & lhs, const SolvableType<Derived> & rhs )
+ { return sameNVRA( lhs, rhs.satSolvable() ); }
+
+
+ /** \relates SolvableType Compare according to \a kind and \a name. */
+ template <class LDerived, class RDerived>
+ inline int compareByN( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
+ { return compareByN( lhs.satSolvable(), rhs.satSolvable() ); }
+ /** \overload */
+ template <class Derived>
+ inline bool compareByN( const SolvableType<Derived> & lhs, const Solvable & rhs )
+ { return compareByN( lhs.satSolvable(), rhs ); }
+ /** \overload */
+ template <class Derived>
+ inline bool compareByN( const Solvable & lhs, const SolvableType<Derived> & rhs )
+ { return compareByN( lhs, rhs.satSolvable() ); }
+
+
+ /** \relates SolvableType Compare according to \a kind, \a name and \a edition. */
+ template <class LDerived, class RDerived>
+ inline int compareByNVR( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
+ { return compareByNVR( lhs.satSolvable(), rhs.satSolvable() ); }
+ /** \overload */
+ template <class Derived>
+ inline bool compareByNVR( const SolvableType<Derived> & lhs, const Solvable & rhs )
+ { return compareByNVR( lhs.satSolvable(), rhs ); }
+ /** \overload */
+ template <class Derived>
+ inline bool compareByNVR( const Solvable & lhs, const SolvableType<Derived> & rhs )
+ { return compareByNVR( lhs, rhs.satSolvable() ); }
+
+ /** \relates SolvableType Compare according to \a kind, \a name, \a edition and \a arch. */
+ template <class LDerived, class RDerived>
+ inline int compareByNVRA( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
+ { return compareByNVRA( lhs.satSolvable(), rhs.satSolvable() ); }
+ /** \overload */
+ template <class Derived>
+ inline bool compareByNVRA( const SolvableType<Derived> & lhs, const Solvable & rhs )
+ { return compareByNVRA( lhs.satSolvable(), rhs ); }
+ /** \overload */
+ template <class Derived>
+ inline bool compareByNVRA( const Solvable & lhs, const SolvableType<Derived> & rhs )
+ { return compareByNVRA( lhs, rhs.satSolvable() ); }
+
+ } // namespace sat
+ ///////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_SAT_SOLVABLETYPE_H
, _trans( nullptr )
{
Queue decisionq;
- for_( it, ResPool::instance().begin(), ResPool::instance().end() )
+ for ( const PoolItem & pi : ResPool::instance() )
{
- if ( ! (*it).status().transacts() )
+ if ( ! pi.status().transacts() )
continue;
- sat::Solvable solv( (*it).satSolvable() );
- decisionq.push( solv.isSystem() ? -solv.id() : solv.id() );
+ decisionq.push( pi.isSystem() ? -pi.id() : pi.id() );
}
Queue noobsq;
- for_( it, sat::Pool::instance().multiversionBegin(), sat::Pool::instance().multiversionEnd() )
+ for ( const Solvable & solv : myPool().multiversionList() )
{
- noobsq.push( SOLVER_NOOBSOLETES | SOLVER_SOLVABLE_NAME );
- noobsq.push( it->id() );
+ noobsq.push( SOLVER_NOOBSOLETES | SOLVER_SOLVABLE );
+ noobsq.push( solv.id() );
}
Map noobsmap;
::solver_calculate_noobsmap( myPool().getPool(), noobsq, noobsmap );
#include "zypp/ZConfig.h"
#include "zypp/sat/detail/PoolImpl.h"
+#include "zypp/sat/SolvableSet.h"
#include "zypp/sat/Pool.h"
#include "zypp/Capability.h"
#include "zypp/Locale.h"
}
- static void _getLocaleDeps( Capability cap_r, std::unordered_set<sat::detail::IdType> & store_r )
+ static void _getLocaleDeps( const Capability & cap_r, LocaleSet & store_r )
{
// Collect locales from any 'namespace:language(lang)' dependency
CapDetail detail( cap_r );
case CapDetail::CAP_NAMESPACE:
if ( detail.lhs().id() == NAMESPACE_LANGUAGE )
{
- store_r.insert( detail.rhs().id() );
+ store_r.insert( Locale( IdString(detail.rhs().id()) ) );
}
break;
{
if ( !_availableLocalesPtr )
{
- // Collect any 'namespace:language(ja)' dependencies
- std::unordered_set<sat::detail::IdType> tmp;
- Pool pool( Pool::instance() );
- for_( it, pool.solvablesBegin(), pool.solvablesEnd() )
- {
- Capabilities cap( it->supplements() );
- for_( cit, cap.begin(), cap.end() )
- {
- _getLocaleDeps( *cit, tmp );
+ _availableLocalesPtr.reset( new LocaleSet );
+ LocaleSet & localeSet( *_availableLocalesPtr );
+
+ for ( const Solvable & pi : Pool::instance().solvables() )
+ {
+ for ( const Capability & cap : pi.supplements() )
+ {
+ _getLocaleDeps( cap, localeSet );
}
- }
-#warning immediately build LocaleSet as soon as Loale is an Id based type
- _availableLocalesPtr.reset( new LocaleSet(tmp.size()) );
- for_( it, tmp.begin(), tmp.end() )
- {
- _availableLocalesPtr->insert( Locale( IdString(*it) ) );
- }
+ }
}
return *_availableLocalesPtr;
}
+
void PoolImpl::multiversionListInit() const
{
_multiversionListPtr.reset( new MultiversionList );
MultiversionList & multiversionList( *_multiversionListPtr );
+
+ MultiversionList::size_type size = 0;
+ for ( const std::string & spec : ZConfig::instance().multiversionSpec() )
+ {
+ static const std::string prefix( "provides:" );
+ bool provides = str::hasPrefix( spec, prefix );
- const std::set<std::string> & multiversionSpec( ZConfig::instance().multiversionSpec() );
- for_( it, multiversionSpec.begin(), multiversionSpec.end() )
- {
- static const std::string prefix( "provides:" );
- if ( str::hasPrefix( *it, prefix ) )
- {
- WhatProvides provides( Capability( it->c_str() + prefix.size() ) );
- if ( provides.empty() )
- {
- MIL << "Multiversion install not provided (" << *it << ")" << endl;
- }
- else
- {
- for_( pit, provides.begin(), provides.end() )
- {
- if ( multiversionList.insert( pit->ident() ).second )
- MIL << "Multiversion install " << pit->ident() << " (" << *it << ")" << endl;
- }
- }
- }
- else
- {
- MIL << "Multiversion install " << *it << endl;
- multiversionList.insert( IdString( *it ) );
- }
+ for ( Solvable solv : WhatProvides( Capability( provides ? spec.c_str() + prefix.size() : spec.c_str() ) ) )
+ {
+ if ( solv.isSystem() )
+ continue;
+ if ( provides || solv.ident() == spec )
+ multiversionList.insert( solv );
+ }
+
+ MultiversionList::size_type nsize = multiversionList.size();
+ MIL << "Multiversion install " << spec << ": " << (nsize-size) << " matches" << endl;
+ size = nsize;
}
}
+ const PoolImpl::MultiversionList & PoolImpl::multiversionList() const
+ {
+ if ( ! _multiversionListPtr )
+ multiversionListInit();
+ return *_multiversionListPtr;
+ }
+
+ bool PoolImpl::isMultiversion( const Solvable & solv_r ) const
+ { return multiversionList().contains( solv_r ); }
+
+
const std::set<std::string> & PoolImpl::requiredFilesystems() const
{
if ( ! _requiredFilesystemsPtr )
///////////////////////////////////////////////////////////////////
namespace sat
{ /////////////////////////////////////////////////////////////////
+ class SolvableSet;
///////////////////////////////////////////////////////////////////
namespace detail
{ /////////////////////////////////////////////////////////////////
public:
/** \name Multiversion install. */
//@{
- typedef IdStringSet MultiversionList;
+ typedef SolvableSet MultiversionList;
- const MultiversionList & multiversionList() const
- {
- if ( ! _multiversionListPtr )
- multiversionListInit();
- return *_multiversionListPtr;
- }
+ const MultiversionList & multiversionList() const;
- bool isMultiversion( IdString ident_r ) const
- {
- const MultiversionList & l( multiversionList() );
- return l.find( ident_r ) != l.end();
- }
+ bool isMultiversion( const Solvable & solv_r ) const;
//@}
public:
}
// Add rules for parallel installable resolvables with different versions
- for_( it, sat::Pool::instance().multiversionBegin(), sat::Pool::instance().multiversionEnd() )
+ for ( const sat::Solvable & solv : myPool().multiversionList() )
{
- queue_push( &(_jobQueue), SOLVER_NOOBSOLETES | SOLVER_SOLVABLE_NAME );
- queue_push( &(_jobQueue), it->id() );
+ queue_push( &(_jobQueue), SOLVER_NOOBSOLETES | SOLVER_SOLVABLE );
+ queue_push( &(_jobQueue), solv.id() );
}
::pool_add_userinstalled_jobs(_SATPool, sat::Pool::instance().autoInstalled(), &(_jobQueue), GET_USERINSTALLED_NAMES|GET_USERINSTALLED_INVERTED);
bool found = false;
for_( iter2, possibleProviders.begin(), possibleProviders.end() ) {
PoolItem provider2 = ResPool::instance().find( *iter2 );
- if (compareByNVR (provider1.resolvable(),provider2.resolvable()) == 0
+ if (compareByNVR (provider1,provider2) == 0
&& ( (provider1.status().isInstalled() && provider2.status().isUninstalled())
|| (provider2.status().isInstalled() && provider1.status().isUninstalled()) )) {
found = true;
if (cmp != 0)
return cmp;
SolverQueueItemLock_constPtr lock = dynamic_pointer_cast<const SolverQueueItemLock>(item);
- return compareByNVRA (_item.resolvable(), lock->_item.resolvable());
+ return compareByNVRA (_item, lock->_item);
}
if (cmp != 0)
return cmp;
SolverQueueItemUpdate_constPtr update = dynamic_pointer_cast<const SolverQueueItemUpdate>(item);
- return compareByNVRA (_item.resolvable(), update->_item.resolvable());
+ return compareByNVRA (_item, update->_item);
}
return str.str();
}
-inline string helixXML( const Resolvable::constPtr &obj, Dep deptag_r )
+inline string helixXML( const PoolItem & obj, Dep deptag_r )
{
stringstream out;
- Capabilities caps( obj->dep(deptag_r) );
+ Capabilities caps( obj[deptag_r] );
if ( ! caps.empty() )
out << TAB << xml_tag_enclose(helixXML(caps), deptag_r.asString()) << endl;
return out.str();
}
-std::string helixXML( const PoolItem &item )
+std::string helixXML( const PoolItem & item )
{
- const Resolvable::constPtr resolvable = item.resolvable();
stringstream str;
- str << "<" << toLower (resolvable->kind().asString()) << ">" << endl;
- str << TAB << xml_tag_enclose (resolvable->name(), "name", true) << endl;
- str << TAB << xml_tag_enclose (item->vendor(), "vendor", true) << endl;
- str << TAB << xml_tag_enclose (item->buildtime().asSeconds(), "buildtime", true) << endl;
- if ( isKind<Package>(resolvable) ) {
+ str << "<" << item.kind() << ">" << endl;
+ str << TAB << xml_tag_enclose( item.name(), "name", true ) << endl;
+ str << TAB << xml_tag_enclose( item.vendor().asString(), "vendor", true ) << endl;
+ str << TAB << xml_tag_enclose( item.buildtime().asSeconds(), "buildtime", true ) << endl;
+ if ( isKind<Package>( item ) ) {
str << TAB << "<history>" << endl << TAB << "<update>" << endl;
- str << TAB2 << helixXML (resolvable->arch()) << endl;
- str << TAB2 << helixXML (resolvable->edition()) << endl;
+ str << TAB2 << helixXML( item.arch() ) << endl;
+ str << TAB2 << helixXML( item.edition() ) << endl;
str << TAB << "</update>" << endl << TAB << "</history>" << endl;
} else {
- str << TAB << helixXML (resolvable->arch()) << endl;
- str << TAB << helixXML (resolvable->edition()) << endl;
+ str << TAB << helixXML( item.arch() ) << endl;
+ str << TAB << helixXML( item.edition() ) << endl;
}
- str << helixXML( resolvable, Dep::PROVIDES);
- str << helixXML( resolvable, Dep::PREREQUIRES);
- str << helixXML( resolvable, Dep::CONFLICTS);
- str << helixXML( resolvable, Dep::OBSOLETES);
- str << helixXML( resolvable, Dep::REQUIRES);
- str << helixXML( resolvable, Dep::RECOMMENDS);
- str << helixXML( resolvable, Dep::ENHANCES);
- str << helixXML( resolvable, Dep::SUPPLEMENTS);
- str << helixXML( resolvable, Dep::SUGGESTS);
-
- str << "</" << toLower (resolvable->kind().asString()) << ">" << endl;
+ str << helixXML( item, Dep::PROVIDES );
+ str << helixXML( item, Dep::PREREQUIRES );
+ str << helixXML( item, Dep::CONFLICTS );
+ str << helixXML( item, Dep::OBSOLETES );
+ str << helixXML( item, Dep::REQUIRES );
+ str << helixXML( item, Dep::RECOMMENDS );
+ str << helixXML( item, Dep::ENHANCES );
+ str << helixXML( item, Dep::SUPPLEMENTS );
+ str << helixXML( item, Dep::SUGGESTS );
+
+ str << "</" << item.kind() << ">" << endl;
return str.str();
}
HelixControl ();
~HelixControl ();
- void installResolvable (const ResObject::constPtr &resObject,
- const ResStatus &status);
- void lockResolvable (const ResObject::constPtr &resObject,
- const ResStatus &status);
- void keepResolvable (const ResObject::constPtr &resObject,
- const ResStatus &status);
- void deleteResolvable (const ResObject::constPtr &resObject,
- const ResStatus &status);
+ void installResolvable( const PoolItem & pi_r );
+ void lockResolvable( const PoolItem & pi_r );
+ void keepResolvable( const PoolItem & pi_r );
+ void deleteResolvable( const PoolItem & pi_r );
void addDependencies (const CapabilitySet &capRequire, const CapabilitySet &capConflict);
void addUpgradeRepos( const std::set<Repository> & upgradeRepos_r );
delete(file);
}
-void HelixControl::installResolvable(const ResObject::constPtr &resObject,
- const ResStatus &status)
+void HelixControl::installResolvable( const PoolItem & pi_r )
{
- *file << "<install channel=\"" << resObject->repoInfo().alias() << "\" kind=\"" << toLower (resObject->kind().asString()) << "\""
- << " name=\"" << resObject->name() << "\"" << " arch=\"" << resObject->arch().asString() << "\""
- << " version=\"" << resObject->edition().version() << "\"" << " release=\"" << resObject->edition().release() << "\""
- << " status=\"" << status << "\""
+ *file << "<install channel=\"" << pi_r.repoInfo().alias() << "\""
+ << " kind=\"" << pi_r.kind() << "\""
+ << " name=\"" << pi_r.name() << "\""
+ << " arch=\"" << pi_r.arch() << "\""
+ << " version=\"" << pi_r.edition().version() << "\""
+ << " release=\"" << pi_r.edition().release() << "\""
+ << " status=\"" << pi_r.status() << "\""
<< "/>" << endl;
}
-void HelixControl::lockResolvable(const ResObject::constPtr &resObject,
- const ResStatus &status)
+void HelixControl::lockResolvable( const PoolItem & pi_r )
{
- *file << "<lock channel=\"" << resObject->repoInfo().alias() << "\" kind=\"" << toLower (resObject->kind().asString()) << "\""
- << " name=\"" << resObject->name() << "\"" << " arch=\"" << resObject->arch().asString() << "\""
- << " version=\"" << resObject->edition().version() << "\"" << " release=\"" << resObject->edition().release() << "\""
- << " status=\"" << status << "\""
+ *file << "<lock channel=\"" << pi_r.repoInfo().alias() << "\""
+ << " kind=\"" << pi_r.kind() << "\""
+ << " name=\"" << pi_r.name() << "\""
+ << " arch=\"" << pi_r.arch() << "\""
+ << " version=\"" << pi_r.edition().version() << "\""
+ << " release=\"" << pi_r.edition().release() << "\""
+ << " status=\"" << pi_r.status() << "\""
<< "/>" << endl;
}
-void HelixControl::keepResolvable(const ResObject::constPtr &resObject,
- const ResStatus &status)
+void HelixControl::keepResolvable( const PoolItem & pi_r )
{
- *file << "<keep channel=\"" << resObject->repoInfo().alias() << "\" kind=\"" << toLower (resObject->kind().asString()) << "\""
- << " name=\"" << resObject->name() << "\"" << " arch=\"" << resObject->arch().asString() << "\""
- << " version=\"" << resObject->edition().version() << "\"" << " release=\"" << resObject->edition().release() << "\""
- << " status=\"" << status << "\""
+ *file << "<keep channel=\"" << pi_r.repoInfo().alias() << "\""
+ << " kind=\"" << pi_r.kind() << "\""
+ << " name=\"" << pi_r.name() << "\""
+ << " arch=\"" << pi_r.arch() << "\""
+ << " version=\"" << pi_r.edition().version() << "\""
+ << " release=\"" << pi_r.edition().release() << "\""
+ << " status=\"" << pi_r.status() << "\""
<< "/>" << endl;
}
-void HelixControl::deleteResolvable(const ResObject::constPtr &resObject,
- const ResStatus &status)
+void HelixControl::deleteResolvable( const PoolItem & pi_r )
{
- *file << "<uninstall " << " kind=\"" << toLower (resObject->kind().asString()) << "\""
- << " name=\"" << resObject->name() << "\""
- << " status=\"" << status << "\""
+ *file << "<uninstall kind=\"" << pi_r.kind() << "\""
+ << " name=\"" << pi_r.name() << "\""
+ << " status=\"" << pi_r.status() << "\""
<< "/>" << endl;
}
if (dumpPool)
system = new HelixResolvable(dumpPath + "/solver-system.xml.gz");
- for ( ResPool::const_iterator it = pool.begin(); it != pool.end(); ++it )
+ for ( const PoolItem & pi : pool )
{
- Resolvable::constPtr res = it->resolvable();
-
- if ( system && it->status().isInstalled() ) {
+ if ( system && pi.status().isInstalled() ) {
// system channel
- system->addResolvable (*it);
+ system->addResolvable( pi );
} else {
// repo channels
- Repository repo = it->resolvable()->satSolvable().repository();
+ Repository repo = pi.repository();
if (dumpPool) {
if (repoTable.find (repo) == repoTable.end()) {
repoTable[repo] = new HelixResolvable(dumpPath + "/"
+ str::numstring((long)repo.id())
+ "-package.xml.gz");
}
- repoTable[repo]->addResolvable (*it);
+ repoTable[repo]->addResolvable( pi );
}
}
- if ( it->status().isToBeInstalled()
- && !(it->status().isBySolver())) {
- items_to_install.push_back (*it);
+ if ( pi.status().isToBeInstalled()
+ && !(pi.status().isBySolver())) {
+ items_to_install.push_back( pi );
}
- if ( it->status().isKept()
- && !(it->status().isBySolver())) {
- items_keep.push_back (*it);
+ if ( pi.status().isKept()
+ && !(pi.status().isBySolver())) {
+ items_keep.push_back( pi );
}
- if ( it->status().isToBeUninstalled()
- && !(it->status().isBySolver())) {
- items_to_remove.push_back (*it);
+ if ( pi.status().isToBeUninstalled()
+ && !(pi.status().isBySolver())) {
+ items_to_remove.push_back( pi );
}
- if ( it->status().isLocked()
- && !(it->status().isBySolver())) {
- items_locked.push_back (*it);
+ if ( pi.status().isLocked()
+ && !(pi.status().isBySolver())) {
+ items_locked.push_back( pi );
}
}
resolver.onlyRequires(),
resolver.ignoreAlreadyRecommended() );
- for (PoolItemList::const_iterator iter = items_to_install.begin(); iter != items_to_install.end(); iter++) {
- control.installResolvable (iter->resolvable(), iter->status());
- }
+ for ( const PoolItem & pi : items_to_install )
+ { control.installResolvable( pi ); }
- for (PoolItemList::const_iterator iter = items_locked.begin(); iter != items_locked.end(); iter++) {
- control.lockResolvable (iter->resolvable(), iter->status());
- }
+ for ( const PoolItem & pi : items_locked )
+ { control.lockResolvable( pi ); }
- for (PoolItemList::const_iterator iter = items_keep.begin(); iter != items_keep.end(); iter++) {
- control.keepResolvable (iter->resolvable(), iter->status());
- }
+ for ( const PoolItem & pi : items_keep )
+ { control.keepResolvable( pi ); }
- for (PoolItemList::const_iterator iter = items_to_remove.begin(); iter != items_to_remove.end(); iter++) {
- control.deleteResolvable (iter->resolvable(), iter->status());
- }
+ for ( const PoolItem & pi : items_to_remove )
+ { control.deleteResolvable( pi ); }
control.addDependencies (resolver.extraRequires(), resolver.extraConflicts());
control.addDependencies (SystemCheck::instance().requiredSystemCap(),
available_size_type availableSize() const;
available_iterator availableBegin() const;
available_iterator availableEnd() const;
+ inline Iterable<available_iterator> available() const
+ { return makeIterable( availableBegin(), availableEnd() ); }
//@}
////////////////////////////////////////////////////////////////////////
installed_size_type installedSize() const;
installed_iterator installedBegin() const;
installed_iterator installedEnd() const;
- //}
+ inline Iterable<installed_iterator> installed() const
+ { return makeIterable( installedBegin(), installedEnd() ); }
+ //@}
////////////////////////////////////////////////////////////////////////
picklist_size_type picklistSize() const;
picklist_iterator picklistBegin() const;
picklist_iterator picklistEnd() const;
- //}
+ inline Iterable<picklist_iterator> picklist() const
+ { return makeIterable( picklistBegin(), picklistEnd() ); }
+ //@}
////////////////////////////////////////////////////////////////////////
* install will deselect any other.
*/
//@{
- /** Whether different versions of this package can be installed at the same time.
- * Per default \c false. \see also \ref ZConfig::multiversion.
+ /** Whether at least one of the available packages has multiversionInstall set.
+ * \see \ref Solvable::multiversionInstall
+ * \see also \ref ZConfig::multiversion.
*/
bool multiversionInstall() const;
bool Selectable::Impl::setPickStatus( const PoolItem & pi_r, Status state_r, ResStatus::TransactByValue causer_r )
{
- if ( pi_r.satSolvable().ident() != ident() )
+ if ( pi_r.ident() != ident() )
return false; // not my PoolItem
- if ( ! multiversionInstall() )
+ if ( ! pi_r.multiversionInstall() )
return false; // We're not yet ready for this.
// TODO: Without multiversionInstall take care at most ONE available is set
// to install. Upon install ALL installed get deleted. Only upon deletetion
*/
PoolItem candidateObjFrom( Repository repo_r ) const
{
- for_( it, availableBegin(), availableEnd() )
+ for ( const PoolItem & pi : available() )
{
- if ( (*it)->repository() == repo_r )
- return *it;
+ if ( pi.repository() == repo_r )
+ return pi;
}
return PoolItem();
}
PoolItem highestAvailableVersionObj() const
{
PoolItem ret;
- for_( it, availableBegin(), availableEnd() )
+ for ( const PoolItem & pi : available() )
{
- if ( !ret || (*it).satSolvable().edition() > ret.satSolvable().edition() )
- ret = *it;
+ if ( !ret || pi.edition() > ret.edition() )
+ ret = pi;
}
return ret;
}
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() );
}
{ return availableEmpty(); }
bool multiversionInstall() const
- { return sat::Pool::instance().isMultiversion( ident() ); }
+ {
+ for ( const PoolItem & pi : available() )
+ {
+ if ( pi.multiversionInstall() )
+ return true;
+ }
+ return false;
+ }
bool pickInstall( const PoolItem & pi_r, ResStatus::TransactByValue causer_r, bool yesno_r );
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() );
{
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 << "} ";
}