Imported Upstream version 14.45.0
[platform/upstream/libzypp.git] / zypp / ResPool.h
index 3682d84..a8d37d9 100644 (file)
 
 #include <iosfwd>
 
-#include "zypp/base/Deprecated.h"
+#include "zypp/APIConfig.h"
 #include "zypp/base/Iterator.h"
 
 #include "zypp/pool/PoolTraits.h"
 #include "zypp/PoolItem.h"
-#include "zypp/ResFilters.h"
+#include "zypp/Filter.h"
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
@@ -27,6 +27,7 @@ namespace zypp
 
   class SerialNumber;
   class ResPoolProxy;
+  class Resolver;
 
   ///////////////////////////////////////////////////////////////////
   //
@@ -53,10 +54,7 @@ namespace zypp
       typedef PoolItem                                  value_type;
       typedef pool::PoolTraits::size_type               size_type;
       typedef pool::PoolTraits::const_iterator          const_iterator;
-
-      typedef pool::PoolTraits::byCapabilityIndex_iterator byCapabilityIndex_iterator;
-      typedef pool::PoolTraits::AdditionalCapabilities    AdditionalCapabilities;
-      typedef pool::PoolTraits::repository_iterator        repository_iterator;
+      typedef pool::PoolTraits::repository_iterator      repository_iterator;
 
     public:
       /** Singleton ctor. */
@@ -65,6 +63,9 @@ namespace zypp
       /** preliminary */
       ResPoolProxy proxy() const;
 
+      /** The Resolver */
+      Resolver & resolver() const;
+
     public:
       /** The pools serial number. Changing whenever the
        * whenever the content changes. (Resolvables or
@@ -78,7 +79,7 @@ namespace zypp
       /**  */
       size_type size() const;
 
-      /** \name Iterate through all PoolItems (all kinds). */
+      /** \name Iterate over all PoolItems (all kinds). */
       //@{
       /** */
       const_iterator begin() const
@@ -95,21 +96,50 @@ namespace zypp
        * \see \ref PoolItem::satSolvable.
        */
       PoolItem find( const sat::Solvable & slv_r ) const;
+      /** \overload */
+      PoolItem find( const ResObject::constPtr & resolvable_r ) const
+      { return( resolvable_r ? find( resolvable_r->satSolvable() ) : PoolItem() ); }
 
     public:
-      /** \name Iterate through all PoolItems matching a \c _Filter. */
+      /** \name Iterate over all PoolItems matching a \c _Filter. */
       //@{
       template<class _Filter>
-          filter_iterator<_Filter,const_iterator> filterBegin( const _Filter & filter_r ) const
+      filter_iterator<_Filter,const_iterator> filterBegin( const _Filter & filter_r ) const
       { return make_filter_begin( filter_r, *this ); }
 
       template<class _Filter>
-          filter_iterator<_Filter,const_iterator> filterEnd( const _Filter & filter_r ) const
+      filter_iterator<_Filter,const_iterator> filterEnd( const _Filter & filter_r ) const
+      { return make_filter_end( filter_r, *this ); }
+      //@}
+
+      /** \name Iterate over all PoolItems by status.
+       *
+       * Simply pass the \ref ResStatus predicate you want to use as filter:
+       * \code
+       *   // iterate over all orphaned items:
+       *   for_( it, pool.byStatusBegin(&ResStatus::isOrphaned), pool.byStatusEnd(&ResStatus::isOrphaned) )
+       *   {...}
+       * \endcode
+       *
+       * Or use \ref filter::ByStatus in more complex queries:
+       * \code
+       *   // iterate over all (orphaned and recommended) items:
+       *   functor::Chain<filter::ByStatus,filter::ByStatus> myfilter( filter::ByStatus(&ResStatus::isOrphaned),
+       *                                                               filter::ByStatus(&ResStatus::isRecommended) );
+       *   for_( it, pool.filterBegin(myfilter), pool.filterEnd(myfilter) )
+       *   { ... }
+       * \endcode
+       */
+      //@{
+      filter_iterator<filter::ByStatus,const_iterator> byStatusBegin( const filter::ByStatus & filter_r ) const
+      { return make_filter_begin( filter_r, *this ); }
+
+      filter_iterator<filter::ByStatus,const_iterator> byStatusEnd( const filter::ByStatus & filter_r ) const
       { return make_filter_end( filter_r, *this ); }
       //@}
 
     public:
-      /** \name Iterate through all PoolItems of a certain name and kind. */
+      /** \name Iterate over all PoolItems of a certain name and kind. */
       //@{
       typedef pool::ByIdent                       ByIdent;
       typedef pool::PoolTraits::byIdent_iterator  byIdent_iterator;
@@ -177,9 +207,9 @@ namespace zypp
      //@}
 
     public:
-      /** \name Iterate through all ResObjects of a certain kind. */
+      /** \name Iterate over all ResObjects of a certain kind. */
       //@{
-      typedef zypp::resfilter::ByKind ByKind;
+      typedef filter::ByKind ByKind;
       typedef filter_iterator<ByKind,const_iterator> byKind_iterator;
 
       byKind_iterator byKindBegin( const ResKind & kind_r ) const
@@ -198,32 +228,25 @@ namespace zypp
       //@}
 
     public:
-      /** \name Iterate through all ResObjects with a certain name (all kinds).
-       * \deprecated Instead of iterating byName and filter byKind use ByIdent iterator.
-      */
+      /** \name Iterate over all ResObjects with a certain name (all kinds). */
       //@{
       typedef zypp::resfilter::ByName ByName;
       typedef filter_iterator<ByName,const_iterator> byName_iterator;
 
-      byName_iterator ZYPP_DEPRECATED byNameBegin( const std::string & name_r ) const
+      byName_iterator byNameBegin( const std::string & name_r ) const
       { return make_filter_begin( ByName(name_r), *this ); }
 
-      byName_iterator ZYPP_DEPRECATED byNameEnd( const std::string & name_r ) const
+      byName_iterator byNameEnd( const std::string & name_r ) const
       { return make_filter_end( ByName(name_r), *this ); }
       //@}
 
     public:
-      /** \name Iterate through all ResObjects which have at least
-       *  one Capability with index \a index_r in dependency \a depType_r.
-       */
+      /** \name Special iterators. */
       //@{
-      byCapabilityIndex_iterator ZYPP_DEPRECATED byCapabilityIndexBegin( const std::string & index_r, Dep depType_r ) const;
 
-      byCapabilityIndex_iterator ZYPP_DEPRECATED byCapabilityIndexEnd( const std::string & index_r, Dep depType_r ) const;
       //@}
-
-    public:
-      /** \name Iterate through all Repositories that contribute ResObjects.
+   public:
+      /** \name Iterate over all Repositories that contribute ResObjects.
        */
       //@{
       size_type knownRepositoriesSize() const;
@@ -231,10 +254,36 @@ namespace zypp
       repository_iterator knownRepositoriesBegin() const;
 
       repository_iterator knownRepositoriesEnd() const;
+
+      /** Find a \ref Repository named \c alias_r.
+       * Returns \ref Repository::norepository if there is no such \ref Repository.
+       */
+      Repository reposFind( const std::string & alias_r ) const;
       //@}
 
-     public:
-      /** \name Iterate through requested/available Locales.
+    public:
+      /** \name Handle locale support.
+       *
+       * A \ref filter::ByLocaleSupport is provided to iterate over
+       * all items supporting a specific locale.
+       *
+       * \see \ref sat::LocaleSupport for a more convenient interface.
+       *
+       * \code
+       * ResPool pool( ResPool::instance() );
+       *
+       * filter::ByLocaleSupport f( Locale("de") );
+       * for_( it, pool.filterBegin(f), pool.filterEnd(f) )
+       * {
+       *   MIL << *it << endl; // supporting "de"
+       * }
+       *
+       * f = filter::ByLocaleSupport( pool.getRequestedLocales() );
+       * for_( it, pool.filterBegin(f), pool.filterEnd(f) )
+       * {
+       *   MIL << *it << endl; // supporting any requested locale
+       * }
+       * \endcode
        */
       //@{
       /** Set the requested locales.
@@ -258,7 +307,7 @@ namespace zypp
       */
       const LocaleSet & getRequestedLocales() const;
 
-      /** Wheter this \ref Locale is in the set of requested locales. */
+      /** Whether this \ref Locale is in the set of requested locales. */
       bool isRequestedLocale( const Locale & locale_r ) const;
 
       /** Get the set of available locales.
@@ -267,72 +316,37 @@ namespace zypp
        */
       const LocaleSet & getAvailableLocales() const;
 
-      /** Wheter this \ref Locale is in the set of available locales. */
+      /** Whether this \ref Locale is in the set of available locales. */
       bool isAvailableLocale( const Locale & locale_r ) const;
       //@}
 
-   public:
-      /** \name Handling addition capabilities in the pool in order for solving it in
-       *  a solver run. This is used for tasks like needing a package with the name "foo".
-       *  The solver has to evaluate a proper package by his own.
-       *
-       *  CAUTION: This has another semantic in the solver. The required resolvable has
-       *  been set for installation (in the pool) only AFTER a solver run.
-       */
-
-      /**
-       *  Handling additional requirement. E.G. need package "foo" and package
-       *  "foo1" which has a greater version than 1.0:
-       *
-       *  \code
-       *  Capabilities capset;
-       *  capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
-       *  capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo1 > 1.0"));
+    public:
+      /** \name Handle hard locks (e.g set from /etc/zypp/locks).
        *
-       *  // The user is setting this capablility
-       *  ResPool::AdditionalCapabilities aCapabilities;
-       *  aCapabilities[ResStatus::USER] = capset;
+       * As this kind of lock is query based, it's quite expensive.
        *
-       *  setAdditionalRequire( aCapabilities );
-       *  \endcode
+       * These queries are re-evaluated when adding new repos to the pool.
        */
-      void setAdditionalRequire( const AdditionalCapabilities & capset ) const;
-      AdditionalCapabilities & additionalRequire() const;
+      //@{
+      typedef pool::PoolTraits::HardLockQueries           HardLockQueries;
+      typedef pool::PoolTraits::hardLockQueries_iterator  hardLockQueries_iterator;
 
-     /**
-       *  Handling additional conflicts. E.G. do not install anything which provides "foo":
-       *
-       *  \code75
-       *  Capabilities capset;
-       *  capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
-       *
-       *  // The user is setting this capablility
-       *  ResPool::AdditionalCapabilities aCapabilities;
-       *  aCapabilities[ResStatus::USER] = capset;
-       *
-       *  setAdditionalConflict( aCapabilities );
-       *  \endcode
+      bool hardLockQueriesEmpty() const;
+      size_type hardLockQueriesSize() const;
+      hardLockQueries_iterator hardLockQueriesBegin() const;
+      hardLockQueries_iterator hardLockQueriesEnd() const;
+
+      /** Set a new set of queries.
+       * The hard-locks of existing PoolItems are adjusted according
+       * to the queries. (usually called on target load)
        */
-      void setAdditionalConflict( const AdditionalCapabilities & capset ) const;
-      AdditionalCapabilities & additionaConflict() const;
+      void setHardLockQueries( const HardLockQueries & newLocks_r );
 
-     /**
-       *  Handling additional provides. This is used for ignoring a requirement.
-       *  e.G. Do ignore the requirement "foo":
-       *
-       *  \code
-       *  Capabilities capset;
-       *  capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
-       *
-       *  // The user is setting this capablility
-       *  ResPool::AdditionalCapabilities aCapabilities;
-       *  aCapabilities[ResStatus::USER] = capset;
-       *
-       *  setAdditionalProvide( aCapabilities );
-       *  \endcode
+      /** Suggest a new set of queries based on the current selection.
+       * (usually remembered on commit).
        */
-      void setAdditionalProvide( const AdditionalCapabilities & capset ) const;
-      AdditionalCapabilities & additionaProvide() const;
+      void getHardLockQueries( HardLockQueries & activeLocks_r );
+      //@}
 
     private:
       const pool::PoolTraits::ItemContainerT & store() const;
@@ -340,9 +354,9 @@ namespace zypp
 
     private:
       /** Ctor */
-      ResPool( pool::PoolTraits::Impl_constPtr impl_r );
-      /** Const access to implementation. */
-      pool::PoolTraits::Impl_constPtr _pimpl;
+      ResPool( pool::PoolTraits::Impl_Ptr impl_r );
+      /** Access to implementation. */
+      RW_pointer<pool::PoolTraits::Impl> _pimpl;
   };
   ///////////////////////////////////////////////////////////////////