Author: mlandres
Date: Fri Jan 25 19:09:15 2008
New Revision: 8374
URL: http://svn.opensuse.org/viewcvs/zypp?rev=8374&view=rev
Log:
added CapDetail
Modified:
branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/NewPool.cc
branches/tmp/ma/jump_sat/libzypp/zypp/Capabilities.h
branches/tmp/ma/jump_sat/libzypp/zypp/Capability.cc
branches/tmp/ma/jump_sat/libzypp/zypp/Capability.h
branches/tmp/ma/jump_sat/libzypp/zypp/IdStringType.h
branches/tmp/ma/jump_sat/libzypp/zypp/sat/detail/PoolImpl.cc
branches/tmp/ma/jump_sat/libzypp/zypp/sat/detail/PoolMember.h
Modified: branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/NewPool.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/NewPool.cc?rev=8374&r1=8373&r2=8374&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/NewPool.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/devel/devel.ma/NewPool.cc Fri Jan 25 19:09:15 2008
@@ -34,6 +34,7 @@
#include "zypp/sat/Pool.h"
#include "zypp/sat/Repo.h"
#include "zypp/sat/Solvable.h"
+#include "zypp/sat/detail/PoolImpl.h"
#include
@@ -423,13 +424,21 @@
sat::Pool satpool( sat::Pool::instance() );
- Patch::Ptr p = make<Patch>( sat::Solvable(23) );
- WAR << p << endl;
-
#if 1
sat::Repo s( satpool.addRepoSolv( "10.3.solv" ) );
//sat::Repo s( satpool.addRepoSolv( "target.solv" ) );
+ Capability lc( "foo <= 13" );
+ Capability rc( "Baa > 5" );
+ int nid = ::rel2id( satpool.get(), lc.id(), rc.id(), 16, /*create*/true );
+ Capability t( nid );
+ INT << lc << endl;
+ INT << rc << endl;
+ INT << t << endl;
+ INT << dump(t) << endl;
+
+ if ( 0 )
+ {
Capabilities r( (*satpool.solvablesBegin())[Dep::PROVIDES] );
MIL << r << endl;
Capabilities::const_iterator it = r.begin();
@@ -437,7 +446,18 @@
it = ++r.begin();
DBG << *it << endl;
- if ( 1 )
+
+
+ r = (*satpool.solvablesBegin())[Dep::REQUIRES];
+ for_( it, r.begin(), r.end() )
+ {
+ if ( it.tagged() )
+ WAR << *it << " (is prereq)" << endl;
+ else
+ MIL << dump(*it) << endl;
+ }
+ }
+ if ( 0 )
{
std::for_each( make_filter_iterator( filter::byValue( &sat::Solvable::name, "bash" ),
satpool.solvablesBegin(), satpool.solvablesEnd() ),
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/Capabilities.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/Capabilities.h?rev=8374&r1=8373&r2=8374&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/Capabilities.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/Capabilities.h Fri Jan 25 19:09:15 2008
@@ -14,6 +14,7 @@
#include <iosfwd>
+#include "zypp/base/DefaultIntegral.h"
#include "zypp/sat/detail/PoolMember.h"
#include "zypp/Capability.h"
@@ -104,6 +105,26 @@
: const_iterator::iterator_adaptor_( _idx )
{ assignVal(); }
+ public:
+ /** Return \c true if the \ref Capability is \c tagged.
+ * The meaning of \c tagged depends on the kind of dependency you
+ * are processing. It is a hint that the iteratir skipped some
+ * internal marker, indicating that subsequent cabailities have
+ * a special property. Within a \ref Solvables requirements e.g.
+ * the pre-requirements are tagged.
+ * \code
+ * Capabilities req( solvable.requires() );
+ * for_( it, req.begin(), req.end() )
+ * {
+ * if ( it.tagged() )
+ * cout << *it << " (is prereq)" << endl;
+ * else
+ * cout << *it << endl;
+ * }
+ * \endcode
+ */
+ bool tagged() const { return _tagged; }
+
private:
friend class boost::iterator_core_access;
@@ -120,7 +141,11 @@
void increment()
{ // jump over satsolvers internal ids.
- if ( sat::detail::isDepMarkerId( *(++base_reference()) ) ) ++base_reference();
+ if ( sat::detail::isDepMarkerId( *(++base_reference()) ) )
+ {
+ _tagged = true;
+ ++base_reference();
+ }
assignVal();
}
@@ -129,6 +154,7 @@
{ _val = ( base() ) ? Capability( *base() ) : Capability::Null; }
mutable Capability _val;
+ DefaultIntegral _tagged;
};
///////////////////////////////////////////////////////////////////
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/Capability.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/Capability.cc?rev=8374&r1=8373&r2=8374&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/Capability.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/Capability.cc Fri Jan 25 19:09:15 2008
@@ -93,31 +93,6 @@
return relFromStr( pool_r, name, op, ed, kind_r );
}
- // By now restrict matching to plain 'name [op edition]'
- struct CapHelp : protected sat::detail::PoolMember
- {
- CapHelp( sat::detail::IdType id_r )
- : _name( id_r )
- {
- if ( ISRELDEP(id_r) )
- {
- ::Reldep * rd = GETRELDEP( myPool().getPool(), id_r );
- if ( ! Rel::isRel( rd->flags ) || ISRELDEP(rd->name) || ISRELDEP(rd->evr) )
- _op = Rel::NONE;
- else
- {
- _name = IdString( rd->name );
- _op = Rel( rd->flags );
- _ed = Edition( rd->evr );
- }
- }
- }
-
- IdString _name;
- Rel _op;
- Edition _ed;
- };
-
/////////////////////////////////////////////////////////////////
} // namespace
///////////////////////////////////////////////////////////////////
@@ -168,22 +143,23 @@
if ( lhs == rhs )
return true;
- CapHelp l( lhs );
- if ( l._op == Rel::NONE )
+ CapDetail l( lhs );
+ if ( ! l.isSimple() )
return false;
- CapHelp r( rhs );
- if ( r._op == Rel::NONE )
+ CapDetail r( rhs );
+ if ( r.isSimple() )
return false;
- if ( l._name != r._name )
+ if ( l.name() != r.name() )
return false;
- if ( l._op == Rel::ANY || r._op == Rel::ANY )
+ if ( l.isNamed() || r.isNamed() )
return true;
- return overlaps( Edition::MatchRange( l._op, l._ed ),
- Edition::MatchRange( r._op, r._ed ) );
+ // both are versioned:
+ return overlaps( Edition::MatchRange( l.op(), l.ed() ),
+ Edition::MatchRange( r.op(), r.ed() ) );
}
bool Capability::isInterestingFileSpec( const char * name_r )
@@ -206,6 +182,88 @@
return str << obj.c_str();
}
+ std::ostream & dumpOn( std::ostream & str, const Capability & obj )
+ {
+ return str << obj.detail();
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : CapDetail
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ void CapDetail::_init()
+ {
+ // : _kind( NOCAP ), _lhs( id_r ), _rhs( 0 ), _flag( 0 )
+
+ if ( !_lhs )
+ return; // NOCAP
+
+ if ( ! ISRELDEP(_lhs) )
+ {
+ _kind = NAMED;
+ return;
+ }
+
+ ::Reldep * rd = GETRELDEP( myPool().getPool(), _lhs );
+ _lhs = rd->name;
+ _rhs = rd->evr;
+ _flag = rd->flags;
+
+ _kind = Rel::isRel( _flag ) ? VERSIONED : EXPRESSION;
+ }
+
+ /******************************************************************
+ **
+ ** FUNCTION NAME : operator<<
+ ** FUNCTION TYPE : std::ostream &
+ */
+ std::ostream & operator<<( std::ostream & str, const CapDetail & obj )
+ {
+ switch ( obj.kind() )
+ {
+ case CapDetail::NOCAP:
+ return str << "<NoCap>";
+ break;
+ case CapDetail::NAMED:
+ return str << obj.name();
+ break;
+ case CapDetail::VERSIONED:
+ return str << obj.name() << " " << obj.op() << " " << obj.ed();
+ break;
+ case CapDetail::EXPRESSION:
+ return str << obj.lhs().detail() << " " << obj.capRel() << " " << obj.rhs().detail();
+ break;
+ }
+ return str << "<UnknownCap>";
+ }
+
+ std::ostream & operator<<( std::ostream & str, CapDetail::Kind obj )
+ {
+ switch ( obj )
+ {
+ case CapDetail::NOCAP: return str << "NoCap"; break;
+ case CapDetail::NAMED: return str << "NamedCap"; break;
+ case CapDetail::VERSIONED: return str << "VersionedCap"; break;
+ case CapDetail::EXPRESSION: return str << "CapExpression"; break;
+ }
+ return str << "UnknownCap";
+ }
+
+ std::ostream & operator<<( std::ostream & str, CapDetail::CapRel obj )
+ {
+ switch ( obj )
+ {
+ case CapDetail::REL_NONE: return str << "NoCapRel"; break;
+ case CapDetail::CAP_AND: return str << "AND"; break;
+ case CapDetail::CAP_OR: return str << "OR"; break;
+ case CapDetail::CAP_WITH: return str << "WITH"; break;
+ case CapDetail::CAP_NAMESPACE: return str << "NAMESPACE"; break;
+ }
+ return str << "UnknownCapRel";
+ }
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/Capability.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/Capability.h?rev=8374&r1=8373&r2=8374&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/Capability.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/Capability.h Fri Jan 25 19:09:15 2008
@@ -16,11 +16,12 @@
#include <set>
#include "zypp/base/SafeBool.h"
-#include "zypp/base/Deprecated.h"
#include "zypp/sat/detail/PoolMember.h"
#include "zypp/IdString.h"
+#include "zypp/Edition.h"
+#include "zypp/Rel.h"
#include "zypp/ResTraits.h"
#include "zypp/CapMatch.h"
@@ -29,9 +30,8 @@
namespace zypp
{ /////////////////////////////////////////////////////////////////
- class Rel;
- class Edition;
class Capability;
+ class CapDetail;
typedef std::set<Capability> CapabilitySet;
@@ -51,7 +51,6 @@
* // avoid this:
* Capability( "pattern:foo", ResKind::pattern ) ==> 'pattern:pattern:foo'
* \endcode
- *
*/
class Capability: protected sat::detail::PoolMember,
private base::SafeBool<Capability>
@@ -118,9 +117,13 @@
{ return string(); }
public:
- /** \name Match two Capabilities
+ /** Helper providing more detailed information about a \ref Capability. */
+ CapDetail detail() const;
+
+ public:
+ /** \name Match two simple Capabilities
* \todo check whether we must promote string to Capability in order to match.
- */
+ */
//@{
static bool matches( const Capability & lhs, const Capability & rhs ) { return _doMatch( lhs.id(), rhs.id() ); }
static bool matches( const Capability & lhs, const IdString & rhs ) { return _doMatch( lhs.id(), rhs.id() ); }
@@ -184,6 +187,9 @@
/** \relates Capability Stream output */
std::ostream & operator<<( std::ostream & str, const Capability & obj );
+ /** \relates Capability Detailed stream output */
+ std::ostream & dumpOn( std::ostream & str, const Capability & obj );
+
/** \relates Capability */
inline bool operator==( const Capability & lhs, const Capability & rhs )
{ return lhs.id() == rhs.id(); }
@@ -196,6 +202,92 @@
inline bool operator<( const Capability & lhs, const Capability & rhs )
{ return lhs.id() < rhs.id(); }
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : CapDetail
+ //
+ /** Helper providing more detailed information about a \ref Capability.
+ */
+ class CapDetail: protected sat::detail::PoolMember
+ {
+ public:
+ enum Kind
+ {
+ NOCAP = 0x00,
+ NAMED = 0x01,
+ VERSIONED = 0x02,
+ EXPRESSION = 0x04
+ };
+
+ /** Enum values corresponding with libsatsolver defines.
+ * MPL check in PoolImpl.cc
+ */
+ enum CapRel
+ {
+ REL_NONE = 0,
+ CAP_AND = 16,
+ CAP_OR = 17,
+ CAP_WITH = 18,
+ CAP_NAMESPACE = 19
+ };
+
+ public:
+ CapDetail()
+ : _kind( NOCAP ), _lhs( 0 ), _rhs( 0 ), _flag( 0 )
+ {}
+ explicit CapDetail( const Capability & cap_r )
+ : _kind( NOCAP ), _lhs( cap_r.id() ), _rhs( 0 ), _flag( 0 )
+ { _init(); }
+ explicit CapDetail( sat::detail::IdType id_r )
+ : _kind( NOCAP ), _lhs( id_r ), _rhs( 0 ), _flag( 0 )
+ { _init(); }
+
+ public:
+ Kind kind() const { return _kind; }
+ bool isNull() const { return _kind == NOCAP; }
+ bool isNamed() const { return _kind == NAMED; }
+ bool isVersioned() const { return _kind == VERSIONED; }
+ bool isSimple() const { return _kind & (NAMED|VERSIONED); }
+ bool isExpression() const { return _kind == EXPRESSION; }
+
+ /** \name Is simple: <tt>name [op edition]</tt> */
+ //@{
+ IdString name() const { return isSimple() ? IdString( _lhs ) : IdString(); }
+ Rel op() const { return isVersioned() ? Rel( _flag ) : Rel::ANY; }
+ Edition ed() const { return isVersioned() ? Edition( _rhs ) : Edition(); }
+ //@}
+
+ /** \name Is expression <tt>cap op cap</tt> */
+ //@{
+ Capability lhs() const { return isExpression() ? Capability( _lhs ) : Capability::Null; }
+ CapRel capRel() const { return isExpression() ? CapRel(_flag) : REL_NONE; }
+ Capability rhs() const { return isExpression() ? Capability( _rhs ) : Capability::Null; }
+ //@}
+
+ private:
+ void _init();
+ private:
+ Kind _kind;
+ sat::detail::IdType _lhs;
+ sat::detail::IdType _rhs;
+ unsigned _flag;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates CapDetail Stream output */
+ std::ostream & operator<<( std::ostream & str, const CapDetail & obj );
+
+ /** \relates CapDetail Stream output */
+ std::ostream & operator<<( std::ostream & str, CapDetail::Kind obj );
+
+ /** \relates CapDetail Stream output */
+ std::ostream & operator<<( std::ostream & str, CapDetail::CapRel obj );
+
+ ///////////////////////////////////////////////////////////////////
+
+ inline CapDetail Capability::detail() const
+ { return CapDetail( _id ); }
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/IdStringType.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/IdStringType.h?rev=8374&r1=8373&r2=8374&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/IdStringType.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/IdStringType.h Fri Jan 25 19:09:15 2008
@@ -187,7 +187,7 @@
/** \relates IdStringType NotEqual */
template <class Derived>
inline bool operator!=( const IdStringType<Derived> & lhs, const IdStringType<Derived> & rhs )
- { return lhs.idStr().compareEQ( rhs.idStr() ); }
+ { return ! lhs.idStr().compareEQ( rhs.idStr() ); }
/** \overload */
template <class Derived>
inline bool operator!=( const IdStringType<Derived> & lhs, const IdString & rhs )
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/sat/detail/PoolImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/sat/detail/PoolImpl.cc?rev=8374&r1=8373&r2=8374&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/sat/detail/PoolImpl.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/sat/detail/PoolImpl.cc Fri Jan 25 19:09:15 2008
@@ -19,6 +19,7 @@
#include "zypp/ZConfig.h"
#include "zypp/sat/detail/PoolImpl.h"
+#include "zypp/Capability.h"
using std::endl;
@@ -32,14 +33,20 @@
namespace detail
{ /////////////////////////////////////////////////////////////////
- // MPL checks for satlib constants we redefine:
+ // MPL checks for satlib constants we redefine to avoid
+ // includes and defines.
BOOST_MPL_ASSERT_RELATION( noId, ==, STRID_NULL );
BOOST_MPL_ASSERT_RELATION( emptyId, ==, STRID_EMPTY );
BOOST_MPL_ASSERT_RELATION( solvablePrereqMarker, ==, SOLVABLE_PREREQMARKER );
BOOST_MPL_ASSERT_RELATION( solvableFileMarker, ==, SOLVABLE_FILEMARKER );
- /////////////////////////////////////////////////////////////////
+ BOOST_MPL_ASSERT_RELATION( CapDetail::CAP_AND, ==, REL_AND );
+ BOOST_MPL_ASSERT_RELATION( CapDetail::CAP_OR, ==, REL_OR );
+ BOOST_MPL_ASSERT_RELATION( CapDetail::CAP_WITH, ==, REL_WITH );
+ BOOST_MPL_ASSERT_RELATION( CapDetail::CAP_NAMESPACE, ==, REL_NAMESPACE );
+
+ /////////////////////////////////////////////////////////////////
void logSat( struct _Pool *, void *data, int type, const char *logString )
{
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/sat/detail/PoolMember.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/sat/detail/PoolMember.h?rev=8374&r1=8373&r2=8374&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/sat/detail/PoolMember.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/sat/detail/PoolMember.h Fri Jan 25 19:09:15 2008
@@ -72,13 +72,16 @@
static const IdType noId( 0 );
static const IdType emptyId( 1 );
- /** Internal ids satlib includes in dependencies. */
- static const IdType solvablePrereqMarker( 16 ); // MPL check in PoolImpl.cc
- static const IdType solvableFileMarker ( 17 ); // MPL check in PoolImpl.cc
+ /** Internal ids satlib includes in dependencies.
+ * MPL check in PoolImpl.cc
+ */
+ static const IdType solvablePrereqMarker( 16 );
+ static const IdType solvableFileMarker ( 17 );
/** Test for internal ids satlib includes in dependencies. */
inline bool isDepMarkerId( IdType id_r )
{ return( id_r == solvablePrereqMarker || id_r == solvableFileMarker ); }
+
/** Id type to connect \ref Solvable and sat-solvable.
* Indext into solvable array.
*/
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org