+// //////////////////////////////////////////////////////////////////////
+// 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:
//
--- /dev/null
+
+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;
+ }
+
defCompatibleWith( _ppc, _ppc64 );
//
///////////////////////////////////////////////////////////////////
+ dumpOn( USR ) << endl;
}
private:
base/Functional.h
base/Gettext.h
base/GzStream.h
- base/Hash.h
base/IOStream.h
base/InputStream.h
base/Iterator.h
base/String.h
base/Regex.h
base/Sysconfig.h
- base/UniqueString.h
base/Unit.h
base/WatchFile.h
)
#define ZYPP_SAT_CAPABILITY_H
#include <iosfwd>
-#include <set>
+#include <tr1/unordered_set>
#include "zypp/base/SafeBool.h"
#include "zypp/base/Deprecated.h"
class Capability;
class CapDetail;
- typedef std::set<Capability> CapabilitySet;
+ typedef std::tr1::unordered_set<Capability> CapabilitySet;
///////////////////////////////////////////////////////////////////
//
* \endcode
*/
class Capability: protected sat::detail::PoolMember,
- private base::SafeBool<Capability>
+ private base::SafeBool<Capability>
{
public:
// legacy
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
+
+ZYPP_DEFINE_ID_HASHABLE( ::zypp::Capability )
+
#endif // ZYPP_SAT_CAPABILITY_H
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
+
+ZYPP_DEFINE_ID_HASHABLE( ::zypp::IdString )
+
#endif // ZYPP_SAT_IDSTR_H
typedef std::map<std::string, std::string> OtherDefaultLanguage;
static OtherDefaultLanguage otherDefaultLanguage;
-
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : Locale::Impl
if (otherDefaultLanguage.find(code()) != otherDefaultLanguage.end())
return LanguageCode(otherDefaultLanguage[code()]);
-
+
if ( _country.hasCode() )
return _language;
: _pimpl( Impl::nullimpl() )
{}
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : Locale::Locale
+ // METHOD TYPE : Ctor
+ //
+ Locale::Locale( IdString code_r )
+ : _pimpl( new Impl( code_r.asString() ) )
+ {}
+
///////////////////////////////////////////////////////////////////
//
// METHOD NAME : Locale::Locale
: _pimpl( new Impl( code_r ) )
{}
+ ///////////////////////////////////////////////////////////////////
+ //
+ // 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
#define ZYPP_LOCALE_H
#include <iosfwd>
+#include <tr1/unordered_set>
#include "zypp/base/PtrTypes.h"
+#include "zypp/IdString.h"
#include "zypp/LanguageCode.h"
#include "zypp/CountryCode.h"
//
// CLASS NAME : Locale
//
- /** */
+ /**
+ * \todo migrate to IdString
+ */
class Locale
{
friend std::ostream & operator<<( std::ostream & str, const Locale & obj );
Locale();
/** 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() );
}
//@}
+ ///////////////////////////////////////////////////////////////////
+
+ 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 hash<std::string>()(__s.code()); }
+ };
+}}
+
///////////////////////////////////////////////////////////////////
namespace std
{ /////////////////////////////////////////////////////////////////
#ifndef ZYPP_PACKAGEKEYWORD_H
#define ZYPP_PACKAGEKEYWORD_H
-#include "zypp/base/UniqueString.h"
+#include "zypp/IdStringType.h"
///////////////////////////////////////////////////////////////////
namespace zypp
//
// 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;
+ };
///////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
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<<
class SerialNumber;
class ResPoolProxy;
-
-
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : ResPool
* 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
{
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:
public:
/** \name Iterate through all PoolItems of a certain name and kind. */
//@{
- typedef pool::ByIdent ByIdent;
- typedef pool::PoolTraits::Id2ItemT Id2ItemT;
- typedef transform_iterator<std::_Select2nd<Id2ItemT::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<Id2ItemT::const_iterator, Id2ItemT::const_iterator> it2
- = id2item().equal_range(id);
- return make_transform_iterator(it2.first, std::_Select2nd<Id2ItemT::value_type>());
- }
-
- byIdent_iterator byIdentEnd( sat::detail::IdType id ) const
- {
- std::pair<Id2ItemT::const_iterator, Id2ItemT::const_iterator> it2
- = id2item().equal_range(id);
- return make_transform_iterator(it2.second, std::_Select2nd<Id2ItemT::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:
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.
#include "zypp/ZYpp.h"
#include "zypp/zypp_detail/ZYppImpl.h"
+#include "zypp/sat/Pool.h"
using std::endl;
///////////////////////////////////////////////////////////////////
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(); }
class ZYppFactory;
class ResPool;
class ResPoolProxy;
- class Locale;
class KeyRing;
///////////////////////////////////////////////////////////////////
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:
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/base/Hash.h
- *
-*/
-#ifndef ZYPP_BASE_HASH_H
-#define ZYPP_BASE_HASH_H
-
-#include <string>
-
-#include <ext/hash_set>
-#include <ext/hash_map>
-
-///////////////////////////////////////////////////////////////////
-namespace __gnu_cxx
-{ /////////////////////////////////////////////////////////////////
-
- /** Specialize hash function for std::string. */
- template<>
- struct hash<std::string>
- {
- size_t operator()( const std::string & __s ) const
- { return __stl_hash_string(__s.c_str()); }
- };
-
- /////////////////////////////////////////////////////////////////
-} // namespace __gnu_cxx
-///////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
- using __gnu_cxx::hash_set;
- using __gnu_cxx::hash_map;
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_BASE_HASH_H
#include <list>
#include <set>
#include <map>
+#include <tr1/unordered_set>
+#include <tr1/unordered_map>
#include "zypp/base/Logger.h"
#include "zypp/base/Iterator.h"
#include "zypp/base/Deprecated.h"
std::ostream & operator<<( std::ostream & str, const std::set<_Tp> & obj )
{ 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() ); }
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;
};
std::ostream & operator<<( std::ostream & str, const std::map<_Key, _Tp> & obj )
{ return str << dumpMap( obj ); }
+ template<class _Key, class _Tp>
+ 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.
*
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/base/UniqueString.h
- *
-*/
-#ifndef ZYPP_BASE_UNIQUESTRING_H
-#define ZYPP_BASE_UNIQUESTRING_H
-
-#include <iosfwd>
-#include <string>
-
-#include <zypp/base/Hash.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace base
- { /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : UniqueString
- //
- /** Immutable strings with unique representation in memory.
- *
- * Each UniqueString provides a <tt>const std::string</tt>.
- * This string is stored in a unifying hash, that way equal
- * UniqueStrings share their string representation in memory.
- *
- * At the same time the unifying hash contains all the string
- * values created so far. Static methods are provided to query
- * the hash contents.
- *
- * Uses CRTP to provide the unifying hash.
- *
- * \code
- * struct KeyWord : public base::UniqueString<KeyWord>
- * {
- * KeyWord()
- * {}
- * KeyWord( const std::string & name_r )
- * :base::UniqueString<KeyWord>( name_r )
- * {}
- * };
- *
- * int main( int argc, char * argv[] )
- * {
- * KeyWord();
- * KeyWord( "a" );
- * KeyWord( "b" );
- * KeyWord( "c" );
- * KeyWord( "a" );
- * KeyWord( "c" );
- *
- * DBG << "Known KeyWords: " << KeyWord::allSize() << endl;
- * for ( KeyWord::const_iterator it = KeyWord::allBegin(); it != KeyWord::allEnd(); ++it )
- * {
- * DBG << *it << endl;
- * }
- *
- * return 0;
- * }
- * \endcode
- * \code
- * Known KeyWords: 3
- * a
- * b
- * c
- * \endcode
- */
- template<class _Derived>
- class UniqueString
- {
- protected:
- /** Default ctor provides an empty string. */
- UniqueString()
- {}
-
- /** Ctor taking a name to store. */
- UniqueString( const std::string & name_r )
- {
- if ( !name_r.empty() )
- {
- _name = *(this->hash().insert( name_r ).first);
- }
- }
-
- /** Dtor */
- virtual ~UniqueString()
- {}
-
- public:
- /** Explicit conversion to string. */
- const std::string & asString() const
- { return _name; }
-
- /** Explicit conversion to string (convenience). */
- const std::string & str() const
- { return asString(); }
-
- /** Implicit conversion to string. */
- operator const std::string & () const
- { return asString(); }
-
- /** Short for <tt>str().size()</tt>. */
- std::string::size_type size() const
- { return asString().size(); }
-
- /** Short for <tt>str().empty()</tt>. */
- bool empty() const
- { return asString().empty(); }
-
- /** Short for <tt>str().compare( s )</tt>.*/
- int compare( const std::string & rhs ) const
- { return asString().compare( rhs ); }
-
- public:
- typedef hash_set<std::string>::size_type size_type;
- typedef hash_set<std::string>::const_iterator const_iterator;
-
- /** Whether there are known UniqueStrings. */
- static bool allEmpty()
- { return hash().empty(); }
-
- /** Number of known UniqueStrings. */
- static size_type allSize()
- { return hash().size(); }
-
- /** Iterator to the 1st UniqueString. */
- static const_iterator allBegin()
- { return hash().begin(); }
-
- /** Iterator behind the last UniqueString. */
- static const_iterator allEnd()
- { return hash().end(); }
-
- private:
- /** Provides the static hash to unify the strings. */
- static hash_set<std::string> & hash()
- {
- static hash_set<std::string> _value;
- return _value;
- }
-
- private:
- /** Immutable string. */
- std::string _name;
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates UniqueString operator == */
- template<class _Derived>
- inline bool operator==( const UniqueString<_Derived> & lhs, const UniqueString<_Derived> & rhs )
- { return ( lhs.str() == rhs.str() ); }
- /** \relates UniqueString operator == */
- template<class _Derived>
- inline bool operator==( const UniqueString<_Derived> & lhs, const std::string & rhs )
- { return ( lhs.str() == rhs ); }
- /** \relates UniqueString operator == */
- template<class _Derived>
- inline bool operator==( const std::string & lhs, const UniqueString<_Derived> & rhs )
- { return ( lhs == rhs.str() ); }
-
-
- /** \relates UniqueString operator != */
- template<class _Derived>
- inline bool operator!=( const UniqueString<_Derived> & lhs, const UniqueString<_Derived> & rhs )
- { return ( lhs.str() != rhs.str() ); }
- /** \relates UniqueString operator != */
- template<class _Derived>
- inline bool operator!=( const UniqueString<_Derived> & lhs, const std::string & rhs )
- { return ( lhs.str() != rhs ); }
- /** \relates UniqueString operator != */
- template<class _Derived>
- inline bool operator!=( const std::string & lhs, const UniqueString<_Derived> & rhs )
- { return ( lhs != rhs.str() ); }
-
-
- /** \relates UniqueString operator < */
- template<class _Derived>
- inline bool operator<( const UniqueString<_Derived> & lhs, const UniqueString<_Derived> & rhs )
- { return ( lhs.str() < rhs.str() ); }
- /** \relates UniqueString operator < */
- template<class _Derived>
- inline bool operator<( const UniqueString<_Derived> & lhs, const std::string & rhs )
- { return ( lhs.str() < rhs ); }
- /** \relates UniqueString operator < */
- template<class _Derived>
- inline bool operator<( const std::string & lhs, const UniqueString<_Derived> & rhs )
- { return ( lhs < rhs.str() ); }
-
-
- /** \relates UniqueString operator > */
- template<class _Derived>
- inline bool operator>( const UniqueString<_Derived> & lhs, const UniqueString<_Derived> & rhs )
- { return ( lhs.str() > rhs.str() ); }
- /** \relates UniqueString operator > */
- template<class _Derived>
- inline bool operator>( const UniqueString<_Derived> & lhs, const std::string & rhs )
- { return ( lhs.str() > rhs ); }
- /** \relates UniqueString operator > */
- template<class _Derived>
- inline bool operator>( const std::string & lhs, const UniqueString<_Derived> & rhs )
- { return ( lhs > rhs.str() ); }
-
-
- /** \relates UniqueString operator <= */
- template<class _Derived>
- inline bool operator<=( const UniqueString<_Derived> & lhs, const UniqueString<_Derived> & rhs )
- { return ( lhs.str() <= rhs.str() ); }
- /** \relates UniqueString operator <= */
- template<class _Derived>
- inline bool operator<=( const UniqueString<_Derived> & lhs, const std::string & rhs )
- { return ( lhs.str() <= rhs ); }
- /** \relates UniqueString operator <= */
- template<class _Derived>
- inline bool operator<=( const std::string & lhs, const UniqueString<_Derived> & rhs )
- { return ( lhs <= rhs.str() ); }
-
-
- /** \relates UniqueString operator >= */
- template<class _Derived>
- inline bool operator>=( const UniqueString<_Derived> & lhs, const UniqueString<_Derived> & rhs )
- { return ( lhs.str() >= rhs.str() ); }
- /** \relates UniqueString operator >= */
- template<class _Derived>
- inline bool operator>=( const UniqueString<_Derived> & lhs, const std::string & rhs )
- { return ( lhs.str() >= rhs ); }
- /** \relates UniqueString operator >= */
- template<class _Derived>
- inline bool operator>=( const std::string & lhs, const UniqueString<_Derived> & rhs )
- { return ( lhs >= rhs.str() ); }
-
- /** \relates UniqueString Stream output */
- template<class _Derived>
- inline std::ostream & operator<<( std::ostream & str, const UniqueString<_Derived> & obj )
- { return str << obj.str(); }
-
- /////////////////////////////////////////////////////////////////
- } // namespace base
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_BASE_UNIQUESTRING_H
#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"
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
* \see \ref PoolItem::satSolvable.
*/
PoolItem find( const sat::Solvable & slv_r ) const
- {
- return store()[slv_r.id()];
- }
+ { return store()[slv_r.id()]; }
///////////////////////////////////////////////////////////////////
//
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;
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;
}
{
if ( _watcher.remember( serial() ) )
invalidate();
+ satpool().prepare(); // always ajust dependencies.
}
void invalidate() const
#include <set>
#include <map>
+#include <list>
+#include <vector>
#include <tr1/unordered_map>
+#include "zypp/base/Iterator.h"
#include "zypp/base/Iterator.h"
#include "zypp/PoolItem.h"
{ 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() )
{}
{
public:
typedef sat::detail::SolvableIdType SolvableIdType;
+
/** pure items */
-#if 0
- typedef std::map<sat::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<ByPoolItem,ItemContainerT::const_iterator>
const_iterator;
typedef ItemContainerT::size_type size_type;
- typedef std::tr1::unordered_multimap<sat::detail::IdType, PoolItem> Id2ItemT;
+
+ /** ident index */
+ typedef std::tr1::unordered_multimap<sat::detail::IdType, PoolItem>
+ Id2ItemT;
+ typedef std::_Select2nd<Id2ItemT::value_type> Id2ItemValueSelector;
+ typedef transform_iterator<Id2ItemValueSelector, Id2ItemT::const_iterator>
+ byIdent_iterator;
+
+
+ /* list of known Repositories */
+ typedef std::list<Repository> RepoContainerT;
+ typedef RepoContainerT::const_iterator repository_iterator;
+
+
// internal organization
typedef std::list<zypp::CapAndItem> CapItemContainerT; // (why,who) pairs
/** 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;
const SerialNumber & Pool::serial() const
{ return myPool().serial(); }
- void Pool::prepare()
+ void Pool::prepare() const
{ return myPool().prepare(); }
bool Pool::reposEmpty() const
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 &
#include "zypp/sat/detail/PoolMember.h"
#include "zypp/sat/Repo.h"
+#include "zypp/Locale.h"
///////////////////////////////////////////////////////////////////
namespace zypp
const SerialNumber & serial() const;
/** Update housekeeping data if necessary (e.g. whatprovides). */
- void prepare();
+ void prepare() const;
public:
/** Whether \ref Pool contains repos. */
Repo systemRepo()
{ 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.
/** Iterator behind the last \ref Solvable. */
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;
}
}
- 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<PoolImpl*>(data)->_locale2Solver );
+ return locale2Solver.find( IdString(rhs) ) == locale2Solver.end() ? -1 : 0;
+ }
+ DBG << Capability( lhs ) << " vs. " << Capability( rhs ) << endl;
return 0;
}
// set namespace callback
_pool->nscallback = &nsCallback;
- _pool->nscallbackdata = (void*)" NAMESPACE ";
- SEC << _pool->nscallback << endl;
+ _pool->nscallbackdata = (void*)this;
}
///////////////////////////////////////////////////////////////////
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 );
}
}
{
setDirty(__FUNCTION__, repo_r->name );
int ret = ::repo_add_solv( repo_r , file_r );
-
if ( ret == 0 )
{
// Filter out unwanted archs
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
#include <satsolver/repo_solv.h>
}
#include <iosfwd>
+#include <tr1/unordered_set>
#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
~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.
*
public:
/** Get id of the first valid \ref Solvable.
* This is the next valid after the system solvable.
- */
+ */
SolvableIdType getFirstId() const
{ return getNextId( 1 ); }
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;
SerialNumberWatcher _watcher;
/** Additional \ref RepoInfo. */
std::map<RepoIdType,RepoInfo> _repoinfos;
+
+ /** */
+ LocaleSet _requestedLocales;
+ mutable LocaleSet _availableLocales;
+ mutable std::tr1::unordered_set<IdString> _localeCollector;
+ mutable std::tr1::unordered_set<IdString> _locale2Solver;
};
///////////////////////////////////////////////////////////////////
#define ZYPP_SAT_DETAIL_POOLMEMBER_H
#include "zypp/base/Iterator.h"
+#include "zypp/base/String.h"
+#include "zypp/base/Easy.h"
extern "C"
{
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
{ /////////////////////////////////////////////////////////////////
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();
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
_target->_pimpl->installSrcPackage( srcPackage_r );
}
- //------------------------------------------------------------------------
- // 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
int ZYppImpl::applyLocks()
{
+#warning make the /etc/zypp/locks path an option zconfig.
Pathname locksrcPath( "/etc/zypp/locks" );
try
{
#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"
/** Install a source package on the Target. */
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;