[zypp-commit] r8063 - in /trunk/libzypp: devel/devel.ma/ zypp/ zypp/pool/ zypp/sat/ zypp/sat/detail/
Author: mlandres Date: Fri Dec 7 17:59:30 2007 New Revision: 8063 URL: http://svn.opensuse.org/viewcvs/zypp?rev=8063&view=rev Log: backup Added: trunk/libzypp/zypp/sat/IdRel.cc trunk/libzypp/zypp/sat/IdRel.h Modified: trunk/libzypp/devel/devel.ma/NewPool.cc trunk/libzypp/zypp/CMakeLists.txt trunk/libzypp/zypp/pool/Res2Sat.cc trunk/libzypp/zypp/sat/IdStr.cc trunk/libzypp/zypp/sat/IdStr.h trunk/libzypp/zypp/sat/Pool.cc trunk/libzypp/zypp/sat/Pool.h trunk/libzypp/zypp/sat/Solvable.h trunk/libzypp/zypp/sat/detail/PoolMember.h Modified: trunk/libzypp/devel/devel.ma/NewPool.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/NewPool.cc?rev=8063&r1=8062&r2=8063&view=diff ============================================================================== --- trunk/libzypp/devel/devel.ma/NewPool.cc (original) +++ trunk/libzypp/devel/devel.ma/NewPool.cc Fri Dec 7 17:59:30 2007 @@ -147,55 +147,9 @@ { bool operator()( const PoolItem & obj_r ) { - if ( obj_r.status().isLocked() ) - SEC << obj_r << endl; + MIL << obj_r << endl; + DBG << " -> " << obj_r .satSolvable() << endl; -// handle( asKind<Package>( obj_r ) ); -// handle( asKind<Patch>( obj_r ) ); -// handle( asKind<Pattern>( obj_r ) ); -// handle( asKind<Product>( obj_r ) ); - return true; - } - - void handle( const Package_constPtr & p ) - { - if ( !p ) - return; - - WAR << p->size() << endl; - MIL << p->diskusage() << endl; - } - - void handle( const Patch_constPtr & p ) - { - if ( !p ) - return; - } - - void handle( const Pattern_constPtr & p ) - { - if ( !p ) - return; - - if ( p->vendor().empty() ) - ERR << p << endl; - else if ( p->vendor() == "SUSE (assumed)" ) - SEC << p << endl; - } - - void handle( const Product_constPtr & p ) - { - if ( !p ) - return; - - USR << p << endl; - USR << p->vendor() << endl; - USR << p->type() << endl; - } - - template<class _C> - bool operator()( const _C & obj_r ) - { return true; } }; @@ -413,7 +367,7 @@ void dumpIdStr() { - for ( unsigned i = 0; i < 30; ++i ) + for ( int i = -3; i < 30; ++i ) { DBG << i << '\t' << sat::IdStr( i ) << endl; } @@ -429,7 +383,6 @@ //zypp::base::LogControl::instance().logfile( "log.restrict" ); INT << "===[START]==========================================" << endl; - sat::Pool satpool( sat::Pool::instance() ); #if 0 @@ -523,6 +476,7 @@ USR << "pool: " << pool << endl; pool.satSync(); + //std::for_each( pool.begin(), pool.end(), Xprint() ); //sat::detail::PoolImpl satpool; Modified: trunk/libzypp/zypp/CMakeLists.txt URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/CMakeLists.txt?rev=8063&r1=8062&r2=8063&view=diff ============================================================================== --- trunk/libzypp/zypp/CMakeLists.txt (original) +++ trunk/libzypp/zypp/CMakeLists.txt Fri Dec 7 17:59:30 2007 @@ -682,6 +682,7 @@ sat/Repo.cc sat/Solvable.cc sat/IdStr.cc + sat/IdRel.cc sat/SATResolver.cc ) @@ -692,6 +693,7 @@ sat/Repo.h sat/Solvable.h sat/IdStr.h + sat/IdRel.h sat/SATResolver.h ) Modified: trunk/libzypp/zypp/pool/Res2Sat.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/pool/Res2Sat.cc?rev=8063&r1=8062&r2=8063&view=diff ============================================================================== --- trunk/libzypp/zypp/pool/Res2Sat.cc (original) +++ trunk/libzypp/zypp/pool/Res2Sat.cc Fri Dec 7 17:59:30 2007 @@ -56,16 +56,19 @@ const CapSet & caps( dep_r[which_r] ); if ( caps.empty() ) return; + const CapSet & prereq( dep_r[Dep::PREREQUIRES] ); for_( it, caps.begin(), caps.end() ) { - // checking PREREQUIRES later - SatIsRreq isreq = ( which_r == Dep::REQUIRES ? ISRREQ_REQUIRES : ISRREQ_NORMAL ); + SatIsRreq isreq = ISRREQ_NORMAL; + if ( which_r == Dep::REQUIRES ) + { + isreq = ( prereq.find( *it ) != prereq.end() ) ? ISRREQ_PREREQUIRES : ISRREQ_REQUIRES; + } std::string name; Rel op; Edition ed; - using capability::VersionedCap; VersionedCap::constPtr vercap = capability::asKind<VersionedCap>(*it); if ( vercap ) @@ -79,26 +82,19 @@ name = (*it).asString(); } - ::Id nid = 0; + sat::IdRel rel; if ( refersTo<Package>( *it ) ) { - store( nid, name ); + rel = sat::IdRel( name, op, ed ); } else { - store( nid, str::form( "%s:%s", - (*it).refers().asString().c_str(), - name.c_str() ) ); +#warning glue kind + // non-packages prefixed by kind + rel = sat::IdRel( name, op, ed, sat::KindId( (*it).refers().asString().c_str() ) ); } - if ( op != Rel::ANY && ed != Edition::noedition ) - { - sat::IdStr eid( ed.asString() ); -#warning TBD calc rel and prereqcheck - nid = ::rel2id( slv_r->repo->pool, nid, eid.id(), op.bits(), true ); - } - - where_r = ::repo_addid_dep( slv_r->repo, where_r, nid, isreq ); + where_r = ::repo_addid_dep( slv_r->repo, where_r, rel.id(), isreq ); } } @@ -122,6 +118,7 @@ } else { + // non-packages prefixed by kind store( slv->name, str::form( "%s:%s", res_r->kind().asString().c_str(), res_r->name().c_str() ) ); @@ -133,14 +130,12 @@ store( slv->provides, slv, res_r->deps(), Dep::PROVIDES ); store( slv->obsoletes, slv, res_r->deps(), Dep::OBSOLETES ); store( slv->conflicts, slv, res_r->deps(), Dep::CONFLICTS ); - store( slv->requires, slv, res_r->deps(), Dep::REQUIRES ); + store( slv->requires, slv, res_r->deps(), Dep::REQUIRES ); // incl. PREREQIRES store( slv->recommends, slv, res_r->deps(), Dep::RECOMMENDS ); store( slv->suggests, slv, res_r->deps(), Dep::SUGGESTS ); store( slv->supplements, slv, res_r->deps(), Dep::SUPPLEMENTS ); store( slv->enhances, slv, res_r->deps(), Dep::ENHANCES ); store( slv->freshens, slv, res_r->deps(), Dep::FRESHENS ); - - //DBG << " " << res_r << " -> " << slv_r << endl; } ///////////////////////////////////////////////////////////////// Added: trunk/libzypp/zypp/sat/IdRel.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/IdRel.cc?rev=8063&view=auto ============================================================================== --- trunk/libzypp/zypp/sat/IdRel.cc (added) +++ trunk/libzypp/zypp/sat/IdRel.cc Fri Dec 7 17:59:30 2007 @@ -0,0 +1,141 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/sat/IdRel.cc + * +*/ +#include <iostream> +#include "zypp/base/Logger.h" + +#include "zypp/base/String.h" +#include "zypp/base/Regex.h" +#include "zypp/base/Gettext.h" +#include "zypp/base/Exception.h" +#include "zypp/Rel.h" +#include "zypp/Edition.h" + +#include "zypp/sat/detail/PoolImpl.h" +#include "zypp/sat/IdRel.h" +#include "zypp/sat/Pool.h" + +using std::endl; + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace sat + { ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace + { ///////////////////////////////////////////////////////////////// + detail::IdType relFromStr( ::_Pool * pool_r, const std::string & name_r, Rel op_r, const Edition & ed_r, const KindId & kind_r ) + { + detail::IdType nid( detail::noId ); +#warning Add or not kind package + if ( ! kind_r ) + { + nid = IdStr( name_r ).id(); + } + else + { + // non-packages prefixed by kind + nid = IdStr( str::form( "%s:%s", + kind_r.c_str(), + name_r.c_str() ) ).id(); + } + + if ( op_r != Rel::ANY && ed_r != Edition::noedition ) + { +#warning glue edition + nid = ::rel2id( pool_r, nid, IdStr( ed_r.asString() ).id(), op_r.bits(), /*create*/true ); + } + + return nid; + } + + detail::IdType relFromStr( ::_Pool * pool_r, const std::string & str_r, const KindId & kind_r ) + { + // strval_r has at least two words which could make 'op edition'? + // improve regex! + static const str::regex rx( "(.*[^ \t])([ \t]+)([^ \t]+)([ \t]+)([^ \t]+)" ); + static str::smatch what; + + std::string name( str_r ); + Rel op; + Edition ed; + if( str_r.find(' ') != std::string::npos + && str::regex_match( str_r, what, rx ) ) + { + try + { + Rel cop( what[3] ); + Edition ced( what[5] ); + name = what[1]; + op = cop; + ed = ced; + } + catch ( Exception & excpt ) + { + // So they don't make valid 'op edition' + ZYPP_CAUGHT( excpt ); + DBG << "Trying named relation for: " << str_r << endl; + } + } + //else + // not a versioned relation + + return relFromStr( pool_r, name, op, ed, kind_r ); + } + + ///////////////////////////////////////////////////////////////// + } // namespace + /////////////////////////////////////////////////////////////////// + + const IdRel IdRel::Null( STRID_NULL ); + + ///////////////////////////////////////////////////////////////// + + IdRel::IdRel( const char * str_r, const KindId & kind_r ) + : _id( relFromStr( myPool().getPool(), str_r, kind_r ) ) + {} + + IdRel::IdRel( const std::string & str_r, const KindId & kind_r ) + : _id( relFromStr( myPool().getPool(), str_r.c_str(), kind_r ) ) + {} + + IdRel::IdRel( const std::string & name_r, Rel op_r, const Edition & ed_r, const KindId & kind_r ) + : _id( relFromStr( myPool().getPool(), name_r, op_r, ed_r, kind_r ) ) + {} + + const char * IdRel::c_str() const + { + return ::dep2str( myPool().getPool(), _id ); + } + + std::string IdRel::string() const + { + return ::dep2str( myPool().getPool(), _id ); + } + + /****************************************************************** + ** + ** FUNCTION NAME : operator<< + ** FUNCTION TYPE : std::ostream & + */ + std::ostream & operator<<( std::ostream & str, const IdRel & obj ) + { + return str << obj.c_str(); + } + + ///////////////////////////////////////////////////////////////// + } // namespace sat + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// Added: trunk/libzypp/zypp/sat/IdRel.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/IdRel.h?rev=8063&view=auto ============================================================================== --- trunk/libzypp/zypp/sat/IdRel.h (added) +++ trunk/libzypp/zypp/sat/IdRel.h Fri Dec 7 17:59:30 2007 @@ -0,0 +1,107 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/sat/IdRel.h + * +*/ +#ifndef ZYPP_SAT_IDREL_H +#define ZYPP_SAT_IDREL_H + +#include <iosfwd> +#include <string> + +#include "zypp/base/SafeBool.h" + +#include "zypp/sat/detail/PoolMember.h" +#include "zypp/sat/IdStr.h" + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + + class Rel; + class Edition; + + /////////////////////////////////////////////////////////////////// + namespace sat + { ///////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// + // + // CLASS NAME : IdRel + // + /** Access to the sat-pools string space. + * Construction from string will place a copy of the string in the + * string space, if it is not already present. + */ + class IdRel: protected detail::PoolMember, + private base::SafeBool<IdRel> + { + public: + /** Default ctor, no relation. */ + IdRel() : _id( Null.id() ) {} + /** Ctor from id. */ + explicit IdRel( detail::IdType id_r ) : _id( id_r ) {} + /** Ctor from string. + * If \c kind_r is provided, \c name is prefixed. + */ + explicit IdRel( const char * str_r, const KindId & kind_r = KindId::Null ); + /** Ctor from string. + * If \c kind_r is provided, \c name is prefixed. + */ + explicit IdRel( const std::string & str_r, const KindId & kind_r = KindId::Null ); + /** Ctor from <tt>name op edition</tt>. + * If \c kind_r is provided, \c name is prefixed. + */ + IdRel( const std::string & name_r, Rel op_r, const Edition & ed_r, const KindId & kind_r = KindId::Null ); + + /** Evaluate in a boolean context (\c != \c Null). */ + using base::SafeBool<IdRel>::operator bool_type; + public: + /** No or Null relation. */ + static const IdRel Null; + public: + /** Conversion to <tt>const char *</tt> */ + const char * c_str() const; + /** Conversion to <tt>std::string</tt> */ + std::string string() const; + /** \overload */ + std::string asString() const + { return string(); } + + public: + /** Expert backdoor. */ + detail::IdType id() const + { return _id; } + private: + friend base::SafeBool<IdRel>::operator bool_type() const; + bool boolTest() const { return _id; } + private: + detail::IdType _id; + }; + /////////////////////////////////////////////////////////////////// + + /** \relates IdRel Stream output */ + std::ostream & operator<<( std::ostream & str, const IdRel & obj ); + + /** \relates IdRel */ + inline bool operator==( const IdRel & lhs, const IdRel & rhs ) + { return lhs.id() == rhs.id(); } + + /** \relates IdRel */ + inline bool operator!=( const IdRel & lhs, const IdRel & rhs ) + { return lhs.id() != rhs.id(); } + + + ///////////////////////////////////////////////////////////////// + } // namespace sat + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// +#endif // ZYPP_SAT_IDREL_H Modified: trunk/libzypp/zypp/sat/IdStr.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/IdStr.cc?rev=8063&r1=8062&r2=8063&view=diff ============================================================================== --- trunk/libzypp/zypp/sat/IdStr.cc (original) +++ trunk/libzypp/zypp/sat/IdStr.cc Fri Dec 7 17:59:30 2007 @@ -14,6 +14,7 @@ #include "zypp/sat/detail/PoolImpl.h" #include "zypp/sat/IdStr.h" +#include "zypp/sat/Pool.h" using std::endl; @@ -24,19 +25,22 @@ namespace sat { ///////////////////////////////////////////////////////////////// - const IdStr IdStr::Null( unsigned(STRID_NULL) ); - const IdStr IdStr::Empty( unsigned(STRID_EMPTY) ); + const IdStr IdStr::Null( STRID_NULL ); + const IdStr IdStr::Empty( STRID_EMPTY ); ///////////////////////////////////////////////////////////////// IdStr::IdStr( const char * str_r ) - : _id( ::str2id( myPool().getPool(), str_r, true ) ) + : _id( ::str2id( myPool().getPool(), str_r, /*create*/true ) ) {} IdStr::IdStr( const std::string & str_r ) - : _id( ::str2id( myPool().getPool(), str_r.c_str(), true ) ) + : _id( ::str2id( myPool().getPool(), str_r.c_str(), /*create*/true ) ) {} + unsigned IdStr::size() const + { return ::strlen( c_str() ); } + const char * IdStr::c_str() const { return ::id2str( myPool().getPool(), _id ); Modified: trunk/libzypp/zypp/sat/IdStr.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/IdStr.h?rev=8063&r1=8062&r2=8063&view=diff ============================================================================== --- trunk/libzypp/zypp/sat/IdStr.h (original) +++ trunk/libzypp/zypp/sat/IdStr.h Fri Dec 7 17:59:30 2007 @@ -15,6 +15,8 @@ #include <iosfwd> #include <string> +#include "zypp/base/SafeBool.h" + #include "zypp/sat/detail/PoolMember.h" /////////////////////////////////////////////////////////////////// @@ -32,28 +34,29 @@ * Construction from string will place a copy of the string in the * string space, if it is not already present. */ - class IdStr: protected detail::PoolMember + class IdStr: protected detail::PoolMember, + private base::SafeBool<IdStr> { - friend std::ostream & operator<<( std::ostream & str, const IdStr & obj ); - public: /** Default ctor, empty string. */ IdStr() : _id( Empty.id() ) {} /** Ctor from id. */ - explicit IdStr( unsigned id_r ) : _id( id_r ) {} + explicit IdStr( detail::IdType id_r ) : _id( id_r ) {} /** Ctor from string. */ explicit IdStr( const char * str_r ); /** Ctor from string. */ explicit IdStr( const std::string & str_r ); + /** Evaluate in a boolean context (\c != \c Null). */ + using base::SafeBool<IdStr>::operator bool_type; public: /** No or Null string. */ static const IdStr Null; /** Empty string. */ - static const IdStr::IdStr Empty; + static const IdStr Empty; public: bool empty() const { return( _id == Empty.id() ); } - + unsigned size() const; public: /** Conversion to <tt>const char *</tt> */ const char * c_str() const; @@ -65,10 +68,13 @@ public: /** Expert backdoor. */ - unsigned id() const + detail::IdType id() const { return _id; } private: - unsigned _id; + friend base::SafeBool<IdStr>::operator bool_type() const; + bool boolTest() const { return _id; } + private: + detail::IdType _id; }; /////////////////////////////////////////////////////////////////// Modified: trunk/libzypp/zypp/sat/Pool.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Pool.cc?rev=8063&r1=8062&r2=8063&view=diff ============================================================================== --- trunk/libzypp/zypp/sat/Pool.cc (original) +++ trunk/libzypp/zypp/sat/Pool.cc Fri Dec 7 17:59:30 2007 @@ -130,6 +130,9 @@ return tmprepo; } + Repo Pool::addRepoSolv( const Pathname & file_r ) + { return addRepoSolv( file_r, file_r.basename() ); } + /****************************************************************** ** ** FUNCTION NAME : operator<< Modified: trunk/libzypp/zypp/sat/Pool.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Pool.h?rev=8063&r1=8062&r2=8063&view=diff ============================================================================== --- trunk/libzypp/zypp/sat/Pool.h (original) +++ trunk/libzypp/zypp/sat/Pool.h Fri Dec 7 17:59:30 2007 @@ -107,8 +107,7 @@ */ Repo addRepoSolv( const Pathname & file_r, const std::string & name_r ); /** \overload Using the files basename as \ref Repo name. */ - Repo addRepoSolv( const Pathname & file_r ) - { return addRepoSolv( file_r, file_r.basename() ); } + Repo addRepoSolv( const Pathname & file_r ); public: /** Whether \ref Pool contains solvables. */ Modified: trunk/libzypp/zypp/sat/Solvable.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Solvable.h?rev=8063&r1=8062&r2=8063&view=diff ============================================================================== --- trunk/libzypp/zypp/sat/Solvable.h (original) +++ trunk/libzypp/zypp/sat/Solvable.h Fri Dec 7 17:59:30 2007 @@ -18,6 +18,7 @@ #include "zypp/sat/detail/PoolMember.h" #include "zypp/sat/IdStr.h" +#include "zypp/sat/IdRel.h" /////////////////////////////////////////////////////////////////// namespace zypp Modified: trunk/libzypp/zypp/sat/detail/PoolMember.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/detail/PoolMember.h?rev=8063&r1=8062&r2=8063&view=diff ============================================================================== --- trunk/libzypp/zypp/sat/detail/PoolMember.h (original) +++ trunk/libzypp/zypp/sat/detail/PoolMember.h Fri Dec 7 17:59:30 2007 @@ -29,6 +29,7 @@ { ///////////////////////////////////////////////////////////////// class IdStr; + class IdRel; class Solvable; class Repo; class Pool; @@ -63,7 +64,13 @@ namespace detail { ///////////////////////////////////////////////////////////////// - /** Id type to connect \ref Solvable and sat-solvable. */ + /** Generic Id type. */ + typedef int IdType; + static const IdType noId( 0 ); + + /** Id type to connect \ref Solvable and sat-solvable. + * Indext into solvable array. + */ typedef unsigned SolvableIdType; /** Id to denote \ref Solvable::nosolvable. */ static const SolvableIdType noSolvableId( 0 ); @@ -91,6 +98,7 @@ /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// + typedef IdStr KindId; typedef IdStr NameId; typedef IdStr EvrId; typedef IdStr ArchId; -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org
participants (1)
-
mlandres@svn.opensuse.org