Author: mlandres
Date: Tue Dec 18 21:49:35 2007
New Revision: 8127
URL: http://svn.opensuse.org/viewcvs/zypp?rev=8127&view=rev
Log:
- Changed ResKind implementation to use IdStr.
- split Solvable ident into kind/name
- map src/nosrc Solvables to kind(SrcPackage) and arch(noarch)
Modified:
branches/tmp/ma/jump_sat/libzypp/zypp/CMakeLists.txt
branches/tmp/ma/jump_sat/libzypp/zypp/ResTraits.cc
branches/tmp/ma/jump_sat/libzypp/zypp/ResTraits.h
branches/tmp/ma/jump_sat/libzypp/zypp/base/KindOf.h
branches/tmp/ma/jump_sat/libzypp/zypp/parser/susetags/FileReaderBaseImpl.h
branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolStats.h
branches/tmp/ma/jump_sat/libzypp/zypp/pool/Res2Sat.cc
branches/tmp/ma/jump_sat/libzypp/zypp/sat/Capability.cc
branches/tmp/ma/jump_sat/libzypp/zypp/sat/Capability.h
branches/tmp/ma/jump_sat/libzypp/zypp/sat/IdStr.h
branches/tmp/ma/jump_sat/libzypp/zypp/sat/Solvable.cc
branches/tmp/ma/jump_sat/libzypp/zypp/sat/Solvable.h
branches/tmp/ma/jump_sat/libzypp/zypp/sat/detail/PoolMember.h
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/CMakeLists.txt?rev=8127&r1=8126&r2=8127&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/CMakeLists.txt (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/CMakeLists.txt Tue Dec 18 21:49:35 2007
@@ -11,8 +11,6 @@
ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_BINARY_DIR}/zypp/sqlite-schema.h PRE_BUILD COMMAND "${CMAKE_BINARY_DIR}/zypp/mkarray" ARGS "${CMAKE_SOURCE_DIR}/zypp/cache/schema/schema.sql" "schemaData" "${CMAKE_BINARY_DIR}/zypp/sqlite-schema.h" DEPENDS mkarray DEPENDS ${CMAKE_SOURCE_DIR}/zypp/cache/schema/schema.sql )
SET( zypp_SRCS
- ZConfig.cc
- Arch.cc
Atom.cc
ByteCount.cc
Capability.cc
@@ -85,6 +83,8 @@
RepoManager.cc
MediaProducts.cc
Locks.cc
+ ZConfig.cc
+ Arch.cc
LanguageCode.cc
CountryCode.cc
Locale.cc
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/ResTraits.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/ResTraits.cc?rev=8127&r1=8126&r2=8127&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/ResTraits.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/ResTraits.cc Tue Dec 18 21:49:35 2007
@@ -17,28 +17,28 @@
{ /////////////////////////////////////////////////////////////////
template<>
- const ResolvableTraits::KindType ResTraits<Package> ::kind( "Package" );
+ const ResKind ResTraits<Package> ::kind( "Package" );
template<>
- const ResolvableTraits::KindType ResTraits<SrcPackage>::kind( "SrcPackage" );
+ const ResKind ResTraits<SrcPackage>::kind( "SrcPackage" );
template<>
- const ResolvableTraits::KindType ResTraits<Selection> ::kind( "Selection" );
+ const ResKind ResTraits<Selection> ::kind( "Selection" );
template<>
- const ResolvableTraits::KindType ResTraits<Pattern> ::kind( "Pattern" );
+ const ResKind ResTraits<Pattern> ::kind( "Pattern" );
template<>
- const ResolvableTraits::KindType ResTraits<Product> ::kind( "Product" );
+ const ResKind ResTraits<Product> ::kind( "Product" );
template<>
- const ResolvableTraits::KindType ResTraits<Patch> ::kind( "Patch" );
+ const ResKind ResTraits<Patch> ::kind( "Patch" );
template<>
- const ResolvableTraits::KindType ResTraits<Script> ::kind( "Script" );
+ const ResKind ResTraits<Script> ::kind( "Script" );
template<>
- const ResolvableTraits::KindType ResTraits<Message> ::kind( "Message" );
+ const ResKind ResTraits<Message> ::kind( "Message" );
template<>
- const ResolvableTraits::KindType ResTraits<Language> ::kind( "Language" );
+ const ResKind ResTraits<Language> ::kind( "Language" );
template<>
- const ResolvableTraits::KindType ResTraits<Atom> ::kind( "Atom" );
+ const ResKind ResTraits<Atom> ::kind( "Atom" );
template<>
- const ResolvableTraits::KindType ResTraits<SystemResObject>::kind( "System" );
+ const ResKind ResTraits<SystemResObject>::kind( "System" );
/////////////////////////////////////////////////////////////////
} // namespace zypp
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/ResTraits.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/ResTraits.h?rev=8127&r1=8126&r2=8127&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/ResTraits.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/ResTraits.h Tue Dec 18 21:49:35 2007
@@ -63,42 +63,72 @@
DEFINE_PTR_TYPE( SystemResObject );
//@}
- /** Base of ResTraits. Defines the Resolvable::Kind type. */
- struct ResolvableTraits
- {
- typedef KindOf<Resolvable> KindType;
- };
+ /** The Resolvables Kind type. */
+ typedef KindOf<Resolvable> ResKind;
/** ResTraits. Defines common types and the Kind value. */
template<typename _Res>
- struct ResTraits : public ResolvableTraits
+ struct ResTraits
{
+ typedef ResKind KindType;
typedef intrusive_ptr<_Res> PtrType;
typedef intrusive_ptr<const _Res> constPtrType;
- static const KindType kind;
+ static const ResKind kind;
};
/** ResTraits specialisation for Resolvable.
* Resolvable is common base and has no Kind value.
- */
+ */
template<>
- struct ResTraits<Resolvable> : public ResolvableTraits
+ struct ResTraits<Resolvable>
{
+ typedef ResKind KindType;
typedef intrusive_ptr<Resolvable> PtrType;
typedef intrusive_ptr<const Resolvable> constPtrType;
};
/** ResTraits specialisation for ResObject.
* ResObject is common base and has no Kind value.
- */
+ */
template<>
- struct ResTraits<ResObject> : public ResolvableTraits
+ struct ResTraits<ResObject>
{
+ typedef ResKind KindType;
typedef intrusive_ptr<ResObject> PtrType;
typedef intrusive_ptr<const ResObject> constPtrType;
};
+ /** Convenient access to well known ResKinds.
+ * \code
+ * ResKind packagekind = ResTraits<Package>::kind;
+ * ResKind packagekind = resKind<Package>();
+ * \endcode
+ */
+ template<typename _Res>
+ inline ResKind resKind() { return ResTraits<_Res>::kind; }
+
+ /** Convenient test for ResKinds.
+ * \code
+ * ResKind value;
+ * if ( ResTraits<Package>::kind == value )
+ * if ( resKind<Package>() == value )
+ * if ( isKind<Package>( value ) )
+ * \endcode
+ */
+ template<typename _Res>
+ inline bool isKind( const ResKind & val_r )
+ { return( resKind<_Res>() == val_r ); }
+ /** \overload */
+ template<typename _Res>
+ inline bool isKind( const std::string & val_r )
+ { return( resKind<_Res>() == val_r ); }
+ /** \overload */
+ template<typename _Res>
+ inline bool isKind( const char * val_r )
+ { return( resKind<_Res>() == val_r ); }
+
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/base/KindOf.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/base/KindOf.h?rev=8127&r1=8126&r2=8127&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/base/KindOf.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/base/KindOf.h Tue Dec 18 21:49:35 2007
@@ -15,6 +15,7 @@
#include <iosfwd>
#include "zypp/base/String.h"
+#include "zypp/sat/IdStr.h"
///////////////////////////////////////////////////////////////////
namespace zypp
@@ -33,55 +34,62 @@
* like to be extensible at runtime.
*
* KindOf stores a \b lowercased version of a string and uses this as
- * identification.
- *
- * \todo Unify strings and associate numerical value for more
- * efficient comparison and use in \c switch.
- * \todo Make lowercased/uppercased/etc an option. First of all
- * get rid of the string::toLower calls operator.
- * \todo Maybe collaboration with some sort of Registry.
+ * identification. Comparison against string values is always case insensitive.
*/
template<class _Tp>
- class KindOf
- {
+ class KindOf : private sat::IdStr
+ {
public:
/** DefaultCtor: empty string */
KindOf()
{}
/** Ctor from string.
* Lowercase version of \a value_r is used as identification.
- */
+ */
explicit
- KindOf( const std::string & value_r )
- : _value( str::toLower(value_r) )
+ KindOf( const std::string & value_r )
+ : sat::IdStr( str::toLower(value_r) )
{}
/** Dtor */
~KindOf()
{}
public:
- /** Identification string. */
- const std::string & asString() const
- { return _value; }
-
- /** Order on KindOf (arbitrary).
- * Not necessarily lexicographical.
- * \todo Enable class _Tp to define the order,
- * Fix logical operators below to use compare,
- */
- int compare( const KindOf & rhs ) const
- { return _value.compare( rhs._value ); }
+ sat::IdStr::empty;
+ sat::IdStr::size;
+ sat::IdStr::c_str;
+ sat::IdStr::string;
+ sat::IdStr::asString;
+ public:
+ /** Fast compare equal. */
+ bool compareEQ( const KindOf & rhs ) const
+ { return sat::IdStr::compareEQ( rhs ); }
- private:
- /** */
- std::string _value;
- };
+ /** Compare KindOf returning <tt>-1,0,1</tt>. */
+ int compare( const KindOf & rhs ) const
+ { return sat::IdStr::compare( rhs ); }
+ /** \overload Remember to compare case insensitive. */
+ int compare( const IdStr & rhs ) const
+ {
+ if ( sat::IdStr::compareEQ( rhs ) )
+ return 0;
+ return str::compareCI( c_str(), rhs.c_str() );
+ }
+ /** \overload Remember to compare case insensitive.*/
+ int compare( const char * rhs ) const
+ { return str::compareCI( c_str(), rhs ); }
+ /** \overload Remember to compare case insensitive.*/
+ int compare( const std::string & rhs ) const
+ { return str::compareCI( c_str(), rhs ); }
+ public:
+ sat::IdStr::id;
+ };
///////////////////////////////////////////////////////////////////
//@{
/** \relates KindOf Stream output*/
template<class _Tp>
inline std::ostream & operator<<( std::ostream & str, const KindOf<_Tp> & obj )
- { return str << obj.asString(); }
+ { return str << obj.c_str(); }
//@}
///////////////////////////////////////////////////////////////////
@@ -90,41 +98,61 @@
/** \relates KindOf */
template<class _Tp>
inline bool operator==( const KindOf<_Tp> & lhs, const KindOf<_Tp> & rhs )
- { return lhs.asString() == rhs.asString(); }
+ { return lhs.compareEQ( rhs ); }
/** \relates KindOf */
template<class _Tp>
inline bool operator==( const KindOf<_Tp> & lhs, const std::string & rhs )
- { return lhs.asString() == str::toLower(rhs); }
+ { return lhs.compare( rhs ) == 0; }
+
+ /** \relates KindOf */
+ template<class _Tp>
+ inline bool operator==( const KindOf<_Tp> & lhs, const char * rhs )
+ { return lhs.compare( rhs ) == 0; }
/** \relates KindOf */
template<class _Tp>
inline bool operator==( const std::string & lhs, const KindOf<_Tp> & rhs )
- { return str::toLower(lhs) == rhs.asString(); }
+ { return rhs.compare( lhs ) == 0; }
+
+ /** \relates KindOf */
+ template<class _Tp>
+ inline bool operator==( const char * lhs, const KindOf<_Tp> & rhs )
+ { return rhs.compare( lhs ) == 0; }
//@}
//@{
/** \relates KindOf */
template<class _Tp>
inline bool operator!=( const KindOf<_Tp> & lhs, const KindOf<_Tp> & rhs )
- { return !( lhs == rhs ); }
+ { return ! lhs.compareEQ( rhs ); }
/** \relates KindOf */
template<class _Tp>
inline bool operator!=( const KindOf<_Tp> & lhs, const std::string & rhs )
- { return !( lhs == rhs ); }
+ { return lhs.compare( rhs ) != 0; }
+
+ /** \relates KindOf */
+ template<class _Tp>
+ inline bool operator!=( const KindOf<_Tp> & lhs, const char * rhs )
+ { return lhs.compare( rhs ) != 0; }
/** \relates KindOf */
template<class _Tp>
inline bool operator!=( const std::string & lhs, const KindOf<_Tp> & rhs )
- { return !( lhs == rhs ); }
+ { return rhs.compare( lhs ) != 0; }
+
+ /** \relates KindOf */
+ template<class _Tp>
+ inline bool operator!=( const char * lhs, const KindOf<_Tp> & rhs )
+ { return rhs.compare( lhs ) != 0; }
//@}
//@{
- /** \relates KindOf Lexicographical order. */
+ /** \relates KindOf std::Container order. */
template<class _Tp>
inline bool operator<( const KindOf<_Tp> & lhs, const KindOf<_Tp> & rhs )
- { return lhs.asString() < rhs.asString(); }
+ { return lhs.id() < rhs.id(); }
//@}
/////////////////////////////////////////////////////////////////
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/parser/susetags/FileReaderBaseImpl.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/parser/susetags/FileReaderBaseImpl.h?rev=8127&r1=8126&r2=8127&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/parser/susetags/FileReaderBaseImpl.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/parser/susetags/FileReaderBaseImpl.h Tue Dec 18 21:49:35 2007
@@ -34,7 +34,7 @@
namespace susetags
{ /////////////////////////////////////////////////////////////////
- inline std::string makeSharedIdent( ResolvableTraits::KindType kind_r,
+ inline std::string makeSharedIdent( ResKind kind_r,
const std::string & name_r,
const Edition & edition_r,
const Arch & arch_r )
@@ -77,7 +77,7 @@
}
capability::CapabilityImpl::Ptr get( const std::string & line_r,
- ResolvableTraits::KindType refers_r )
+ ResKind refers_r )
{
capability::CapabilityImpl::Ptr & ret( _cache[refers_r][line_r] );
if ( ! ret )
@@ -88,7 +88,7 @@
}
private:
- std::map