prepare namespace callback
authorMichael Andres <ma@suse.de>
Thu, 7 Feb 2008 16:41:02 +0000 (16:41 +0000)
committerMichael Andres <ma@suse.de>
Thu, 7 Feb 2008 16:41:02 +0000 (16:41 +0000)
zypp/CMakeLists.txt
zypp/Capabilities.h
zypp/Capability.cc
zypp/sat/Repo.h
zypp/sat/Solvable.cc
zypp/sat/Solvable.h
zypp/sat/detail/PoolImpl.cc
zypp/sat/detail/PoolImpl.h

index 1f09082..789d4e4 100644 (file)
@@ -11,7 +11,6 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
 ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_BINARY_DIR}/zypp/sqlite-schema.h PRE_BUILD COMMAND "${CMAKE_BINARY_DIR}/zypp/mkarray" ARGS "${CMAKE_SOURCE_DIR}/zypp/cache/schema/schema.sql" "schemaData" "${CMAKE_BINARY_DIR}/zypp/sqlite-schema.h" DEPENDS mkarray DEPENDS ${CMAKE_SOURCE_DIR}/zypp/cache/schema/schema.sql )
 
 SET( zypp_SRCS
-  Arch.cc
   Atom.cc
   ByteCount.cc
   Capabilities.cc
@@ -19,7 +18,6 @@ SET( zypp_SRCS
   CapMatch.cc
   Changelog.cc
   CheckSum.cc
-  CountryCode.cc
   Date.cc
   Dep.cc
   Dependencies.cc
@@ -33,8 +31,6 @@ SET( zypp_SRCS
   FileChecker.cc
   IdString.cc
   KeyRing.cc
-  LanguageCode.cc
-  Locale.cc
   Locks.cc
   MediaProducts.cc
   MediaSetAccess.cc
@@ -79,12 +75,18 @@ SET( zypp_SRCS
   UpgradeStatistics.cc
   Url.cc
   VendorAttr.cc
-  ZConfig.cc
   ZYpp.cc
   ZYppCommitPolicy.cc
   ZYppCommitResult.cc
   ZYppFactory.cc
 )
+SET( zypp_EARLY_SRCS
+  ZConfig.cc
+  Arch.cc
+  Locale.cc
+  CountryCode.cc
+  LanguageCode.cc
+)
 
 SET( zypp_HEADERS
   Arch.h
@@ -831,6 +833,7 @@ ${zypp_SRCS}
 ${zypp_zypp_detail_SRCS}
 ${zypp_sat_SRCS}
 ${zypp_sat_detail_SRCS}
+${zypp_EARLY_SRCS}
 ${zypp_base_SRCS}
 )
 
index 469cfb1..9746f98 100644 (file)
@@ -93,7 +93,7 @@ namespace zypp
       , const sat::detail::IdType *      // Base
       , const Capability                 // Value
       , boost::forward_traversal_tag     // CategoryOrTraversal
-      , const Capability &               // Reference
+      , const Capability                 // Reference
       >
   {
     public:
@@ -103,7 +103,7 @@ namespace zypp
 
       explicit const_iterator( const sat::detail::IdType * _idx )
       : const_iterator::iterator_adaptor_( _idx )
-      { assignVal(); }
+      {}
 
     public:
       /** Return \c true if the \ref Capability is \c tagged.
@@ -129,31 +129,26 @@ namespace zypp
       friend class boost::iterator_core_access;
 
       reference dereference() const
-      { return _val; }
+      { return ( base() ) ? Capability( *base() ) : Capability::Null; }
 
       template <class OtherDerived, class OtherIterator, class V, class C, class R, class D>
-          bool equal( const boost::iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> & rhs ) const
-          { // NULL pointer is eqal pointer to Id 0
-            return ( base() == rhs.base() // includes both NULL...
-                || ( !rhs.base() && !*base()     )
-                || ( !base()     && !*rhs.base() ) );
-          }
-
-          void increment()
-          { // jump over satsolvers internal ids.
-            if ( sat::detail::isDepMarkerId( *(++base_reference()) ) )
-            {
-              _tagged = true;
-              ++base_reference();
-            }
-            assignVal();
-          }
+      bool equal( const boost::iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> & rhs ) const
+      { // NULL pointer is eqal pointer to Id 0
+        return ( base() == rhs.base() // includes both NULL...
+                 || ( !rhs.base() && !*base()     )
+                 || ( !base()     && !*rhs.base() ) );
+      }
+
+      void increment()
+      { // jump over satsolvers internal ids.
+        if ( sat::detail::isDepMarkerId( *(++base_reference()) ) )
+        {
+          _tagged = true;
+          ++base_reference();
+        }
+      }
 
     private:
-      void assignVal()
-      { _val = ( base() ) ? Capability( *base() ) : Capability::Null; }
-
-      mutable Capability _val;
       DefaultIntegral<bool,false> _tagged;
   };
   ///////////////////////////////////////////////////////////////////
index 0786b77..7fbe077 100644 (file)
@@ -198,7 +198,7 @@ namespace zypp
   */
   std::ostream & operator<<( std::ostream & str, const Capability & obj )
   {
-    return str << obj.c_str();
+    return str << obj.detail();
   }
 
   std::ostream & dumpOn( std::ostream & str, const Capability & obj )
@@ -252,7 +252,17 @@ namespace zypp
         return str << obj.name() << " " << obj.op() << " " << obj.ed();
         break;
       case CapDetail::EXPRESSION:
-        return str << obj.lhs().detail() << " " << obj.capRel() << " " << obj.rhs().detail();
+        switch ( obj.capRel() )
+        {
+          case CapDetail::REL_NONE:
+          case CapDetail::CAP_AND:
+          case CapDetail::CAP_OR:
+          case CapDetail::CAP_WITH:
+            return str << obj.lhs().detail() << " " << obj.capRel() << " " << obj.rhs().detail();
+            break;
+          case CapDetail::CAP_NAMESPACE:
+            return str << obj.lhs().detail() << "(" << obj.rhs().detail() << ")";
+        }
         break;
     }
     return str <<  "<UnknownCap>";
index 4980e00..1740275 100644 (file)
@@ -24,6 +24,7 @@ namespace zypp
 { /////////////////////////////////////////////////////////////////
 
   class Pathname;
+  class RepoInfo;
 
   ///////////////////////////////////////////////////////////////////
   namespace sat
index 39a0ba9..d1e7bcb 100644 (file)
@@ -270,31 +270,78 @@ namespace zypp
 
     Capabilities Solvable::operator[]( Dep which_r ) const
     {
-      NO_SOLVABLE_RETURN( Capabilities() );
-      ::Offset offs = 0;
       switch( which_r.inSwitch() )
       {
-        case Dep::PROVIDES_e:    offs = _solvable->provides;    break;
-        case Dep::REQUIRES_e:    offs = _solvable->requires;    break;
-        case Dep::CONFLICTS_e:   offs = _solvable->conflicts;   break;
-        case Dep::OBSOLETES_e:   offs = _solvable->obsoletes;   break;
-        case Dep::RECOMMENDS_e:  offs = _solvable->recommends;  break;
-        case Dep::SUGGESTS_e:    offs = _solvable->suggests;    break;
-        case Dep::FRESHENS_e:    offs = _solvable->freshens;    break;
-        case Dep::ENHANCES_e:    offs = _solvable->enhances;    break;
-        case Dep::SUPPLEMENTS_e: offs = _solvable->supplements; break;
-
-        case Dep::PREREQUIRES_e:
-          // prerequires are a subset of requires
-          if ( (offs = _solvable->requires) )
-            return Capabilities( _solvable->repo->idarraydata + offs, detail::solvablePrereqMarker );
-          else
-            return Capabilities();
-          break;
+        case Dep::PROVIDES_e:    return provides();    break;
+        case Dep::REQUIRES_e:    return requires();    break;
+        case Dep::CONFLICTS_e:   return conflicts();   break;
+        case Dep::OBSOLETES_e:   return obsoletes();   break;
+        case Dep::RECOMMENDS_e:  return recommends();  break;
+        case Dep::SUGGESTS_e:    return suggests();    break;
+        case Dep::FRESHENS_e:    return freshens();    break;
+        case Dep::ENHANCES_e:    return enhances();    break;
+        case Dep::SUPPLEMENTS_e: return supplements(); break;
+        case Dep::PREREQUIRES_e: return prerequires(); break;
       }
+      return Capabilities();
+    }
 
-      return offs ? Capabilities( _solvable->repo->idarraydata + offs )
-                  : Capabilities();
+    inline Capabilities _getCapabilities( detail::IdType * idarraydata_r, ::Offset offs_r )
+    {
+      return offs_r ? Capabilities( idarraydata_r + offs_r ) : Capabilities();
+    }
+    Capabilities Solvable::provides() const
+    {
+      NO_SOLVABLE_RETURN( Capabilities() );
+      return _getCapabilities( _solvable->repo->idarraydata, _solvable->provides );
+    }
+    Capabilities Solvable::requires() const
+    {
+      NO_SOLVABLE_RETURN( Capabilities() );
+      return _getCapabilities( _solvable->repo->idarraydata, _solvable->requires );
+    }
+    Capabilities Solvable::conflicts() const
+    {
+      NO_SOLVABLE_RETURN( Capabilities() );
+      return _getCapabilities( _solvable->repo->idarraydata, _solvable->conflicts );
+    }
+    Capabilities Solvable::obsoletes() const
+    {
+      NO_SOLVABLE_RETURN( Capabilities() );
+      return _getCapabilities( _solvable->repo->idarraydata, _solvable->obsoletes );
+    }
+    Capabilities Solvable::recommends() const
+    {
+      NO_SOLVABLE_RETURN( Capabilities() );
+      return _getCapabilities( _solvable->repo->idarraydata, _solvable->recommends );
+    }
+    Capabilities Solvable::suggests() const
+    {
+      NO_SOLVABLE_RETURN( Capabilities() );
+      return _getCapabilities( _solvable->repo->idarraydata, _solvable->suggests );
+    }
+    Capabilities Solvable::freshens() const
+    {
+      NO_SOLVABLE_RETURN( Capabilities() );
+      return _getCapabilities( _solvable->repo->idarraydata, _solvable->freshens );
+    }
+    Capabilities Solvable::enhances() const
+    {
+      NO_SOLVABLE_RETURN( Capabilities() );
+      return _getCapabilities( _solvable->repo->idarraydata, _solvable->enhances );
+    }
+    Capabilities Solvable::supplements() const
+    {
+      NO_SOLVABLE_RETURN( Capabilities() );
+      return _getCapabilities( _solvable->repo->idarraydata, _solvable->supplements );
+    }
+    Capabilities Solvable::prerequires() const
+    {
+      NO_SOLVABLE_RETURN( Capabilities() );
+      // prerequires are a subset of requires
+       ::Offset offs = _solvable->requires;
+       return offs ? Capabilities( _solvable->repo->idarraydata + offs, detail::solvablePrereqMarker )
+                   : Capabilities();
     }
 
     /******************************************************************
index 9bda209..e552a8a 100644 (file)
@@ -184,9 +184,9 @@ namespace zypp
       class SolvableIterator : public boost::iterator_adaptor<
           SolvableIterator                   // Derived
           , ::_Solvable*                     // Base
-          , Solvable                         // Value
-          , boost::single_pass_traversal_tag // CategoryOrTraversal
-          , Solvable                         // Reference
+          , const Solvable                   // Value
+          , boost::forward_traversal_tag     // CategoryOrTraversal
+          , const Solvable                   // Reference
           >
       {
         public:
@@ -205,12 +205,13 @@ namespace zypp
         private:
           friend class boost::iterator_core_access;
 
-          void increment()
-          { assignVal( _val.nextInPool() ); }
-
           Solvable dereference() const
           { return _val; }
 
+          void increment()
+          { assignVal( _val.nextInPool() ); }
+
+        private:
           void assignVal( const Solvable & val_r )
           { _val = val_r; base_reference() = _val.get(); }
 
index 5fb4fa1..ba94e1a 100644 (file)
@@ -51,7 +51,7 @@ namespace zypp
 
      /////////////////////////////////////////////////////////////////
 
-      void logSat( struct _Pool *, void *data, int type, const char *logString )
+      static void logSat( struct _Pool *, void *data, int type, const char *logString )
       {
          if ((type & (SAT_FATAL|SAT_ERROR))) {
              _ERR("satsolver") << logString;
@@ -60,6 +60,12 @@ namespace zypp
          }
       }
 
+      static detail::IdType nsCallback( struct _Pool *, void *data, detail::IdType lhs, detail::IdType rhs )
+      {
+        //T << Cability( lhs ) << (const char *)data << Capability( rhs ) << endl;
+        return 0;
+      }
+
       ///////////////////////////////////////////////////////////////////
       //
       //       METHOD NAME : PoolMember::myPool
@@ -89,7 +95,12 @@ namespace zypp
         ::pool_setdebugcallback( _pool, logSat, NULL );
 
         // set pool architecture
-        //::pool_setarch( _pool,  ZConfig::instance().systemArchitecture().asString().c_str() );
+        ::pool_setarch( _pool,  ZConfig::instance().systemArchitecture().asString().c_str() );
+
+        // set namespace callback
+        _pool->nscallback = &nsCallback;
+        _pool->nscallbackdata = (void*)" NAMESPACE ";
+        SEC << _pool->nscallback << endl;
       }
 
       ///////////////////////////////////////////////////////////////////
@@ -102,6 +113,8 @@ namespace zypp
         ::pool_free( _pool );
       }
 
+      ///////////////////////////////////////////////////////////////////
+
       void PoolImpl::setDirty( const char * a1, const char * a2, const char * a3 )
       {
         if ( a1 )
@@ -111,16 +124,15 @@ namespace zypp
           else           DBG << a1 << endl;
         }
         _serial.setDirty();
+        ::pool_freewhatprovides( _pool );
       }
 
       void PoolImpl::prepare()
       {
-        if ( _serial.dirty() )
+        if ( _watcher.remember( _serial ) )
         {
            // sat solver claims to handle this on it's own:
-           ::pool_setarch( _pool,  ZConfig::instance().systemArchitecture().asString().c_str() );
            ::pool_createwhatprovides( _pool );
-           _serial.serial();
         }
       }
 
index 6e12824..d1c974b 100644 (file)
@@ -65,7 +65,7 @@ namespace zypp
           */
           void prepare();
 
-        private:
+        public:
           /** Invalidate housekeeping data (e.g. whatprovides).
           */
           void setDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
@@ -172,6 +172,8 @@ namespace zypp
           ::_Pool * _pool;
           /** Serial number. */
           SerialNumber _serial;
+          /** Watch serial number. */
+          SerialNumberWatcher _watcher;
           /** Additional \ref RepoInfo. */
           std::map<RepoIdType,RepoInfo> _repoinfos;
       };