- ResPoolProxy save/restore
authorMichael Andres <ma@suse.de>
Fri, 10 Feb 2006 16:58:15 +0000 (16:58 +0000)
committerMichael Andres <ma@suse.de>
Fri, 10 Feb 2006 16:58:15 +0000 (16:58 +0000)
zypp/PoolItem.cc
zypp/PoolItem.h
zypp/ResPoolProxy.cc
zypp/ResPoolProxy.h
zypp/pool/PoolImpl.h

index 445d872..49b5535 100644 (file)
@@ -133,6 +133,12 @@ namespace zypp
   ResObject::constPtr PoolItem_Ref::resolvable() const
   { return _pimpl->resolvable(); }
 
+  void PoolItem_Ref::saveState() const
+  { _pimpl->saveState(); }
+
+  void PoolItem_Ref::restoreState() const
+  { _pimpl->restoreState(); }
+
   /******************************************************************
    **
    **  FUNCTION NAME : operator<<
index 4a10a59..3d0cd15 100644 (file)
@@ -90,6 +90,15 @@ namespace zypp
   private:
     /** Pointer to implementation */
     RW_pointer<Impl> _pimpl;
+
+  private:
+    /** \name tmp hack for save/restore state. */
+    /** \todo get rid of it. */
+    //@{
+    friend class PoolItemSaver;
+    void saveState() const;
+    void restoreState() const;
+    //@}
   };
   ///////////////////////////////////////////////////////////////////
 
index f75de2b..12ce8cb 100644 (file)
@@ -25,6 +25,22 @@ using std::endl;
 namespace zypp
 { /////////////////////////////////////////////////////////////////
 
+  /** Tem. friend of PoolItem */
+  struct PoolItemSaver
+  {
+    void saveState( ResPool_Ref pool_r, const ResObject::Kind & kind_r )
+    {
+      std::for_each( pool_r.byKindBegin(kind_r), pool_r.byKindEnd(kind_r),
+                     std::mem_fun_ref(&PoolItem::saveState) );
+    }
+
+    void restoreState( ResPool_Ref pool_r, const ResObject::Kind & kind_r )
+    {
+      std::for_each( pool_r.byKindBegin(kind_r), pool_r.byKindEnd(kind_r),
+                     std::mem_fun_ref(&PoolItem::restoreState) );
+    }
+  };
+
   struct SelPoolHelper
   {
     typedef std::set<ResPool::Item>         ItemC;
@@ -134,6 +150,15 @@ namespace zypp
     const_iterator byKindEnd( const ResObject::Kind & kind_r ) const
     { return _selPool[kind_r].end(); }
 
+
+  public:
+
+    void saveState( const ResObject::Kind & kind_r ) const
+    { PoolItemSaver().saveState( _pool, kind_r ); }
+
+    void restoreState( const ResObject::Kind & kind_r ) const
+    { PoolItemSaver().restoreState( _pool, kind_r ); }
+
   private:
     ResPool_Ref _pool;
     mutable SelectablePool _selPool;
@@ -204,6 +229,12 @@ namespace zypp
   ResPoolProxy::const_iterator ResPoolProxy::byKindEnd( const ResObject::Kind & kind_r ) const
   { return _pimpl->byKindEnd( kind_r ); }
 
+  void ResPoolProxy::saveState( const ResObject::Kind & kind_r ) const
+  { _pimpl->saveState( kind_r ); }
+
+  void ResPoolProxy::restoreState( const ResObject::Kind & kind_r ) const
+  { _pimpl->restoreState( kind_r ); }
+
   /******************************************************************
    **
    **  FUNCTION NAME : operator<<
index 3f08eb4..6029185 100644 (file)
@@ -100,15 +100,22 @@ namespace zypp
       bool hasInstalledObj() const
       { return hasInstalledObj( ResTraits<_Res>::kind ); }
 
-
-
   public:
-    /** \name Save and restore state.
-     * \todo make it work.
+    /** \name Save and restore state per kind of resolvable.
+     * Simple version, no savety net.
     */
     //@{
-    void SaveState();
-    void RestoreState();
+    void saveState( const ResObject::Kind & kind_r ) const;
+
+    template<class _Res>
+      void saveState() const
+      { return saveState( ResTraits<_Res>::kind ); }
+
+    void restoreState( const ResObject::Kind & kind_r ) const;
+
+    template<class _Res>
+      void restoreState() const
+      { return restoreState( ResTraits<_Res>::kind ); }
     //@}
 
   private:
index b16705c..5a7e67a 100644 (file)
@@ -176,6 +176,14 @@ namespace zypp
       }
 
     public:
+      /** \name Save and restore state. */
+      //@{
+      void SaveState( const ResObject::Kind & kind_r );
+
+      void RestoreState( const ResObject::Kind & kind_r );
+      //@}
+
+    public:
       /** */
       ContainerT _store;
       IndexContainerT _providesstore;