1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/sat/Pool.h
12 #ifndef ZYPP_SAT_POOL_H
13 #define ZYPP_SAT_POOL_H
17 #include "zypp/Pathname.h"
19 #include "zypp/sat/detail/PoolMember.h"
20 #include "zypp/Repository.h"
21 #include "zypp/sat/WhatProvides.h"
22 #include "zypp/sat/Queue.h"
24 ///////////////////////////////////////////////////////////////////
26 { /////////////////////////////////////////////////////////////////
31 ///////////////////////////////////////////////////////////////////
33 { /////////////////////////////////////////////////////////////////
35 ///////////////////////////////////////////////////////////////////
41 * Explicitly shared singleton \ref Pool::instance.
43 class Pool : protected detail::PoolMember
46 typedef detail::SolvableIterator SolvableIterator;
47 typedef zypp::detail::RepositoryIterator RepositoryIterator;
48 typedef detail::size_type size_type;
51 /** Singleton ctor. */
52 static Pool instance()
55 /** Ctor from \ref PoolMember. */
56 Pool( const detail::PoolMember & )
60 /** Internal array size for stats only. */
61 size_type capacity() const;
63 /** Housekeeping data serial number. */
64 const SerialNumber & serial() const;
66 /** Update housekeeping data if necessary (e.g. whatprovides). */
69 /** \ref prepare plus some expensive checks done before solving only. */
70 void prepareForSolving() const;
72 /** Get rootdir (for file conflicts check) */
73 Pathname rootDir() const;
75 /** Set rootdir (for file conflicts check) */
76 void rootDir( const Pathname & root_r );
79 /** Whether \ref Pool contains repos. */
80 bool reposEmpty() const;
82 /** Number of repos in \ref Pool. */
83 size_type reposSize() const;
85 /** Iterator to the first \ref Repository. */
86 RepositoryIterator reposBegin() const;
88 /** Iterator behind the last \ref Repository. */
89 RepositoryIterator reposEnd() const;
91 /** Return a \ref Repository named \c alias_r.
92 * It a such a \ref Repository does not already exist
93 * a new empty \ref Repository is created.
95 Repository reposInsert( const std::string & alias_r );
97 /** Find a \ref Repository named \c alias_r.
98 * Returns \ref norepository if there is no such \ref Repository.
100 Repository reposFind( const std::string & alias_r ) const;
102 /** Remove a \ref Repository named \c alias_r.
103 * \see \ref Repository::eraseFromPool
105 void reposErase( const std::string & alias_r )
106 { reposFind( alias_r ).eraseFromPool(); }
109 /** Reserved system repository alias \c @System. */
110 static const std::string & systemRepoAlias();
112 /** Return the system repository if it is on the pool. */
113 Repository findSystemRepo() const;
115 /** Return the system repository, create it if missing. */
116 Repository systemRepo();
119 /** Load \ref Solvables from a solv-file into a \ref Repository named \c name_r.
120 * In case of an exception the \ref Repository is removed from the \ref Pool.
121 * \throws Exception if loading the solv-file fails.
122 * \see \ref Repository::EraseFromPool
124 Repository addRepoSolv( const Pathname & file_r, const std::string & name_r );
125 /** \overload Using the files basename as \ref Repository name. */
126 Repository addRepoSolv( const Pathname & file_r );
127 /** \overload Using the \ref RepoInfo::alias \ref Repo name.
128 * Additionally stores the \ref RepoInfo. \See \ref Prool::setInfo.
130 Repository addRepoSolv( const Pathname & file_r, const RepoInfo & info_r );
133 /** Load \ref Solvables from a helix-file into a \ref Repository named \c name_r.
134 * Supports loading of gzip compressed files (.gz). In case of an exception
135 * the \ref Repository is removed from the \ref Pool.
136 * \throws Exception if loading the helix-file fails.
137 * \see \ref Repository::EraseFromPool
139 Repository addRepoHelix( const Pathname & file_r, const std::string & name_r );
140 /** \overload Using the files basename as \ref Repository name. */
141 Repository addRepoHelix( const Pathname & file_r );
142 /** \overload Using the \ref RepoInfo::alias \ref Repo name.
143 * Additionally stores the \ref RepoInfo. \See \ref Prool::setInfo.
145 Repository addRepoHelix( const Pathname & file_r, const RepoInfo & info_r );
148 /** Whether \ref Pool contains solvables. */
149 bool solvablesEmpty() const;
151 /** Number of solvables in \ref Pool. */
152 size_type solvablesSize() const;
154 /** Iterator to the first \ref Solvable. */
155 SolvableIterator solvablesBegin() const;
157 /** Iterator behind the last \ref Solvable. */
158 SolvableIterator solvablesEnd() const;
161 /** \name Iterate all Solvables matching a \c _Filter. */
163 template<class _Filter>
164 filter_iterator<_Filter,SolvableIterator> filterBegin( const _Filter & filter_r ) const
165 { return make_filter_iterator( filter_r, solvablesBegin(), solvablesEnd() ); }
167 template<class _Filter>
168 filter_iterator<_Filter,SolvableIterator> filterEnd( const _Filter & filter_r ) const
169 { return make_filter_iterator( filter_r, solvablesEnd(), solvablesEnd() ); }
173 /** Conainer of all \ref Solvable providing \c cap_r. */
174 WhatProvides whatProvides( Capability cap_r ) const
175 { return WhatProvides( cap_r ); }
178 /** \name Requested locales. */
180 /** Set the default language for retrieving translated texts.
181 * Updated when calling \ref ZConfig::setTextLocale.
183 void setTextLocale( const Locale & locale_r );
185 /** Set the requested locales.
186 * Languages to be supported by the system, e.g. language specific
187 * packages to be installed.
189 void setRequestedLocales( const LocaleSet & locales_r );
191 /** Add one \ref Locale to the set of requested locales.
192 * Return \c true if \c locale_r was newly added to the set.
194 bool addRequestedLocale( const Locale & locale_r );
196 /** Erase one \ref Locale from the set of requested locales.
197 * Return \c false if \c locale_r was not found in the set.
199 bool eraseRequestedLocale( const Locale & locale_r );
201 /** Return the requested locales.
202 * \see \ref setRequestedLocales
204 const LocaleSet & getRequestedLocales() const;
206 /** Whether this \ref Locale is in the set of requested locales. */
207 bool isRequestedLocale( const Locale & locale_r ) const;
209 /** Get the set of available locales.
210 * This is computed from the package data so it actually
211 * represents all locales packages claim to support.
213 const LocaleSet & getAvailableLocales() const;
215 /** Whether this \ref Locale is in the set of available locales. */
216 bool isAvailableLocale( const Locale & locale_r ) const;
220 /** \name Multiversion install.
221 * Ident list of all packages that can be installed in different version
222 * at the same time. (\see \ref ZConfig::multiversionSpec)
225 typedef IdStringSet::const_iterator MultiversionIterator;
227 bool multiversionEmpty() const;
228 size_t multiversionSize() const;
229 MultiversionIterator multiversionBegin() const;
230 MultiversionIterator multiversionEnd() const;
232 bool isMultiversion( IdString ident_r ) const;
236 /** \name Autoinstalled */
238 /** Get ident list of all autoinstalled solvables. */
239 Queue autoInstalled() const;
240 /** Set ident list of all autoinstalled solvables. */
241 void setAutoInstalled( const Queue & autoInstalled_r );
245 /** Expert backdoor. */
246 ::_Pool * get() const;
251 ///////////////////////////////////////////////////////////////////
253 /** \relates Pool Stream output */
254 std::ostream & operator<<( std::ostream & str, const Pool & obj );
257 inline bool operator==( const Pool & lhs, const Pool & rhs )
258 { return lhs.get() == rhs.get(); }
261 inline bool operator!=( const Pool & lhs, const Pool & rhs )
262 { return lhs.get() != rhs.get(); }
264 /////////////////////////////////////////////////////////////////
266 ///////////////////////////////////////////////////////////////////
267 /////////////////////////////////////////////////////////////////
269 ///////////////////////////////////////////////////////////////////
270 #endif // ZYPP_SAT_POOL_H