Author: mlandres
Date: Tue Nov 13 17:59:55 2007
New Revision: 7798
URL: http://svn.opensuse.org/viewcvs/zypp?rev=7798&view=rev
Log:
backup
Added:
trunk/libzypp/devel/devel.ma/Sat.cc
trunk/libzypp/zypp/sat/Pool.cc
trunk/libzypp/zypp/sat/Pool.h
trunk/libzypp/zypp/sat/Repo.cc
trunk/libzypp/zypp/sat/Repo.h
trunk/libzypp/zypp/sat/Solvable.cc
trunk/libzypp/zypp/sat/Solvable.h
Modified:
trunk/libzypp/devel/devel.ma/CMakeLists.txt
trunk/libzypp/devel/devel.ma/NewPool.cc
trunk/libzypp/devel/devel.ma/Tools.h
trunk/libzypp/zypp/CMakeLists.txt
Modified: trunk/libzypp/devel/devel.ma/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/CMakeLists.txt?rev=7798&r1=7797&r2=7798&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.ma/CMakeLists.txt (original)
+++ trunk/libzypp/devel/devel.ma/CMakeLists.txt Tue Nov 13 17:59:55 2007
@@ -29,7 +29,7 @@
## ############################################################
-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
)
Modified: trunk/libzypp/devel/devel.ma/NewPool.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/NewPool.cc?rev=7798&r1=7797&r2=7798&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.ma/NewPool.cc (original)
+++ trunk/libzypp/devel/devel.ma/NewPool.cc Tue Nov 13 17:59:55 2007
@@ -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 @@
}
}
-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 @@
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 @@
{
//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 @@
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 @@
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;
Added: trunk/libzypp/devel/devel.ma/Sat.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/Sat.cc?rev=7798&view=auto
==============================================================================
--- trunk/libzypp/devel/devel.ma/Sat.cc (added)
+++ trunk/libzypp/devel/devel.ma/Sat.cc Tue Nov 13 17:59:55 2007
@@ -0,0 +1,52 @@
+extern "C"
+{
+#include
+#include
+#include
+}
+#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;
+}
Modified: trunk/libzypp/devel/devel.ma/Tools.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/Tools.h?rev=7798&r1=7797&r2=7798&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.ma/Tools.h (original)
+++ trunk/libzypp/devel/devel.ma/Tools.h Tue Nov 13 17:59:55 2007
@@ -19,6 +19,9 @@
#include
#include
+#include "zypp/ResPool.h"
+#include "zypp/ResPoolProxy.h"
+
#include
#include
@@ -119,4 +122,55 @@
}
///////////////////////////////////////////////////////////////////
+
+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
Modified: trunk/libzypp/zypp/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/CMakeLists.txt?rev=7798&r1=7797&r2=7798&view=diff
==============================================================================
--- trunk/libzypp/zypp/CMakeLists.txt (original)
+++ trunk/libzypp/zypp/CMakeLists.txt Tue Nov 13 17:59:55 2007
@@ -676,12 +676,16 @@
)
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
)
Added: trunk/libzypp/zypp/sat/Pool.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Pool.cc?rev=7798&view=auto
==============================================================================
--- trunk/libzypp/zypp/sat/Pool.cc (added)
+++ trunk/libzypp/zypp/sat/Pool.cc Tue Nov 13 17:59:55 2007
@@ -0,0 +1,133 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/sat/Pool.cc
+ *
+*/
+
+extern "C"
+{
+#include
+#include
+#include
+}
+#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( ::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::setstd::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
+///////////////////////////////////////////////////////////////////
Added: trunk/libzypp/zypp/sat/Pool.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Pool.h?rev=7798&view=auto
==============================================================================
--- trunk/libzypp/zypp/sat/Pool.h (added)
+++ trunk/libzypp/zypp/sat/Pool.h Tue Nov 13 17:59:55 2007
@@ -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
Added: trunk/libzypp/zypp/sat/Repo.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Repo.cc?rev=7798&view=auto
==============================================================================
--- trunk/libzypp/zypp/sat/Repo.cc (added)
+++ trunk/libzypp/zypp/sat/Repo.cc Tue Nov 13 17:59:55 2007
@@ -0,0 +1,83 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/sat/Repo.cc
+ *
+*/
+extern "C"
+{
+#include
+#include
+}
+#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
+///////////////////////////////////////////////////////////////////
Added: trunk/libzypp/zypp/sat/Repo.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Repo.h?rev=7798&view=auto
==============================================================================
--- trunk/libzypp/zypp/sat/Repo.h (added)
+++ trunk/libzypp/zypp/sat/Repo.h Tue Nov 13 17:59:55 2007
@@ -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 RepoIterator;
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace sat
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_SAT_REPO_H
Added: trunk/libzypp/zypp/sat/Solvable.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Solvable.cc?rev=7798&view=auto
==============================================================================
--- trunk/libzypp/zypp/sat/Solvable.cc (added)
+++ trunk/libzypp/zypp/sat/Solvable.cc Tue Nov 13 17:59:55 2007
@@ -0,0 +1,118 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/sat/Solvable.cc
+ *
+*/
+extern "C"
+{
+#include
+#include
+}
+#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
+///////////////////////////////////////////////////////////////////
Added: trunk/libzypp/zypp/sat/Solvable.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Solvable.h?rev=7798&view=auto
==============================================================================
--- trunk/libzypp/zypp/sat/Solvable.h (added)
+++ trunk/libzypp/zypp/sat/Solvable.h Tue Nov 13 17:59:55 2007
@@ -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
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org