Author: mlandres Date: Fri Feb 15 18:03:19 2008 New Revision: 8755 URL: http://svn.opensuse.org/viewcvs/zypp?rev=8755&view=rev Log: correctly provide available locales Modified: trunk/libzypp/zypp/Capabilities.h trunk/libzypp/zypp/sat/detail/PoolImpl.cc trunk/libzypp/zypp/sat/detail/PoolImpl.h Modified: trunk/libzypp/zypp/Capabilities.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Capabilities.h?rev=8755&r1=8754&r2=8755&view=diff ============================================================================== --- trunk/libzypp/zypp/Capabilities.h (original) +++ trunk/libzypp/zypp/Capabilities.h Fri Feb 15 18:03:19 2008 @@ -71,7 +71,7 @@ /** Iterator pointing to the first \ref Capability. */ const_iterator begin() const; - /** Iterator pointing bhind the last \ref Capability. */ + /** Iterator pointing behind the last \ref Capability. */ const_iterator end() const; private: Modified: trunk/libzypp/zypp/sat/detail/PoolImpl.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/detail/PoolImpl.cc?rev=8755&r1=8754&r2=8755&view=diff ============================================================================== --- trunk/libzypp/zypp/sat/detail/PoolImpl.cc (original) +++ trunk/libzypp/zypp/sat/detail/PoolImpl.cc Fri Feb 15 18:03:19 2008 @@ -16,12 +16,14 @@ #include "zypp/base/LogTools.h" #include "zypp/base/Gettext.h" #include "zypp/base/Exception.h" +#include "zypp/base/Measure.h" #include "zypp/ZConfig.h" #include "zypp/sat/detail/PoolImpl.h" -#include "zypp/sat/Repo.h" +#include "zypp/sat/Pool.h" #include "zypp/Capability.h" +#include "zypp/Locale.h" using std::endl; @@ -129,8 +131,8 @@ else if ( a2 ) DBG << a1 << " " << a2 << endl; else DBG << a1 << endl; } - _serial.setDirty(); // pool content change - _localeCollector.clear(); // available locales may change + _serial.setDirty(); // pool content change + _availableLocalesPtr.reset(); // available locales may change // invaldate dependency/namespace related indices: depSetDirty(); @@ -254,6 +256,56 @@ return false; } + static void _getLocaleDeps( Capability cap_r, std::tr1::unordered_setsat::detail::IdType & store_r ) + { + // Collect locales from any 'namespace:language(lang)' dependency + CapDetail detail( cap_r ); + if ( detail.kind() == CapDetail::EXPRESSION ) + { + switch ( detail.capRel() ) + { + case CapDetail::CAP_AND: + case CapDetail::CAP_OR: + // expand + _getLocaleDeps( detail.lhs(), store_r ); + _getLocaleDeps( detail.rhs(), store_r ); + break; + + case CapDetail::CAP_NAMESPACE: + if ( detail.lhs().id() == NAMESPACE_LANGUAGE ) + { + store_r.insert( detail.rhs().id() ); + } + break; + } + } + } + + const LocaleSet & PoolImpl::getAvailableLocales() const + { + if ( !_availableLocalesPtr ) + { + // Collect any 'namespace:language(ja)' dependencies + std::tr1::unordered_setsat::detail::IdType tmp; + Pool pool( Pool::instance() ); + for_( it, pool.solvablesBegin(), pool.solvablesEnd() ) + { + Capabilities cap( it->supplements() ); + for_( cit, cap.begin(), cap.end() ) + { + _getLocaleDeps( *cit, tmp ); + } + } +#warning immediately build LocaleSet as soon as Loale is an Id based type + _availableLocalesPtr.reset( new LocaleSet(tmp.size()) ); + for_( it, tmp.begin(), tmp.end() ) + { + _availableLocalesPtr->insert( Locale( IdString(*it) ) ); + } + } + return *_availableLocalesPtr; + } + ///////////////////////////////////////////////////////////////// } // namespace detail /////////////////////////////////////////////////////////////////// Modified: trunk/libzypp/zypp/sat/detail/PoolImpl.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/detail/PoolImpl.h?rev=8755&r1=8754&r2=8755&view=diff ============================================================================== --- trunk/libzypp/zypp/sat/detail/PoolImpl.h (original) +++ trunk/libzypp/zypp/sat/detail/PoolImpl.h Fri Feb 15 18:03:19 2008 @@ -189,16 +189,7 @@ 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; - } + const LocaleSet & getAvailableLocales() const; bool isAvailableLocale( const Locale & locale_r ) const { @@ -221,8 +212,7 @@ /** */ LocaleSet _requestedLocales; - mutable LocaleSet _availableLocales; - mutable std::tr1::unordered_set<IdString> _localeCollector; + mutable scoped_ptr<LocaleSet> _availableLocalesPtr; mutable std::tr1::unordered_set<IdString> _locale2Solver; }; /////////////////////////////////////////////////////////////////// -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org