- Added 'commit' interface in ZYpp.
authorMichael Andres <ma@suse.de>
Thu, 16 Feb 2006 14:41:34 +0000 (14:41 +0000)
committerMichael Andres <ma@suse.de>
Thu, 16 Feb 2006 14:41:34 +0000 (14:41 +0000)
zypp/Makefile.am
zypp/Target.h
zypp/ZYpp.cc
zypp/ZYpp.h
zypp/ZYppCommitResult.h [new file with mode: 0644]
zypp/zypp_detail/ZYppImpl.cc
zypp/zypp_detail/ZYppImpl.h

index d91ea1d..9849661 100644 (file)
@@ -73,8 +73,9 @@ pkginclude_HEADERS = NeedAType.h \
        DeltaRpm.h      \
        VendorAttr.h    \
        UpgradeStatistics.h     \
-       ZYpp.h          \
        TranslatedText.h \
+       ZYpp.h          \
+       ZYppCommitResult.h      \
        ZYppFactory.h   \
        ZYppCallbacks.h
 
index ce8eccc..0f8e79b 100644 (file)
@@ -15,6 +15,7 @@
 #include <iosfwd>
 
 #include "zypp/base/PtrTypes.h"
+#include "zypp/base/Deprecated.h"
 
 #include "zypp/ResStore.h"
 #include "zypp/Pathname.h"
@@ -54,13 +55,17 @@ namespace zypp
     static Target_Ptr nullimpl();
     /** Refference to the RPM database */
     target::rpm::RpmDb & rpmDb();
-    /** Commit changes in the pool 
+    /** Commit changes in the pool
      *  \param medianr 0 = all/any media
      *                 > 0 means only the given media number
      * return number of successfully committed resolvables
+     *
+     * \todo Interface to commit should be ZYpp::commit( medianr ). This call
+     * should be removed from the targets public interface, as soon as ZYpp::Impl
+     * is able to call Target::I,pl.
     */
     int commit( ResPool pool_r, int medianr, PoolItemList & errors_r
-        , PoolItemList & remaining_r, PoolItemList & srcremaining_r );
+        , PoolItemList & remaining_r, PoolItemList & srcremaining_r ) ZYPP_DEPRECATED;
 
       /** If the package is installed and provides the file
          Needed to evaluate split provides during Resolver::Upgrade() */
index 631e78e..610d7a6 100644 (file)
@@ -82,6 +82,8 @@ namespace zypp
     _pimpl->addResolvables (store);
   }
 
+  ///////////////////////////////////////////////////////////////////
+
   Target_Ptr ZYpp::target() const
   { return _pimpl->target(); }
 
@@ -91,6 +93,9 @@ namespace zypp
   void ZYpp::finishTarget()
   { _pimpl->finishTarget(); }
 
+  ZYpp::CommitResult ZYpp::commit( int medianr_r )
+  { return _pimpl->commit( medianr_r ); }
+
   ///////////////////////////////////////////////////////////////////
 
   void ZYpp::setTextLocale( const Locale & textLocale_r )
index da10334..58cee3d 100644 (file)
@@ -40,7 +40,9 @@ namespace zypp
   //
   //   CLASS NAME : ZYpp
   //
-  /** */
+  /**
+   * \todo define Exceptions
+  */
   class ZYpp : public base::ReferenceCounted, private base::NonCopyable
   {
   public:
@@ -66,6 +68,7 @@ namespace zypp
 
     void removeResolvables (const ResStore& store);
 
+  public:
     /**
      * \throws Exception
      */
@@ -82,6 +85,20 @@ namespace zypp
      */
     void finishTarget();
 
+
+  public:
+    /** Result returned from ZYpp::commit. */
+    struct CommitResult;
+
+    /** Commit changes and transactions.
+     * \param medianr 0 = all/any media
+     *                 > 0 means only the given media number
+     * \return \ref CommitResult
+     * \throws Exception
+    */
+    CommitResult commit( int medianr_r );
+
+  public:
     /** */
     Resolver_Ptr resolver() const;
 
diff --git a/zypp/ZYppCommitResult.h b/zypp/ZYppCommitResult.h
new file mode 100644 (file)
index 0000000..f4d53a9
--- /dev/null
@@ -0,0 +1,47 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/ZYppCommitResult.h
+ *
+*/
+#ifndef ZYPP_ZYPPCOMMITRESULT_H
+#define ZYPP_ZYPPCOMMITRESULT_H
+
+#include <iosfwd>
+#include <list>
+
+#include "zypp/ZYpp.h"
+#include "zypp/PoolItem.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : ZYpp::CommitResult
+  //
+  /** Result returned from ZYpp::commit.
+   * \see \ref ZYpp::commit
+   * \todo document fields.
+  */
+  struct ZYpp::CommitResult
+  {
+    typedef std::list<PoolItem_Ref> PoolItemList;
+
+    int          _result;
+    PoolItemList _errors;
+    PoolItemList _remaining;
+    PoolItemList _srcremaining;
+  };
+  ///////////////////////////////////////////////////////////////////
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_ZYPPCOMMITRESULT_H
index 16b6ee4..f77a1da 100644 (file)
@@ -107,6 +107,29 @@ namespace zypp
       _target = 0;
     }
 
+    /** \todo Remove workflow from target, lot's of it could be done here,
+    * and target used for transact. */
+    ZYpp::CommitResult ZYppImpl::commit( int medianr_r )
+    {
+      MIL << "Attempt to commit (medianr " << medianr_r << ")" << endl;
+      if (! _target)
+       ZYPP_THROW( Exception("Target not initialized.") );
+
+      ZYpp::CommitResult res;
+      // must redirect to Target::Impl. This kind of commit should not be
+      // in the Target interface.
+      res._result = _target->commit( pool(), medianr_r,
+                                     res._errors, res._remaining, res._srcremaining );
+
+      MIL << "Commit (medianr " << medianr_r << ") returned: "
+          << res._result
+          << " (errors " << res._errors.size()
+          << ", remaining " << res._remaining.size()
+          << ", srcremaining " << res._srcremaining.size()
+          << ")" << endl;
+      return res;
+    }
+
     /******************************************************************
      **
      **        FUNCTION NAME : operator<<
index f394336..a2f0987 100644 (file)
@@ -19,6 +19,7 @@
 #include "zypp/Target.h"
 #include "zypp/Resolver.h"
 #include "zypp/Locale.h"
+#include "zypp/ZYppCommitResult.h"
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
@@ -61,6 +62,8 @@ namespace zypp
 
       void removeResolvables (const ResStore& store);
 
+    public:
+      /** \todo Signal locale change. */
       /**
        * \throws Exception
        */
@@ -77,6 +80,9 @@ namespace zypp
        */
       void finishTarget();
 
+      /** Commit changes and transactions. */
+      ZYpp::CommitResult commit( int medianr_r );
+
     public:
       /** \todo Signal locale change. */
       void setTextLocale( const Locale & textLocale_r )