Imported Upstream version 14.45.0
[platform/upstream/libzypp.git] / zypp / ui / Selectable.h
index 0331cab..3743e96 100644 (file)
@@ -64,6 +64,9 @@ namespace zypp
       typedef SelectableTraits::installed_iterator      installed_iterator;
       typedef SelectableTraits::installed_size_type     installed_size_type;
 
+      typedef SelectableTraits::picklist_iterator      picklist_iterator;
+      typedef SelectableTraits::picklist_size_type     picklist_size_type;
+
     public:
       /** \name Static ctor substitues picking the item from the pool.
        * \code
@@ -140,8 +143,21 @@ namespace zypp
        */
       PoolItem updateCandidateObj() const;
 
-      /** \c True if \a rhs has the same content as an installed one.
-       *  Basically the same name, edition, arch, vendor and buildtime.
+      /** Simply the highest available version, ignoring priorities and policies.
+       * It's doubtful whether solely looking at the version makes a good
+       * candidate, but apps ask for it. Beware that different vendors may
+       * use different (uncomparable) version schemata.
+       */
+      PoolItem highestAvailableVersionObj() 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
+       */
+      bool identicalAvailable( const PoolItem & rhs ) const;
+
+     /** \c True if \a rhs has the same content as an installed one.
+       * Basically the same name, edition, arch, vendor and buildtime.
        * \see \ref sat::Solvable::identical
        */
       bool identicalInstalled( const PoolItem & rhs ) const;
@@ -158,6 +174,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
@@ -195,7 +222,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 );
 
@@ -220,7 +247,7 @@ namespace zypp
 
       ////////////////////////////////////////////////////////////////////////
 
-      /** \name Insatlled objects iterators.
+      /** \name Installed objects iterators.
        * Ordered by install time. Latest first.
       */
       //@{
@@ -232,6 +259,19 @@ namespace zypp
 
       ////////////////////////////////////////////////////////////////////////
 
+      /** \name picklist iterators.
+       * This is basically the available items list prepended by those
+       * installed items, that are nolonger \ref identicalAvailable.
+       */
+      //@{
+      bool picklistEmpty() const;
+      picklist_size_type picklistSize() const;
+      picklist_iterator picklistBegin() const;
+      picklist_iterator picklistEnd() const;
+      //}
+
+      ////////////////////////////////////////////////////////////////////////
+
     public:
       /** \name Query for objects within this Selectable.
       */
@@ -246,7 +286,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
@@ -267,6 +307,65 @@ namespace zypp
        */
       bool isUnmaintained() const;
 
+      /** \name Multiversion install.
+       *
+       * Using \ref pickInstall or \ref pickDelete with non-multiversionInstall items
+       * is possible, but additional constraints will apply. E.g. selecting one item for
+       * 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.
+       */
+      bool multiversionInstall() const;
+
+      /** 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
+       * installed (or available) one.
+       * \code
+       *   Assume there are 3 identical 'foo-1.1 (vendor A)' items,
+       *   one 'foo-2.1 (vendor A)' and one ''foo-1.1 (vendor B)':
+       *
+       *   installed: . foo-1.1 (vendor A)          -> S_KeepInstalled
+       *   available:   foo-2.1 (vendor A) (repo 1) -> S_NoInst
+       *              . foo-1.1 (vendor A) (repo 1) -> S_KeepInstalled
+       *              . foo-1.1 (vendor A) (repo 2) -> S_KeepInstalled
+       *                foo-1.1 (vendor B) (repo 3) -> S_NoInst
+       *
+       *   After 'foo-1.1 (vendor A) (repo 1)' was selected to be installed:
+       *
+       *   installed: . foo-1.1 (vendor A)          -> S_Update
+       *   available:   foo-2.1 (vendor A) (repo 1) -> S_NoInst
+       *              I foo-1.1 (vendor A) (repo 1) -> S_Update
+       *              . foo-1.1 (vendor A) (repo 2) -> S_KeepInstalled
+       *                foo-1.1 (vendor B) (repo 3) -> S_NoInst
+       * \endcode
+       * \see \ref sat::Solvable::identical
+       */
+      Status pickStatus( const PoolItem & pi_r ) const;
+
+      /** 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).
        * A patch is either \c not \c relevant, \c satisfied or \c broken.
        * The same applies to other pseudo installed kinds.
@@ -275,7 +374,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
@@ -289,17 +388,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,
@@ -313,6 +415,10 @@ namespace zypp
       bool unmodified() const
       { return fate() == UNMODIFIED; }
 
+      /** True if locked (subclass of unmodified). */
+      bool locked() const
+      { Status st( status() ); return( st == S_Protected || st == S_Taboo ); }
+
       /** True if either to delete or to install */
       bool toModify() const
       { return fate() != UNMODIFIED; }
@@ -374,7 +480,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;