Mailinglist Archive: zypp-commit (606 mails)

< Previous Next >
[zypp-commit] r9394 - in /trunk/libzypp: devel/devel.ma/NewPool.cc zypp/Repository.cc zypp/Repository.h zypp/base/Easy.h zypp/sat/LookupAttr.cc zypp/sat/LookupAttr.h zypp/sat/Pool.cc
  • From: mlandres@xxxxxxxxxxxxxxxx
  • Date: Fri, 04 Apr 2008 22:01:32 -0000
  • Message-id: <20080404220133.22D87342C5@xxxxxxxxxxxxxxxx>
Author: mlandres
Date: Sat Apr 5 00:01:32 2008
New Revision: 9394

URL: http://svn.opensuse.org/viewcvs/zypp?rev=9394&view=rev
Log:
- LookupAttr added fast forward moving, position info and pool search.
- Add Repository::nextInPool() retiurning the next repo in pool.
- fixed Pool::reposEmpty and Repository::solvablesEmpty

Modified:
trunk/libzypp/devel/devel.ma/NewPool.cc
trunk/libzypp/zypp/Repository.cc
trunk/libzypp/zypp/Repository.h
trunk/libzypp/zypp/base/Easy.h
trunk/libzypp/zypp/sat/LookupAttr.cc
trunk/libzypp/zypp/sat/LookupAttr.h
trunk/libzypp/zypp/sat/Pool.cc

Modified: trunk/libzypp/devel/devel.ma/NewPool.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/NewPool.cc?rev=9394&r1=9393&r2=9394&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.ma/NewPool.cc (original)
+++ trunk/libzypp/devel/devel.ma/NewPool.cc Sat Apr 5 00:01:32 2008
@@ -506,81 +506,8 @@
{
namespace sat
{
-#if 0
- class LookupAttr
- {
- public:
- LookupAttr()
- {}
- LookupAttr( SolvAttr attr_r )
- : _attr( attr_r )
- {}
- LookupAttr( SolvAttr attr_r, Repository repo_r )
- : _attr( attr_r ), _repo( repo_r )
- {}
- LookupAttr( SolvAttr attr_r, Solvable slv_r )
- : _attr( attr_r ), _repo( slv_r.repository() ), _slv( slv_r )
- {}
-
- public:
- class iterator : public boost::iterator_adaptor<
- iterator // Derived
- , RepoDataIterator * // Base
- , const sat::Solvable // Value
- , boost::forward_traversal_tag // CategoryOrTraversal
- , const sat::Solvable & // Reference
- >
- {
- friend bool operator==( const iterator & lhs, const iterator & rhs );
-
- public:
- iterator()
- : _valid( false )
- {}
-
- public:
- iterator & operator++()
- { _valid = ::dataiterator_step( &_di ); return *this; }
-
- IdString operator*() const
- { return IdString( _valid ? ::repodata_globalize_id( _di.data,
_di.kv.id ) : detail::noId ); }
-
- private:
- friend class LookupAttr;
- iterator( ::Dataiterator di_r )
- : _di( di_r ), _valid( ::dataiterator_step( &_di ) )
- {}
-
- private:
- ::Dataiterator _di;
- bool _valid;
- };
-
- public:
- iterator begin() const
- {
- if ( ! (_attr && _repo ) )
- return iterator();
- ::Dataiterator di;
- ::dataiterator_init( &di, _repo.id(), _slv.id(), _attr.id(), 0,
SEARCH_NO_STORAGE_SOLVABLE );
- return iterator( di );
- }
-
- iterator end() const
- { return iterator(); }
-
- private:
- SolvAttr _attr;
- Repository _repo;
- Solvable _slv;
- };

- inline bool operator==( const LookupAttr::iterator & lhs, const
LookupAttr::iterator & rhs )
- { return( lhs._valid == rhs._valid && ( !lhs._valid || lhs._di == rhs._di
) ); }

- inline bool operator!=( const LookupAttr::iterator & lhs, const
LookupAttr::iterator & rhs )
- { return ! (lhs == rhs); }
-#endif

}
}
@@ -589,47 +516,25 @@
void ditest( sat::Solvable slv_r )
{
MIL << slv_r << endl;
-#if 0
- sat::LookupAttr q( sat::SolvAttr::keywords, slv_r );
- dumpRange( MIL, q.begin(), q.end() ) << endl;
- sat::LookupAttr::iterator a1( q.begin() );
- SEC << ( a1 == q.begin() ) << endl;
- ++a1;
- SEC << ( a1 == q.begin() ) << endl;
- SEC << ( a1 == ++q.begin() ) << endl;
- return;
-#endif
- ::_Pool * pool = sat::Pool::instance().get();
- ::_Repo * repo = slv_r.repository().get();
- sat::SolvAttr attr( "susetags:datadir" );
- attr = sat::SolvAttr::keywords;
- attr = sat::SolvAttr::keywords;
-
- if ( attr )
- {
- INT << attr << endl;
- unsigned steps = 3;
- ::Dataiterator di;
- ::dataiterator_init( &di, repo, 0, attr.id(), 0,
SEARCH_NO_STORAGE_SOLVABLE );
- ::Dataiterator di2 = di;
- while ( dataiterator_step( &di ) && --steps )
- {
- MIL << sat::Solvable(di.solvid) << endl;
- DBG << dump(IdString(di.keyname)) << endl;
- DBG << dump(IdString(::repodata_globalize_id(di.data, di.kv.id))) <<
endl;
- }
- SEC << endl;
- di = di2;
- steps = 5;
- while ( dataiterator_step( &di ) && --steps )
+
+ //sat::LookupAttr q( sat::SolvAttr::keywords, slv_r.repository() );
+ sat::LookupAttr q( sat::SolvAttr::allAttr );
+
+ WAR << q << endl;
+ for_( it, q.begin(), q.end() )
+ {
+ WAR << "" << it << endl;
+ const ::_Dataiterator * dip( it.get() );
+
+ switch ( it.solvAttrType() )
{
- MIL << sat::Solvable(di.solvid) << endl;
- DBG << dump(IdString(di.keyname)) << endl;
- DBG << dump(IdString(::repodata_globalize_id(di.data, di.kv.id))) <<
endl;
- }

+ }

- }
+ //it.nextSkipRepo();
+ it.nextSkipSolvable();
+ }
+ return;
}

void ditest( const PoolItem & pi_r )

Modified: trunk/libzypp/zypp/Repository.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Repository.cc?rev=9394&r1=9393&r2=9394&view=diff
==============================================================================
--- trunk/libzypp/zypp/Repository.cc (original)
+++ trunk/libzypp/zypp/Repository.cc Sat Apr 5 00:01:32 2008
@@ -61,7 +61,7 @@
bool Repository::solvablesEmpty() const
{
NO_REPOSITORY_RETURN( true );
- return _repo->nsolvables;
+ return !_repo->nsolvables;
}

Repository::size_type Repository::solvablesSize() const
@@ -124,6 +124,21 @@
_id = sat::detail::noRepoId;
}

+ Repository Repository::nextInPool() const
+ {
+ NO_REPOSITORY_RETURN( noRepository );
+ for_( it, sat::Pool::instance().reposBegin(),
sat::Pool::instance().reposEnd() )
+ {
+ if ( *it == *this )
+ {
+ if ( ++it != _for_end )
+ return *it;
+ break;
+ }
+ }
+ return noRepository;
+ }
+
#warning NEED POOL MANIP EXEPTIONS
void Repository::addSolv( const Pathname & file_r )
{
@@ -156,7 +171,7 @@
std::ostream & operator<<( std::ostream & str, const Repository & obj )
{
if ( ! obj )
- return str << "sat::repo()";
+ return str << "noRepository";

return str << "sat::repo(" << obj.name() << ")"
<< "{"

Modified: trunk/libzypp/zypp/Repository.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Repository.h?rev=9394&r1=9393&r2=9394&view=diff
==============================================================================
--- trunk/libzypp/zypp/Repository.h (original)
+++ trunk/libzypp/zypp/Repository.h Sat Apr 5 00:01:32 2008
@@ -92,7 +92,11 @@
/** Functor calling \ref eraseFromPool. */
struct EraseFromPool;

- public:
+ public:
+ /** Return next Repository in \ref Pool (or \ref noRepository). */
+ Repository nextInPool() const;
+
+ public:
/** \name Repository content manipulating methods.
* \todo maybe a separate Repository/Solvable content manip interface
* provided by the pool.
@@ -186,11 +190,11 @@
//
/** */
class RepositoryIterator : public boost::iterator_adaptor<
- RepositoryIterator // Derived
+ RepositoryIterator // Derived
, ::_Repo ** // Base
- , Repository // Value
+ , Repository // Value
, boost::forward_traversal_tag // CategoryOrTraversal
- , Repository // Reference
+ , Repository // Reference
>
{
public:

Modified: trunk/libzypp/zypp/base/Easy.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/base/Easy.h?rev=9394&r1=9393&r2=9394&view=diff
==============================================================================
--- trunk/libzypp/zypp/base/Easy.h (original)
+++ trunk/libzypp/zypp/base/Easy.h Sat Apr 5 00:01:32 2008
@@ -21,7 +21,7 @@
* }
* \endcode
*/
-#define for_(IT,BEG,END) for ( typeof(BEG) IT = BEG, _ZZ = END; IT != _ZZ;
++IT )
+#define for_(IT,BEG,END) for ( typeof(BEG) IT = BEG, _for_end = END; IT !=
_for_end; ++IT )

///////////////////////////////////////////////////////////////////
namespace zypp

Modified: trunk/libzypp/zypp/sat/LookupAttr.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/LookupAttr.cc?rev=9394&r1=9393&r2=9394&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/LookupAttr.cc (original)
+++ trunk/libzypp/zypp/sat/LookupAttr.cc Sat Apr 5 00:01:32 2008
@@ -28,20 +28,27 @@

LookupAttr::iterator LookupAttr::begin() const
{
-// if ( ! (_attr ) )
-// return iterator();
+ if ( _attr == SolvAttr::noAttr )
+ return iterator();

scoped_ptr< ::_Dataiterator> dip( new ::Dataiterator );
+ // needed while LookupAttr::iterator::dip_equal does ::memcmp:
::memset( dip.get(), 0, sizeof(::_Dataiterator) );
+ bool chain = false;
+
if ( _solv )
::dataiterator_init( dip.get(), _solv.repository().id(), _solv.id(),
_attr.id(), 0, SEARCH_NO_STORAGE_SOLVABLE );
else if ( _repo )
::dataiterator_init( dip.get(), _repo.id(), 0, _attr.id(), 0,
SEARCH_NO_STORAGE_SOLVABLE );
+ else if ( ! sat::Pool::instance().reposEmpty() )
+ {
+ ::dataiterator_init( dip.get(),
sat::Pool::instance().reposBegin()->id(), 0, _attr.id(), 0,
SEARCH_NO_STORAGE_SOLVABLE );
+ chain = true;
+ }
else
-#warning pool search still disabled.
- return iterator(); // pool search not yet s
+ return iterator();

- return iterator( dip ); // iterator takes over ownership!
+ return iterator( dip, chain ); // iterator takes over ownership!
}

LookupAttr::iterator LookupAttr::end() const
@@ -51,10 +58,14 @@

std::ostream & operator<<( std::ostream & str, const LookupAttr & obj )
{
- if ( ! obj.attr() )
+ if ( obj.attr() == SolvAttr::noAttr )
return str << "search nothing";

- str << "seach " << obj.attr() << " in ";
+ if ( obj.attr() )
+ str << "seach " << obj.attr() << " in ";
+ else
+ str << "seach ALL in ";
+
if ( obj.solvable() )
return str << obj.solvable();
if ( obj.repo() )
@@ -78,6 +89,31 @@
//
///////////////////////////////////////////////////////////////////

+ Repository LookupAttr::iterator::inRepo() const
+ { return Repository( _dip->repo ); }
+
+ Solvable LookupAttr::iterator::inSolvable() const
+ { return Solvable( _dip->solvid ); }
+
+ SolvAttr LookupAttr::iterator::inSolvAttr() const
+ { return SolvAttr( _dip->key->name ); }
+
+ detail::IdType LookupAttr::iterator::solvAttrType() const
+ { return _dip->key->type; }
+
+ void LookupAttr::iterator::nextSkipSolvAttr()
+ { ::dataiterator_skip_attribute( _dip.get() ); }
+
+ void LookupAttr::iterator::nextSkipSolvable()
+ { ::dataiterator_skip_solvable( _dip.get() ); }
+
+ void LookupAttr::iterator::nextSkipRepo()
+ { ::dataiterator_skip_repo( _dip.get() ); }
+
+ ///////////////////////////////////////////////////////////////////
+ // internal stuff below
+ ///////////////////////////////////////////////////////////////////
+
::_Dataiterator * LookupAttr::iterator::cloneFrom( const ::_Dataiterator *
rhs )
{
if ( ! rhs )
@@ -89,6 +125,7 @@

bool LookupAttr::iterator::dip_equal( const ::_Dataiterator & lhs, const
::_Dataiterator & rhs ) const
{
+ // requires ::memset in LookupAttr::begin
return ::memcmp( &lhs, &rhs, sizeof(::_Dataiterator) ) == 0;
}

@@ -102,8 +139,21 @@
{
if ( _dip && ! ::dataiterator_step( _dip.get() ) )
{
- _dip.reset();
- base_reference() = 0;
+ bool haveNext = false;
+ if ( _chainRepos )
+ {
+ Repository nextRepo( inRepo().nextInPool() );
+ if ( nextRepo )
+ {
+ ::dataiterator_jump_to_repo( _dip.get(), nextRepo.get() );
+ haveNext = ::dataiterator_step( _dip.get() );
+ }
+ }
+ if ( ! haveNext )
+ {
+ _dip.reset();
+ base_reference() = 0;
+ }
}
}

@@ -113,10 +163,10 @@
if ( ! dip )
return str << "EndOfQuery" << endl;

- str << Solvable( dip->solvid )
- << '<' << SolvAttr( dip->keyname )
- << "> = " << IdString( dip->key->type )
- << "(" << dip->kv.id << ")";
+ str << obj.inSolvable()
+ << '<' << obj.inSolvAttr()
+ << "> = " << obj.solvAttrType()
+ << "(" << dip->kv.id << ")" << (dip->data && dip->data->localpool ?
"*" : "" );
return str;
}


Modified: trunk/libzypp/zypp/sat/LookupAttr.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/LookupAttr.h?rev=9394&r1=9393&r2=9394&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/LookupAttr.h (original)
+++ trunk/libzypp/zypp/sat/LookupAttr.h Sat Apr 5 00:01:32 2008
@@ -19,6 +19,7 @@
#include <iosfwd>

#include "zypp/base/PtrTypes.h"
+#include "zypp/base/DefaultIntegral.h"
#include "zypp/sat/Pool.h"

///////////////////////////////////////////////////////////////////
@@ -40,18 +41,22 @@
*
* Modifying the query will not affect any running
* iterator.
+ *
+ * Use \ref SolvAttr::allAttr to search all attributes.
*/
class LookupAttr
{
public:
- /** Default ctor. */
+ /** Default ctor finds nothing. */
LookupAttr()
{}
/** Lookup \ref SolvAttr in \ref Pool (all repositories). */
+ explicit
LookupAttr( SolvAttr attr_r )
: _attr( attr_r )
{}
/** Lookup \ref SolvAttr in one\ref Repository. */
+ explicit
LookupAttr( SolvAttr attr_r, Repository repo_r )
: _attr( attr_r ), _repo( repo_r )
{}
@@ -141,6 +146,7 @@
// CLASS NAME : LookupAttr::iterator
//
/** Result iterator.
+ * Extended iterator methods valid only if not @end.
* \note Implementation: Keep iterator_adaptor base and _dip in sync!
*/
class LookupAttr::iterator : public boost::iterator_adaptor<
@@ -152,14 +158,56 @@
>
{
public:
- iterator()
- : iterator_adaptor_( 0 )
- {}
+ /** \name Moving fast forward. */
+ //@{
+ /** On the next call to \ref operator++ advance to the next \ref
SolvAttr. */
+ void nextSkipSolvAttr();

- public:
+ /** On the next call to \ref operator++ advance to the next \ref
Solvable. */
+ void nextSkipSolvable();
+
+ /** On the next call to \ref operator++ advance to the next \ref
Repository. */
+ void nextSkipRepo();
+
+ /** Immediately advance to the next \ref SolvAttr. */
+ void skipSolvAttr()
+ { nextSkipSolvAttr(); increment(); }
+
+ /** Immediately advance to the next \ref Solvable. */
+ void skipSolvable()
+ { nextSkipSolvable(); increment(); }
+
+ /** Immediately advance to the next \ref Repository. */
+ void skipRepo()
+ { nextSkipRepo(); increment(); }
+ //@}
+
+ /** \name Current position info. */
+ //@{
+ /** The current \ref Repository. */
+ Repository inRepo() const;
+
+ /** The current \ref Solvabele. */
+ Solvable inSolvable() const;

+ /** The current \ref SolvAttr. */
+ SolvAttr inSolvAttr() const;

+ /** The current \ref SolvAttr type. */
+ detail::IdType solvAttrType() const;
+ //@}
+
+ /** \name Retrieving attribute values. */
+ //@{
+ //@}
+ ///////////////////////////////////////////////////////////////////
+ // internal stuff below
+ ///////////////////////////////////////////////////////////////////
public:
+ iterator()
+ : iterator_adaptor_( 0 )
+ {}
+
iterator( const iterator & rhs )
: iterator_adaptor_( cloneFrom( rhs.base() ) )
, _dip( base() )
@@ -177,8 +225,9 @@

private:
friend class LookupAttr;
- iterator( scoped_ptr< ::_Dataiterator> & dip_r )
+ iterator( scoped_ptr< ::_Dataiterator> & dip_r, bool chain_r )
: iterator_adaptor_( dip_r.get() )
+ , _chainRepos( chain_r )
{
_dip.swap( dip_r ); // take ownership!
increment();
@@ -208,6 +257,7 @@
{ return _dip.get(); }
private:
scoped_ptr< ::_Dataiterator> _dip;
+ DefaultIntegral<bool,false> _chainRepos;
};
///////////////////////////////////////////////////////////////////


Modified: trunk/libzypp/zypp/sat/Pool.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Pool.cc?rev=9394&r1=9393&r2=9394&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/Pool.cc (original)
+++ trunk/libzypp/zypp/sat/Pool.cc Sat Apr 5 00:01:32 2008
@@ -53,7 +53,7 @@
{ return myPool().prepare(); }

bool Pool::reposEmpty() const
- { return myPool()->nrepos; }
+ { return ! myPool()->nrepos; }

Pool::size_type Pool::reposSize() const
{ return myPool()->nrepos; }

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages