Imported Upstream version 17.23.0
[platform/upstream/libzypp.git] / zypp / pool / PoolImpl.h
index fbabc91..60d5cf7 100644 (file)
 #define ZYPP_POOL_POOLIMPL_H
 
 #include <iosfwd>
-#include <map>
 
 #include "zypp/base/Easy.h"
+#include "zypp/base/LogTools.h"
 #include "zypp/base/SerialNumber.h"
+#include "zypp/APIConfig.h"
+
 #include "zypp/pool/PoolTraits.h"
 #include "zypp/ResPoolProxy.h"
-#include "zypp/ZYppFactory.h"
+#include "zypp/PoolQueryResult.h"
+
+#include "zypp/sat/Pool.h"
+#include "zypp/Product.h"
+
+using std::endl;
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
+
+  namespace resstatus
+  {
+    /** Manipulator for \ref ResStatus::UserLockQueryField.
+     * Field is not public available. It is intended to remember the
+     * initial lock status usually derived from /etc/zypp/locks. So
+     * we are able to detect changes we have to write back on commit.
+    */
+    struct UserLockQueryManip
+    {
+      /** Set lock and UserLockQuery bit according to \c yesno_r. */
+      static void setLock( ResStatus & status_r, bool yesno_r )
+      {
+        status_r.setLock( yesno_r, ResStatus::USER );
+        status_r.setUserLockQueryMatch( yesno_r );
+      }
+
+      /** Update lock and UserLockQuery bit IFF the item gained the bit. */
+      static void reapplyLock( ResStatus & status_r, bool yesno_r )
+      {
+        if ( yesno_r && ! status_r.isUserLockQueryMatch() )
+        {
+          status_r.setLock( yesno_r, ResStatus::USER );
+          status_r.setUserLockQueryMatch( yesno_r );
+        }
+      }
+
+      /** Test whether the lock status differs from the remembered UserLockQuery bit. */
+      static int diffLock( const ResStatus & status_r )
+      {
+        bool userLock( status_r.isUserLocked() );
+        if ( userLock == status_r.isUserLockQueryMatch() )
+          return 0;
+        return userLock ? 1 : -1;
+      }
+
+    };
+  }
+
+  namespace
+  {
+    inline PoolQuery makeTrivialQuery( IdString ident_r )
+    {
+      sat::Solvable::SplitIdent ident( ident_r );
+
+      PoolQuery q;
+      q.addAttribute( sat::SolvAttr::name, ident.name().asString() );
+      q.addKind( ident.kind() );
+      q.setMatchExact();
+      q.setCaseSensitive(true);
+      return q;
+   }
+
+    inline bool hardLockQueriesRemove( pool::PoolTraits::HardLockQueries & activeLocks_r, IdString ident_r )
+    {
+      unsigned s( activeLocks_r.size() );
+      activeLocks_r.remove( makeTrivialQuery( ident_r ) );
+      return( activeLocks_r.size() != s );
+    }
+
+    inline bool hardLockQueriesAdd( pool::PoolTraits::HardLockQueries & activeLocks_r, IdString ident_r )
+    {
+      PoolQuery q( makeTrivialQuery( ident_r ) );
+      for_( it, activeLocks_r.begin(), activeLocks_r.end() )
+      {
+        if ( *it == q )
+          return false;
+      }
+      activeLocks_r.push_back( q );
+      return true;
+    }
+  }
+
+  ///////////////////////////////////////////////////////////////////
+  namespace solver {
+    namespace detail {
+      void establish( sat::Queue & pseudoItems_r, sat::Queue & pseudoFlags_r );        // in solver/detail/SATResolver.cc
+    }
+  }
+  ///////////////////////////////////////////////////////////////////
+  /// Store initial establish status of pseudo installed items.
+  ///
+  class ResPool::EstablishedStates::Impl
+  {
+  public:
+    Impl()
+    { solver::detail::establish( _pseudoItems, _pseudoFlags ); }
+
+    /** Return all pseudo installed items whose current state differs from their initial one. */
+    ResPool::EstablishedStates::ChangedPseudoInstalled changedPseudoInstalled() const
+    {
+      ChangedPseudoInstalled ret;
+
+      if ( ! _pseudoItems.empty() )
+      {
+       for ( sat::Queue::size_type i = 0; i < _pseudoItems.size(); ++i )
+       {
+         PoolItem pi { sat::Solvable(_pseudoItems[i]) };
+         ResStatus::ValidateValue vorig { validateValue( i ) };
+         if ( pi.status().validate() != vorig )
+           ret[pi] = vorig;
+       }
+      }
+      return ret;
+    }
+
+  private:
+    ResStatus::ValidateValue validateValue( sat::Queue::size_type i ) const
+    {
+      ResStatus::ValidateValue ret { ResStatus::UNDETERMINED };
+      switch ( _pseudoFlags[i] )
+      {
+       case  0: ret = ResStatus::BROKEN      /*2*/; break;
+       case  1: ret = ResStatus::SATISFIED   /*4*/; break;
+       case -1: ret = ResStatus::NONRELEVANT /*6*/; break;
+      }
+      return ret;
+    }
+
+  private:
+    sat::Queue _pseudoItems;
+    sat::Queue _pseudoFlags;
+  };
+
   ///////////////////////////////////////////////////////////////////
   namespace pool
   { /////////////////////////////////////////////////////////////////
 
     ///////////////////////////////////////////////////////////////////
     //
-    // CLASS NAME : NameHash
+    // CLASS NAME : PoolImpl
     //
     /** */
-    class NameHash
+    class PoolImpl
     {
-    public:
-      /** Default ctor */
-      NameHash();
-      /** Dtor */
-      ~NameHash();
+      friend std::ostream & operator<<( std::ostream & str, const PoolImpl & obj );
 
       public:
+        /** */
+        typedef PoolTraits::ItemContainerT             ContainerT;
+        typedef PoolTraits::size_type                  size_type;
+        typedef PoolTraits::const_iterator             const_iterator;
+       typedef PoolTraits::Id2ItemT                    Id2ItemT;
 
-      typedef PoolTraits::ItemContainerT        ItemContainerT;
-      typedef PoolTraits::NameItemContainerT    ContainerT;
-      typedef PoolTraits::size_type             size_type;
-      typedef PoolTraits::iterator              iterator;
-      typedef PoolTraits::const_iterator        const_iterator;
+        typedef PoolTraits::repository_iterator                repository_iterator;
 
-      private:
-       ItemContainerT & getItemContainer( const std::string & tag_r );
-       const ItemContainerT & getConstItemContainer( const std::string & tag_r ) const;
+        typedef sat::detail::SolvableIdType            SolvableIdType;
+
+       typedef ResPool::EstablishedStates::Impl        EstablishedStatesImpl;
 
       public:
-      /**  */
-      ContainerT & store()
-      { return _store; }
-      /**  */
-      const ContainerT & store() const
-      { return _store; }
-
-      /**  */
-      bool empty() const
-      { return _store.empty(); }
-      /**  */
-      size_type size() const
-      { return _store.size(); }
-
-      /** */
-      iterator begin( const std::string & tag_r )
-      { return getItemContainer( tag_r ).begin(); }
-      /** */
-      const_iterator begin( const std::string & tag_r ) const
-      { return getConstItemContainer( tag_r ).begin(); }
-
-      /** */
-      iterator end( const std::string & tag_r )
-      { return getItemContainer( tag_r ).end(); }
-      /** */
-      const_iterator end( const std::string & tag_r ) const
-      { return getConstItemContainer( tag_r ).end(); }
-
-      /** */
-      void clear()
-      { _store.clear(); }
-
-      /** */
-      void insert( const PoolItem & item_r );
-      /** */
-      void erase( const PoolItem & item_r );
+        /** Default ctor */
+        PoolImpl();
+        /** Dtor */
+        ~PoolImpl();
 
-      private:
-       ContainerT _store;
-       ItemContainerT _empty;  // for begin(), end() if tag_r can't be found
-    };
+      public:
+        /** convenience. */
+        const sat::Pool satpool() const
+        { return sat::Pool::instance(); }
 
-    ///////////////////////////////////////////////////////////////////
-    //
-    // CLASS NAME : CapHash
-    //
-    /** */
-    class CapHash
-    {
-    public:
-      /** Default ctor */
-      CapHash();
-      /** Dtor */
-      ~CapHash();
+        /** Housekeeping data serial number. */
+        const SerialNumber & serial() const
+        { return satpool().serial(); }
 
+        ///////////////////////////////////////////////////////////////////
+        //
+        ///////////////////////////////////////////////////////////////////
       public:
+        /**  */
+        bool empty() const
+        { return satpool().solvablesEmpty(); }
 
-      typedef PoolTraits::DepCapItemContainerT ContainerT;
-      typedef PoolTraits::capitemsize_type     size_type;
-      typedef PoolTraits::capitemiterator      iterator;
-      typedef PoolTraits::const_capitemiterator        const_iterator;
+        /**  */
+        size_type size() const
+        { return satpool().solvablesSize(); }
 
-      private:
+        const_iterator begin() const
+        { return make_filter_begin( pool::ByPoolItem(), store() ); }
 
-      typedef PoolTraits::CapItemStoreT                CapItemStoreT;
-      typedef PoolTraits::CapItemContainerT    CapItemContainerT;
+        const_iterator end() const
+        { return make_filter_end( pool::ByPoolItem(), store() ); }
 
-      // Dep -> CapItemStoreT
-      const CapItemStoreT & capItemStore ( Dep cap_r ) const;
+      public:
+        /** Return the corresponding \ref PoolItem.
+         * Pool and sat pool should be in sync. Returns an empty
+         * \ref PoolItem if there is no corresponding \ref PoolItem.
+         * \see \ref PoolItem::satSolvable.
+         */
+        PoolItem find( const sat::Solvable & slv_r ) const
+        {
+          const ContainerT & mystore( store() );
+          return( slv_r.id() < mystore.size() ? mystore[slv_r.id()] : PoolItem() );
+        }
+
+        ///////////////////////////////////////////////////////////////////
+        //
+        ///////////////////////////////////////////////////////////////////
+      public:
+        /** \name Save and restore state. */
+        //@{
+        void SaveState( const ResKind & kind_r );
 
-      // CapItemStoreT, index -> CapItemContainerT
-      const CapItemContainerT & capItemContainer( const CapItemStoreT & cis, const std::string & tag_r ) const;
+        void RestoreState( const ResKind & kind_r );
+        //@}
 
+        ///////////////////////////////////////////////////////////////////
+        //
+        ///////////////////////////////////////////////////////////////////
       public:
+        ResPoolProxy proxy( ResPool self ) const
+        {
+          checkSerial();
+          if ( !_poolProxy )
+          {
+            _poolProxy.reset( new ResPoolProxy( self, *this ) );
+          }
+          return *_poolProxy;
+        }
+
+        /** True factory for \ref ResPool::EstablishedStates.
+        * Internally we maintain the ResPool::EstablishedStates::Impl
+        * reference shared_ptr. Updated whenever the pool content changes.
+        * On demand hand it out as ResPool::EstablishedStates Impl.
+        */
+        ResPool::EstablishedStates establishedStates() const
+        { store(); return ResPool::EstablishedStates( _establishedStates ); }
 
-      /**  */
-      ContainerT & store()
-      { return _store; }
-      /**  */
-      const ContainerT & store() const
-      { return _store; }
-
-      /**  */
-      bool empty() const
-      { return _store.empty(); }
-      /**  */
-      size_type size() const
-      { return _store.size(); }
-
-      /** */
-      iterator begin( const std::string & tag_r, Dep cap_r )
-      { return _store[cap_r][tag_r].begin(); }
-      /** */
-      const_iterator begin( const std::string & tag_r, Dep cap_r ) const
-      { const CapItemStoreT & capitemstore = capItemStore( cap_r );
-       const CapItemContainerT & capcontainer = capItemContainer ( capitemstore, tag_r );
-       return capcontainer.begin(); }
-
-      /** */
-      iterator end( const std::string & tag_r, Dep cap_r )
-      { return _store[cap_r][tag_r].begin(); }
-      /** */
-      const_iterator end( const std::string & tag_r, Dep cap_r ) const
-      { const CapItemStoreT & capitemstore = capItemStore( cap_r );
-       const CapItemContainerT & capcontainer = capItemContainer ( capitemstore, tag_r );
-       return capcontainer.end(); }
-
-      /** */
-      void clear()
-      { _store.clear(); }
-
-      /** */
-      void insert( const PoolItem & item_r );
-      /** */
-      void erase( const PoolItem & item_r );
+      public:
+        /** Forward list of Repositories that contribute ResObjects from \ref sat::Pool */
+        size_type knownRepositoriesSize() const
+        { checkSerial(); return satpool().reposSize(); }
 
-      private:
-       PoolTraits::DepCapItemContainerT _store;
-    };
+        repository_iterator knownRepositoriesBegin() const
+        { checkSerial(); return satpool().reposBegin(); }
 
-    ///////////////////////////////////////////////////////////////////
-    //
-    // CLASS NAME : PoolImpl
-    //
-    /** */
-    class PoolImpl
-    {
-      friend std::ostream & operator<<( std::ostream & str, const PoolImpl & obj );
+        repository_iterator knownRepositoriesEnd() const
+        { checkSerial(); return satpool().reposEnd(); }
 
-    public:
-    /** */
-    typedef PoolTraits::Item                   Item;
-    typedef PoolTraits::ItemContainerT         ContainerT;
-    typedef PoolTraits::iterator               iterator;
-    typedef PoolTraits::const_iterator         const_iterator;
-    typedef PoolTraits::size_type              size_type;
-    typedef PoolTraits::Inserter               Inserter;
-    typedef PoolTraits::Deleter                        Deleter;
-    typedef PoolTraits::AdditionalCapSet       AdditionalCapSet;
-    typedef PoolTraits::RepoContainerT          KnownRepositories;
-
-    public:
-      /** Default ctor */
-      PoolImpl();
-      /** Dtor */
-      ~PoolImpl();
-
-      /** \todo no poll, but make ZYpp distribute it. */
-      Arch targetArch() const
-      { return getZYpp()->architecture(); }
-
-    public:
-      /**  */
-      ContainerT & store()
-      { return _store; }
-      /**  */
-      const ContainerT & store() const
-      { return _store; }
-
-      /**  */
-      bool empty() const
-      { return _store.empty(); }
-      /**  */
-      size_type size() const
-      { return _store.size(); }
-
-      /** */
-      iterator begin()
-      { return _store.begin(); }
-      /** */
-      const_iterator begin() const
-      { return _store.begin(); }
-
-      /** */
-      iterator end()
-      { return _store.end(); }
-      /** */
-      const_iterator end() const
-      { return _store.end(); }
-
-      /**
-       *  Handling additional requirement. E.G. need package "foo" and package
-       *  "foo1" which has a greater version than 1.0:
-       *
-       *  Capset capset;
-       *  capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
-       *  capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo1 > 1.0"));
-       *
-       *  setAdditionalRequire( capset );
-       */
-       void setAdditionalRequire( const AdditionalCapSet & capset ) const
-           { _additionalRequire = capset; }
-       AdditionalCapSet & additionalRequire() const
-           { return _additionalRequire; }
-
-       /**
-       *  Handling additional conflicts. E.G. do not install anything which provides "foo":
-       *
-       *  Capset capset;
-       *  capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
-       *
-       *  setAdditionalConflict( capset );
-       */
-       void setAdditionalConflict( const AdditionalCapSet & capset ) const
-           { _additionaConflict = capset; }
-       AdditionalCapSet & additionaConflict() const
-           { return _additionaConflict; }
-
-       /**
-        *  Handling additional provides. This is used for ignoring a requirement.
-        *  e.G. Do ignore the requirement "foo":
-        *
-        *  Capset capset;
-        *  capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo"));
-        *
-        *  setAdditionalProvide( cap );
-        */
-       void setAdditionalProvide( const AdditionalCapSet & capset ) const
-           { _additionaProvide = capset; }
-       AdditionalCapSet & additionaProvide() const
-           { return _additionaProvide; }
+        Repository reposFind( const std::string & alias_r ) const
+        { checkSerial(); return satpool().reposFind( alias_r ); }
 
-      /** */
-      void clear()
-      {
-        _store.clear();
-       _caphash.clear();
-       _namehash.clear();
-        _additionalRequire.clear();
-       _additionaConflict.clear();
-       _additionaProvide.clear();
-       // don't miss to invalidate ResPoolProxy
-       invalidateProxy();
-       return;
-      }
-
-      /** erase all resolvables coming from the target  */
-      void eraseInstalled() const;
+        ///////////////////////////////////////////////////////////////////
+        //
+        ///////////////////////////////////////////////////////////////////
+      public:
+        typedef PoolTraits::HardLockQueries           HardLockQueries;
+        typedef PoolTraits::hardLockQueries_iterator  hardLockQueries_iterator;
+
+        const HardLockQueries & hardLockQueries() const
+        { return _hardLockQueries; }
+
+        void reapplyHardLocks() const
+        {
+          // It is assumed that reapplyHardLocks is called after new
+          // items were added to the pool, but the _hardLockQueries
+          // did not change since. Action is to be performed only on
+          // those items that gained the bit in the UserLockQueryField.
+          MIL << "Re-apply " << _hardLockQueries.size() << " HardLockQueries" << endl;
+          PoolQueryResult locked;
+          for_( it, _hardLockQueries.begin(), _hardLockQueries.end() )
+          {
+            locked += *it;
+          }
+          MIL << "HardLockQueries match " << locked.size() << " Solvables." << endl;
+          for_( it, begin(), end() )
+          {
+            resstatus::UserLockQueryManip::reapplyLock( it->status(), locked.contains( *it ) );
+          }
+        }
+
+        void setHardLockQueries( const HardLockQueries & newLocks_r )
+        {
+          MIL << "Apply " << newLocks_r.size() << " HardLockQueries" << endl;
+          _hardLockQueries = newLocks_r;
+          // now adjust the pool status
+          PoolQueryResult locked;
+          for_( it, _hardLockQueries.begin(), _hardLockQueries.end() )
+          {
+            locked += *it;
+          }
+          MIL << "HardLockQueries match " << locked.size() << " Solvables." << endl;
+          for_( it, begin(), end() )
+          {
+            resstatus::UserLockQueryManip::setLock( it->status(), locked.contains( *it ) );
+          }
+        }
+
+        bool getHardLockQueries( HardLockQueries & activeLocks_r )
+        {
+          activeLocks_r = _hardLockQueries; // current queries
+          // Now diff to the pool collecting names only.
+          // Thus added and removed locks are not necessarily
+          // disjoint. Added locks win.
+          typedef std::unordered_set<IdString> IdentSet;
+          IdentSet addedLocks;
+          IdentSet removedLocks;
+          for_( it, begin(), end() )
+          {
+            switch ( resstatus::UserLockQueryManip::diffLock( it->status() ) )
+            {
+              case 0:  // unchanged
+                break;
+              case 1:
+                addedLocks.insert( it->satSolvable().ident() );
+                break;
+              case -1:
+                removedLocks.insert( it->satSolvable().ident() );
+               break;
+            }
+          }
+          // now the bad part - adjust the queries
+          bool setChanged = false;
+          for_( it, removedLocks.begin(), removedLocks.end() )
+          {
+            if ( addedLocks.find( *it ) != addedLocks.end() )
+              continue; // Added locks win
+            if ( hardLockQueriesRemove( activeLocks_r, *it ) && ! setChanged )
+              setChanged = true;
+          }
+          for_( it, addedLocks.begin(), addedLocks.end() )
+          {
+            if ( hardLockQueriesAdd( activeLocks_r, *it ) && ! setChanged )
+              setChanged = true;
+          }
+          return setChanged;
+       }
 
-    public:
-      /** Access list of Repositories that contribute ResObjects.
-       * Built on demand.
-      */
-      const KnownRepositories & knownRepositories() const
-      {
-       if ( ! _knownRepositoriesPtr )
+      public:
+        const ContainerT & store() const
+        {
+          checkSerial();
+          if ( _storeDirty )
+          {
+            sat::Pool pool( satpool() );
+            bool addedItems = false;
+           bool reusedIDs = _watcherIDs.remember( pool.serialIDs() );
+            std::list<PoolItem> addedProducts;
+
+           _store.resize( pool.capacity() );
+
+            if ( pool.capacity() )
+            {
+              for ( sat::detail::SolvableIdType i = pool.capacity()-1; i != 0; --i )
+              {
+                sat::Solvable s( i );
+                PoolItem & pi( _store[i] );
+                if ( ! s &&  pi )
+                {
+                  // the PoolItem got invalidated (e.g unloaded repo)
+                  pi = PoolItem();
+                }
+                else if ( reusedIDs || (s && ! pi) )
+                {
+                  // new PoolItem to add
+                  pi = PoolItem::makePoolItem( s ); // the only way to create a new one!
+                  // remember products for buddy processing (requires clean store)
+                  if ( s.isKind( ResKind::product ) )
+                    addedProducts.push_back( pi );
+                  if ( !addedItems )
+                    addedItems = true;
+                }
+              }
+            }
+            _storeDirty = false;
+
+            // Now, as the pool is adjusted, ....
+
+            // .... we check for product buddies.
+            if ( ! addedProducts.empty() )
+            {
+              for_( it, addedProducts.begin(), addedProducts.end() )
+              {
+                it->setBuddy( asKind<Product>(*it)->referencePackage() );
+              }
+            }
+
+            // .... we must reapply those query based hard locks.
+            if ( addedItems )
+            {
+              reapplyHardLocks();
+            }
+
+           // Compute the initial status of Patches etc.
+            if ( !_establishedStates )
+             _establishedStates.reset( new EstablishedStatesImpl );
+          }
+          return _store;
+        }
+
+       const Id2ItemT & id2item () const
        {
-         _knownRepositoriesPtr.reset( new KnownRepositories );
-         for_( it, _store.begin(), _store.end() )
+         checkSerial();
+         if ( _id2itemDirty )
          {
-           if ( (*it)->repository() != Repository::noRepository )
-           {
-             _knownRepositoriesPtr->insert( (*it)->repository() );
-           }
-         }
+           store();
+           _id2item = Id2ItemT( size() );
+            for_( it, begin(), end() )
+            {
+              const sat::Solvable &s = (*it)->satSolvable();
+              sat::detail::IdType id = s.ident().id();
+              if ( s.isKind( ResKind::srcpackage ) )
+                id = -id;
+              _id2item.insert( std::make_pair( id, *it ) );
+            }
+            //INT << _id2item << endl;
+           _id2itemDirty = false;
+          }
+         return _id2item;
        }
 
-       return *_knownRepositoriesPtr;
-      }
-
-    public:
-      /** \name Save and restore state. */
-      //@{
-      void SaveState( const ResObject::Kind & kind_r );
-
-      void RestoreState( const ResObject::Kind & kind_r );
-      //@}
-
-    public:
-      /** Serial number changing whenever the content
-       * (Resolvables or Dependencies) changes. */
-      const SerialNumber & serial() const;
-
-      /** Wheter in sync with sat-pool. */
-      bool satSynced() const
-      { return _satSyncRequired.isClean( _serial ); }
-
-      /** Sync with sat-pool. */
-      void satSync() const;
-
-    private:
-      /** Serial number. */
-      SerialNumber        _serial;
-      /** Watch for changes in /etc/sysconfig/storage. */
-      SerialNumberWatcher _watchFilesystemSysconfigStorage;
-      /** Watch for changes in /etc/sysconfig/storage. */
-      SerialNumberWatcher _satSyncRequired;
-
-    public:
-      ContainerT   _store;
-      NameHash     _namehash;
-      CapHash      _caphash;
-      mutable AdditionalCapSet _additionalRequire;
-      mutable AdditionalCapSet _additionaConflict;
-      mutable AdditionalCapSet _additionaProvide;
-
-    public:
-      ResPoolProxy proxy( ResPool self ) const
-      {
-        if ( !_poolProxy )
-          _poolProxy.reset( new ResPoolProxy( self ) );
-        return *_poolProxy;
-      }
+        ///////////////////////////////////////////////////////////////////
+        //
+        ///////////////////////////////////////////////////////////////////
+      private:
+        void checkSerial() const
+        {
+          if ( _watcher.remember( serial() ) )
+            invalidate();
+          satpool().prepare(); // always ajust dependencies.
+        }
+
+        void invalidate() const
+        {
+          _storeDirty = true;
+         _id2itemDirty = true;
+         _id2item.clear();
+          _poolProxy.reset();
+         _establishedStates.reset();
+        }
 
-      /** Invalidate all data we build on demand.
-       * To be called whenever the pools content changes
-       */
-      void invalidateProxy()
-      {
-        _serial.setDirty();
-       _poolProxy.reset();
-       _knownRepositoriesPtr.reset();
-      }
+      private:
+        /** Watch sat pools serial number. */
+        SerialNumberWatcher                   _watcher;
+       /** Watch sat pools Serial number of IDs - changes whenever resusePoolIDs==true - ResPool must also invalidate it's PoolItems! */
+        SerialNumberWatcher                   _watcherIDs;
+        mutable ContainerT                    _store;
+        mutable DefaultIntegral<bool,true>    _storeDirty;
+       mutable Id2ItemT                      _id2item;
+        mutable DefaultIntegral<bool,true>    _id2itemDirty;
 
-      mutable shared_ptr<ResPoolProxy> _poolProxy;
+      private:
+        mutable shared_ptr<ResPoolProxy>      _poolProxy;
+       mutable shared_ptr<EstablishedStatesImpl> _establishedStates;
 
-    private:
-      /** Set of known repositories built on demand.
-       * Invalidated on any Pool content change. Rebuilt on next access.
-       */
-      mutable scoped_ptr<KnownRepositories> _knownRepositoriesPtr;
+      private:
+        /** Set of queries that define hardlocks. */
+        HardLockQueries                       _hardLockQueries;
     };
     ///////////////////////////////////////////////////////////////////
 
-    /** \relates PoolImpl Stream output */
-    std::ostream & operator<<( std::ostream & str, const PoolImpl & obj );
-
     /////////////////////////////////////////////////////////////////
   } // namespace pool
   ///////////////////////////////////////////////////////////////////