- drafted interface suitable for pkg-bindings in
authorMichael Andres <ma@suse.de>
Thu, 9 Feb 2006 14:15:11 +0000 (14:15 +0000)
committerMichael Andres <ma@suse.de>
Thu, 9 Feb 2006 14:15:11 +0000 (14:15 +0000)
  ui::Selectable.

zypp/ui/Selectable.h
zypp/ui/Status.h

index b24916f..dbd32dc 100644 (file)
@@ -59,14 +59,6 @@ namespace zypp
       /** The ResObjects name.  */
       const std::string & name() const;
 
-      /** Return the current Status */
-      Status status() const;
-
-      /** Try to set a new Status.
-       * Returns \c false if the transitions is not allowed.
-      */
-      bool set_status( const Status state_r );
-
       /** Installed object. */
       ResObject::constPtr installedObj() const;
 
@@ -86,6 +78,12 @@ namespace zypp
       available_iterator availableEnd() const;
 
     public:
+      /** \name Query for objects within this Selectable.
+      */
+      //@{
+      /** True if either installed or candidate object is present */
+      bool hasObject() const
+      { return installedObj() || candidateObj(); }
 
       /** True if installed object is present. */
       bool hasInstalledObj() const
@@ -95,6 +93,123 @@ namespace zypp
       bool hasCandidateObj() const
       { return candidateObj(); }
 
+      /** True if installed and candidate object is present */
+      bool hasBothObjects() const
+      { return installedObj() && candidateObj(); }
+
+      /** True if installed object is present but no candidate. */
+      bool hasInstalledObjOnly() const
+      { return installedObj() && ! candidateObj(); }
+
+      /** True if candidate object is present but no installed. */
+      bool hasCandidateObjOnly() const
+      { return ! installedObj() && candidateObj(); }
+      //@}
+
+    public:
+      /** \name Query objects fate in case of commit.
+      */
+      //@{
+      enum Fate {
+        TO_DELETE  = -1,
+        UNMODIFIED = 0,
+        TO_INSTALL = 1
+      };
+      /**  */
+      Fate fate() const { return UNMODIFIED; } //TBI
+
+      /** True if either to delete or to install */
+      bool unmodified() const
+      { return fate() == UNMODIFIED; }
+
+      /** True if either to delete or to install */
+      bool toModify() const
+      { return fate() != UNMODIFIED; }
+
+      /** True if to delete */
+      bool toDelete() const
+      { return fate() == TO_DELETE; }
+
+      /** True if to install */
+      bool toInstall() const
+      { return fate() == TO_INSTALL; }
+
+      /** Return who caused the modification. */
+      ResStatus::TransactByValue modifiedBy() const { return ResStatus::USER; } //TBI
+
+      /** True if modification was caused by by_r. */
+      bool isModifiedBy( ResStatus::TransactByValue by_r ) const;
+
+      /** True if the object won't be present on the targetSystem after commit. */
+      bool isOffSystem() const { return false; } //TBI
+
+      /** True if the object will be present on the targetSystem after commit. */
+      bool isOnSystem() const { return false; } //TBI
+      //@}
+
+    public:
+      /** \name Status manipulation.
+       *
+       * \note Every status manipulation will fail, if it
+       * contradicts an action with higher ResStatus::TransactByValue.
+      */
+      //@{
+      bool setFate( Fate fate_r, ResStatus::TransactByValue by_r )
+      { return false; } //TBI
+
+      /** */
+      bool setUnmodified( ResStatus::TransactByValue by_r )
+      { return setFate( UNMODIFIED, by_r ); }
+
+      /** Request to delete an installed object.
+       * Also fails if no installed object is present.
+      */
+      bool setToDelete( ResStatus::TransactByValue by_r )
+      { return setFate( TO_DELETE, by_r ); }
+
+      /** Request to install an available object.
+       * Also fails if no available object is present.
+      */
+      bool setToInstall( ResStatus::TransactByValue by_r )
+      { return setFate( TO_INSTALL, by_r ); }
+
+       /** Request to take care the object is not present after commit.
+        * Delete if installed, and do not install.
+       */
+      bool setOffSystem( ResStatus::TransactByValue by_r )
+      { return false; } //TBI
+
+      /** Request to take care the object is present after commit.
+       * Install if not installed, and do not delete.
+      */
+      bool setOnSystem( ResStatus::TransactByValue by_r )
+      { return false; } //TBI
+
+      /** Request to take care the object is present after commit,
+       * replacing the installed one, if a newer candidate is available.
+       * Install if not installed, and do not delete.
+      */
+      bool setOnSystemNew( ResStatus::TransactByValue by_r )
+      { return false; } //TBI
+
+      //@}
+
+    public:
+      /** \name Special inteface for Y2UI.
+       * \note This interface acts on \ref ResStatus::USER level.
+       * The \ref Status enum, and allowed state transitions are
+       * tightly related to the Y2UI. It might be not verry usefull
+       * outside the Y2UI.
+      */
+      //@{
+      /** Return the current Status */
+      Status status() const;
+      /** Try to set a new Status.
+       * Returns \c false if the transitions is not allowed.
+      */
+      bool set_status( const Status state_r );
+      //@}
+
     public:
       /** Implementation  */
       class Impl;
index 7d30bc4..9d5d061 100644 (file)
@@ -24,6 +24,11 @@ namespace zypp
 
     /** UI status
      * Status values calculated by \ref Selectable.
+
+     * \note The \ref Status enum, and it's use within \ref Selectabe
+     * is tightly related to the Y2UI. It might be not verry usefull
+     * outside the Y2UI.
+     *
      * \todo make it an EnumerationClass
     */
     enum Status