Author: mlandres
Date: Tue Dec 11 21:56:36 2007
New Revision: 8110
URL: http://svn.opensuse.org/viewcvs/zypp?rev=8110&view=rev
Log:
- add sat::Capability
- add sat::Capabilities (read only Capability container)
- add acessor to Capabilities in sat::Solvable
- add sat::IdStr vs. std::string / const char* comparison
Added:
trunk/libzypp/zypp/sat/Capabilities.cc
trunk/libzypp/zypp/sat/Capabilities.h
trunk/libzypp/zypp/sat/Capability.cc
- copied, changed from r8085, trunk/libzypp/zypp/sat/IdRel.cc
trunk/libzypp/zypp/sat/Capability.h
- copied, changed from r8085, trunk/libzypp/zypp/sat/IdRel.h
Removed:
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/Solvable.cc
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=8110&r1=8109&r2=8110&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.ma/NewPool.cc (original)
+++ trunk/libzypp/devel/devel.ma/NewPool.cc Tue Dec 11 21:56:36 2007
@@ -152,6 +152,12 @@
return true;
}
+
+ bool operator()( const sat::Solvable & obj_r )
+ {
+ dumpOn( MIL, obj_r ) << endl;
+ return true;
+ }
};
///////////////////////////////////////////////////////////////////
@@ -373,6 +379,12 @@
}
}
+void ttt( const char * lhs, const char * rhs )
+{
+ DBG << lhs << " <=> " << rhs << " --> " << ::strcmp( lhs, rhs ) << endl;
+}
+
+
/******************************************************************
**
** FUNCTION NAME : main
@@ -385,11 +397,12 @@
sat::Pool satpool( sat::Pool::instance() );
-#if 0
+#if 1
//sat::Repo r( satpool.addRepoSolv( "sl10.1-beta7-packages.solv" ) );
- sat::Repo s( satpool.addRepoSolv( "sl10.1-beta7-selections.solv" ) );
+ //sat::Repo s( satpool.addRepoSolv( "sl10.1-beta7-selections.solv" ) );
+ sat::Repo s( satpool.addRepoSolv( "target.solv" ) );
- std::for_each( satpool.solvablesBegin(), satpool.solvablesEnd(), Print() );
+ std::for_each( satpool.solvablesBegin(), satpool.solvablesEnd(), Xprint() );
///////////////////////////////////////////////////////////////////
INT << "===[END]============================================" << endl << endl;
Modified: trunk/libzypp/zypp/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/CMakeLists.txt?rev=8110&r1=8109&r2=8110&view=diff
==============================================================================
--- trunk/libzypp/zypp/CMakeLists.txt (original)
+++ trunk/libzypp/zypp/CMakeLists.txt Tue Dec 11 21:56:36 2007
@@ -682,7 +682,8 @@
sat/Repo.cc
sat/Solvable.cc
sat/IdStr.cc
- sat/IdRel.cc
+ sat/Capability.cc
+ sat/Capabilities.cc
sat/SATResolver.cc
)
@@ -693,7 +694,8 @@
sat/Repo.h
sat/Solvable.h
sat/IdStr.h
- sat/IdRel.h
+ sat/Capability.h
+ sat/Capabilities.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=8110&r1=8109&r2=8110&view=diff
==============================================================================
--- trunk/libzypp/zypp/pool/Res2Sat.cc (original)
+++ trunk/libzypp/zypp/pool/Res2Sat.cc Tue Dec 11 21:56:36 2007
@@ -82,16 +82,17 @@
name = (*it).asString();
}
- sat::IdRel rel;
+ sat::Capability rel;
if ( refersTo<Package>( *it ) )
{
- rel = sat::IdRel( name, op, ed );
+ rel = sat::Capability( name, op, ed );
}
else
{
#warning glue kind
// non-packages prefixed by kind
- rel = sat::IdRel( name, op, ed, sat::KindId( (*it).refers().asString().c_str() ) );
+ rel = sat::Capability( name, op, ed,
+ sat::KindId( (*it).refers().asString().c_str() ) );
}
where_r = ::repo_addid_dep( slv_r->repo, where_r, rel.id(), isreq );
Added: trunk/libzypp/zypp/sat/Capabilities.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Capabilities.cc?rev=8110&view=auto
==============================================================================
--- trunk/libzypp/zypp/sat/Capabilities.cc (added)
+++ trunk/libzypp/zypp/sat/Capabilities.cc Tue Dec 11 21:56:36 2007
@@ -0,0 +1,52 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/sat/Capabilities.cc
+ *
+*/
+#include <iostream>
+#include "zypp/base/LogTools.h"
+
+#include "zypp/sat/Capabilities.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace sat
+ { /////////////////////////////////////////////////////////////////
+
+ Capabilities::size_type Capabilities::size() const
+ {
+ if ( ! _begin )
+ return 0;
+
+ const detail::IdType * end = _begin;
+ for ( ; *end; ++end )
+ ;/*NOOP*/
+ return end - _begin;
+ }
+
+ /******************************************************************
+ **
+ ** FUNCTION NAME : operator<<
+ ** FUNCTION TYPE : std::ostream &
+ */
+ std::ostream & operator<<( std::ostream & str, const Capabilities & obj )
+ {
+ return dumpRange( str << "(" << obj.size() << ")", obj.begin(), obj.end() );
+ }
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace sat
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
Added: trunk/libzypp/zypp/sat/Capabilities.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Capabilities.h?rev=8110&view=auto
==============================================================================
--- trunk/libzypp/zypp/sat/Capabilities.h (added)
+++ trunk/libzypp/zypp/sat/Capabilities.h Tue Dec 11 21:56:36 2007
@@ -0,0 +1,131 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/sat/Capabilities.h
+ *
+*/
+#ifndef ZYPP_SAT_CAPABILITIES_H
+#define ZYPP_SAT_CAPABILITIES_H
+
+#include <iosfwd>
+
+#include "zypp/sat/detail/PoolMember.h"
+#include "zypp/sat/Capability.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace sat
+ { /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : Capabilities
+ //
+ /** Container of \ref Capability (currently read only).
+ * \todo PREREQ iteration
+ */
+ class Capabilities
+ {
+ public:
+ typedef Capability value_type;
+ typedef unsigned size_type;
+
+ public:
+ /** Default ctor */
+ Capabilities()
+ : _begin( 0 )
+ {}
+
+ /** Ctor from Id pointer (for \ref Solvable). */
+ explicit
+ Capabilities( const detail::IdType * base_r )
+ : _begin( base_r )
+ {}
+
+ public:
+ /** Whether the container is empty. */
+ bool empty() const
+ { return ! ( _begin && *_begin ); }
+
+ /** Number of capabilities inside. */
+ size_type size() const;
+
+ public:
+ class const_iterator;
+
+ /** Iterator pointing to the first \ref Capability. */
+ const_iterator begin() const;
+
+ /** Iterator pointing bhind the last \ref Capability. */
+ const_iterator end() const;
+
+ private:
+ const detail::IdType * _begin;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates Capabilities Stream output */
+ std::ostream & operator<<( std::ostream & str, const Capabilities & obj );
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : Capabilities::const_iterator
+ //
+ /** \ref Capabilities iterator.
+ */
+ class Capabilities::const_iterator : public boost::iterator_adaptor<
+ const_iterator // Derived
+ , const detail::IdType * // Base
+ , const Capability // Value
+ , boost::forward_traversal_tag // CategoryOrTraversal
+ , const Capability & // Reference
+ >
+ {
+ public:
+ const_iterator()
+ : const_iterator::iterator_adaptor_( 0 )
+ {}
+
+ explicit const_iterator( const detail::IdType * _idx )
+ : const_iterator::iterator_adaptor_( _idx )
+ {}
+
+ private:
+ friend class boost::iterator_core_access;
+
+ reference dereference() const
+ { return (_val = Capability( *base() )); }
+
+ template
+ bool equal( const boost::iterator_adaptor & rhs ) const
+ { // NULL pointer is eqal pointer to Id 0
+ return ( base() == rhs.base()
+ || ( !base() && !*rhs.base() )
+ || ( !rhs.base() && !*base() ) );
+ }
+
+ private:
+ mutable Capability _val;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ inline Capabilities::const_iterator Capabilities::begin() const
+ { return const_iterator( _begin ); }
+
+ inline Capabilities::const_iterator Capabilities::end() const
+ { return const_iterator( 0 ); }
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace sat
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_SAT_CAPABILITIES_H
Copied: trunk/libzypp/zypp/sat/Capability.cc (from r8085, trunk/libzypp/zypp/sat/IdRel.cc)
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Capability.cc?p2=trunk/libzypp/zypp/sat/Capability.cc&p1=trunk/libzypp/zypp/sat/IdRel.cc&r1=8085&r2=8110&rev=8110&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/IdRel.cc (original)
+++ trunk/libzypp/zypp/sat/Capability.cc Tue Dec 11 21:56:36 2007
@@ -6,7 +6,7 @@
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
-/** \file zypp/sat/IdRel.cc
+/** \file zypp/sat/Capability.cc
*
*/
#include <iostream>
@@ -20,7 +20,7 @@
#include "zypp/Edition.h"
#include "zypp/sat/detail/PoolImpl.h"
-#include "zypp/sat/IdRel.h"
+#include "zypp/sat/Capability.h"
#include "zypp/sat/Pool.h"
using std::endl;
@@ -97,38 +97,34 @@
} // namespace
///////////////////////////////////////////////////////////////////
- const IdRel IdRel::Null( STRID_NULL );
+ const Capability Capability::Null( STRID_NULL );
/////////////////////////////////////////////////////////////////
- IdRel::IdRel( const char * str_r, const KindId & kind_r )
+ Capability::Capability( 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 )
+ Capability::Capability( 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 )
+ Capability::Capability( 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 );
- }
+ const char * Capability::c_str() const
+ { return ::dep2str( myPool().getPool(), _id ); }
- std::string IdRel::string() const
- {
- return ::dep2str( myPool().getPool(), _id );
- }
+ std::string Capability::string() const
+ { return ::dep2str( myPool().getPool(), _id ); }
/******************************************************************
**
** FUNCTION NAME : operator<<
** FUNCTION TYPE : std::ostream &
*/
- std::ostream & operator<<( std::ostream & str, const IdRel & obj )
+ std::ostream & operator<<( std::ostream & str, const Capability & obj )
{
return str << obj.c_str();
}
Copied: trunk/libzypp/zypp/sat/Capability.h (from r8085, trunk/libzypp/zypp/sat/IdRel.h)
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Capability.h?p2=trunk/libzypp/zypp/sat/Capability.h&p1=trunk/libzypp/zypp/sat/IdRel.h&r1=8085&r2=8110&rev=8110&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/IdRel.h (original)
+++ trunk/libzypp/zypp/sat/Capability.h Tue Dec 11 21:56:36 2007
@@ -6,7 +6,7 @@
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
-/** \file zypp/sat/IdRel.h
+/** \file zypp/sat/Capability.h
*
*/
#ifndef ZYPP_SAT_IDREL_H
@@ -33,38 +33,36 @@
///////////////////////////////////////////////////////////////////
//
- // CLASS NAME : IdRel
+ // CLASS NAME : Capability
//
- /** 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.
+ /** A sat capability.
*/
- class IdRel: protected detail::PoolMember,
- private base::SafeBool<IdRel>
+ class Capability: protected detail::PoolMember,
+ private base::SafeBool<Capability>
{
public:
- /** Default ctor, no relation. */
- IdRel() : _id( Null.id() ) {}
+ /** Default ctor, no capability. */
+ Capability() : _id( Null.id() ) {}
/** Ctor from id. */
- explicit IdRel( detail::IdType id_r ) : _id( id_r ) {}
+ explicit Capability( detail::IdType id_r ) : _id( id_r ) {}
/** Ctor from string.
- * If \c kind_r is provided, \c name is prefixed.
+ * If no \c kind_r is provided, the \ref Capability refers to a \c package.
*/
- explicit IdRel( const char * str_r, const KindId & kind_r = KindId::Null );
+ explicit Capability( const char * str_r, const KindId & kind_r = KindId::Null );
/** Ctor from string.
- * If \c kind_r is provided, \c name is prefixed.
+ * If no \c kind_r is provided, the \ref Capability refers to a \c package.
*/
- explicit IdRel( const std::string & str_r, const KindId & kind_r = KindId::Null );
+ explicit Capability( 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.
+ * If no \c kind_r is provided, the \ref Capability refers to a \c package.
*/
- IdRel( const std::string & name_r, Rel op_r, const Edition & ed_r, const KindId & kind_r = KindId::Null );
+ Capability( 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;
+ using base::SafeBool<Capability>::operator bool_type;
public:
- /** No or Null relation. */
- static const IdRel Null;
+ /** No or Null \ref Capability. */
+ static const Capability Null;
public:
/** Conversion to <tt>const char *</tt> */
const char * c_str() const;
@@ -79,22 +77,22 @@
detail::IdType id() const
{ return _id; }
private:
- friend base::SafeBool<IdRel>::operator bool_type() const;
+ friend base::SafeBool<Capability>::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 Capability Stream output */
+ std::ostream & operator<<( std::ostream & str, const Capability & obj );
- /** \relates IdRel */
- inline bool operator==( const IdRel & lhs, const IdRel & rhs )
+ /** \relates Capability */
+ inline bool operator==( const Capability & lhs, const Capability & rhs )
{ return lhs.id() == rhs.id(); }
- /** \relates IdRel */
- inline bool operator!=( const IdRel & lhs, const IdRel & rhs )
+ /** \relates Capability */
+ inline bool operator!=( const Capability & lhs, const Capability & rhs )
{ return lhs.id() != rhs.id(); }
Modified: trunk/libzypp/zypp/sat/IdStr.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/IdStr.cc?rev=8110&r1=8109&r2=8110&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/IdStr.cc (original)
+++ trunk/libzypp/zypp/sat/IdStr.cc Tue Dec 11 21:56:36 2007
@@ -42,16 +42,36 @@
{ return ::strlen( c_str() ); }
const char * IdStr::c_str() const
+ { return ::id2str( myPool().getPool(), _id ); }
+
+ std::string IdStr::string() const
+ { return ::id2str( myPool().getPool(), _id ); }
+
+ int IdStr::compare( const IdStr & rhs ) const
{
- return ::id2str( myPool().getPool(), _id );
+ if ( _id == rhs._id )
+ return 0;
+ // Explicitly handle IdStr::Null because
+ // it's string representation is "<NULL>"
+ // and not something less than "".
+ if ( ! _id )
+ return -1;
+ if ( ! rhs._id )
+ return 1;
+ return ::strcmp( c_str(), rhs.c_str() );
}
- std::string IdStr::string() const
+ int IdStr::compare( const char * rhs ) const
{
- return ::id2str( myPool().getPool(), _id );
+ // Explicitly handle IdStr::Null == (const char *)0
+ if ( ! _id )
+ return rhs ? -1 : 0;
+ if ( ! rhs )
+ return _id ? 1 : 0;
+ return ::strcmp( c_str(), rhs );
}
- /******************************************************************
+ /******************************************************************
**
** FUNCTION NAME : operator<<
** FUNCTION TYPE : std::ostream &
Modified: trunk/libzypp/zypp/sat/IdStr.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/IdStr.h?rev=8110&r1=8109&r2=8110&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/IdStr.h (original)
+++ trunk/libzypp/zypp/sat/IdStr.h Tue Dec 11 21:56:36 2007
@@ -67,7 +67,30 @@
/** \overload */
std::string asString() const
{ return string(); }
+ public:
+ /** Compare IdStr returning <tt>-1,0,1</tt>. */
+ int compare( const IdStr & rhs ) const;
+ /** \overload */
+ int compare( const char * rhs ) const;
+ /** \overload */
+ int compare( const std::string & rhs ) const
+ { return compare( rhs.c_str() ); }
+ /** Compare IdStr returning <tt>-1,0,1</tt>. */
+ static int compare( const IdStr & lhs, const IdStr & rhs )
+ { return lhs.compare( rhs ); }
+ /** \overload */
+ static int compare( const IdStr & lhs, const char * rhs )
+ { return lhs.compare( rhs ); }
+ /** \overload */
+ static int compare( const IdStr & lhs, const std::string & rhs )
+ { return lhs.compare( rhs ); }
+ /** \overload */
+ static int compare( const char * lhs, const IdStr & rhs )
+ { return -rhs.compare( lhs ); }
+ /** \overload */
+ static int compare( const std::string & lhs, const IdStr & rhs )
+ { return -rhs.compare( lhs ); }
public:
/** Expert backdoor. */
detail::IdType id() const
@@ -83,39 +106,103 @@
/** \relates IdStr Stream output */
std::ostream & operator<<( std::ostream & str, const IdStr & obj );
- /** \relates IdStr */
+ /** \relates IdStr Equal */
inline bool operator==( const IdStr & lhs, const IdStr & rhs )
{ return lhs.id() == rhs.id(); }
/** \overload */
inline bool operator==( const IdStr & lhs, const char * rhs )
- { if ( ! rhs ) return( ! lhs ); return( ::strcmp( lhs.c_str(), rhs ) == 0 ); }
+ { return IdStr::compare( lhs, rhs ) == 0; }
/** \overload */
inline bool operator==( const IdStr & lhs, const std::string & rhs )
- { return( lhs == rhs.c_str() ); }
+ { return IdStr::compare( lhs, rhs ) == 0; }
/** \overload */
inline bool operator==( const char * lhs, const IdStr & rhs )
- { return( rhs == lhs ); }
+ { return IdStr::compare( lhs, rhs ) == 0; }
/** \overload */
inline bool operator==( const std::string & lhs, const IdStr & rhs )
- { return( rhs == lhs ); }
+ { return IdStr::compare( lhs, rhs ) == 0; }
- /** \relates IdStr */
+ /** \relates IdStr NotEqual */
inline bool operator!=( const IdStr & lhs, const IdStr & rhs )
- { return ! ( lhs == rhs ); }
+ { return lhs.id() != rhs.id(); }
/** \overload */
inline bool operator!=( const IdStr & lhs, const char * rhs )
- { return ! ( lhs == rhs ); }
+ { return IdStr::compare( lhs, rhs ) != 0; }
/** \overload */
inline bool operator!=( const IdStr & lhs, const std::string & rhs )
- { return ! ( lhs == rhs ); }
+ { return IdStr::compare( lhs, rhs ) != 0; }
/** \overload */
inline bool operator!=( const char * lhs, const IdStr & rhs )
- { return ! ( lhs == rhs ); }
+ { return IdStr::compare( lhs, rhs ) != 0; }
/** \overload */
inline bool operator!=( const std::string & lhs, const IdStr & rhs )
- { return ! ( lhs == rhs ); }
+ { return IdStr::compare( lhs, rhs ) != 0; }
+
+ /** \relates IdStr Less */
+ inline bool operator<( const IdStr & lhs, const IdStr & rhs )
+ { return IdStr::compare( lhs, rhs ) < 0; }
+ /** \overload */
+ inline bool operator<( const IdStr & lhs, const char * rhs )
+ { return IdStr::compare( lhs, rhs ) < 0; }
+ /** \overload */
+ inline bool operator<( const IdStr & lhs, const std::string & rhs )
+ { return IdStr::compare( lhs, rhs ) < 0; }
+ /** \overload */
+ inline bool operator<( const char * lhs, const IdStr & rhs )
+ { return IdStr::compare( lhs, rhs ) < 0; }
+ /** \overload */
+ inline bool operator<( const std::string & lhs, const IdStr & rhs )
+ { return IdStr::compare( lhs, rhs ) < 0; }
+
+ /** \relates IdStr LessEqual*/
+ inline bool operator<=( const IdStr & lhs, const IdStr & rhs )
+ { return IdStr::compare( lhs, rhs ) <= 0; }
+ /** \overload */
+ inline bool operator<=( const IdStr & lhs, const char * rhs )
+ { return IdStr::compare( lhs, rhs ) <= 0; }
+ /** \overload */
+ inline bool operator<=( const IdStr & lhs, const std::string & rhs )
+ { return IdStr::compare( lhs, rhs ) <= 0; }
+ /** \overload */
+ inline bool operator<=( const char * lhs, const IdStr & rhs )
+ { return IdStr::compare( lhs, rhs ) <= 0; }
+ /** \overload */
+ inline bool operator<=( const std::string & lhs, const IdStr & rhs )
+ { return IdStr::compare( lhs, rhs ) <= 0; }
+
+ /** \relates IdStr Greater */
+ inline bool operator>( const IdStr & lhs, const IdStr & rhs )
+ { return IdStr::compare( lhs, rhs ) > 0; }
+ /** \overload */
+ inline bool operator>( const IdStr & lhs, const char * rhs )
+ { return IdStr::compare( lhs, rhs ) > 0; }
+ /** \overload */
+ inline bool operator>( const IdStr & lhs, const std::string & rhs )
+ { return IdStr::compare( lhs, rhs ) > 0; }
+ /** \overload */
+ inline bool operator>( const char * lhs, const IdStr & rhs )
+ { return IdStr::compare( lhs, rhs ) > 0; }
+ /** \overload */
+ inline bool operator>( const std::string & lhs, const IdStr & rhs )
+ { return IdStr::compare( lhs, rhs ) > 0; }
+
+ /** \relates IdStr GreaterEqual*/
+ inline bool operator>=( const IdStr & lhs, const IdStr & rhs )
+ { return IdStr::compare( lhs, rhs ) >= 0; }
+ /** \overload */
+ inline bool operator>=( const IdStr & lhs, const char * rhs )
+ { return IdStr::compare( lhs, rhs ) >= 0; }
+ /** \overload */
+ inline bool operator>=( const IdStr & lhs, const std::string & rhs )
+ { return IdStr::compare( lhs, rhs ) >= 0; }
+ /** \overload */
+ inline bool operator>=( const char * lhs, const IdStr & rhs )
+ { return IdStr::compare( lhs, rhs ) >= 0; }
+ /** \overload */
+ inline bool operator>=( const std::string & lhs, const IdStr & rhs )
+ { return IdStr::compare( lhs, rhs ) >= 0; }
- /////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
} // namespace sat
///////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/sat/Solvable.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Solvable.cc?rev=8110&r1=8109&r2=8110&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/Solvable.cc (original)
+++ trunk/libzypp/zypp/sat/Solvable.cc Tue Dec 11 21:56:36 2007
@@ -49,7 +49,7 @@
for ( detail::SolvableIdType next = _id+1; next < unsigned(_solvable->repo->end); ++next )
{
::_Solvable * nextS( myPool().getSolvable( next ) );
- if ( nextS && nextS->repo == _solvable->repo )
+ if ( nextS && nextS->repo == _solvable->repo )
{
return Solvable( next );
}
@@ -57,6 +57,12 @@
return nosolvable;
}
+ Repo Solvable::repo() const
+ {
+ NO_SOLVABLE_RETURN( Repo::norepo );
+ return Repo( _solvable->repo );
+ }
+
bool Solvable::isSystem() const
{ return repo().isSystemRepo(); }
@@ -83,10 +89,26 @@
return VendorId( _solvable->vendor );
}
- Repo Solvable::repo() const
+ Capabilities Solvable::operator[]( Dep idx_r ) const
{
- NO_SOLVABLE_RETURN( Repo::norepo );
- return Repo( _solvable->repo );
+ NO_SOLVABLE_RETURN( Capabilities() );
+ ::Offset offs = 0;
+ switch( idx_r.inSwitch() )
+ {
+ case Dep::PROVIDES_e: offs = _solvable->provides; break;
+ case Dep::PREREQUIRES_e: break; // not yet handled.
+ case Dep::REQUIRES_e: offs = _solvable->requires; break;
+ case Dep::CONFLICTS_e: offs = _solvable->conflicts; break;
+ case Dep::OBSOLETES_e: offs = _solvable->obsoletes; break;
+ case Dep::RECOMMENDS_e: offs = _solvable->recommends; break;
+ case Dep::SUGGESTS_e: offs = _solvable->suggests; break;
+ case Dep::FRESHENS_e: offs = _solvable->freshens; break;
+ case Dep::ENHANCES_e: offs = _solvable->enhances; break;
+ case Dep::SUPPLEMENTS_e: offs = _solvable->supplements; break;
+ }
+ if ( ! offs )
+ return Capabilities();
+ return Capabilities( _solvable->repo->idarraydata + offs );
}
/******************************************************************
@@ -104,6 +126,32 @@
<< obj.repo().name() << "}";
}
+ /******************************************************************
+ **
+ ** FUNCTION NAME : dumpOn
+ ** FUNCTION TYPE : std::ostream &
+ */
+ std::ostream & dumpOn( std::ostream & str, const Solvable & obj )
+ {
+ str << obj;
+ if ( obj )
+ {
+#define OUTS(X) if ( ! obj[Dep::X].empty() ) str << endl << " " #X " " << obj[Dep::PROVIDES]
+ OUTS(PROVIDES);
+ OUTS(PREREQUIRES);
+ OUTS(REQUIRES);
+ OUTS(CONFLICTS);
+ OUTS(OBSOLETES);
+ OUTS(RECOMMENDS);
+ OUTS(SUGGESTS);
+ OUTS(FRESHENS);
+ OUTS(ENHANCES);
+ OUTS(SUPPLEMENTS);
+#undef OUTS
+ }
+ return str;
+ }
+
/////////////////////////////////////////////////////////////////
} // namespace sat
///////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/sat/Solvable.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/Solvable.h?rev=8110&r1=8109&r2=8110&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/Solvable.h (original)
+++ trunk/libzypp/zypp/sat/Solvable.h Tue Dec 11 21:56:36 2007
@@ -17,8 +17,11 @@
#include "zypp/base/SafeBool.h"
#include "zypp/sat/detail/PoolMember.h"
+#include "zypp/sat/Capabilities.h"
+#include "zypp/sat/Capability.h"
#include "zypp/sat/IdStr.h"
-#include "zypp/sat/IdRel.h"
+
+#include "zypp/Dep.h"
///////////////////////////////////////////////////////////////////
namespace zypp
@@ -54,6 +57,9 @@
/** Return whether this \ref Solvable belongs to the system repo. */
bool isSystem() const;
+ /** The \ref Repository this \ref Solvable belongs to. */
+ Repo repo() const;
+
public:
NameId name() const;
EvrId evr() const;
@@ -61,13 +67,15 @@
VendorId vendor() const;
public:
- Repo repo() const;
+ /** Access to the \ref Solvable dependencies. */
+ Capabilities operator[]( Dep idx_r ) const;
public:
/** Return next Solvable in \ref Pool (or \ref nosolvable). */
Solvable nextInPool() const;
/** Return next Solvable in \ref Repo (or \ref nosolvable). */
Solvable nextInRepo() const;
+
public:
/** Expert backdoor. */
::_Solvable * get() const;
@@ -84,6 +92,9 @@
/** \relates Solvable Stream output */
std::ostream & operator<<( std::ostream & str, const Solvable & obj );
+ /** \relates Solvable More verbose stream output including dependencies */
+ std::ostream & dumpOn( std::ostream & str, const Solvable & obj );
+
/** \relates Solvable */
inline bool operator==( const Solvable & lhs, const Solvable & rhs )
{ return lhs.get() == rhs.get(); }
Modified: trunk/libzypp/zypp/sat/detail/PoolMember.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/detail/PoolMember.h?rev=8110&r1=8109&r2=8110&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/detail/PoolMember.h (original)
+++ trunk/libzypp/zypp/sat/detail/PoolMember.h Tue Dec 11 21:56:36 2007
@@ -29,7 +29,8 @@
{ /////////////////////////////////////////////////////////////////
class IdStr;
- class IdRel;
+ class Capability;
+ class Capabilities;
class Solvable;
class Repo;
class Pool;
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org