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/SolvableSet.h"
23 #include "zypp/sat/Queue.h"
25 ///////////////////////////////////////////////////////////////////
27 { /////////////////////////////////////////////////////////////////
32 ///////////////////////////////////////////////////////////////////
34 { /////////////////////////////////////////////////////////////////
36 ///////////////////////////////////////////////////////////////////
42 * Explicitly shared singleton \ref Pool::instance.
44 class Pool : protected detail::PoolMember
47 typedef detail::SolvableIterator SolvableIterator;
48 typedef zypp::detail::RepositoryIterator RepositoryIterator;
49 typedef detail::size_type size_type;
52 /** Singleton ctor. */
53 static Pool instance()
56 /** Ctor from \ref PoolMember. */
57 Pool( const detail::PoolMember & )
61 /** Internal array size for stats only. */
62 size_type capacity() const;
64 /** Housekeeping data serial number. */
65 const SerialNumber & serial() const;
67 /** Update housekeeping data if necessary (e.g. whatprovides). */
70 /** \ref prepare plus some expensive checks done before solving only. */
71 void prepareForSolving() const;
73 /** Get rootdir (for file conflicts check) */
74 Pathname rootDir() const;
76 /** Set rootdir (for file conflicts check) */
77 void rootDir( const Pathname & root_r );
80 /** Whether \ref Pool contains repos. */
81 bool reposEmpty() const;
83 /** Number of repos in \ref Pool. */
84 size_type reposSize() const;
86 /** Iterator to the first \ref Repository. */
87 RepositoryIterator reposBegin() const;
89 /** Iterator behind the last \ref Repository. */
90 RepositoryIterator reposEnd() const;
92 /** Iterate the repositories. */
93 Iterable<RepositoryIterator> repos() const
94 { return makeIterable( reposBegin(), reposEnd() ); }
96 /** Return a \ref Repository named \c alias_r.
97 * It a such a \ref Repository does not already exist
98 * a new empty \ref Repository is created.
100 Repository reposInsert( const std::string & alias_r );
102 /** Find a \ref Repository named \c alias_r.
103 * Returns \ref norepository if there is no such \ref Repository.
105 Repository reposFind( const std::string & alias_r ) const;
107 /** Remove a \ref Repository named \c alias_r.
108 * \see \ref Repository::eraseFromPool
110 void reposErase( const std::string & alias_r )
111 { reposFind( alias_r ).eraseFromPool(); }
114 /** Reserved system repository alias \c @System. */
115 static const std::string & systemRepoAlias();
117 /** Return the system repository if it is on the pool. */
118 Repository findSystemRepo() const;
120 /** Return the system repository, create it if missing. */
121 Repository systemRepo();
124 /** Load \ref Solvables from a solv-file into a \ref Repository named \c name_r.
125 * In case of an exception the \ref Repository is removed from the \ref Pool.
126 * \throws Exception if loading the solv-file fails.
127 * \see \ref Repository::EraseFromPool
129 Repository addRepoSolv( const Pathname & file_r, const std::string & name_r );
130 /** \overload Using the files basename as \ref Repository name. */
131 Repository addRepoSolv( const Pathname & file_r );
132 /** \overload Using the \ref RepoInfo::alias \ref Repo name.
133 * Additionally stores the \ref RepoInfo. \See \ref Prool::setInfo.
135 Repository addRepoSolv( const Pathname & file_r, const RepoInfo & info_r );
138 /** Load \ref Solvables from a helix-file into a \ref Repository named \c name_r.
139 * Supports loading of gzip compressed files (.gz). In case of an exception
140 * the \ref Repository is removed from the \ref Pool.
141 * \throws Exception if loading the helix-file fails.
142 * \see \ref Repository::EraseFromPool
144 Repository addRepoHelix( const Pathname & file_r, const std::string & name_r );
145 /** \overload Using the files basename as \ref Repository name. */
146 Repository addRepoHelix( const Pathname & file_r );
147 /** \overload Using the \ref RepoInfo::alias \ref Repo name.
148 * Additionally stores the \ref RepoInfo. \See \ref Prool::setInfo.
150 Repository addRepoHelix( const Pathname & file_r, const RepoInfo & info_r );
153 /** Whether \ref Pool contains solvables. */
154 bool solvablesEmpty() const;
156 /** Number of solvables in \ref Pool. */
157 size_type solvablesSize() const;
159 /** Iterator to the first \ref Solvable. */
160 SolvableIterator solvablesBegin() const;
162 /** Iterator behind the last \ref Solvable. */
163 SolvableIterator solvablesEnd() const;
165 /** Iterate the solvables. */
166 Iterable<SolvableIterator> solvables() const
167 { return makeIterable( solvablesBegin(), solvablesEnd() ); }
170 /** \name Iterate all Solvables matching a \c TFilter. */
172 template<class TFilter>
173 filter_iterator<TFilter,SolvableIterator> filterBegin( const TFilter & filter_r ) const
174 { return make_filter_iterator( filter_r, solvablesBegin(), solvablesEnd() ); }
176 template<class TFilter>
177 filter_iterator<TFilter,SolvableIterator> filterEnd( const TFilter & filter_r ) const
178 { return make_filter_iterator( filter_r, solvablesEnd(), solvablesEnd() ); }
182 /** Conainer of all \ref Solvable providing \c cap_r. */
183 WhatProvides whatProvides( Capability cap_r ) const
184 { return WhatProvides( cap_r ); }
187 /** \name Requested locales. */
189 /** Set the default language for retrieving translated texts.
190 * Updated when calling \ref ZConfig::setTextLocale.
192 void setTextLocale( const Locale & locale_r );
194 /** Set the requested locales.
195 * Languages to be supported by the system, e.g. language specific
196 * packages to be installed.
198 void setRequestedLocales( const LocaleSet & locales_r );
200 /** Add one \ref Locale to the set of requested locales.
201 * Return \c true if \c locale_r was newly added to the set.
203 bool addRequestedLocale( const Locale & locale_r );
205 /** Erase one \ref Locale from the set of requested locales.
206 * Return \c false if \c locale_r was not found in the set.
208 bool eraseRequestedLocale( const Locale & locale_r );
210 /** Return the requested locales.
211 * \see \ref setRequestedLocales
213 const LocaleSet & getRequestedLocales() const;
215 /** Whether this \ref Locale is in the set of requested locales. */
216 bool isRequestedLocale( const Locale & locale_r ) const;
219 /** Start tracking changes based on this \a locales_r. */
220 void initRequestedLocales( const LocaleSet & locales_r );
222 /** Added since last initRequestedLocales. */
223 const LocaleSet & getAddedRequestedLocales() const;
225 /** Removed since last initRequestedLocales.*/
226 const LocaleSet & getRemovedRequestedLocales() const;
229 /** Get the set of available locales.
230 * This is computed from the package data so it actually
231 * represents all locales packages claim to support.
233 const LocaleSet & getAvailableLocales() const;
235 /** Whether this \ref Locale is in the set of available locales. */
236 bool isAvailableLocale( const Locale & locale_r ) const;
240 /** \name Multiversion install.
241 * Whether the pool contains packages which are multiversion installable.
242 * \see \ref Solvable::multiversionInstall
243 * \see \ref ZConfig::multiversionSpec
246 typedef SolvableSet MultiversionList;
247 const MultiversionList & multiversion() const;
248 /** \deprecated Legacy, use multiversion().empty() instead. */
249 ZYPP_DEPRECATED bool multiversionEmpty() const { return multiversion().empty(); }
253 /** \name Autoinstalled */
255 /** Get ident list of all autoinstalled solvables. */
256 Queue autoInstalled() const;
257 /** Set ident list of all autoinstalled solvables. */
258 void setAutoInstalled( const Queue & autoInstalled_r );
262 /** Expert backdoor. */
263 detail::CPool * get() const;
268 ///////////////////////////////////////////////////////////////////
270 /** \relates Pool Stream output */
271 std::ostream & operator<<( std::ostream & str, const Pool & obj );
274 inline bool operator==( const Pool & lhs, const Pool & rhs )
275 { return lhs.get() == rhs.get(); }
278 inline bool operator!=( const Pool & lhs, const Pool & rhs )
279 { return lhs.get() != rhs.get(); }
281 /** Create solv file content digest for zypper bash completion */
282 void updateSolvFileIndex( const Pathname & solvfile_r );
284 /////////////////////////////////////////////////////////////////
286 ///////////////////////////////////////////////////////////////////
287 /////////////////////////////////////////////////////////////////
289 ///////////////////////////////////////////////////////////////////
290 #endif // ZYPP_SAT_POOL_H