Imported Upstream version 17.14.0
[platform/upstream/libzypp.git] / zypp / ui / Selectable.h
index 62ef05f..64a2224 100644 (file)
@@ -114,7 +114,7 @@ namespace zypp
       IdString ident() const;
 
       /** The ResObjects kind. */
-      ResObject::Kind kind() const;
+      ResKind kind() const;
 
       /** The ResObjects name.  */
       const std::string & name() const;
@@ -150,7 +150,10 @@ namespace zypp
        */
       PoolItem highestAvailableVersionObj() const;
 
-     /** \c True if \a rhs is installed and one with the same content is available.
+      /** Whether this \ref ident is flagged as AutoInstalled. */
+      bool identIsAutoInstalled() const;
+
+      /** \c True if \a rhs is installed and one with the same content is available.
        * Basically the same name, edition, arch, vendor and buildtime.
        * \see \ref sat::Solvable::identical
        */
@@ -174,6 +177,17 @@ namespace zypp
       bool identicalInstalledUpdateCandidate() const
       { return identicalInstalled( updateCandidateObj() ); }
 
+      /** Return an available Object with the same content as \c rhs.
+       * Basically the same name, edition, arch, vendor and buildtime.
+       * \see \ref sat::Solvable::identical
+       */
+      PoolItem identicalAvailableObj( const PoolItem & rhs ) const;
+
+     /** \Return an installed Object with the same content as \c rhs.
+       * Basically the same name, edition, arch, vendor and buildtime.
+       * \see \ref sat::Solvable::identical
+       */
+      PoolItem identicalInstalledObj( const PoolItem & rhs ) const;
 
       /** Return the \ref installedObj resolvable casted to a specific kind.
        * \code
@@ -181,9 +195,9 @@ namespace zypp
        *   Package::constPtr p( mySelectable.installedAsKind<Package>() );
        * \endcode
       */
-      template<class _Res>
-      typename ResTraits<_Res>::constPtrType installedAsKind() const
-      { return asKind<_Res>( candidateObj() ); }
+      template<class TRes>
+      typename ResTraits<TRes>::constPtrType installedAsKind() const
+      { return asKind<TRes>( candidateObj() ); }
 
       /** Return the \ref candidateObj resolvable casted to a specific kind.
        * \code
@@ -191,9 +205,9 @@ namespace zypp
        *   Package::constPtr p( mySelectable.candidateAsKind<Package>() );
        * \endcode
       */
-      template<class _Res>
-      typename ResTraits<_Res>::constPtrType candidateAsKind() const
-      { return asKind<_Res>( candidateObj() ); }
+      template<class TRes>
+      typename ResTraits<TRes>::constPtrType candidateAsKind() const
+      { return asKind<TRes>( candidateObj() ); }
 
       /** Set a candidate (out of available objects).
        * \return The new candidate, or NULL if choice was invalid
@@ -211,7 +225,7 @@ namespace zypp
        * If the specified candidate is not already installed (\ref identicalInstalled),
        * and the \a causer_r has sufficient permisssion, then \a newCandidate_r is set as the new
        * candidate (\ref setCandidate) and selected for installation.
-       * \returns \c True if \a newCandidate_r is already installed or sucessfully selected for installation.
+       * \returns \c True if \a newCandidate_r is already installed or successfully selected for installation.
        */
       bool setOnSystem( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
 
@@ -232,6 +246,8 @@ namespace zypp
       available_size_type availableSize() const;
       available_iterator availableBegin() const;
       available_iterator availableEnd() const;
+      inline Iterable<available_iterator>  available() const
+      { return makeIterable( availableBegin(), availableEnd() ); }
       //@}
 
       ////////////////////////////////////////////////////////////////////////
@@ -244,7 +260,9 @@ namespace zypp
       installed_size_type installedSize() const;
       installed_iterator installedBegin() const;
       installed_iterator installedEnd() const;
-      //}
+      inline Iterable<installed_iterator> installed() const
+      { return makeIterable( installedBegin(), installedEnd() ); }
+      //@}
 
       ////////////////////////////////////////////////////////////////////////
 
@@ -257,7 +275,21 @@ namespace zypp
       picklist_size_type picklistSize() const;
       picklist_iterator picklistBegin() const;
       picklist_iterator picklistEnd() const;
-      //}
+      inline Iterable<picklist_iterator> picklist() const
+      { return makeIterable( picklistBegin(), picklistEnd() ); }
+
+      /** Returned by \ref picklistPos if the Item does not belong to the picklist. */
+      static constexpr const picklist_size_type picklistNoPos = picklist_size_type(-1);
+
+      /** Return the position of \a pi_r in the piclist or \ref picklistNoPos.
+       * \note \ref picklistNoPos is returned if you pass an installed Poolitem,
+       * whci has an \ref identicalAvailableObj.
+       */
+      picklist_size_type picklistPos( const PoolItem & pi_r ) const;
+
+      /** \overload taking a sat::Solvable */
+      picklist_size_type picklistPos( const sat::Solvable & solv_r ) const;
+      //@}
 
       ////////////////////////////////////////////////////////////////////////
 
@@ -275,7 +307,7 @@ namespace zypp
 
       /** True if candidate object is present. */
       bool hasCandidateObj() const
-      { return candidateObj(); }
+      { return bool(candidateObj()); }
 
       /** True if installed and candidate object is present */
       bool hasBothObjects() const
@@ -303,13 +335,29 @@ namespace zypp
        * 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 setPickStatus( const PoolItem & pi_r, const Status state_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
+      /** Select a specific available item for installation.
+       */
+      bool pickInstall( const PoolItem & pi_r, ResStatus::TransactByValue causer_r = ResStatus::USER, bool yesno_r = true );
+
+      /** Deselect a specific available item from installation.
+      */
+      bool pickNoInstall( const PoolItem & pi_r, ResStatus::TransactByValue causer_r = ResStatus::USER )
+      { return pickInstall( pi_r, causer_r, false ); }
+
+      /** Select a specific installed item for deletion.
+       */
+      bool pickDelete( const PoolItem & pi_r, ResStatus::TransactByValue causer_r = ResStatus::USER, bool yesno_r = true );
+
+      /** Deselect a specific installed item from deletion.
+       */
+      bool pickNoDelete( const PoolItem & pi_r, ResStatus::TransactByValue causer_r = ResStatus::USER )
+      { return pickDelete( pi_r, causer_r, false ); }
 
       /** Compute the \ref ui::Status for an individual PoolItem.
        * This just takes into account the item and any identical
@@ -335,6 +383,9 @@ namespace zypp
        * \see \ref sat::Solvable::identical
        */
       Status pickStatus( const PoolItem & pi_r ) const;
+
+      /** Assign a new status to a specific item. */
+      bool setPickStatus( const PoolItem & pi_r, Status state_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
       //@}
 
       /** \name Classification of available patches (pseudo installed items).
@@ -345,7 +396,7 @@ namespace zypp
       //@{
       /** Returns true for packages, because packages are not
        * classified by the solver.
-      */
+       */
       bool isUndetermined() const;
 
       /** Returns true if the patch is relevant which means that at least
@@ -359,17 +410,20 @@ namespace zypp
       /** Whether a relevant patchs requirements are broken. */
       bool isBroken() const;
 
-      /** This includes still broken patches, as well as those already
-       *  selected to be installed.
-       * This is because already selected patches will be classified as
-       * \c satisfied.
+      /** This includes \c unlocked broken patches, as well as those already
+       * selected to be installed. This is because already selected
+       * patches will be classified as \c satisfied. \c Locked but broken
+       * patches will be classified as \ref isUnwanted.
        */
       bool isNeeded() const;
+
+      /** Broken (needed) but locked patches. */
+       bool isUnwanted() const;
       //@}
 
      public:
       /** \name Query and maip objects fate in case of commit.
-      */
+       */
       //@{
       enum Fate {
         TO_DELETE  = -1,
@@ -383,10 +437,22 @@ namespace zypp
       bool unmodified() const
       { return fate() == UNMODIFIED; }
 
-      /** True if locked (subclass of unmodified). */
+      /** True if locked (subclass of unmodified).
+       * The \ref locked status indicates that \b all installed and/or \b all available
+       * items are locked. So you can't remove and/or can't install any item. This
+       * is the common case.
+       * \see \ref hasLocks
+       */
       bool locked() const
       { Status st( status() ); return( st == S_Protected || st == S_Taboo ); }
 
+      /** True if it includes locked items (don't mix this with the \ref locked status).
+       * This is also \c true for partially locked items, where only specific versions
+       * are locked.
+       * \see \ref locked
+       */
+      bool hasLocks() const;
+
       /** True if either to delete or to install */
       bool toModify() const
       { return fate() != UNMODIFIED; }
@@ -448,7 +514,7 @@ namespace zypp
        * Try to set a new Status.
        * Returns \c false if the transitions is not allowed.
        */
-      bool setStatus( const Status state_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
+      bool setStatus( Status state_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
 
       /** Return who caused the modification. */
       ResStatus::TransactByValue modifiedBy() const;
@@ -462,7 +528,7 @@ namespace zypp
 
     public:
       /** Implementation  */
-      class Impl;
+      struct Impl;
       typedef shared_ptr<Impl> Impl_Ptr;
       /** Default ctor */
       Selectable( Impl_Ptr pimpl_r );