Mailinglist Archive: zypp-commit (606 mails)

< Previous Next >
[zypp-commit] r9496 - in /trunk/libzypp: devel/devel.ma/ package/ zypp/ zypp/sat/ zypp/ui/
  • From: mlandres@xxxxxxxxxxxxxxxx
  • Date: Wed, 09 Apr 2008 19:37:14 -0000
  • Message-id: <20080409193714.6FB0831B6A@xxxxxxxxxxxxxxxx>
Author: mlandres
Date: Wed Apr 9 21:37:13 2008
New Revision: 9496

URL: http://svn.opensuse.org/viewcvs/zypp?rev=9496&view=rev
Log:
- Enable ui::Selectable lookup by Solvable/PoolItem in ResPoolProxy.
- Add SolvIterMixin: Base class providing PoolItem_iterator and
Selectable_iterator iterator types based on a Solvable iterator.
- Enhanced WhatProvides and SolvableSet to PoolItem_iterator to offer
PoolItem_iterator and Selectable_iterator.
- Add Solvable::SplitIdent: Helper class that splits an identifier
into kind and name.
- Provide methods Pattern::contents returning a collection of packages
associated with the pattern/patch.

Added:
trunk/libzypp/zypp/sat/SolvIterMixin.cc
trunk/libzypp/zypp/sat/SolvIterMixin.h
Modified:
trunk/libzypp/devel/devel.ma/NewPool.cc
trunk/libzypp/package/libzypp.changes
trunk/libzypp/zypp/CMakeLists.txt
trunk/libzypp/zypp/Package.cc
trunk/libzypp/zypp/Patch.cc
trunk/libzypp/zypp/Patch.h
trunk/libzypp/zypp/PoolItem.h
trunk/libzypp/zypp/ResPoolProxy.cc
trunk/libzypp/zypp/ResPoolProxy.h
trunk/libzypp/zypp/sat/LookupAttr.cc
trunk/libzypp/zypp/sat/LookupAttr.h
trunk/libzypp/zypp/sat/Solvable.cc
trunk/libzypp/zypp/sat/Solvable.h
trunk/libzypp/zypp/sat/SolvableSet.h
trunk/libzypp/zypp/sat/WhatProvides.h
trunk/libzypp/zypp/ui/Selectable.cc
trunk/libzypp/zypp/ui/Selectable.h

Modified: trunk/libzypp/devel/devel.ma/NewPool.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/NewPool.cc?rev=9496&r1=9495&r2=9496&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.ma/NewPool.cc (original)
+++ trunk/libzypp/devel/devel.ma/NewPool.cc Wed Apr 9 21:37:13 2008
@@ -36,6 +36,8 @@
#include "zypp/sat/Pool.h"
#include "zypp/sat/LocaleSupport.h"
#include "zypp/sat/LookupAttr.h"
+#include "zypp/sat/SolvableSet.h"
+#include "zypp/sat/SolvIterMixin.h"
#include "zypp/sat/detail/PoolImpl.h"

#include <zypp/base/GzStream.h>
@@ -506,34 +508,31 @@
{
namespace sat
{
-
-
-
}
}

+void dit( const Pattern::Contents & c_r )
+{
+ {
+ sat::WhatProvides c( Capability("amarok") );
+ INT << c << endl;
+ dumpRange( MIL, c.solvableBegin(), c.solvableEnd() ) << endl;
+ dumpRange( WAR, c.poolItemBegin(), c.poolItemEnd() ) << endl;
+ dumpRange( ERR, c.selectableBegin(), c.selectableEnd() ) << endl;
+ }
+ {
+ const Pattern::Contents & c( c_r );
+ dumpRange( MIL, c.solvableBegin(), c.solvableEnd() ) << endl;
+ dumpRange( WAR, c.poolItemBegin(), c.poolItemEnd() ) << endl;
+ dumpRange( ERR, c.selectableBegin(), c.selectableEnd() ) << endl;
+ }
+}

void ditest( sat::Solvable slv_r )
{
MIL << slv_r << endl;
-
- //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() )
- {
-
- }
-
- //it.nextSkipRepo();
- it.nextSkipSolvable();
- }
+ Package::Ptr pkg( make<Package>( slv_r ) );
+ dumpRange( DBG, pkg->keywords().begin(), pkg->keywords().end() ) << endl;
return;
}

@@ -639,18 +638,13 @@
///////////////////////////////////////////////////////////////////


- //Repository repo( satpool.reposFind("openSUSE-10.3-DVD 10.3") );
- if(0)//for_( it, repo.solvablesBegin(), repo.solvablesEnd() )
- {
- //testDump( MIL, PoolItem(*it) );
- }
-
for_( it, pool.byKindBegin<Pattern>(), pool.byKindEnd<Pattern>() )
{
if ( (*it)->name() != "apparmor" )
continue;
- USR << asKind<Pattern>(*it)->contents() << endl;
-
+ Pattern::Contents c( asKind<Pattern>(*it)->contents() );
+ dumpRange( USR, c.begin(), c.end() ) << endl;
+ dit( c );
break;
}


Modified: trunk/libzypp/package/libzypp.changes
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?rev=9496&r1=9495&r2=9496&view=diff
==============================================================================
--- trunk/libzypp/package/libzypp.changes (original)
+++ trunk/libzypp/package/libzypp.changes Wed Apr 9 21:37:13 2008
@@ -1,4 +1,18 @@
-------------------------------------------------------------------
+Wed Apr 9 21:24:54 CEST 2008 - ma@xxxxxxx
+
+- Enable ui::Selectable lookup by Solvable/PoolItem in ResPoolProxy.
+- Add SolvIterMixin: Base class providing PoolItem_iterator and
+ Selectable_iterator iterator types based on a Solvable iterator.
+- Enhanced WhatProvides and SolvableSet to PoolItem_iterator to offer
+ PoolItem_iterator and Selectable_iterator.
+- Add Solvable::SplitIdent: Helper class that splits an identifier
+ into kind and name.
+- Provide methods Pattern::contents returning a collection of packages
+ associated with the pattern/patch.
+- revision 9496
+
+-------------------------------------------------------------------
Tue Apr 8 15:50:48 CEST 2008 - jreidinger@xxxxxxx

- add comparing to PoolQuery

Modified: trunk/libzypp/zypp/CMakeLists.txt
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/CMakeLists.txt?rev=9496&r1=9495&r2=9496&view=diff
==============================================================================
--- trunk/libzypp/zypp/CMakeLists.txt (original)
+++ trunk/libzypp/zypp/CMakeLists.txt Wed Apr 9 21:37:13 2008
@@ -515,6 +515,7 @@
sat/Pool.cc
sat/Solvable.cc
sat/SolvableSet.cc
+ sat/SolvIterMixin.cc
sat/WhatProvides.cc
sat/LocaleSupport.cc
sat/LookupAttr.cc
@@ -526,6 +527,7 @@
sat/Pool.h
sat/Solvable.h
sat/SolvableSet.h
+ sat/SolvIterMixin.h
sat/WhatProvides.h
sat/LocaleSupport.h
sat/LookupAttr.h

Modified: trunk/libzypp/zypp/Package.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Package.cc?rev=9496&r1=9495&r2=9496&view=diff
==============================================================================
--- trunk/libzypp/zypp/Package.cc (original)
+++ trunk/libzypp/zypp/Package.cc Wed Apr 9 21:37:13 2008
@@ -79,10 +79,12 @@
ByteCount Package::sourcesize() const
{ return lookupNumAttribute( sat::SolvAttr::sourcesize ); }

- /** */
-#warning DUMMY authors
std::list<std::string> Package::authors() const
- { return std::list<std::string>(); }
+ {
+ std::list<std::string> ret;
+ str::split( lookupStrAttribute( sat::SolvAttr::authors ),
std::back_inserter(ret), "\n" );
+ return ret;
+ }

/** */
#warning DUMMY filenames

Modified: trunk/libzypp/zypp/Patch.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Patch.cc?rev=9496&r1=9495&r2=9496&view=diff
==============================================================================
--- trunk/libzypp/zypp/Patch.cc (original)
+++ trunk/libzypp/zypp/Patch.cc Wed Apr 9 21:37:13 2008
@@ -78,52 +78,44 @@
return Contents();
}

- /////////////////////////////////////////////////////////////////

-
- Patch::ReferenceIterator::ReferenceIterator()
- {}
-
- Patch::ReferenceIterator::ReferenceIterator( const sat::Solvable & val_r )
- {
- base_reference() = sat::LookupAttr( sat::SolvAttr::updateReferenceId,
- val_r ).begin();
- _hrefit = sat::LookupAttr( sat::SolvAttr::updateReferenceHref,
- val_r ).begin();
- _titleit = sat::LookupAttr( sat::SolvAttr::updateReferenceTitle,
- val_r ).begin();
- _typeit = sat::LookupAttr( sat::SolvAttr::updateReferenceType,
- val_r ).begin();
- }
-
-
- std::string Patch::ReferenceIterator::id() const
- { return base_reference().asString(); }
- std::string Patch::ReferenceIterator::href() const
- { return _hrefit.asString(); }
- std::string Patch::ReferenceIterator::title() const
- { return _titleit.asString(); }
- std::string Patch::ReferenceIterator::type() const
- { return _typeit.asString(); }
-
-
-
- int Patch::ReferenceIterator::dereference() const
- { return 0; }
-
- void Patch::ReferenceIterator::increment()
- {
- ++base_reference();
- ++_hrefit;
- ++_titleit;
- ++_typeit;
- }
-
- inline Patch::ReferenceIterator Patch::referencesBegin() const
- { return ReferenceIterator(satSolvable()); }
- inline Patch::ReferenceIterator Patch::referencesEnd() const
- { return ReferenceIterator(); }
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : Patch::ReferenceIterator
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ Patch::ReferenceIterator::ReferenceIterator( const sat::Solvable & val_r )
+ {
+ base_reference() = sat::LookupAttr( sat::SolvAttr::updateReferenceId,
+ val_r ).begin();
+ _hrefit = sat::LookupAttr( sat::SolvAttr::updateReferenceHref,
+ val_r ).begin();
+ _titleit = sat::LookupAttr( sat::SolvAttr::updateReferenceTitle,
+ val_r ).begin();
+ _typeit = sat::LookupAttr( sat::SolvAttr::updateReferenceType,
+ val_r ).begin();
+ }


+ std::string Patch::ReferenceIterator::id() const
+ { return base_reference().asString(); }
+ std::string Patch::ReferenceIterator::href() const
+ { return _hrefit.asString(); }
+ std::string Patch::ReferenceIterator::title() const
+ { return _titleit.asString(); }
+ std::string Patch::ReferenceIterator::type() const
+ { return _typeit.asString(); }
+
+
+ void Patch::ReferenceIterator::increment()
+ {
+ ++base_reference();
+ ++_hrefit;
+ ++_titleit;
+ ++_typeit;
+ }
+
+ /////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////

Modified: trunk/libzypp/zypp/Patch.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Patch.h?rev=9496&r1=9495&r2=9496&view=diff
==============================================================================
--- trunk/libzypp/zypp/Patch.h (original)
+++ trunk/libzypp/zypp/Patch.h Wed Apr 9 21:37:13 2008
@@ -22,10 +22,10 @@

DEFINE_PTR_TYPE(Patch);

-
- /**
+
+ /**
* Class representing a patch.
- *
+ *
* A patch represents a specific problem that
* can be fixed by pulling in the patch dependencies.
*
@@ -44,7 +44,7 @@
typedef sat::SolvableSet Contents;

public:
- /**
+ /**
* issue date time
*/
Date timestamp() const
@@ -61,7 +61,7 @@
bool reboot_needed() const;

/**
- * Does the patch affect the package manager itself?
+ * Does the patch affect the package manager itself?
*/
bool affects_pkg_manager() const;

@@ -77,68 +77,9 @@
Contents contents() const;

public:
-
- /**
- * Query class for Patch issue references
- * like bugzilla and security issues the
- * patch is supposed to fix.
- *
- * The iterator does not provide a dereference
- * operator so you can do * on it, but you can
- * access the attributes of each patch issue reference
- * directly from the iterator.
- *
- * \code
- * for ( Patch::ReferenceIterator it = patch->referencesBegin();
- * it != patch->referencesEnd();
- * ++it )
- * {
- * cout << it.href() << endl;
- * }
- * \endcode
- *
- */
- class ReferenceIterator : public boost::iterator_adaptor<
- Patch::ReferenceIterator // Derived
- , sat::LookupAttr::iterator // Base
- , int // Value
- , boost::forward_traversal_tag // CategoryOrTraversal
- , int
- >
- {
- public:
- ReferenceIterator();
- explicit ReferenceIterator( const sat::Solvable & val_r );
-
- /**
- * The id of the reference. For bugzilla entries
- * this is the bug number as a string.
- */
- std::string id() const;
- /**
- * Url or ponter where to find more information
- */
- std::string href() const;
- /**
- * Title describing the issue
- */
- std::string title() const;
- /**
- * Type of the reference. For example
- * "bugzilla"
- */
- std::string type() const;
- private:
- friend class boost::iterator_core_access;
-
- int dereference() const;
- void increment();
- private:
- sat::LookupAttr::iterator _hrefit;
- sat::LookupAttr::iterator _titleit;
- sat::LookupAttr::iterator _typeit;
- };

+ /** Query class for Patch issue references */
+ class ReferenceIterator
/**
* Get an iterator to the beginning of the patch
* references. \see Patch::ReferenceIterator
@@ -173,6 +114,74 @@
virtual ~Patch();
};

+
+ /**
+ * Query class for Patch issue references
+ * like bugzilla and security issues the
+ * patch is supposed to fix.
+ *
+ * The iterator does not provide a dereference
+ * operator so you can do * on it, but you can
+ * access the attributes of each patch issue reference
+ * directly from the iterator.
+ *
+ * \code
+ * for ( Patch::ReferenceIterator it = patch->referencesBegin();
+ * it != patch->referencesEnd();
+ * ++it )
+ * {
+ * cout << it.href() << endl;
+ * }
+ * \endcode
+ *
+ */
+ class Patch::ReferenceIterator : public boost::iterator_adaptor<
+ Patch::ReferenceIterator // Derived
+ , sat::LookupAttr::iterator // Base
+ , int // Value
+ , boost::forward_traversal_tag // CategoryOrTraversal
+ , int
+ >
+ {
+ public:
+ ReferenceIterator() {}
+ explicit ReferenceIterator( const sat::Solvable & val_r );
+
+ /**
+ * The id of the reference. For bugzilla entries
+ * this is the bug number as a string.
+ */
+ std::string id() const;
+ /**
+ * Url or pointer where to find more information
+ */
+ std::string href() const;
+ /**
+ * Title describing the issue
+ */
+ std::string title() const;
+ /**
+ * Type of the reference. For example
+ * "bugzilla"
+ */
+ std::string type() const;
+ private:
+ friend class boost::iterator_core_access;
+
+ int dereference() const { return 0; }
+ void increment();
+ private:
+ sat::LookupAttr::iterator _hrefit;
+ sat::LookupAttr::iterator _titleit;
+ sat::LookupAttr::iterator _typeit;
+ };
+
+ inline Patch::ReferenceIterator Patch::referencesBegin() const
+ { return ReferenceIterator(satSolvable()); }
+
+ inline Patch::ReferenceIterator Patch::referencesEnd() const
+ { return ReferenceIterator(); }
+
/////////////////////////////////////////////////////////////////

} // namespace zypp

Modified: trunk/libzypp/zypp/PoolItem.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PoolItem.h?rev=9496&r1=9495&r2=9496&view=diff
==============================================================================
--- trunk/libzypp/zypp/PoolItem.h (original)
+++ trunk/libzypp/zypp/PoolItem.h Wed Apr 9 21:37:13 2008
@@ -160,6 +160,18 @@
inline bool operator!=( const ResObject::constPtr & lhs, const PoolItem &
rhs )
{ return ! (lhs==rhs); }

+ /** Solvable to PoolItem transform functor.
+ * \relates PoolItem
+ * \relates sat::SolvIterMixin
+ */
+ struct asPoolItem
+ {
+ typedef PoolItem result_type;
+
+ PoolItem operator()( const sat::Solvable & solv_r ) const
+ { return PoolItem( solv_r ); }
+ };
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////

Modified: trunk/libzypp/zypp/ResPoolProxy.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ResPoolProxy.cc?rev=9496&r1=9495&r2=9496&view=diff
==============================================================================
--- trunk/libzypp/zypp/ResPoolProxy.cc (original)
+++ trunk/libzypp/zypp/ResPoolProxy.cc Wed Apr 9 21:37:13 2008
@@ -136,7 +136,9 @@
//
// CLASS NAME : ResPoolProxy::Impl
//
- /** ResPoolProxy implementation. */
+ /** ResPoolProxy implementation.
+ * \todo Seedup as it is still using old index
+ */
struct ResPoolProxy::Impl
{
public:
@@ -154,7 +156,18 @@
}

public:
+ ui::Selectable::Ptr lookup( ResKind kind_r, const std::string & name_r )
const
+ {
+ SelectableIndex idx( _selPool[kind_r] );
+ for_( it, idx.begin(), idx.end() )
+ {
+ if ( (*it)->name() == name_r )
+ return *it;
+ }
+ return ui::Selectable::Ptr();
+ }

+ public:
bool empty( const ResObject::Kind & kind_r ) const
{ return _selPool[kind_r].empty(); }

@@ -255,6 +268,9 @@
//
///////////////////////////////////////////////////////////////////

+ ui::Selectable::Ptr ResPoolProxy::lookup( ResKind kind_r, const std::string
& name_r ) const
+ { return _pimpl->lookup( kind_r, name_r ); }
+
bool ResPoolProxy::empty( const ResObject::Kind & kind_r ) const
{ return _pimpl->empty( kind_r ); }


Modified: trunk/libzypp/zypp/ResPoolProxy.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ResPoolProxy.h?rev=9496&r1=9495&r2=9496&view=diff
==============================================================================
--- trunk/libzypp/zypp/ResPoolProxy.h (original)
+++ trunk/libzypp/zypp/ResPoolProxy.h Wed Apr 9 21:37:13 2008
@@ -46,7 +46,7 @@
typedef SelectableIndex::const_iterator const_iterator;
typedef SelectableIndex::size_type size_type;

- typedef ResPool::repository_iterator repository_iterator;
+ typedef ResPool::repository_iterator repository_iterator;

public:

@@ -63,6 +63,24 @@
~ResPoolProxy();

public:
+ /** \name Lookup individual Selectables. */
+ //@{
+ ui::Selectable::Ptr lookup( IdString ident_r ) const
+ { sat::Solvable::SplitIdent id( ident_r ); return lookup( id.kind(),
id.name() ); }
+
+ ui::Selectable::Ptr lookup( ResKind kind_r, const std::string & name_r )
const;
+
+ ui::Selectable::Ptr lookup( const sat::Solvable & solv_r ) const
+ { return lookup( solv_r.kind(), solv_r.name() ); }
+
+ ui::Selectable::Ptr lookup( const ResObject::constPtr & resolvable_r )
const
+ { return resolvable_r ? lookup( resolvable_r->satSolvable() ) :
ui::Selectable::Ptr(); }
+
+ ui::Selectable::Ptr lookup( const PoolItem & pi_r ) const
+ { return lookup( pi_r.satSolvable() ); }
+ //@}
+
+ public:

/** True if there are items of a certain kind. */
bool empty( const ResObject::Kind & kind_r ) const;

Modified: trunk/libzypp/zypp/sat/LookupAttr.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/LookupAttr.cc?rev=9496&r1=9495&r2=9496&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/LookupAttr.cc (original)
+++ trunk/libzypp/zypp/sat/LookupAttr.cc Wed Apr 9 21:37:13 2008
@@ -63,6 +63,14 @@
bool LookupAttr::empty() const
{ return begin() == end(); }

+ LookupAttr::size_type LookupAttr::size() const
+ {
+ size_type c = 0;
+ for_( it, begin(), end() )
+ ++c;
+ return c;
+ }
+
std::ostream & operator<<( std::ostream & str, const LookupAttr & obj )
{
if ( obj.attr() == SolvAttr::noAttr )

Modified: trunk/libzypp/zypp/sat/LookupAttr.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/LookupAttr.h?rev=9496&r1=9495&r2=9496&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/LookupAttr.h (original)
+++ trunk/libzypp/zypp/sat/LookupAttr.h Wed Apr 9 21:37:13 2008
@@ -70,6 +70,9 @@
*/
class LookupAttr
{
+ public:
+ typedef unsigned size_type;
+
public:
/** Default ctor finds nothing. */
LookupAttr()
@@ -104,6 +107,11 @@
/** Whether the query is empty. */
bool empty() const;

+ /** Ammount of results.
+ * \note This is not a cheap call. It runs the query.
+ */
+ size_type size() const;
+
/** TransformIterator returning an \ref iterator vaue of type \c
_ResultT. */
template<class _ResultT, class _AttrT> class transformIterator;
//@}

Added: trunk/libzypp/zypp/sat/SolvIterMixin.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/SolvIterMixin.cc?rev=9496&view=auto
==============================================================================
--- trunk/libzypp/zypp/sat/SolvIterMixin.cc (added)
+++ trunk/libzypp/zypp/sat/SolvIterMixin.cc Wed Apr 9 21:37:13 2008
@@ -0,0 +1,37 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/sat/SolvIterMixin.cc
+ *
+*/
+//#include <iostream>
+//#include "zypp/base/Logger.h"
+
+#include "zypp/sat/SolvIterMixin.h"
+#include "zypp/ResPoolProxy.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace ui
+ { /////////////////////////////////////////////////////////////////
+
+ Selectable_Ptr asSelectable::operator()( const sat::Solvable & sov_r )
const
+ {
+ return ResPool::instance().proxy().lookup( sov_r );
+ }
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace ui
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////

Added: trunk/libzypp/zypp/sat/SolvIterMixin.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/SolvIterMixin.h?rev=9496&view=auto
==============================================================================
--- trunk/libzypp/zypp/sat/SolvIterMixin.h (added)
+++ trunk/libzypp/zypp/sat/SolvIterMixin.h Wed Apr 9 21:37:13 2008
@@ -0,0 +1,132 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/sat/SolvIterMixin.h
+ *
+*/
+#ifndef ZYPP_SAT_SOLVITERMIXIN_H
+#define ZYPP_SAT_SOLVITERMIXIN_H
+
+#include <iosfwd>
+
+#include "zypp/base/PtrTypes.h"
+#include "zypp/base/Iterator.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ class asPoolItem; // transform functor
+
+ namespace ui
+ {
+ class asSelectable; // transform functor
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ namespace sat
+ { /////////////////////////////////////////////////////////////////
+
+ class Solvable;
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : SolvIterMixin<Derived,DerivedSolvable_iterator>
+ //
+ /** Base class providing common iterator types based on a \ref Solvable
iterator.
+ *
+ * A class deriving from \ref SolvIterMixin must provide two methods
+ * \c begin and \c end returning iterator over \ref sat::Solvable.
+ *
+ * \ref SolvIterMixin will then provide iterators over the corresponding
+ * \ref PoolItem and \ref ui::Selectable_Ptr.
+ *
+ * \code
+ * namespace detail
+ * {
+ * class WhatProvidesIterator;
+ * }
+ *
+ * class WhatProvides : public
SolvIterMixin<WhatProvides,detail::WhatProvidesIterator>
+ * {
+ * public:
+ * typedef detail::WhatProvidesIterator const_iterator;
+ *
+ * // Iterator pointing to the first Solvable.
+ * const_iterator begin() const;
+ *
+ * // Iterator pointing behind the last Solvable.
+ * const_iterator end() const;
+ *
+ * };
+ *
+ * namespace detail
+ * {
+ * class WhatProvidesIterator : public boost::iterator_adaptor<
+ * WhatProvidesIterator // Derived
+ * , const detail::IdType * // Base
+ * , const Solvable // Value
+ * , boost::forward_traversal_tag // CategoryOrTraversal
+ * , const Solvable // Reference
+ * >
+ * {
+ * ...
+ * };
+ * }
+ * \endcode
+ * \ingroup g_CRTP
+ */
+ template <class Derived,class DerivedSolvable_iterator>
+ class SolvIterMixin
+ {
+ public:
+ /** \name Iterate as Solvable */
+ //@{
+ typedef DerivedSolvable_iterator Solvable_iterator;
+ Solvable_iterator solvableBegin() const
+ { return self().begin(); }
+ Solvable_iterator solvableEnd() const
+ { return self().end(); }
+ //@}
+
+ /** \name Iterate as PoolItem */
+ //@{
+ typedef transform_iterator<asPoolItem,Solvable_iterator>
PoolItem_iterator;
+ PoolItem_iterator poolItemBegin() const
+ { return make_transform_iterator( solvableBegin(), asPoolItem() ); }
+ PoolItem_iterator poolItemEnd() const
+ { return make_transform_iterator( solvableEnd(), asPoolItem() ); }
+ //@}
+
+ /** \name Iterate ui::Selectable::Ptr */
+ //@{
+ typedef transform_iterator<ui::asSelectable,Solvable_iterator>
Selectable_iterator;
+ Selectable_iterator selectableBegin() const
+ { return make_transform_iterator( solvableBegin(), ui::asSelectable()
); }
+ Selectable_iterator selectableEnd() const
+ { return make_transform_iterator( solvableEnd(), ui::asSelectable() );
}
+ //@}
+
+ private:
+ const Derived & self() const
+ { return *static_cast<const Derived*>( this ); }
+ protected:
+ SolvIterMixin() {}
+ ~SolvIterMixin() {}
+ SolvIterMixin(const SolvIterMixin &) {}
+ void operator=(const SolvIterMixin &) {}
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace sat
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_SAT_SOLVITERMIXIN_H

Modified: trunk/libzypp/zypp/sat/Solvable.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Solvable.cc?rev=9496&r1=9495&r2=9496&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/Solvable.cc (original)
+++ trunk/libzypp/zypp/sat/Solvable.cc Wed Apr 9 21:37:13 2008
@@ -32,6 +32,49 @@
namespace sat
{ /////////////////////////////////////////////////////////////////

+ Solvable::SplitIdent::SplitIdent( IdString ident_r )
+ {
+ if ( ! ident_r )
+ return;
+
+ const char * ident = ident_r.c_str();
+ const char * sep = ::strchr( ident, ':' );
+
+ // no ':' in package names (hopefully)
+ if ( ! sep )
+ {
+ _kind = ResKind::package;
+ _name = ident_r.asString();
+ return;
+ }
+
+ // save name
+ _name = sep+1;
+ // quick check for well known kinds
+ if ( sep-ident >= 4 )
+ {
+ switch ( ident[3] )
+ {
+#define OUTS(K,S) if ( !::strncmp( ident, ResKind::K.c_str(), S ) ) _kind =
ResKind::K
+ // ----v
+ case 'c': OUTS( patch, 5 ); return; break;
+ case 'd': OUTS( product, 7 ); return; break;
+ case 'i': OUTS( script, 6 ); return; break;
+ case 'k': OUTS( package, 7 ); return; break;
+ case 'm': OUTS( atom, 4 ); return; break;
+ case 'p': OUTS( srcpackage, 10 ); return; break;
+ case 's': OUTS( message, 7 ); return; break;
+ case 't': OUTS( pattern, 7 ); return; break;
+#undef OUTS
+ }
+ }
+
+ // an unknown kind
+ _kind = ResKind( std::string( ident, sep-ident ) );
+ }
+
+ /////////////////////////////////////////////////////////////////
+
const Solvable Solvable::noSolvable;

/////////////////////////////////////////////////////////////////
@@ -343,7 +386,7 @@

bool Solvable::isSatisfied() const
{
- NO_SOLVABLE_RETURN( false );
+ NO_SOLVABLE_RETURN( false );
if (solvable_trivial_installable (_solvable,
Pool::instance().systemRepo().get()) == 1)
return true;
else

Modified: trunk/libzypp/zypp/sat/Solvable.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Solvable.h?rev=9496&r1=9495&r2=9496&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/Solvable.h (original)
+++ trunk/libzypp/zypp/sat/Solvable.h Wed Apr 9 21:37:13 2008
@@ -209,6 +209,21 @@
/** Return next Solvable in \ref Repo (or \ref noSolvable). */
Solvable nextInRepo() const;

+ /** Helper that splits an identifier into kind and name.
+ * \see \ref ident
+ */
+ class SplitIdent
+ {
+ public:
+ SplitIdent() {}
+ SplitIdent( IdString ident_r );
+ ResKind kind() const { return _kind; }
+ std::string name() const { return _name; }
+ private:
+ ResKind _kind;
+ std::string _name;
+ };
+
public:
/** Expert backdoor. */
::_Solvable * get() const;

Modified: trunk/libzypp/zypp/sat/SolvableSet.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/SolvableSet.h?rev=9496&r1=9495&r2=9496&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/SolvableSet.h (original)
+++ trunk/libzypp/zypp/sat/SolvableSet.h Wed Apr 9 21:37:13 2008
@@ -17,6 +17,7 @@
#include "zypp/base/PtrTypes.h"
#include "zypp/base/Tr1hash.h"
#include "zypp/sat/Solvable.h"
+#include "zypp/sat/SolvIterMixin.h"

///////////////////////////////////////////////////////////////////
namespace zypp
@@ -31,7 +32,7 @@
//
/** Solvable set wrapper to allow adding additioanal convenience iterators.
*/
- class SolvableSet
+ class SolvableSet : public
SolvIterMixin<SolvableSet,std::tr1::unordered_set<Solvable>::const_iterator>
{
friend std::ostream & operator<<( std::ostream & str, const SolvableSet
& obj );


Modified: trunk/libzypp/zypp/sat/WhatProvides.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/WhatProvides.h?rev=9496&r1=9495&r2=9496&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/WhatProvides.h (original)
+++ trunk/libzypp/zypp/sat/WhatProvides.h Wed Apr 9 21:37:13 2008
@@ -18,6 +18,7 @@
#include "zypp/base/PtrTypes.h"
#include "zypp/sat/detail/PoolMember.h"
#include "zypp/sat/Solvable.h"
+#include "zypp/sat/SolvIterMixin.h"

///////////////////////////////////////////////////////////////////
namespace zypp
@@ -26,6 +27,11 @@
namespace sat
{ /////////////////////////////////////////////////////////////////

+ namespace detail
+ {
+ class WhatProvidesIterator;
+ }
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : WhatProvides
@@ -78,7 +84,8 @@
* }
* \endcode
*/
- class WhatProvides : protected detail::PoolMember
+ class WhatProvides : public
SolvIterMixin<WhatProvides,detail::WhatProvidesIterator>,
+ protected detail::PoolMember
{
public:
typedef Solvable value_type;
@@ -111,7 +118,7 @@
size_type size() const;

public:
- class const_iterator;
+ typedef detail::WhatProvidesIterator const_iterator;

/** Iterator pointing to the first \ref Solvable. */
const_iterator begin() const;
@@ -128,14 +135,16 @@
/** \relates WhatProvides Stream output */
std::ostream & operator<<( std::ostream & str, const WhatProvides & obj );

+ namespace detail
+ {
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : WhatProvides::const_iterator
//
/** \ref WhatProvides iterator.
*/
- class WhatProvides::const_iterator : public boost::iterator_adaptor<
- const_iterator // Derived
+ class WhatProvidesIterator : public boost::iterator_adaptor<
+ WhatProvidesIterator // Derived
, const detail::IdType * // Base
, const Solvable // Value
, boost::forward_traversal_tag // CategoryOrTraversal
@@ -143,12 +152,12 @@
>
{
public:
- const_iterator()
- : const_iterator::iterator_adaptor_( 0 )
+ WhatProvidesIterator()
+ : iterator_adaptor_( 0 )
{}

- explicit const_iterator( const sat::detail::IdType * _idx )
- : const_iterator::iterator_adaptor_( _idx )
+ explicit WhatProvidesIterator( const sat::detail::IdType * _idx )
+ : iterator_adaptor_( _idx )
{}

private:
@@ -169,6 +178,7 @@
{ ++base_reference(); }
};
///////////////////////////////////////////////////////////////////
+ }

inline WhatProvides::const_iterator WhatProvides::begin() const
{ return const_iterator( _begin ); }

Modified: trunk/libzypp/zypp/ui/Selectable.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ui/Selectable.cc?rev=9496&r1=9495&r2=9496&view=diff
==============================================================================
--- trunk/libzypp/zypp/ui/Selectable.cc (original)
+++ trunk/libzypp/zypp/ui/Selectable.cc Wed Apr 9 21:37:13 2008
@@ -22,6 +22,8 @@
namespace ui
{ /////////////////////////////////////////////////////////////////

+ IMPL_PTR_TYPE(Selectable);
+
///////////////////////////////////////////////////////////////////
//
// METHOD NAME : Selectable::Selectable
@@ -80,12 +82,12 @@

Selectable::available_iterator Selectable::availableBegin() const
{ return _pimpl->availableBegin(); }
-
+
Selectable::available_iterator Selectable::availableEnd() const
{ return _pimpl->availableEnd(); }

////////////////////////////////////////////////////////////////////////
-
+
bool Selectable::installedEmpty() const
{ return _pimpl->installedEmpty(); }

@@ -103,7 +105,7 @@

bool Selectable::isUnmaintained() const
{ return _pimpl->isUnmaintained(); }
-
+


ResStatus::TransactByValue Selectable::modifiedBy() const

Modified: trunk/libzypp/zypp/ui/Selectable.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ui/Selectable.h?rev=9496&r1=9495&r2=9496&view=diff
==============================================================================
--- trunk/libzypp/zypp/ui/Selectable.h (original)
+++ trunk/libzypp/zypp/ui/Selectable.h Wed Apr 9 21:37:13 2008
@@ -29,6 +29,8 @@
namespace ui
{ /////////////////////////////////////////////////////////////////

+ DEFINE_PTR_TYPE(Selectable);
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : Selectable
@@ -109,8 +111,8 @@
*/
available_size_type availableSize() const;

- /**
- * Number of available objects.
+ /**
+ * Number of available objects.
* \deprecated Use availableSize
*/
ZYPP_DEPRECATED available_size_type availableObjs() const
@@ -154,8 +156,8 @@
bool hasObject() const
{ return (! installedEmpty()) || candidateObj(); }

- /**
- * True if installed object is present.
+ /**
+ * True if installed object is present.
* \deprecated Use ! installedEmpty()
*/
ZYPP_DEPRECATED bool hasInstalledObj() const
@@ -214,7 +216,7 @@
//@}

public:
- /**
+ /**
* \name Special inteface for Y2UI.
* \note This interface acts on \ref ResStatus::USER level.
* The \ref Status enum, and allowed state transitions are
@@ -225,7 +227,7 @@
/** Return the current Status */
Status status() const;

- /**
+ /**
* Try to set a new Status.
* Returns \c false if the transitions is not allowed.
*/
@@ -265,6 +267,20 @@
/** \relates Selectable Stream output */
std::ostream & operator<<( std::ostream & str, const Selectable & obj );

+ /** Solvable to Selectable transform functor.
+ * \relates Selectable
+ * \relates sat::SolvIterMixin
+ */
+ struct asSelectable
+ {
+ typedef Selectable_Ptr result_type;
+
+ Selectable_Ptr operator()( const sat::Solvable & solv_r ) const;
+
+ Selectable_Ptr operator()( const PoolItem & pi_r ) const
+ { return operator()( pi_r.satSolvable() ); }
+ };
+
/////////////////////////////////////////////////////////////////
} // namespace ui
///////////////////////////////////////////////////////////////////

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

< Previous Next >
This Thread
  • No further messages