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/sat/Repo.h"
21 #include "zypp/sat/WhatProvides.h"
22 #include "zypp/Locale.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 detail::RepoIterator RepoIterator;
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). */
70 /** Whether \ref Pool contains repos. */
71 bool reposEmpty() const;
73 /** Number of repos in \ref Pool. */
74 size_type reposSize() const;
76 /** Iterator to the first \ref Repo. */
77 RepoIterator reposBegin() const;
79 /** Iterator behind the last \ref Repo. */
80 RepoIterator reposEnd() const;
82 /** Return a \ref Repo named \c name_r.
83 * It a such a \ref Repo does not already exist
84 * a new empty \ref Repo is created.
86 Repo reposInsert( const std::string & name_r );
88 /** Find a \ref Repo named \c name_r.
89 * Returns \ref norepo if there is no such \ref Repo.
91 Repo reposFind( const std::string & name_r ) const;
93 /** Remove a \ref Repo named \c name_r.
94 * \see \ref Repo::eraseFromPool
96 void reposErase( const std::string & name_r )
97 { reposFind( name_r ).eraseFromPool(); }
100 /** Reserved system repo name \c @System. */
101 static const std::string & systemRepoName();
103 /** Return the system repo. */
105 { return reposInsert( systemRepoName() ); }
108 /** Load \ref Solvables from a solv-file into a \ref Repo named \c name_r.
109 * In case of an exception the \ref Repo is removed from the \ref Pool.
110 * \throws Exception if loading the solv-file fails.
111 * \see \ref Repo::EraseFromPool
113 Repo addRepoSolv( const Pathname & file_r, const std::string & name_r );
114 /** \overload Using the files basename as \ref Repo name. */
115 Repo addRepoSolv( const Pathname & file_r );
116 /** \overload Using the \ref RepoInfo::alias \ref Repo name.
117 * Additionally stores the \ref RepoInfo. \See \ref Prool::setInfo.
119 Repo addRepoSolv( const Pathname & file_r, const RepoInfo & info_r );
122 /** Whether \ref Pool contains solvables. */
123 bool solvablesEmpty() const;
125 /** Number of solvables in \ref Pool. */
126 size_type solvablesSize() const;
128 /** Iterator to the first \ref Solvable. */
129 SolvableIterator solvablesBegin() const;
131 /** Iterator behind the last \ref Solvable. */
132 SolvableIterator solvablesEnd() const;
135 /** Conainer of all \ref Solvable providing \c cap_r. */
136 WhatProvides whatProvides( Capability cap_r ) const
137 { return WhatProvides( cap_r ); }
140 /** \name Requested locales. */
142 /** Set the requested locales.
143 * Languages to be supported by the system, e.g. language specific
144 * packages to be installed.
146 void setRequestedLocales( const LocaleSet & locales_r );
148 /** Add one \ref Locale to the set of requested locales.
149 * Return \c true if \c locale_r was newly added to the set.
151 bool addRequestedLocale( const Locale & locale_r );
153 /** Erase one \ref Locale from the set of requested locales.
154 * Return \c false if \c locale_r was not found in the set.
156 bool eraseRequestedLocale( const Locale & locale_r );
158 /** Return the requested locales.
159 * \see \ref setRequestedLocales
161 const LocaleSet & getRequestedLocales() const;
163 /** Wheter this \ref Locale is in the set of requested locales. */
164 bool isRequestedLocale( const Locale & locale_r ) const;
166 /** Get the set of available locales.
167 * This is computed from the package data so it actually
168 * represents all locales packages claim to support.
170 const LocaleSet & getAvailableLocales() const;
172 /** Wheter this \ref Locale is in the set of available locales. */
173 bool isAvailableLocale( const Locale & locale_r ) const;
177 /** Expert backdoor. */
178 ::_Pool * get() const;
183 ///////////////////////////////////////////////////////////////////
185 /** \relates Pool Stream output */
186 std::ostream & operator<<( std::ostream & str, const Pool & obj );
189 inline bool operator==( const Pool & lhs, const Pool & rhs )
190 { return lhs.get() == rhs.get(); }
193 inline bool operator!=( const Pool & lhs, const Pool & rhs )
194 { return lhs.get() != rhs.get(); }
196 /////////////////////////////////////////////////////////////////
198 ///////////////////////////////////////////////////////////////////
199 /////////////////////////////////////////////////////////////////
201 ///////////////////////////////////////////////////////////////////
202 #endif // ZYPP_SAT_POOL_H