Author: mlandres
Date: Fri Feb 15 00:13:41 2008
New Revision: 8696
URL: http://svn.opensuse.org/viewcvs/zypp?rev=8696&view=rev
Log:
add basic locale interface to ResPool, remove deprecated _gxx hashes
Added:
branches/tmp/ma/jump_sat/libzypp/zypp/@DOXYGEN/n_ResPool_nomorenameiter
Removed:
branches/tmp/ma/jump_sat/libzypp/zypp/base/Hash.h
branches/tmp/ma/jump_sat/libzypp/zypp/base/UniqueString.h
Modified:
branches/tmp/ma/jump_sat/libzypp/zypp/@DOXYGEN/g_CodeSnippets
branches/tmp/ma/jump_sat/libzypp/zypp/Arch.cc
branches/tmp/ma/jump_sat/libzypp/zypp/CMakeLists.txt
branches/tmp/ma/jump_sat/libzypp/zypp/Capability.h
branches/tmp/ma/jump_sat/libzypp/zypp/IdString.h
branches/tmp/ma/jump_sat/libzypp/zypp/Locale.cc
branches/tmp/ma/jump_sat/libzypp/zypp/Locale.h
branches/tmp/ma/jump_sat/libzypp/zypp/PackageKeyword.h
branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.cc
branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.h
branches/tmp/ma/jump_sat/libzypp/zypp/ZYpp.cc
branches/tmp/ma/jump_sat/libzypp/zypp/ZYpp.h
branches/tmp/ma/jump_sat/libzypp/zypp/base/LogTools.h
branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolImpl.h
branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolTraits.h
branches/tmp/ma/jump_sat/libzypp/zypp/sat/Pool.cc
branches/tmp/ma/jump_sat/libzypp/zypp/sat/Pool.h
branches/tmp/ma/jump_sat/libzypp/zypp/sat/detail/PoolImpl.cc
branches/tmp/ma/jump_sat/libzypp/zypp/sat/detail/PoolImpl.h
branches/tmp/ma/jump_sat/libzypp/zypp/sat/detail/PoolMember.h
branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/ResolverUpgrade.cc
branches/tmp/ma/jump_sat/libzypp/zypp/zypp_detail/ZYppImpl.cc
branches/tmp/ma/jump_sat/libzypp/zypp/zypp_detail/ZYppImpl.h
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/@DOXYGEN/g_CodeSnippets
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/%40DOXYGEN/g_CodeSnippets?rev=8696&r1=8695&r2=8696&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/@DOXYGEN/g_CodeSnippets (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/@DOXYGEN/g_CodeSnippets Fri Feb 15 00:13:41 2008
@@ -1,3 +1,27 @@
+// //////////////////////////////////////////////////////////////////////
+// If you prefer using iterator in a for' loop, but dislike to figure out
+// the exact type of the iterator, you may find the 'for_' macro convenient:
+// //////////////////////////////////////////////////////////////////////
+
+ #include "zypp/base/Easy.h"
+
+ for_( it, pool.byIdentBegin( kind, name ),
+ pool.byIdentEnd( kind, name ) )
+ {
+ PoolItem copy = *it;
+ }
+
+instead of:
+
+ for ( ResPool::byIdent_iterator it = pool.byIdentBegin( kind, name ),
+ end = pool.byIdentEnd( kind, name );
+ it != end, ++it )
+ {
+ PoolItem copy = *it;
+ }
+
+
+// //////////////////////////////////////////////////////////////////////
// Avoid buggy code, that tries to erase elements, matching a
// certain property from containers. Example:
//
Added: branches/tmp/ma/jump_sat/libzypp/zypp/@DOXYGEN/n_ResPool_nomorenameiter
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/%40DOXYGEN/n_ResPool_nomorenameiter?rev=8696&view=auto
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/@DOXYGEN/n_ResPool_nomorenameiter (added)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/@DOXYGEN/n_ResPool_nomorenameiter Fri Feb 15 00:13:41 2008
@@ -0,0 +1,71 @@
+
+I tagged the byName iterator as deprecated, so the compiler tells you
+where it is used. Please review the code and check whether byIdent is
+an appropriate replacement.
+
+
+--
+The 'old' zypp pool internally maintained a byName index, so it was a
+fast way to iterate the pool by name and filter by kind to visit e.g.
+all packages named foo:
+
+ invokeOnEach( pool.byNameBegin( name ), pool.byNameEnd( name ),
+ resfilter::ByKind( kind ),
+ action() );
+
+ for_( it, pool.byNameBegin( name ), pool.byNameEnd( name ) )
+ {
+ if ( (*it)->kind() == kind )
+ {
+ ...
+ }
+ }
+
+This is no longer true.
+
+
+
+In contrary, byName now is a 'quite expensive' iteration. It's faster to
+rewrite these loops using byIdent (and no filter):
+
+ invokeOnEach( pool.byIdentBegin( kind, name ),
+ pool.byIdentEnd( kind, name ),
+ action() );
+
+ for_( it, pool.byIdentBegin( kind, name ), pool.byNameEnd( kind, name ) )
+ {
+ ...
+ }
+
+
+How to construct the byIdent iterator:
+
+ ResPool::byIdentBegin( poolItem ) // using this poolItems kind and name
+ ResPool::byIdentBegin( kind, name ) // explicit kind and name
+ ResPool::byIdentBegin<Package>( name ) // or templated kind
+
+
+
+--
+
+If you prefer using iterator in a for' loop, but dislike to figure out
+the exact type of the iterator, you may find the 'for_' macro convenient:
+
+ #include "zypp/base/Easy.h"
+
+ for_( it, pool.byIdentBegin( kind, name ),
+ pool.byIdentEnd( kind, name ) )
+ {
+ PoolItem copy = *it;
+ }
+
+
+instead of:
+
+ for ( ResPool::byIdent_iterator it = pool.byIdentBegin( kind, name ),
+ end = pool.byIdentEnd( kind, name );
+ it != end, ++it )
+ {
+ PoolItem copy = *it;
+ }
+
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/Arch.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/Arch.cc?rev=8696&r1=8695&r2=8696&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/Arch.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/Arch.cc Fri Feb 15 00:13:41 2008
@@ -238,6 +238,7 @@
defCompatibleWith( _ppc, _ppc64 );
//
///////////////////////////////////////////////////////////////////
+ dumpOn( USR ) << endl;
}
private:
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=8696&r1=8695&r2=8696&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/CMakeLists.txt (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/CMakeLists.txt Fri Feb 15 00:13:41 2008
@@ -223,7 +223,6 @@
base/Functional.h
base/Gettext.h
base/GzStream.h
- base/Hash.h
base/IOStream.h
base/InputStream.h
base/Iterator.h
@@ -241,7 +240,6 @@
base/String.h
base/Regex.h
base/Sysconfig.h
- base/UniqueString.h
base/Unit.h
base/WatchFile.h
)
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=8696&r1=8695&r2=8696&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/Capability.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/Capability.h Fri Feb 15 00:13:41 2008
@@ -13,7 +13,7 @@
#define ZYPP_SAT_CAPABILITY_H
#include <iosfwd>
-#include <set>
+#include
#include "zypp/base/SafeBool.h"
#include "zypp/base/Deprecated.h"
@@ -34,7 +34,7 @@
class Capability;
class CapDetail;
- typedef std::set<Capability> CapabilitySet;
+ typedef std::tr1::unordered_set<Capability> CapabilitySet;
///////////////////////////////////////////////////////////////////
//
@@ -54,7 +54,7 @@
* \endcode
*/
class Capability: protected sat::detail::PoolMember,
- private base::SafeBool<Capability>
+ private base::SafeBool<Capability>
{
public:
// legacy
@@ -302,4 +302,7 @@
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
+
+ZYPP_DEFINE_ID_HASHABLE( ::zypp::Capability )
+
#endif // ZYPP_SAT_CAPABILITY_H
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/IdString.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/IdString.h?rev=8696&r1=8695&r2=8696&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/IdString.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/IdString.h Fri Feb 15 00:13:41 2008
@@ -208,4 +208,7 @@
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
+
+ZYPP_DEFINE_ID_HASHABLE( ::zypp::IdString )
+
#endif // ZYPP_SAT_IDSTR_H
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/Locale.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/Locale.cc?rev=8696&r1=8695&r2=8696&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/Locale.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/Locale.cc Fri Feb 15 00:13:41 2008
@@ -22,7 +22,7 @@
typedef std::map OtherDefaultLanguage;
static OtherDefaultLanguage otherDefaultLanguage;
-
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : Locale::Impl
@@ -89,7 +89,7 @@
if (otherDefaultLanguage.find(code()) != otherDefaultLanguage.end())
return LanguageCode(otherDefaultLanguage[code()]);
-
+
if ( _country.hasCode() )
return _language;
@@ -142,6 +142,15 @@
// METHOD NAME : Locale::Locale
// METHOD TYPE : Ctor
//
+ Locale::Locale( IdString code_r )
+ : _pimpl( new Impl( code_r.asString() ) )
+ {}
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : Locale::Locale
+ // METHOD TYPE : Ctor
+ //
Locale::Locale( const std::string & code_r )
: _pimpl( new Impl( code_r ) )
{}
@@ -151,6 +160,15 @@
// METHOD NAME : Locale::Locale
// METHOD TYPE : Ctor
//
+ Locale::Locale( const char * code_r )
+ : _pimpl( new Impl( C_Str(code_r).c_str() ) )
+ {}
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : Locale::Locale
+ // METHOD TYPE : Ctor
+ //
Locale::Locale( const LanguageCode & language_r,
const CountryCode & country_r )
: _pimpl( new Impl( language_r, country_r ) )
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/Locale.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/Locale.h?rev=8696&r1=8695&r2=8696&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/Locale.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/Locale.h Fri Feb 15 00:13:41 2008
@@ -13,9 +13,11 @@
#define ZYPP_LOCALE_H
#include <iosfwd>
+#include
#include "zypp/base/PtrTypes.h"
+#include "zypp/IdString.h"
#include "zypp/LanguageCode.h"
#include "zypp/CountryCode.h"
@@ -27,7 +29,9 @@
//
// CLASS NAME : Locale
//
- /** */
+ /**
+ * \todo migrate to IdString
+ */
class Locale
{
friend std::ostream & operator<<( std::ostream & str, const Locale & obj );
@@ -42,8 +46,14 @@
/** Ctor taking a string. */
explicit
+ Locale( IdString code_r );
+
+ explicit
Locale( const std::string & code_r );
+ explicit
+ Locale( const char * code_r );
+
/** Ctor taking LanguageCode and optional CountryCode. */
Locale( const LanguageCode & language_r,
const CountryCode & country_r = CountryCode() );
@@ -112,10 +122,23 @@
}
//@}
+ ///////////////////////////////////////////////////////////////////
+
+ typedef std::tr1::unordered_set<Locale> LocaleSet;
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
+namespace std { namespace tr1 {
+ /** \relates ::zypp::Locale hash function */
+ template<> struct hash< ::zypp::Locale>
+ {
+ size_t operator()( const ::zypp::Locale & __s ) const
+ { return hashstd::string()(__s.code()); }
+ };
+}}
+
///////////////////////////////////////////////////////////////////
namespace std
{ /////////////////////////////////////////////////////////////////
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/PackageKeyword.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/PackageKeyword.h?rev=8696&r1=8695&r2=8696&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/PackageKeyword.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/PackageKeyword.h Fri Feb 15 00:13:41 2008
@@ -12,7 +12,7 @@
#ifndef ZYPP_PACKAGEKEYWORD_H
#define ZYPP_PACKAGEKEYWORD_H
-#include "zypp/base/UniqueString.h"
+#include "zypp/IdStringType.h"
///////////////////////////////////////////////////////////////////
namespace zypp
@@ -22,16 +22,25 @@
//
// CLASS NAME : PackageKeyword
//
- /** Package keywords. */
- struct PackageKeyword : public base::UniqueString<PackageKeyword>
+ /** Package keywords.
+ * \see \ref IdStringType
+ */
+ class PackageKeyword : public IdStringType<PackageKeyword>
{
- PackageKeyword()
- {}
+ public:
+ /** Default ctor: empty keyword */
+ PackageKeyword() {}
- PackageKeyword( const std::string & name_r )
- : base::UniqueString<PackageKeyword>( name_r )
- {}
- };
+ /** Ctor taking keyword as string. */
+ explicit PackageKeyword( sat::detail::IdType id_r ) : _str( IdString(id_r).c_str() ) {}
+ explicit PackageKeyword( const IdString & idstr_r ) : _str( idstr_r.c_str() ) {}
+ explicit PackageKeyword( const std::string & str_r ) : _str( str_r ) {}
+ explicit PackageKeyword( const char * cstr_r ) : _str( cstr_r ) {}
+
+ private:
+ friend class IdStringType<PackageKeyword>;
+ IdString _str;
+ };
///////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.cc?rev=8696&r1=8695&r2=8696&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.cc Fri Feb 15 00:13:41 2008
@@ -104,6 +104,32 @@
const pool::PoolTraits::Id2ItemT & ResPool::id2item() const
{ return _pimpl->id2item(); }
+ ///////////////////////////////////////////////////////////////////
+ //
+ // Forward to sat::Pool:
+ //
+ ///////////////////////////////////////////////////////////////////
+ void ResPool::setRequestedLocales( const LocaleSet & locales_r )
+ { sat::Pool::instance().setRequestedLocales( locales_r ); }
+
+ bool ResPool::addRequestedLocale( const Locale & locale_r )
+ { return sat::Pool::instance().addRequestedLocale( locale_r ); }
+
+ bool ResPool::eraseRequestedLocale( const Locale & locale_r )
+ { return sat::Pool::instance().eraseRequestedLocale( locale_r ); }
+
+ const LocaleSet & ResPool::getRequestedLocales() const
+ { return sat::Pool::instance().getRequestedLocales(); }
+
+ bool ResPool::isRequestedLocale( const Locale & locale_r ) const
+ { return sat::Pool::instance().isRequestedLocale( locale_r ); }
+
+ const LocaleSet & ResPool::getAvailableLocales() const
+ { return sat::Pool::instance().getAvailableLocales(); }
+
+ bool ResPool::isAvailableLocale( const Locale & locale_r ) const
+ { return sat::Pool::instance().isAvailableLocale( locale_r ); }
+
/******************************************************************
**
** FUNCTION NAME : operator<<
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.h?rev=8696&r1=8695&r2=8696&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.h Fri Feb 15 00:13:41 2008
@@ -28,8 +28,6 @@
class SerialNumber;
class ResPoolProxy;
-
-
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : ResPool
@@ -43,6 +41,8 @@
* the index is not yet implemented, they are realized as
* an ordinary filter iterator. Do not provide filter iterators
* here, if there is no index table for it.
+ *
+ * \include n_ResPool_nomorenameiter
*/
class ResPool
{
@@ -55,7 +55,7 @@
typedef pool::PoolTraits::const_iterator const_iterator;
typedef pool::PoolTraits::byCapabilityIndex_iterator byCapabilityIndex_iterator;
- typedef pool::PoolTraits::AdditionalCapabilities AdditionalCapabilities;
+ typedef pool::PoolTraits::AdditionalCapabilities AdditionalCapabilities;
typedef pool::PoolTraits::repository_iterator repository_iterator;
public:
@@ -111,72 +111,69 @@
public:
/** \name Iterate through all PoolItems of a certain name and kind. */
//@{
- typedef pool::ByIdent ByIdent;
- typedef pool::PoolTraits::Id2ItemT Id2ItemT;
- typedef transform_iteratorId2ItemT::value_type, Id2ItemT::const_iterator> byIdent_iterator;
+ typedef pool::ByIdent ByIdent;
+ typedef pool::PoolTraits::byIdent_iterator byIdent_iterator;
- byIdent_iterator byIdentBegin( sat::detail::IdType id ) const
+ byIdent_iterator byIdentBegin( const ByIdent & ident_r ) const
{
- std::pair it2
- = id2item().equal_range(id);
- return make_transform_iterator(it2.first, std::_Select2ndId2ItemT::value_type());
- }
-
- byIdent_iterator byIdentEnd( sat::detail::IdType id ) const
- {
- std::pair it2
- = id2item().equal_range(id);
- return make_transform_iterator(it2.second, std::_Select2ndId2ItemT::value_type());
+ return make_transform_iterator( id2item().equal_range( ident_r.get() ).first,
+ pool::PoolTraits::Id2ItemValueSelector() );
}
byIdent_iterator byIdentBegin( ResKind kind_r, IdString name_r ) const
- { return byIdentBegin( ByIdent(kind_r,name_r).get() ); }
+ { return byIdentBegin( ByIdent(kind_r,name_r) ); }
byIdent_iterator byIdentBegin( ResKind kind_r, const C_Str & name_r ) const
- { return byIdentBegin( ByIdent(kind_r,name_r).get() ); }
+ { return byIdentBegin( ByIdent(kind_r,name_r) ); }
template<class _Res>
byIdent_iterator byIdentBegin( IdString name_r ) const
- { return byIdentBegin( ByIdent(ResTraits<_Res>::kind,name_r).get() ); }
+ { return byIdentBegin( ByIdent(ResTraits<_Res>::kind,name_r) ); }
template<class _Res>
byIdent_iterator byIdentBegin( const C_Str & name_r ) const
- { return byIdentBegin( ByIdent(ResTraits<_Res>::kind,name_r).get() ); }
+ { return byIdentBegin( ByIdent(ResTraits<_Res>::kind,name_r) ); }
/** Derive name and kind from \ref PoolItem. */
byIdent_iterator byIdentBegin( const PoolItem & pi_r ) const
- { return byIdentBegin( ByIdent(pi_r.satSolvable()).get() ); }
+ { return byIdentBegin( ByIdent(pi_r.satSolvable()) ); }
/** Derive name and kind from \ref sat::Solvable. */
byIdent_iterator byIdentBegin( sat::Solvable slv_r ) const
- { return byIdentBegin( ByIdent(slv_r).get() ); }
+ { return byIdentBegin( ByIdent(slv_r) ); }
/** Takes a \ref sat::Solvable::ident string. */
byIdent_iterator byIdentBegin( IdString ident_r ) const
- { return byIdentBegin( ByIdent(ident_r).get() ); }
+ { return byIdentBegin( ByIdent(ident_r) ); }
+ byIdent_iterator byIdentEnd( const ByIdent & ident_r ) const
+ {
+ return make_transform_iterator( id2item().equal_range( ident_r.get() ).second,
+ pool::PoolTraits::Id2ItemValueSelector() );
+ }
+
byIdent_iterator byIdentEnd( ResKind kind_r, IdString name_r ) const
- { return byIdentEnd( ByIdent(kind_r,name_r).get() ); }
+ { return byIdentEnd( ByIdent(kind_r,name_r) ); }
byIdent_iterator byIdentEnd( ResKind kind_r, const C_Str & name_r ) const
- { return byIdentEnd( ByIdent(kind_r,name_r).get() ); }
+ { return byIdentEnd( ByIdent(kind_r,name_r) ); }
template<class _Res>
byIdent_iterator byIdentEnd( IdString name_r ) const
- { return byIdentEnd( ByIdent(ResTraits<_Res>::kind,name_r).get() ); }
+ { return byIdentEnd( ByIdent(ResTraits<_Res>::kind,name_r) ); }
template<class _Res>
byIdent_iterator byIdentEnd( const C_Str & name_r ) const
- { return byIdentEnd( ByIdent(ResTraits<_Res>::kind,name_r).get() ); }
+ { return byIdentEnd( ByIdent(ResTraits<_Res>::kind,name_r) ); }
/** Derive name and kind from \ref PoolItem. */
byIdent_iterator byIdentEnd( const PoolItem & pi_r ) const
- { return byIdentEnd( ByIdent(pi_r.satSolvable()).get() ); }
+ { return byIdentEnd( ByIdent(pi_r.satSolvable()) ); }
/** Derive name and kind from \ref sat::Solvable. */
byIdent_iterator byIdentEnd( sat::Solvable slv_r ) const
- { return byIdentEnd( ByIdent(slv_r).get() ); }
+ { return byIdentEnd( ByIdent(slv_r) ); }
/** Takes a \ref sat::Solvable::ident string. */
byIdent_iterator byIdentEnd( IdString ident_r ) const
- { return byIdentEnd( ByIdent(ident_r).get() ); }
+ { return byIdentEnd( ByIdent(ident_r) ); }
//@}
public:
@@ -236,7 +233,45 @@
repository_iterator knownRepositoriesEnd() const;
//@}
- public:
+ public:
+ /** \name Iterate through requested/available Locales.
+ */
+ //@{
+ /** Set the requested locales.
+ * Languages to be supported by the system, e.g. language specific
+ * packages to be installed.
+ */
+ void setRequestedLocales( const LocaleSet & locales_r );
+
+ /** Add one \ref Locale to the set of requested locales.
+ * Return \c true if \c locale_r was newly added to the set.
+ */
+ bool addRequestedLocale( const Locale & locale_r );
+
+ /** Erase one \ref Locale from the set of requested locales.
+ * Return \c false if \c locale_r was not found in the set.
+ */
+ bool eraseRequestedLocale( const Locale & locale_r );
+
+ /** Return the requested locales.
+ * \see \ref setRequestedLocales
+ */
+ const LocaleSet & getRequestedLocales() const;
+
+ /** Wheter this \ref Locale is in the set of requested locales. */
+ bool isRequestedLocale( const Locale & locale_r ) const;
+
+ /** Get the set of available locales.
+ * This is computed from the package data so it actually
+ * represents all locales packages claim to support.
+ */
+ const LocaleSet & getAvailableLocales() const;
+
+ /** Wheter this \ref Locale is in the set of available locales. */
+ bool isAvailableLocale( const Locale & locale_r ) const;
+ //@}
+
+ public:
/** \name Handling addition capabilities in the pool in order for solving it in
* a solver run. This is used for tasks like needing a package with the name "foo".
* The solver has to evaluate a proper package by his own.
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/ZYpp.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/ZYpp.cc?rev=8696&r1=8695&r2=8696&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/ZYpp.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/ZYpp.cc Fri Feb 15 00:13:41 2008
@@ -14,6 +14,7 @@
#include "zypp/ZYpp.h"
#include "zypp/zypp_detail/ZYppImpl.h"
+#include "zypp/sat/Pool.h"
using std::endl;
@@ -99,16 +100,14 @@
///////////////////////////////////////////////////////////////////
void ZYpp::setRequestedLocales( const LocaleSet & locales_r )
- { _pimpl->setRequestedLocales( locales_r ); }
+ { sat::Pool::instance().setRequestedLocales( locales_r ); }
- ZYpp::LocaleSet ZYpp::getRequestedLocales() const
- { return _pimpl->getRequestedLocales(); }
+ const LocaleSet & ZYpp::getRequestedLocales() const
+ { return sat::Pool::instance().getRequestedLocales(); }
- ZYpp::LocaleSet ZYpp::getAvailableLocales() const
- { return _pimpl->getAvailableLocales(); }
+ const LocaleSet & ZYpp::getAvailableLocales() const
+ { return sat::Pool::instance().getAvailableLocales(); }
- void ZYpp::availableLocale( const Locale & locale_r )
- { _pimpl->availableLocale( locale_r ); }
Pathname ZYpp::homePath() const
{ return _pimpl->homePath(); }
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/ZYpp.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/ZYpp.h?rev=8696&r1=8695&r2=8696&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/ZYpp.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/ZYpp.h Fri Feb 15 00:13:41 2008
@@ -41,7 +41,6 @@
class ZYppFactory;
class ResPool;
class ResPoolProxy;
- class Locale;
class KeyRing;
///////////////////////////////////////////////////////////////////
@@ -129,30 +128,28 @@
public:
/** \name move to pool
+ * \deprecated Use ResPool diretcly.
*/
//@{
- typedef std::set<Locale> LocaleSet;
/** Set the requested locales.
* Languages to be supported by the system, e.g. language specific
* packages to be installed. This function operates on the pool,
* so only the locales that are available as resolvables
* are marked as requested. The rest is ignored.
+ * \deprecated Use ResPool diretcly.
*/
- void setRequestedLocales( const LocaleSet & locales_r );
- /** */
- LocaleSet getRequestedLocales() const;
+ void setRequestedLocales( const LocaleSet & locales_r ) ZYPP_DEPRECATED;
+
+ /** \deprecated Use ResPool diretcly. */
+ const LocaleSet & getRequestedLocales() const ZYPP_DEPRECATED;
/**
* Get the set of available locales.
* This is computed from the package data so it actually
* represents all locales packages claim to support.
+ * \deprecated Use ResPool diretcly.
*/
- LocaleSet getAvailableLocales() const;
-
- /**
- * internal use only
- **/
- void availableLocale( const Locale & locale_r );
+ const LocaleSet & getAvailableLocales() const ZYPP_DEPRECATED;
//@}
public:
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/base/LogTools.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/base/LogTools.h?rev=8696&r1=8695&r2=8696&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/base/LogTools.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/base/LogTools.h Fri Feb 15 00:13:41 2008
@@ -18,6 +18,8 @@
#include <list>
#include <set>
#include <map>
+#include
+#include
#include "zypp/base/Logger.h"
#include "zypp/base/Iterator.h"
#include "zypp/base/Deprecated.h"
@@ -121,6 +123,10 @@
{ return dumpRange( str, obj.begin(), obj.end() ); }
template<class _Tp>
+ std::ostream & operator<<( std::ostream & str, const std::tr1::unordered_set<_Tp> & obj )
+ { return dumpRange( str, obj.begin(), obj.end() ); }
+
+ template<class _Tp>
std::ostream & operator<<( std::ostream & str, const std::list<_Tp> & obj )
{ return dumpRange( str, obj.begin(), obj.end() ); }
@@ -203,14 +209,6 @@
MapEntry_const_iterator end() const
{ return make_transform_iterator( map().end(), Transformer() );}
- /** \deprecated Use begin. */
- ZYPP_DEPRECATED MapEntry_const_iterator map_begin() const
- { return make_transform_iterator( map().begin(), Transformer() ); }
-
- /** \deprecated Use end. */
- ZYPP_DEPRECATED MapEntry_const_iterator map_end() const
- { return make_transform_iterator( map().end(), Transformer() );}
-
private:
const _Map *const _map;
};
@@ -329,6 +327,10 @@
std::ostream & operator<<( std::ostream & str, const std::map<_Key, _Tp> & obj )
{ return str << dumpMap( obj ); }
+ template
+ std::ostream & operator<<( std::ostream & str, const std::tr1::unordered_map<_Key, _Tp> & obj )
+ { return str << dumpMap( obj ); }
+
/** Print stream status bits.
* Prints the values of a streams \c good, \c eof, \c failed and \c bad bit.
*
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolImpl.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolImpl.h?rev=8696&r1=8695&r2=8696&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolImpl.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolImpl.h Fri Feb 15 00:13:41 2008
@@ -13,9 +13,9 @@
#define ZYPP_POOL_POOLIMPL_H
#include <iosfwd>
-#include <map>
#include "zypp/base/Easy.h"
+#include "zypp/base/LogTools.h"
#include "zypp/base/SerialNumber.h"
#include "zypp/base/Deprecated.h"
@@ -81,6 +81,12 @@
size_type size() const
{ return satpool().solvablesSize(); }
+ const_iterator begin() const
+ { return make_filter_begin( pool::ByPoolItem(), store() ); }
+
+ const_iterator end() const
+ { return make_filter_end( pool::ByPoolItem(), store() ); }
+
public:
/** Return the corresponding \ref PoolItem.
* Pool and sat pool should be in sync. Returns an empty
@@ -88,9 +94,7 @@
* \see \ref PoolItem::satSolvable.
*/
PoolItem find( const sat::Solvable & slv_r ) const
- {
- return store()[slv_r.id()];
- }
+ { return store()[slv_r.id()]; }
///////////////////////////////////////////////////////////////////
//
@@ -209,30 +213,6 @@
pi = PoolItem( s );
}
}
-#if 0
- // pass 1: delete no longer existing solvables
- for ( ContainerT::iterator it = _store.begin(); it != _store.end(); /**/ )
- {
- if ( ! it->first ) // solvable became invalid
- _store.erase( it++ ); // postfix! Incrementing before erase
- else
- ++it;
- }
-
- // pass 2: add new solvables
- sat::Pool pool( satpool() );
- if ( _store.size() != pool.solvablesSize() )
- {
- for_( it, pool.solvablesBegin(), pool.solvablesEnd() )
- {
- PoolItem & pi( _store[*it] );
- if ( ! pi ) // newly created
- {
- pi = PoolItem( *it );
- }
- }
- }
-#endif
_storeDirty = false;
}
return _store;
@@ -241,23 +221,21 @@
const Id2ItemT & id2item () const
{
checkSerial();
- if (_id2itemDirty)
+ if ( _id2itemDirty )
{
- _id2itemDirty = false;
store();
- _id2item = Id2ItemT(size());
- const_iterator it = make_filter_begin( ByPoolItem(), store() );
- const_iterator e = make_filter_end( ByPoolItem(), store() );
- for (; it != e; ++it)
- {
- sat::detail::IdType id;
- const sat::Solvable &s = (*it)->satSolvable();
- id = s.ident().id();
- if (s.isKind( ResKind::srcpackage ))
- id = -id;
- _id2item.insert(std::make_pair(id, *it));
- }
- }
+ _id2item = Id2ItemT( size() );
+ for_( it, begin(), end() )
+ {
+ const sat::Solvable &s = (*it)->satSolvable();
+ sat::detail::IdType id = s.ident().id();
+ if ( s.isKind( ResKind::srcpackage ) )
+ id = -id;
+ _id2item.insert( std::make_pair( id, *it ) );
+ }
+ //INT << _id2item << endl;
+ _id2itemDirty = false;
+ }
return _id2item;
}
@@ -270,6 +248,7 @@
{
if ( _watcher.remember( serial() ) )
invalidate();
+ satpool().prepare(); // always ajust dependencies.
}
void invalidate() const
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolTraits.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolTraits.h?rev=8696&r1=8695&r2=8696&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolTraits.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolTraits.h Fri Feb 15 00:13:41 2008
@@ -14,9 +14,12 @@
#include <set>
#include <map>
+#include <list>
+#include <vector>
#include
#include "zypp/base/Iterator.h"
+#include "zypp/base/Iterator.h"
#include "zypp/PoolItem.h"
#include "zypp/sat/Pool.h"
@@ -41,17 +44,21 @@
{ return pi; }
};
- /** Main filter selecting PoolItems bu \c name and \c kind.
+ /** Main filter selecting PoolItems by \c name and \c kind.
*
*/
class ByIdent
{
public:
- ByIdent( sat::Solvable slv_r )
+ ByIdent()
+ : _id( 0 )
+ {}
+
+ explicit ByIdent( sat::Solvable slv_r )
: _id( makeIdent( slv_r ) )
{}
- ByIdent( IdString ident_r )
+ explicit ByIdent( IdString ident_r )
: _id( ident_r.id() )
{}
@@ -120,18 +127,27 @@
{
public:
typedef sat::detail::SolvableIdType SolvableIdType;
+
/** pure items */
-#if 0
- typedef std::mapsat::Solvable,PoolItem ItemContainerT;
- typedef MapKVIteratorTraits<ItemContainerT>::Value_const_iterator
- const_iterator;
-#endif
typedef std::vector<PoolItem> ItemContainerT;
typedef ItemContainerT::const_iterator item_iterator;
typedef filter_iterator
const_iterator;
typedef ItemContainerT::size_type size_type;
- typedef std::tr1::unordered_multimap Id2ItemT;
+
+ /** ident index */
+ typedef std::tr1::unordered_multimap
+ Id2ItemT;
+ typedef std::_Select2ndId2ItemT::value_type Id2ItemValueSelector;
+ typedef transform_iterator
+ byIdent_iterator;
+
+
+ /* list of known Repositories */
+ typedef std::list<Repository> RepoContainerT;
+ typedef RepoContainerT::const_iterator repository_iterator;
+
+
// internal organization
typedef std::listzypp::CapAndItem CapItemContainerT; // (why,who) pairs
@@ -144,9 +160,6 @@
/** hashed by capability index */
typedef const_capitemiterator byCapabilityIndex_iterator;
- /* list of known Repositories */
- typedef std::list<Repository> RepoContainerT;
- typedef RepoContainerT::const_iterator repository_iterator;
typedef PoolImpl Impl;
typedef shared_ptr<PoolImpl> Impl_Ptr;
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/sat/Pool.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/sat/Pool.cc?rev=8696&r1=8695&r2=8696&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/sat/Pool.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/sat/Pool.cc Fri Feb 15 00:13:41 2008
@@ -49,7 +49,7 @@
const SerialNumber & Pool::serial() const
{ return myPool().serial(); }
- void Pool::prepare()
+ void Pool::prepare() const
{ return myPool().prepare(); }
bool Pool::reposEmpty() const
@@ -147,8 +147,30 @@
return ret;
}
+ /////////////////////////////////////////////////////////////////
+
+ void Pool::setRequestedLocales( const LocaleSet & locales_r )
+ { myPool().setRequestedLocales( locales_r ); }
+
+ bool Pool::addRequestedLocale( const Locale & locale_r )
+ { return myPool().addRequestedLocale( locale_r ); }
+
+ bool Pool::eraseRequestedLocale( const Locale & locale_r )
+ { return myPool().eraseRequestedLocale( locale_r ); }
+
+ const LocaleSet & Pool::getRequestedLocales() const
+ { return myPool().getRequestedLocales(); }
+
+ bool Pool::isRequestedLocale( const Locale & locale_r ) const
+ { return myPool().isRequestedLocale( locale_r ); }
+
+ const LocaleSet & Pool::getAvailableLocales() const
+ { return myPool().getAvailableLocales(); }
+
+ bool Pool::isAvailableLocale( const Locale & locale_r ) const
+ { return myPool().isAvailableLocale( locale_r ); }
- /******************************************************************
+ /******************************************************************
**
** FUNCTION NAME : operator<<
** FUNCTION TYPE : std::ostream &
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/sat/Pool.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/sat/Pool.h?rev=8696&r1=8695&r2=8696&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/sat/Pool.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/sat/Pool.h Fri Feb 15 00:13:41 2008
@@ -18,6 +18,7 @@
#include "zypp/sat/detail/PoolMember.h"
#include "zypp/sat/Repo.h"
+#include "zypp/Locale.h"
///////////////////////////////////////////////////////////////////
namespace zypp
@@ -62,7 +63,7 @@
const SerialNumber & serial() const;
/** Update housekeeping data if necessary (e.g. whatprovides). */
- void prepare();
+ void prepare() const;
public:
/** Whether \ref Pool contains repos. */
@@ -103,8 +104,6 @@
{ return reposInsert( systemRepoName() ); }
public:
-
- public:
/** Load \ref Solvables from a solv-file into a \ref Repo named \c name_r.
* In case of an exception the \ref Repo is removed from the \ref Pool.
* \throws Exception if loading the solv-file fails.
@@ -132,6 +131,43 @@
SolvableIterator solvablesEnd() const;
public:
+ /** \name Requested locales. */
+ //@{
+ /** Set the requested locales.
+ * Languages to be supported by the system, e.g. language specific
+ * packages to be installed.
+ */
+ void setRequestedLocales( const LocaleSet & locales_r );
+
+ /** Add one \ref Locale to the set of requested locales.
+ * Return \c true if \c locale_r was newly added to the set.
+ */
+ bool addRequestedLocale( const Locale & locale_r );
+
+ /** Erase one \ref Locale from the set of requested locales.
+ * Return \c false if \c locale_r was not found in the set.
+ */
+ bool eraseRequestedLocale( const Locale & locale_r );
+
+ /** Return the requested locales.
+ * \see \ref setRequestedLocales
+ */
+ const LocaleSet & getRequestedLocales() const;
+
+ /** Wheter this \ref Locale is in the set of requested locales. */
+ bool isRequestedLocale( const Locale & locale_r ) const;
+
+ /** Get the set of available locales.
+ * This is computed from the package data so it actually
+ * represents all locales packages claim to support.
+ */
+ const LocaleSet & getAvailableLocales() const;
+
+ /** Wheter this \ref Locale is in the set of available locales. */
+ bool isAvailableLocale( const Locale & locale_r ) const;
+ //@}
+
+ public:
/** Expert backdoor. */
::_Pool * get() const;
private:
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=8696&r1=8695&r2=8696&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 Feb 15 00:13:41 2008
@@ -62,9 +62,14 @@
}
}
- static detail::IdType nsCallback( struct _Pool *, void *data, detail::IdType lhs, detail::IdType rhs )
+ detail::IdType PoolImpl::nsCallback( struct _Pool *, void *data, detail::IdType lhs, detail::IdType rhs )
{
- //T << Cability( lhs ) << (const char *)data << Capability( rhs ) << endl;
+ if ( lhs == NAMESPACE_LANGUAGE )
+ {
+ const std::tr1::unordered_set<IdString> & locale2Solver( reinterpret_cast(data)->_locale2Solver );
+ return locale2Solver.find( IdString(rhs) ) == locale2Solver.end() ? -1 : 0;
+ }
+ DBG << Capability( lhs ) << " vs. " << Capability( rhs ) << endl;
return 0;
}
@@ -101,8 +106,7 @@
// set namespace callback
_pool->nscallback = &nsCallback;
- _pool->nscallbackdata = (void*)" NAMESPACE ";
- SEC << _pool->nscallback << endl;
+ _pool->nscallbackdata = (void*)this;
}
///////////////////////////////////////////////////////////////////
@@ -125,16 +129,34 @@
else if ( a2 ) DBG << a1 << " " << a2 << endl;
else DBG << a1 << endl;
}
- _serial.setDirty();
+ _serial.setDirty(); // pool content change
+ _localeCollector.clear(); // available locales may change
+
+ // invaldate dependency/namespace related indices:
+ depSetDirty();
+ }
+
+ void PoolImpl::depSetDirty( const char * a1, const char * a2, const char * a3 )
+ {
+ if ( a1 )
+ {
+ if ( a3 ) DBG << a1 << " " << a2 << " " << a3 << endl;
+ else if ( a2 ) DBG << a1 << " " << a2 << endl;
+ else DBG << a1 << endl;
+ }
::pool_freewhatprovides( _pool );
}
- void PoolImpl::prepare()
+ void PoolImpl::prepare() const
{
if ( _watcher.remember( _serial ) )
{
- // sat solver claims to handle this on it's own:
- ::pool_createwhatprovides( _pool );
+ /* nothing to do here, but _watcher MUST remember... */
+ }
+ if ( ! _pool->whatprovides )
+ {
+ DBG << "pool_createwhatprovides..." << endl;
+ ::pool_createwhatprovides( _pool );
}
}
@@ -144,7 +166,6 @@
{
setDirty(__FUNCTION__, repo_r->name );
int ret = ::repo_add_solv( repo_r , file_r );
-
if ( ret == 0 )
{
// Filter out unwanted archs
@@ -184,10 +205,54 @@
blockBegin = blockSize = 0;
}
}
-
return ret;
}
+ ///////////////////////////////////////////////////////////////////
+
+ // need on demand and id based Locale
+ void _locale_hack( const LocaleSet & locales_r,
+ std::tr1::unordered_set<IdString> & locale2Solver )
+ {
+ std::tr1::unordered_set<IdString>( 2*locales_r.size() ).swap( locale2Solver ) ;
+ for_( it, locales_r.begin(),locales_r.end() )
+ {
+ for ( Locale l( *it ); l != Locale::noCode; l = l.fallback() )
+ locale2Solver.insert( IdString( l.code() ) );
+ }
+ DBG << "New Solver Locales: " << locale2Solver << endl;
+ }
+
+
+ void PoolImpl::setRequestedLocales( const LocaleSet & locales_r )
+ {
+ depSetDirty( "setRequestedLocales" );
+ _requestedLocales = locales_r;
+ DBG << "New RequestedLocales: " << locales_r << endl;
+ _locale_hack( _requestedLocales, _locale2Solver );
+ }
+
+ bool PoolImpl::addRequestedLocale( const Locale & locale_r )
+ {
+ if ( _requestedLocales.insert( locale_r ).second )
+ {
+ depSetDirty( "addRequestedLocale", locale_r.code().c_str() );
+ _locale_hack( _requestedLocales, _locale2Solver );
+ return true;
+ }
+ return false;
+ }
+
+ bool PoolImpl::eraseRequestedLocale( const Locale & locale_r )
+ {
+ if ( _requestedLocales.erase( locale_r ) )
+ {
+ depSetDirty( "addRequestedLocale", locale_r.code().c_str() );
+ _locale_hack( _requestedLocales, _locale2Solver );
+ return true;
+ }
+ return false;
+ }
/////////////////////////////////////////////////////////////////
} // namespace detail
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/sat/detail/PoolImpl.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/sat/detail/PoolImpl.h?rev=8696&r1=8695&r2=8696&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/sat/detail/PoolImpl.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/sat/detail/PoolImpl.h Fri Feb 15 00:13:41 2008
@@ -20,11 +20,14 @@
#include
}
#include <iosfwd>
+#include
#include "zypp/base/NonCopyable.h"
#include "zypp/base/SerialNumber.h"
#include "zypp/sat/detail/PoolMember.h"
#include "zypp/RepoInfo.h"
+#include "zypp/Locale.h"
+#include "zypp/IdString.h"
///////////////////////////////////////////////////////////////////
namespace zypp
@@ -51,25 +54,31 @@
~PoolImpl();
/** Pointer style access forwarded to sat-pool. */
- ::_Pool * operator->()
- { return _pool; }
+ ::_Pool * operator->()
+ { return _pool; }
public:
/** Serial number changing whenever the content changes. */
const SerialNumber & serial() const
{ return _serial; }
-
/** Update housekeeping data (e.g. whatprovides).
* \todo actually requires a watcher.
- */
- void prepare();
+ */
+ void prepare() const;
- public:
- /** Invalidate housekeeping data (e.g. whatprovides).
- */
+ private:
+ /** Invalidate housekeeping data (e.g. whatprovides) if the
+ * pools content changed.
+ */
void setDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
+ /** Invalidate housekeeping data (e.g. whatprovides) if dependencies changed.
+ */
+ void depSetDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
+
+ static detail::IdType nsCallback( ::_Pool *, void * data, detail::IdType lhs, detail::IdType rhs );
+
public:
/** \name Actions invalidating housekeeping data.
*
@@ -134,7 +143,7 @@
public:
/** Get id of the first valid \ref Solvable.
* This is the next valid after the system solvable.
- */
+ */
SolvableIdType getFirstId() const
{ return getNextId( 1 ); }
@@ -164,6 +173,42 @@
void eraseRepoInfo( RepoIdType id_r )
{ _repoinfos.erase( id_r ); }
+ public:
+ /** \name Requested locales. */
+ //@{
+ void setRequestedLocales( const LocaleSet & locales_r );
+ bool addRequestedLocale( const Locale & locale_r );
+ bool eraseRequestedLocale( const Locale & locale_r );
+
+ const LocaleSet & getRequestedLocales() const
+ { return _requestedLocales; }
+
+ bool isRequestedLocale( const Locale & locale_r ) const
+ {
+ LocaleSet::const_iterator it( _requestedLocales.find( locale_r ) );
+ return it != _requestedLocales.end();
+ }
+
+ const LocaleSet & getAvailableLocales() const
+ {
+ if ( _availableLocales.size() != _localeCollector.size() )
+ {
+ _availableLocales.clear();
+ for_( it, _localeCollector.begin(), _localeCollector.end() )
+ _availableLocales.insert( Locale( *it ) );
+ }
+ return _availableLocales;
+ }
+
+ bool isAvailableLocale( const Locale & locale_r ) const
+ {
+ const LocaleSet & avl( getAvailableLocales() );
+ LocaleSet::const_iterator it( avl.find( locale_r ) );
+ return it != avl.end();
+ }
+
+ //@}
+
private:
/** sat-pool. */
::_Pool * _pool;
@@ -173,6 +218,12 @@
SerialNumberWatcher _watcher;
/** Additional \ref RepoInfo. */
std::map _repoinfos;
+
+ /** */
+ LocaleSet _requestedLocales;
+ mutable LocaleSet _availableLocales;
+ mutable std::tr1::unordered_set<IdString> _localeCollector;
+ mutable std::tr1::unordered_set<IdString> _locale2Solver;
};
///////////////////////////////////////////////////////////////////
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=8696&r1=8695&r2=8696&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 Feb 15 00:13:41 2008
@@ -13,6 +13,8 @@
#define ZYPP_SAT_DETAIL_POOLMEMBER_H
#include "zypp/base/Iterator.h"
+#include "zypp/base/String.h"
+#include "zypp/base/Easy.h"
extern "C"
{
@@ -21,6 +23,16 @@
struct _Pool;
}
+#define ZYPP_DEFINE_ID_HASHABLE(C) \
+namespace std { namespace tr1 { \
+ template<class _Tp> struct hash; \
+ template<> struct hash<C> \
+ { \
+ size_t operator()( const C & __s ) const \
+ { return __s.id(); } \
+ }; \
+}}
+
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/ResolverUpgrade.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/ResolverUpgrade.cc?rev=8696&r1=8695&r2=8696&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/ResolverUpgrade.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/ResolverUpgrade.cc Fri Feb 15 00:13:41 2008
@@ -599,6 +599,10 @@
bool requested_locale_match = false;
Capabilities freshens( guess->dep( Dep::FRESHENS ) );
+#warning THIS DOES NO LONGER WORK, CREATE SAT::sOLVABLE::WHATEVERISNEEDED (IN DOUBT ASK MA@)
+// We no longer have any 'locale()' deps in FRESHENS!
+// Providing 'bool sat::Solvable::supportsRequestedLocale()' should simplify this code.
+// Maybe an enum instead of bool ( yes, no and via fallback list )
// is this a language package ?
for (Capabilities::const_iterator cit = freshens.begin(); cit != freshens.end(); ++cit) {
string citName = cit->asString();
@@ -625,8 +629,7 @@
break;
} else {
freshens = item->dep( Dep::FRESHENS );
- ZYpp::Ptr z = zypp::getZYpp();
- ZYpp::LocaleSet requested_locales = z->getRequestedLocales();
+ const LocaleSet & requested_locales = sat::Pool::instance().getRequestedLocales();
// try to find a match of the locale freshens with one of the requested locales
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/zypp_detail/ZYppImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/zypp_detail/ZYppImpl.cc?rev=8696&r1=8695&r2=8696&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/zypp_detail/ZYppImpl.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/zypp_detail/ZYppImpl.cc Fri Feb 15 00:13:41 2008
@@ -164,113 +164,6 @@
}
//------------------------------------------------------------------------
- // locales
-
- /** */
- void ZYppImpl::setRequestedLocales( const LocaleSet & locales_r )
- {
-#warning REIMPLEMENT WITHOUT LANGUAGE RESOLVABLE
-#if 0
- ResPool mpool( ResPool::instance() );
- // assert all requested are available
- for ( LocaleSet::const_iterator it = locales_r.begin();
- it != locales_r.end(); ++it )
- {
- NameKindProxy select( nameKindProxy<Language>( mpool, it->code() ) );
- if ( select.installedEmpty() && select.availableEmpty() )
- _pool.insert( Language::availableInstance( *it ) );
- }
-
- // now adjust status
- for ( ResPool::byKind_iterator it = mpool.byKindBegin<Language>();
- it != mpool.byKindEnd<Language>(); ++it )
- {
- NameKindProxy select( nameKindProxy<Language>( mpool, (*it)->name() ) );
- if ( locales_r.find( Locale( (*it)->name() ) ) != locales_r.end() )
- {
- // Language is requested
- if ( select.installedEmpty() )
- {
- if ( select.availableEmpty() )
- {
- // no item ==> provide available to install
- _pool.insert( Language::availableInstance( Locale((*it)->name()) ) );
- select = nameKindProxy<Language>( mpool, (*it)->name() );
- }
- // available only ==> to install
- select.availableBegin()->status().setTransactValue( ResStatus::TRANSACT, ResStatus::USER );
- }
- else
- {
- // installed ==> keep it
- select.installedBegin()->status().setTransactValue( ResStatus::KEEP_STATE, ResStatus::USER );
- if ( ! select.availableEmpty() )
- {
- // both items ==> keep
- select.availableBegin()->status().resetTransact( ResStatus::USER );
- }
- }
- }
- else
- {
- // Language is NOT requested
- if ( ! select.installedEmpty() )
- select.installedBegin()->status().setTransactValue( ResStatus::TRANSACT, ResStatus::USER );
- if ( ! select.availableEmpty() )
- select.availableBegin()->status().resetTransact( ResStatus::USER );
- }
- }
-#endif
- }
-
- /** */
- ZYppImpl::LocaleSet ZYppImpl::getAvailableLocales() const
- {
- ZYpp::LocaleSet ret;
-#warning REIMPLEMENT WITHOUT LANGUAGE RESOLVABLE
-#if 0
- ResPool mpool( ResPool::instance() );
- for ( ResPool::byKind_iterator it = mpool.byKindBegin<Language>();
- it != mpool.byKindEnd<Language>(); ++it )
- {
- if ( (*it).status().isUninstalled() ) // available!
- ret.insert( Locale( (*it)->name() ) );
- }
-#endif
- return ret;
- }
-
- /** */
- ZYppImpl::LocaleSet ZYppImpl::getRequestedLocales() const
- {
- ZYpp::LocaleSet ret;
-#warning REIMPLEMENT WITHOUT LANGUAGE RESOLVABLE
-#if 0
- ResPool mpool( ResPool::instance() );
- for ( ResPool::byKind_iterator it = mpool.byKindBegin<Language>();
- it != mpool.byKindEnd<Language>(); ++it )
- {
- NameKindProxy select( nameKindProxy<Language>( mpool, (*it)->name() ) );
- if ( ! select.installedEmpty()
- && select.installedBegin()->status().getTransactValue() != ResStatus::TRANSACT )
- ret.insert( Locale( (*it)->name() ) );
- else if ( ! select.availableEmpty()
- && select.availableBegin()->status().getTransactValue() == ResStatus::TRANSACT )
- ret.insert( Locale( (*it)->name() ) );
- }
-#endif
- return ret;
- }
-
- void ZYppImpl::availableLocale( const Locale & locale_r )
- {
-#warning REIMPLEMENT WITHOUT LANGUAGE RESOLVABLE
-#if 0
- _pool.insert( Language::availableInstance( locale_r ) );
-#endif
- }
-
- //------------------------------------------------------------------------
// target store path
Pathname ZYppImpl::homePath() const
@@ -287,6 +180,7 @@
int ZYppImpl::applyLocks()
{
+#warning make the /etc/zypp/locks path an option zconfig.
Pathname locksrcPath( "/etc/zypp/locks" );
try
{
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/zypp_detail/ZYppImpl.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/zypp_detail/ZYppImpl.h?rev=8696&r1=8695&r2=8696&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/zypp_detail/ZYppImpl.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/zypp_detail/ZYppImpl.h Fri Feb 15 00:13:41 2008
@@ -17,7 +17,6 @@
#include "zypp/TmpPath.h"
#include "zypp/Target.h"
#include "zypp/Resolver.h"
-#include "zypp/Locale.h"
#include "zypp/KeyRing.h"
#include "zypp/ZYppCommit.h"
#include "zypp/ResTraits.h"
@@ -88,18 +87,6 @@
void installSrcPackage( const SrcPackage_constPtr & srcPackage_r );
public:
- typedef std::set<Locale> LocaleSet;
- /** */
- void setRequestedLocales( const LocaleSet & locales_r );
- /** */
- LocaleSet getRequestedLocales() const;
- /** */
- LocaleSet getAvailableLocales() const;
-
- /** internal use */
- void availableLocale( const Locale & locale_r );
-
- public:
/** Get the path where zypp related plugins store persistent data and caches */
Pathname homePath() const;
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org