Author: mlandres Date: Fri Mar 14 17:26:25 2008 New Revision: 9167 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9167&view=rev Log: Convenience constructor for PoolItem from Solvable and ResObject Modified: trunk/libzypp/devel/devel.ma/NewPool.cc trunk/libzypp/tests/zypp/data/Vendor/zypp2.conf trunk/libzypp/zypp/OnMediaLocation.h trunk/libzypp/zypp/Package.cc trunk/libzypp/zypp/PoolItem.cc trunk/libzypp/zypp/PoolItem.h trunk/libzypp/zypp/ResObject.cc trunk/libzypp/zypp/ResObject.h trunk/libzypp/zypp/ResPool.h trunk/libzypp/zypp/pool/PoolImpl.h trunk/libzypp/zypp/sat/Solvable.cc trunk/libzypp/zypp/sat/Solvable.h trunk/libzypp/zypp/sat/WhatProvides.cc Modified: trunk/libzypp/devel/devel.ma/NewPool.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/NewPool.cc?rev=9167&r1=9166&r2=9167&view=diff ============================================================================== --- trunk/libzypp/devel/devel.ma/NewPool.cc (original) +++ trunk/libzypp/devel/devel.ma/NewPool.cc Fri Mar 14 17:26:25 2008 @@ -436,6 +436,18 @@ } // namespace zypp /////////////////////////////////////////////////////////////////// +void tt( const std::string & name_r, ResKind kind_r = ResKind::package ) +{ + Capability cap( name_r, kind_r ); + sat::WhatProvides possibleProviders(cap); + (possibleProviders.empty()?WAR:MIL) << name_r << endl; + for_(iter, possibleProviders.begin(), possibleProviders.end()) + { + MIL << name_r << endl; + PoolItem provider = ResPool::instance().find(*iter); + } +} + /****************************************************************** ** ** FUNCTION NAME : main @@ -450,7 +462,7 @@ ResPool pool( ResPool::instance() ); USR << "pool: " << pool << endl; - if ( 0 ) + if ( 1 ) { RepoManager repoManager( makeRepoManager( sysRoot ) ); RepoInfoList repos = repoManager.knownRepositories(); @@ -521,20 +533,37 @@ /////////////////////////////////////////////////////////////////// - const char* argv[] = + for_( it, pool.begin(), pool.end() ) { - "ls", "-fail", - NULL - }; - ExternalProgram prog(argv,ExternalProgram::Discard_Stderr, false, -1, true); - int ret = prog.close(); - if ( ret != 0 ) - { - Exception ex(str::form("Failed command (%s)", prog.execError().c_str() ) ); - ex.remember( prog.command() ); - ZYPP_THROW(ex); + tt( (*it)->name() ); } +#if 0 + IdString id ("amarok"); + sat::WhatProvides w( Capability(id.id()) ); + + for_( it, w.begin(), w.end() ) + { + WAR << *it << endl; + MIL << PoolItem(*it) << endl; + Package_Ptr p( asKind<Package>(PoolItem(*it)) ); + MIL << p << endl; + if ( p ) + { + OnMediaLocation l( p->location() ); + MIL << l << endl; + } + //OnMediaLocation + } + + sat::Solvable a(65241); + PoolItem p( a ); + USR << p << endl; + p.status().setTransact( true, ResStatus::USER ); + USR << p << endl; + USR << PoolItem() << endl; +#endif + if ( 0 ) { Measure x( "Upgrade" ); Modified: trunk/libzypp/tests/zypp/data/Vendor/zypp2.conf URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/data/Vendor/zypp2.conf?rev=9167&r1=9166&r2=9167&view=diff ============================================================================== --- trunk/libzypp/tests/zypp/data/Vendor/zypp2.conf (original) +++ trunk/libzypp/tests/zypp/data/Vendor/zypp2.conf Fri Mar 14 17:26:25 2008 @@ -123,5 +123,5 @@ ## Default value: /etc/zypp/vondors.d ## #vendordir = ./../../tests/zypp/data/Vendor/vendors.d -vendordir = @VENDOR_D@ +vendordir = /Local/ma/zypp/libzypp/tests/zypp/data/Vendor/vendors.d Modified: trunk/libzypp/zypp/OnMediaLocation.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/OnMediaLocation.h?rev=9167&r1=9166&r2=9167&view=diff ============================================================================== --- trunk/libzypp/zypp/OnMediaLocation.h (original) +++ trunk/libzypp/zypp/OnMediaLocation.h Fri Mar 14 17:26:25 2008 @@ -33,6 +33,8 @@ * size. It does not specify the URI of the file. * * Media number \c 0 usually indicates no media access. + * + * \todo Implement cheap copy via COW. */ class OnMediaLocation { @@ -110,7 +112,7 @@ CheckSum _checksum; ByteCount _downloadsize; ByteCount _opendownloadsize; - CheckSum _openchecksum; + CheckSum _openchecksum; }; /////////////////////////////////////////////////////////////////// Modified: trunk/libzypp/zypp/Package.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Package.cc?rev=9167&r1=9166&r2=9167&view=diff ============================================================================== --- trunk/libzypp/zypp/Package.cc (original) +++ trunk/libzypp/zypp/Package.cc Fri Mar 14 17:26:25 2008 @@ -112,6 +112,7 @@ OnMediaLocation Package::location() const { +#warning MISSING checkdums in OnMediaLocation OnMediaLocation loc; unsigned medianr; std::string filename = lookupLocation( medianr ); Modified: trunk/libzypp/zypp/PoolItem.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PoolItem.cc?rev=9167&r1=9166&r2=9167&view=diff ============================================================================== --- trunk/libzypp/zypp/PoolItem.cc (original) +++ trunk/libzypp/zypp/PoolItem.cc Fri Mar 14 17:26:25 2008 @@ -13,6 +13,7 @@ #include "zypp/base/Logger.h" #include "zypp/PoolItem.h" +#include "zypp/ResPool.h" #include "zypp/Package.h" #include "zypp/VendorAttr.h" @@ -52,7 +53,7 @@ return _status; } - + private: mutable ResStatus _status; ResObject::constPtr _resolvable; @@ -121,11 +122,37 @@ // METHOD TYPE : Ctor // PoolItem::PoolItem( const sat::Solvable & solvable_r ) - : _pimpl( new Impl( makeResObject( solvable_r ), solvable_r.isSystem() ) ) + : _pimpl( ResPool::instance().find( solvable_r )._pimpl ) + {} + + /////////////////////////////////////////////////////////////////// + // + // METHOD NAME : PoolItem::PoolItem + // METHOD TYPE : Ctor + // + PoolItem::PoolItem( const ResObject::constPtr & resolvable_r ) + : _pimpl( ResPool::instance().find( resolvable_r )._pimpl ) + {} + + /////////////////////////////////////////////////////////////////// + // + // METHOD NAME : PoolItem::PoolItem + // METHOD TYPE : Ctor + // + PoolItem::PoolItem( Impl * implptr_r ) + : _pimpl( implptr_r ) {} /////////////////////////////////////////////////////////////////// // + // METHOD NAME : PoolItem::makePoolItem + // METHOD TYPE : PoolItem + // + PoolItem PoolItem::makePoolItem( const sat::Solvable & solvable_r ) + { return PoolItem( new Impl( makeResObject( solvable_r ), solvable_r.isSystem() ) ); } + + /////////////////////////////////////////////////////////////////// + // // METHOD NAME : PoolItem::~PoolItem // METHOD TYPE : Dtor // @@ -134,6 +161,14 @@ /////////////////////////////////////////////////////////////////// // + // METHOD NAME : PoolItem::pool + // METHOD TYPE : ResPool + // + ResPool PoolItem::pool() const + { return ResPool::instance(); } + + /////////////////////////////////////////////////////////////////// + // // Forward to Impl: // /////////////////////////////////////////////////////////////////// @@ -146,7 +181,7 @@ ResStatus & PoolItem::statusReset() const { return _pimpl->statusReset(); } - + void PoolItem::saveState() const { _pimpl->saveState(); } Modified: trunk/libzypp/zypp/PoolItem.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PoolItem.h?rev=9167&r1=9166&r2=9167&view=diff ============================================================================== --- trunk/libzypp/zypp/PoolItem.h (original) +++ trunk/libzypp/zypp/PoolItem.h Fri Mar 14 17:26:25 2008 @@ -23,6 +23,8 @@ namespace zypp { ///////////////////////////////////////////////////////////////// + class ResPool; + namespace pool { class PoolImpl; @@ -57,10 +59,20 @@ /** Default ctor for use in std::container. */ PoolItem(); + /** Ctor looking up the \ref sat::Solvable in the \ref ResPool. */ + explicit PoolItem( const sat::Solvable & solvable_r ); + + /** Ctor looking up the \ref ResObject in the \ref ResPool. */ + explicit PoolItem( const ResObject::constPtr & resolvable_r ); + /** Dtor */ ~PoolItem(); public: + /** Return the \ref ResPool the item belongs to. */ + ResPool pool() const; + + public: /** Returns the current status. */ ResStatus & status() const; @@ -93,8 +105,10 @@ private: friend class pool::PoolImpl; - /** ctor */ - explicit PoolItem( const sat::Solvable & solvable_r ); + /** \ref PoolItem generator for \ref pool::PoolImpl. */ + static PoolItem makePoolItem( const sat::Solvable & solvable_r ); + /** internal ctor */ + explicit PoolItem( Impl * implptr_r ); /** Pointer to implementation */ RW_pointer<Impl> _pimpl; Modified: trunk/libzypp/zypp/ResObject.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ResObject.cc?rev=9167&r1=9166&r2=9167&view=diff ============================================================================== --- trunk/libzypp/zypp/ResObject.cc (original) +++ trunk/libzypp/zypp/ResObject.cc Fri Mar 14 17:26:25 2008 @@ -60,9 +60,7 @@ /////////////////////////////////////////////////////////////////// Text ResObject::summary() const - { - return lookupStrAttribute( sat::SolvAttr::summary ); - } + { return lookupStrAttribute( sat::SolvAttr::summary ); } Text ResObject::description() const { return lookupStrAttribute( sat::SolvAttr::description ); } @@ -82,21 +80,22 @@ ByteCount ResObject::downloadSize() const { return ByteCount( lookupNumAttribute( sat::SolvAttr::downloadsize ), ByteCount::K ); } - RepoInfo ResObject::repoInfo() const - { return repository().info(); } - unsigned ResObject::mediaNr() const { return lookupNumAttribute( sat::SolvAttr::medianr ); } +#warning DUMMY installOnly bool ResObject::installOnly() const { return false; } +#warning DUMMY Date ResObject::buildtime() const { return Date(); } +#warning DUMMY installtime Date ResObject::installtime() const { return Date(); } +#warning DUMMY diskusage const DiskUsage & ResObject::diskusage() const { static DiskUsage _du; Modified: trunk/libzypp/zypp/ResObject.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ResObject.h?rev=9167&r1=9166&r2=9167&view=diff ============================================================================== --- trunk/libzypp/zypp/ResObject.h (original) +++ trunk/libzypp/zypp/ResObject.h Fri Mar 14 17:26:25 2008 @@ -51,21 +51,14 @@ * \see \ref sat::Solvable */ //@{ - /** Whether this \c Solvable claims to support locales. */ + /** \see \ref sat::Solvable::supportsLocales */ using sat::Solvable::supportsLocales; - /** Whether this \c Solvable supports a specific \ref Locale. */ + /** \see \ref sat::Solvable::supportsLocale */ using sat::Solvable::supportsLocale; - /** Whether this \c Solvable supports at least one of the specified locales. */ - //using sat::Solvable::supportsLocale; - /** Whether this \c Solvable supports at least one requested locale. - * \see \ref Pool::setRequestedLocales - */ + /** \see \ref sat::Solvable::supportsRequestedLocales */ using sat::Solvable::supportsRequestedLocales; - /** Return the supported locales via locales_r. */ + /** \see \ref sat::Solvable::getSupportedLocales */ using sat::Solvable::getSupportedLocales; - - using sat::Solvable::repository;; - //@} public: @@ -119,10 +112,14 @@ /** Size of the rpm package. */ ByteCount downloadSize() const; + /** \see \ref sat::Solvable::repository */ + using sat::Solvable::repository; + /** \ref RepoInfo associated with the repository * providing this resolvable. */ - RepoInfo repoInfo() const; + RepoInfo repoInfo() const + { return repository().info(); } /** * Media number where the resolvable is located Modified: trunk/libzypp/zypp/ResPool.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ResPool.h?rev=9167&r1=9166&r2=9167&view=diff ============================================================================== --- trunk/libzypp/zypp/ResPool.h (original) +++ trunk/libzypp/zypp/ResPool.h Fri Mar 14 17:26:25 2008 @@ -95,6 +95,9 @@ * \see \ref PoolItem::satSolvable. */ PoolItem find( const sat::Solvable & slv_r ) const; + /** \overload */ + PoolItem find( const ResObject::constPtr & resolvable_r ) const + { return( resolvable_r ? find( resolvable_r->satSolvable() ) : PoolItem() ); } public: /** \name Iterate through all PoolItems matching a \c _Filter. */ Modified: trunk/libzypp/zypp/pool/PoolImpl.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/pool/PoolImpl.h?rev=9167&r1=9166&r2=9167&view=diff ============================================================================== --- trunk/libzypp/zypp/pool/PoolImpl.h (original) +++ trunk/libzypp/zypp/pool/PoolImpl.h Fri Mar 14 17:26:25 2008 @@ -94,7 +94,10 @@ * \see \ref PoolItem::satSolvable. */ PoolItem find( const sat::Solvable & slv_r ) const - { return store()[slv_r.id()]; } + { + const ContainerT & mystore( store() ); + return( slv_r.id() < mystore.size() ? mystore[slv_r.id()] : PoolItem() ); + } /////////////////////////////////////////////////////////////////// // @@ -210,7 +213,7 @@ if ( ! s && pi ) pi = PoolItem(); else if ( s && ! pi ) - pi = PoolItem( s ); + pi = PoolItem::makePoolItem( s ); // the only way to create a new one! } } _storeDirty = false; Modified: trunk/libzypp/zypp/sat/Solvable.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Solvable.cc?rev=9167&r1=9166&r2=9167&view=diff ============================================================================== --- trunk/libzypp/zypp/sat/Solvable.cc (original) +++ trunk/libzypp/zypp/sat/Solvable.cc Fri Mar 14 17:26:25 2008 @@ -95,6 +95,9 @@ unsigned int nr; char *l = solvable_get_location(_solvable, &nr); medianr = nr; +// /* XXX This datadir should be part of RepoInfo. */ +// if (repoInfo().type().toEnum() == repo::RepoType::YAST2_e) +// filename = std::string("suse/") + filename; return l ? std::string(l) : std::string(); } Modified: trunk/libzypp/zypp/sat/Solvable.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Solvable.h?rev=9167&r1=9166&r2=9167&view=diff ============================================================================== --- trunk/libzypp/zypp/sat/Solvable.h (original) +++ trunk/libzypp/zypp/sat/Solvable.h Fri Mar 14 17:26:25 2008 @@ -91,18 +91,19 @@ */ unsigned lookupNumAttribute( const SolvAttr &attr ) const; - /** - * returns the media location: media number in \ref medianr, - * file name as return value. The file name is possibly prepended - * with a subdirectory. - */ - std::string lookupLocation(unsigned &medianr) const; - /** - * + * returns the boolean attribute value for \ref attr + * or \c false if it does not exists. */ bool lookupBoolAttribute( const SolvAttr &attr ) const; + /** + * returns the media location: media number in \ref medianr, + * file name as return value. The file name is possibly prepended + * with a subdirectory. + */ + std::string lookupLocation( unsigned & medianr ) const; + public: /** The identifier. * This is the solvables \ref name, \b except for packages and Modified: trunk/libzypp/zypp/sat/WhatProvides.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/WhatProvides.cc?rev=9167&r1=9166&r2=9167&view=diff ============================================================================== --- trunk/libzypp/zypp/sat/WhatProvides.cc (original) +++ trunk/libzypp/zypp/sat/WhatProvides.cc Fri Mar 14 17:26:25 2008 @@ -26,7 +26,20 @@ WhatProvides::WhatProvides( Capability cap_r ) : _begin( myPool().whatProvides( cap_r ) ) - {} + { +#warning REMOVE THIS DEBUGSTUFF AGAIN + if ( ! _begin ) + return; + int limit = myPool()->nsolvables; + for ( const sat::detail::IdType * end = _begin; *end; ++end ) + { + if ( *end >= limit ) + { + INT << "Illegal index: WhatProvides (" << cap_r << ") = " << *end << " (limit " << limit << ")" << endl; + } + } + myPool()->nsolvables; + } WhatProvides::size_type WhatProvides::size() const { -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org