backup
authorMichael Andres <ma@suse.de>
Tue, 13 Nov 2007 16:59:55 +0000 (16:59 +0000)
committerMichael Andres <ma@suse.de>
Tue, 13 Nov 2007 16:59:55 +0000 (16:59 +0000)
devel/devel.ma/CMakeLists.txt
devel/devel.ma/NewPool.cc
devel/devel.ma/Sat.cc [new file with mode: 0644]
devel/devel.ma/Tools.h
zypp/CMakeLists.txt
zypp/sat/Pool.cc [new file with mode: 0644]
zypp/sat/Pool.h [new file with mode: 0644]
zypp/sat/Repo.cc [new file with mode: 0644]
zypp/sat/Repo.h [new file with mode: 0644]
zypp/sat/Solvable.cc [new file with mode: 0644]
zypp/sat/Solvable.h [new file with mode: 0644]

index 7b1c893..1e3c5f9 100644 (file)
@@ -29,7 +29,7 @@ ADD_CUSTOM_TARGET( ma_test
 
 ## ############################################################
 
-FOREACH( loop_var NewPool ScanSource Iorder Xml Ex Main FakePool AOUT Parse Test Basic)
+FOREACH( loop_var NewPool ScanSource Iorder Xml Ex Main FakePool AOUT Parse Test Basic Sat)
    ADD_EXECUTABLE( ${loop_var}
       ${loop_var}.cc
    )
index 89ec155..5d441d9 100644 (file)
@@ -40,6 +40,9 @@
 #include "zypp/ui/PatchContents.h"
 #include "zypp/ResPoolProxy.h"
 
+#include "zypp/sat/Pool.h"
+#include "zypp/sat/Repo.h"
+
 using namespace std;
 using namespace zypp;
 using namespace zypp::functor;
@@ -116,54 +119,6 @@ namespace zypp
       }
 }
 
-template<class _Res>
-Selectable::Ptr getSel( const std::string & name_r )
-{
-  ResPoolProxy uipool( getZYpp()->poolProxy() );
-  for_(it, uipool.byKindBegin<_Res>(), uipool.byKindEnd<_Res>() )
-  {
-    if ( (*it)->name() == name_r )
-      return (*it);
-  }
-  return 0;
-}
-
-template<class _Res>
-PoolItem getPi( const std::string & name_r, const Edition & ed_r, const Arch & arch_r )
-{
-  PoolItem ret;
-  ResPool pool( getZYpp()->pool() );
-  for_(it, pool.byNameBegin(name_r), pool.byNameEnd(name_r) )
-  {
-    if ( !ret && isKind<_Res>( (*it).resolvable() )
-         && ( ed_r == Edition() || ed_r == (*it)->edition() )
-         && ( arch_r == Arch()  || arch_r == (*it)->arch()  ) )
-    {
-      ret = (*it);
-      MIL << "    ->" << *it << endl;
-    }
-    else
-    {
-      DBG << "     ?" << *it << endl;
-    }
-  }
-  return ret;
-}
-template<class _Res>
-PoolItem getPi( const std::string & name_r )
-{
-  return getPi<_Res>( name_r, Edition(), Arch() );
-}
-template<class _Res>
-PoolItem getPi( const std::string & name_r, const Edition & ed_r )
-{
-  return getPi<_Res>( name_r, ed_r, Arch() );
-}
-template<class _Res>
-PoolItem getPi( const std::string & name_r, const Arch & arch_r )
-{
-  return getPi<_Res>( name_r, Edition(), arch_r );
-}
 
 void dbgDu( Selectable::Ptr sel )
 {
@@ -439,6 +394,7 @@ namespace container
     bool isIn( const std::set<_Tp> & cont, const typename std::set<_Tp>::value_type & val )
     { return cont.find( val ) != cont.end(); }
 }
+///////////////////////////////////////////////////////////////////
 
 /******************************************************************
 **
@@ -449,7 +405,31 @@ int main( int argc, char * argv[] )
 {
   //zypp::base::LogControl::instance().logfile( "log.restrict" );
   INT << "===[START]==========================================" << endl;
+
+  zypp::sat::Pool satpool;
+  MIL << satpool << endl;
+  DBG << satpool.addRepoSolv( "sl10.1-beta7-selections.solv" ) << endl;
+  MIL << satpool << endl;
+  DBG << satpool.addRepoSolv( "1234567890.solv" ) << endl;
+  MIL << satpool << endl;
+  DBG << satpool.addRepoSolv( "sl10.1-beta7-packages.solv" ) << endl;
+  MIL << satpool << endl;
+
+  for_( it, satpool.reposBegin(), satpool.reposEnd() )
+  {
+    WAR << *it << endl;
+    for_( sit, it->solvablesBegin(), it->solvablesEnd() )
+      MIL << *sit << endl;
+  }
+
+
+  satpool.t();
+
+
+  ///////////////////////////////////////////////////////////////////
+  INT << "===[END]============================================" << endl << endl;
   zypp::base::LogControl::instance().logNothing();
+  return 0;
 
   setenv( "ZYPP_CONF", (sysRoot/"zypp.conf").c_str(), 1 );
 
@@ -473,8 +453,8 @@ int main( int argc, char * argv[] )
        SEC << "cleanCache" << endl;
        repoManager.cleanCache( nrepo );
       }
-      //SEC << "refreshMetadata" << endl;
-      //repoManager.refreshMetadata( nrepo, RepoManager::RefreshForced );
+      SEC << "refreshMetadata" << endl;
+      repoManager.refreshMetadata( nrepo, RepoManager::RefreshForced );
       SEC << "buildCache" << endl;
       repoManager.buildCache( nrepo );
     }
@@ -526,12 +506,13 @@ int main( int argc, char * argv[] )
   ResPool pool( getZYpp()->pool() );
   USR << "pool: " << pool << endl;
 
-  {
-  }
-
   //std::for_each( pool.begin(), pool.end(), Xprint() );
 
- ///////////////////////////////////////////////////////////////////
+  //sat::detail::PoolImpl satpool;
+  //sat::Pool satpool;
+  //MIL << satpool << endl;
+
+  ///////////////////////////////////////////////////////////////////
   INT << "===[END]============================================" << endl << endl;
   zypp::base::LogControl::instance().logNothing();
   return 0;
diff --git a/devel/devel.ma/Sat.cc b/devel/devel.ma/Sat.cc
new file mode 100644 (file)
index 0000000..5a9dd30
--- /dev/null
@@ -0,0 +1,52 @@
+extern "C"
+{
+#include <stdio.h>
+#include <satsolver/pool.h>
+#include <satsolver/repo_solv.h>
+}
+#include <cstdio>
+#include <iostream>
+
+#include "zypp/Pathname.h"
+#include "zypp/base/Logger.h"
+#include "zypp/base/LogControl.h"
+
+using std::endl;
+using namespace zypp;
+
+int main( int argc, char * argv[] )
+{
+  //zypp::base::LogControl::instance().logfile( "log.restrict" );
+  INT << "===[START]==========================================" << endl;
+
+  ::_Pool * _pool = ::pool_create();
+
+  Pathname p;
+
+  p = "sl10.1-beta7-selections.solv";
+  FILE * file = ::fopen( p.c_str(), "r" );
+  ::pool_addrepo_solv( _pool, file, p.c_str() );
+  ::fclose( file );
+
+  p = "1234567890.solv";
+  file = ::fopen( p.c_str(), "r" );
+  ::pool_addrepo_solv( _pool, file, p.c_str() );
+  ::fclose( file );
+
+  p = "sl10.1-beta7-packages.solv";
+  file = ::fopen( p.c_str(), "r" );
+  ::pool_addrepo_solv( _pool, file, p.c_str() );
+  ::fclose( file );
+
+  ::_Pool & pool( *_pool );
+
+  MIL << _pool->nrepos << endl;
+  MIL << (void*)(*pool.repos) << " " << (*pool.repos)->name << endl;
+  MIL << (void*)(*(pool.repos+1)) << " " << (*(pool.repos+1))->name << endl;
+  MIL << (void*)(*(pool.repos+2)) << " " << (*(pool.repos+2))->name << endl;
+
+  ///////////////////////////////////////////////////////////////////
+  INT << "===[END]============================================" << endl << endl;
+  zypp::base::LogControl::instance().logNothing();
+  return 0;
+}
index 899345c..9578876 100644 (file)
@@ -19,6 +19,9 @@
 #include <zypp/ResObject.h>
 #include <zypp/pool/PoolStats.h>
 
+#include "zypp/ResPool.h"
+#include "zypp/ResPoolProxy.h"
+
 #include <zypp/Repository.h>
 #include <zypp/RepoManager.h>
 
@@ -119,4 +122,55 @@ inline RepoManager makeRepoManager( const Pathname & mgrdir_r )
 }
 
 ///////////////////////////////////////////////////////////////////
+
+template<class _Res>
+ui::Selectable::Ptr getSel( const std::string & name_r )
+{
+  ResPoolProxy uipool( getZYpp()->poolProxy() );
+  for_(it, uipool.byKindBegin<_Res>(), uipool.byKindEnd<_Res>() )
+  {
+    if ( (*it)->name() == name_r )
+      return (*it);
+  }
+  return 0;
+}
+
+template<class _Res>
+PoolItem getPi( const std::string & name_r, const Edition & ed_r, const Arch & arch_r )
+{
+  PoolItem ret;
+  ResPool pool( getZYpp()->pool() );
+  for_(it, pool.byNameBegin(name_r), pool.byNameEnd(name_r) )
+  {
+    if ( !ret && isKind<_Res>( (*it).resolvable() )
+         && ( ed_r == Edition() || ed_r == (*it)->edition() )
+         && ( arch_r == Arch()  || arch_r == (*it)->arch()  ) )
+    {
+      ret = (*it);
+      MIL << "    ->" << *it << endl;
+    }
+    else
+    {
+      DBG << "     ?" << *it << endl;
+    }
+  }
+  return ret;
+}
+template<class _Res>
+PoolItem getPi( const std::string & name_r )
+{
+  return getPi<_Res>( name_r, Edition(), Arch() );
+}
+template<class _Res>
+PoolItem getPi( const std::string & name_r, const Edition & ed_r )
+{
+  return getPi<_Res>( name_r, ed_r, Arch() );
+}
+template<class _Res>
+PoolItem getPi( const std::string & name_r, const Arch & arch_r )
+{
+  return getPi<_Res>( name_r, Edition(), arch_r );
+}
+
+///////////////////////////////////////////////////////////////////
 #endif // Tools_h
index 3ee02b8..de46818 100644 (file)
@@ -676,12 +676,16 @@ INSTALL(  FILES
 )
 
 SET( zypp_sat_SRCS
-#  sat/Pool.cc
+  sat/Pool.cc
+  sat/Repo.cc
+  sat/Solvable.cc
   sat/SATResolver.cc
 )
 
 SET( zypp_sat_HEADERS
-#  sat/Pool.h
+  sat/Pool.h
+  sat/Repo.h
+  sat/Solvable.h
   sat/SATResolver.h
 )
 
diff --git a/zypp/sat/Pool.cc b/zypp/sat/Pool.cc
new file mode 100644 (file)
index 0000000..0114cf0
--- /dev/null
@@ -0,0 +1,133 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/sat/Pool.cc
+ *
+*/
+
+extern "C"
+{
+#include <stdio.h>
+#include <satsolver/repo_solv.h>
+#include <satsolver/pool.h>
+}
+#include <cstdio>
+#include <iostream>
+#include <set>
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/Gettext.h"
+#include "zypp/base/Exception.h"
+
+#include "zypp/sat/Pool.h"
+#include "zypp/sat/Repo.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace sat
+  { /////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : Pool
+    //
+    ///////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // METHOD NAME : Pool::Pool
+    // METHOD TYPE : Ctor
+    //
+    Pool::Pool()
+      : _raii( ::pool_create(), ::pool_free )
+      , _pool( *_raii.value() )
+    {
+      if ( _raii == NULL )
+      {
+        _raii.resetDispose(); // no call to ::pool_free
+        ZYPP_THROW( Exception( _("Can not create sat-pool.") ) );
+      }
+    }
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // METHOD NAME : Pool::~Pool
+    // METHOD TYPE : Dtor
+    //
+    Pool::~Pool()
+    {}
+
+    unsigned Pool::reposSize() const
+    { return _pool.nrepos; }
+
+    RepoIterator Pool::reposBegin() const
+    { return make_transform_iterator( _pool.repos, detail::mkRepo() ); }
+
+    RepoIterator Pool::reposEnd() const
+    { return make_transform_iterator( _pool.repos+_pool.nrepos, detail::mkRepo() ); }
+
+
+    unsigned Pool::solvablesSize() const
+    { return _pool.nsolvables;}
+
+    SolvableIterator Pool::solvablesBegin() const
+    { return SolvableIterator( _pool.solvables ); }
+
+    SolvableIterator Pool::solvablesEnd() const
+    { return SolvableIterator( _pool.solvables+_pool.nsolvables ); }
+
+
+    void Pool::t() const
+    {
+      if ( _pool.nrepos )
+      {
+        SEC << (void*)(*_pool.repos)<< Repo( *_pool.repos ) << " " << (*_pool.repos)->name << std::endl;
+      }
+      else
+      {
+        SEC << "NOREPO" << std::endl;
+      }
+
+    }
+
+    Repo Pool::addRepoSolv( const Pathname & file_r )
+    {
+      AutoDispose<FILE*> file( ::fopen( file_r.c_str(), "r" ), ::fclose );
+      if ( file == NULL )
+      {
+        file.resetDispose();
+        return Repo();
+      }
+
+#warning Workaround sat-repo not doing strdup on name.
+      // simply spend a static array of reponames
+      static std::set<std::string> _reponames;
+      return ::pool_addrepo_solv( &_pool, file, _reponames.insert( file_r.asString() ).first->c_str() );
+    }
+
+    /******************************************************************
+    **
+    ** FUNCTION NAME : operator<<
+    ** FUNCTION TYPE : std::ostream &
+    */
+    std::ostream & operator<<( std::ostream & str, const Pool & obj )
+    {
+      return str << "sat::pool(){"
+          << obj.reposSize() << "repos|"
+          << obj.solvablesSize() << "slov}";
+
+    }
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace sat
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/sat/Pool.h b/zypp/sat/Pool.h
new file mode 100644 (file)
index 0000000..c8a5e36
--- /dev/null
@@ -0,0 +1,81 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/sat/Pool.h
+ *
+*/
+#ifndef ZYPP_SAT_POOL_H
+#define ZYPP_SAT_POOL_H
+
+#include <iosfwd>
+
+#include "zypp/base/PtrTypes.h"
+#include "zypp/base/Iterator.h"
+
+#include "zypp/AutoDispose.h"
+#include "zypp/Pathname.h"
+
+#include "zypp/sat/Repo.h"
+
+///////////////////////////////////////////////////////////////////
+extern "C"
+{
+struct _Pool;
+}
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace sat
+  { /////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : Pool
+    //
+    /** */
+    class Pool
+    {
+      public:
+        /** Default ctor */
+        Pool();
+        /** Dtor */
+        ~Pool();
+
+      public:
+        unsigned reposSize() const;
+        RepoIterator reposBegin() const;
+        RepoIterator reposEnd() const;
+
+        unsigned solvablesSize() const;
+        SolvableIterator solvablesBegin() const;
+        SolvableIterator solvablesEnd() const;
+
+        void t() const;
+
+      public:
+        Repo addRepoSolv( const Pathname & file_r );
+
+      private:
+        /** Explicitly shared sat-pool. */
+        AutoDispose< ::_Pool *> _raii;
+        /** Convenient access. */
+        ::_Pool & _pool;
+    };
+    ///////////////////////////////////////////////////////////////////
+
+    /** \relates Pool Stream output */
+    std::ostream & operator<<( std::ostream & str, const Pool & obj );
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace sat
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_SAT_POOL_H
diff --git a/zypp/sat/Repo.cc b/zypp/sat/Repo.cc
new file mode 100644 (file)
index 0000000..bb7b680
--- /dev/null
@@ -0,0 +1,83 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/sat/Repo.cc
+ *
+*/
+extern "C"
+{
+#include <satsolver/pool.h>
+#include <satsolver/repo.h>
+}
+#include <iostream>
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/Gettext.h"
+#include "zypp/base/Exception.h"
+
+#include "zypp/sat/Repo.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace sat
+  { /////////////////////////////////////////////////////////////////
+
+    const Repo Repo::norepo( NULL );
+
+    const char * Repo::name() const
+    {
+      if ( ! _repo ) return "";
+      return _repo->name;
+    }
+
+    unsigned Repo::solvablesSize() const
+    {
+      if ( ! _repo ) return 0;
+      return _repo->nsolvables;
+    }
+
+    SolvableIterator Repo::solvablesBegin() const
+    {
+      if ( ! _repo ) return SolvableIterator();
+      return SolvableIterator( _repo->pool->solvables+_repo->start );
+    }
+
+    SolvableIterator Repo::solvablesEnd() const
+    {
+      if ( ! _repo ) return SolvableIterator();
+      return SolvableIterator( _repo->pool->solvables+_repo->start+_repo->nsolvables );
+    }
+
+    /******************************************************************
+    **
+    ** FUNCTION NAME : operator<<
+    ** FUNCTION TYPE : std::ostream &
+    */
+    std::ostream & operator<<( std::ostream & str, const Repo & obj )
+    {
+      if ( ! obj )
+        return str << "sat::repo()";
+
+      return str << "sat::repo(" << obj.name() << ")"
+          << "{"
+          << obj.solvablesSize()
+          << (obj.get()->start < 0      ? "_START_":"")
+          << (obj.get()->nsolvables < 0 ?"_NUMSOLV_":"")
+          <<"}";
+    }
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace sat
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/sat/Repo.h b/zypp/sat/Repo.h
new file mode 100644 (file)
index 0000000..e3a20e8
--- /dev/null
@@ -0,0 +1,105 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/sat/Repo.h
+ *
+*/
+#ifndef ZYPP_SAT_REPO_H
+#define ZYPP_SAT_REPO_H
+
+#include <iosfwd>
+
+#include "zypp/base/SafeBool.h"
+
+#include "zypp/sat/Solvable.h"
+
+///////////////////////////////////////////////////////////////////
+extern "C"
+{
+struct _Repo;
+}
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace sat
+  { /////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : Repo
+    //
+    /** */
+    class Repo : private base::SafeBool<Repo>
+    {
+      public:
+        /** Ctor defaults to \ref norepo.*/
+        Repo( ::_Repo * repo_r = NULL )
+        : _repo( repo_r )
+        {}
+
+      public:
+        /** Represents no \ref Repo. */
+        static const Repo norepo;
+
+        /** Evaluate \ref Repo in a boolean context (\c != \c norepo). */
+        using base::SafeBool<Repo>::operator bool_type;
+
+      public:
+        /** The repos name (alias?). */
+        const char * name() const;
+
+        unsigned solvablesSize() const;
+        SolvableIterator solvablesBegin() const;
+        SolvableIterator solvablesEnd() const;
+
+      public:
+        /** Expert backdoor. */
+        ::_Repo * get() const { return _repo; }
+      private:
+        friend base::SafeBool<Repo>::operator bool_type() const;
+        bool boolTest() const { return _repo; }
+      private:
+        ::_Repo * _repo;
+    };
+    ///////////////////////////////////////////////////////////////////
+
+    /** \relates Repo Stream output */
+    std::ostream & operator<<( std::ostream & str, const Repo & obj );
+
+    /** \relates Repo */
+    inline bool operator==( const Repo & lhs, const Repo & rhs )
+    { return lhs.get() == rhs.get(); }
+
+    /** \relates Repo */
+    inline bool operator!=( const Repo & lhs, const Repo & rhs )
+    { return lhs.get() != rhs.get(); }
+
+    //////////////////////////////////////////////////////////////////
+    namespace detail
+    { /////////////////////////////////////////////////////////////////
+      /** Helper functor constructing \ref Repo. */
+      struct mkRepo
+      {
+        typedef Repo result_type;
+        result_type operator()( ::_Repo *const & ptr_r ) const
+        { return ptr_r; }
+      };
+    } /////////////////////////////////////////////////////////////////
+    // namespace detail
+    //////////////////////////////////////////////////////////////////
+
+    typedef transform_iterator<detail::mkRepo, ::_Repo **> RepoIterator;
+
+   /////////////////////////////////////////////////////////////////
+  } // namespace sat
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_SAT_REPO_H
diff --git a/zypp/sat/Solvable.cc b/zypp/sat/Solvable.cc
new file mode 100644 (file)
index 0000000..9b4c6d1
--- /dev/null
@@ -0,0 +1,118 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/sat/Solvable.cc
+ *
+*/
+extern "C"
+{
+#include <satsolver/solvable.h>
+#include <satsolver/poolid.h>
+}
+#include <iostream>
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/Gettext.h"
+#include "zypp/base/Exception.h"
+
+#include "zypp/sat/Solvable.h"
+#include "zypp/sat/Repo.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace sat
+  { /////////////////////////////////////////////////////////////////
+
+    const PoolId PoolId::noid;
+
+    /******************************************************************
+    **
+    ** FUNCTION NAME : operator<<
+    ** FUNCTION TYPE : std::ostream &
+    */
+    std::ostream & operator<<( std::ostream & str, const PoolId & obj )
+    {
+      return str << "sat::Id(" << obj.get() << ")";
+    }
+
+    const Solvable Solvable::nosolvable( NULL );
+
+    NameId Solvable::name() const
+    {
+      if ( ! _solvable ) return NameId::noid;
+      return _solvable->name; }
+
+    EvrId Solvable::evr() const
+    {
+      if ( ! _solvable ) return EvrId::noid;
+      return _solvable->arch;
+    }
+
+    ArchId Solvable::arch() const
+    {
+      if ( ! _solvable ) return ArchId::noid;
+      return _solvable->evr;
+    }
+
+    VendorId Solvable::vendor() const
+    {
+      if ( ! _solvable ) return VendorId::noid;
+      return _solvable->vendor;
+    }
+
+    Repo Solvable::repo() const
+    {
+      if ( ! _solvable ) return 0;
+      return _solvable->repo;
+    }
+
+    const char * Solvable::string( const PoolId & id_r ) const
+    {
+      if ( ! _solvable ) return "";
+      SEC << id_r<< endl;
+      SEC << "   n " << ::id2str( _solvable->repo->pool, id_r.get() ) << endl;
+      SEC << "   e " << ::dep2str( _solvable->repo->pool, id_r.get() )<< endl;
+      SEC << "   a " << ::id2rel( _solvable->repo->pool, id_r.get() )<< endl;
+      SEC << "   v " << ::id2evr( _solvable->repo->pool, id_r.get() )<< endl;
+      return ::id2str( _solvable->repo->pool, id_r.get() );
+    }
+
+
+    /******************************************************************
+    **
+    ** FUNCTION NAME : operator<<
+    ** FUNCTION TYPE : std::ostream &
+    */
+    std::ostream & operator<<( std::ostream & str, const Solvable & obj )
+    {
+      if ( ! obj )
+        return str << "sat::solvable()";
+
+      return str << "sat::solvable(" << obj.name() << '-' << obj.evr() << '.' << obj.arch() << "){"
+          << obj.repo().name() << "}";
+    }
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : SolvableIterator
+    //
+    ///////////////////////////////////////////////////////////////////
+
+    void SolvableIterator::increment()
+    { ++base_reference(); }
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace sat
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/sat/Solvable.h b/zypp/sat/Solvable.h
new file mode 100644 (file)
index 0000000..69fe6e0
--- /dev/null
@@ -0,0 +1,162 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/sat/Solvable.h
+ *
+*/
+#ifndef ZYPP_SAT_SOLVABLE_H
+#define ZYPP_SAT_SOLVABLE_H
+
+#include <iosfwd>
+
+#include "zypp/base/SafeBool.h"
+#include "zypp/base/Iterator.h"
+
+///////////////////////////////////////////////////////////////////
+extern "C"
+{
+struct _Solvable;
+}
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace sat
+  { /////////////////////////////////////////////////////////////////
+
+    class Repo;
+
+    class PoolId : private base::SafeBool<PoolId>
+    {
+      public:
+        PoolId() : _id( 0 ) {}
+        PoolId( int id_r ) : _id( id_r ) {}
+        static const PoolId noid;
+        /** Evaluate \ref PoolId in a boolean context (\c != \c 0). */
+        using base::SafeBool<PoolId>::operator bool_type;
+        int get() const { return _id; }
+      private:
+        friend base::SafeBool<PoolId>::operator bool_type() const;
+        bool boolTest() const { return _id; }
+      private:
+        int _id;
+    };
+
+    /** \relates PoolId Stream output */
+    std::ostream & operator<<( std::ostream & str, const PoolId & obj );
+
+    /** \relates PoolId */
+    inline bool operator==( const PoolId & lhs, const PoolId & rhs )
+    { return lhs.get() == rhs.get(); }
+
+    /** \relates PoolId */
+    inline bool operator!=( const PoolId & lhs, const PoolId & rhs )
+    { return lhs.get() != rhs.get(); }
+
+    typedef PoolId NameId;
+    typedef PoolId EvrId;
+    typedef PoolId ArchId;
+    typedef PoolId VendorId;
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : Solvable
+    //
+    /** */
+    class Solvable : private base::SafeBool<Solvable>
+    {
+      public:
+        /** Ctor defaults to \ref nosolvable.*/
+        Solvable( ::_Solvable * solvable_r = NULL )
+        : _solvable( solvable_r )
+        {}
+
+      public:
+        /** Represents no \ref Solvable. */
+        static const Solvable nosolvable;
+
+        /** Evaluate \ref Solvable in a boolean context (\c != \c nosolvable). */
+        using base::SafeBool<Solvable>::operator bool_type;
+
+      public:
+        NameId   name() const;
+        EvrId    evr() const;
+        ArchId   arch() const;
+        VendorId vendor() const;
+
+        Repo repo() const;
+
+      public:
+        const char * string( const PoolId & id_r ) const;
+
+        const char * nameStr() const { return string( name() ); }
+        const char * evrStr() const { return string( evr() ); }
+        const char * archStr() const { return string( arch() ); }
+        const char * vendorStr() const { return string( vendor() ); }
+
+      public:
+        /** Expert backdoor. */
+        ::_Solvable * get() const { return _solvable; }
+      private:
+        friend base::SafeBool<Solvable>::operator bool_type() const;
+        bool boolTest() const { return _solvable; }
+      private:
+        ::_Solvable * _solvable;
+    };
+    ///////////////////////////////////////////////////////////////////
+
+    /** \relates Solvable Stream output */
+    std::ostream & operator<<( std::ostream & str, const Solvable & obj );
+
+    /** \relates Solvable */
+    inline bool operator==( const Solvable & lhs, const Solvable & rhs )
+    { return lhs.get() == rhs.get(); }
+
+    /** \relates Solvable */
+    inline bool operator!=( const Solvable & lhs, const Solvable & rhs )
+    { return lhs.get() != rhs.get(); }
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : SolvableIterator
+    //
+    /** */
+    class SolvableIterator : public boost::iterator_adaptor<
+                                      SolvableIterator                  // Derived
+                                      , ::_Solvable *                   // Base
+                                      , Solvable                        // Value
+                                      , boost::forward_traversal_tag    // CategoryOrTraversal
+                                      , Solvable                        // Reference
+                                    >
+    {
+      public:
+        SolvableIterator()
+        : SolvableIterator::iterator_adaptor_( 0 )
+        {}
+
+        explicit SolvableIterator( ::_Solvable * p )
+        : SolvableIterator::iterator_adaptor_( p )
+        {}
+
+      private:
+        friend class boost::iterator_core_access;
+
+        void increment();
+
+        Solvable dereference() const
+        { return base(); }
+    };
+    ///////////////////////////////////////////////////////////////////
+
+   /////////////////////////////////////////////////////////////////
+  } // namespace sat
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_SAT_SOLVABLE_H