1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/sat/Pool.cc
15 #include "zypp/base/Easy.h"
16 #include "zypp/base/Logger.h"
17 #include "zypp/base/Gettext.h"
18 #include "zypp/base/Exception.h"
20 #include "zypp/AutoDispose.h"
22 #include "zypp/sat/detail/PoolImpl.h"
23 #include "zypp/sat/Pool.h"
24 #include "zypp/sat/LookupAttr.h"
26 ///////////////////////////////////////////////////////////////////
28 { /////////////////////////////////////////////////////////////////
29 ///////////////////////////////////////////////////////////////////
31 { /////////////////////////////////////////////////////////////////
33 const std::string & Pool::systemRepoAlias()
34 { return detail::PoolImpl::systemRepoAlias(); }
36 detail::CPool * Pool::get() const
37 { return myPool().getPool(); }
39 Pool::size_type Pool::capacity() const
40 { return myPool()->nsolvables; }
42 const SerialNumber & Pool::serial() const
43 { return myPool().serial(); }
45 void Pool::prepare() const
46 { return myPool().prepare(); }
48 void Pool::prepareForSolving() const
49 { return myPool().prepareForSolving(); }
51 Pathname Pool::rootDir() const
52 { return myPool().rootDir(); }
54 void Pool::rootDir( const Pathname & root_r )
55 { return myPool().rootDir( root_r ); }
57 bool Pool::reposEmpty() const
58 { return ! myPool()->urepos; }
60 Pool::size_type Pool::reposSize() const
61 { return myPool()->urepos; }
63 Pool::RepositoryIterator Pool::reposBegin() const
65 if ( myPool()->urepos )
67 for_( it, myPool()->repos+1, myPool()->repos+myPool()->nrepos )
69 return RepositoryIterator( it );
74 Pool::RepositoryIterator Pool::reposEnd() const
75 { return RepositoryIterator( myPool()->repos+myPool()->nrepos ); }
77 bool Pool::solvablesEmpty() const
79 // return myPool()->nsolvables;
80 // nsolvables is the array size including
82 for_( it, reposBegin(), reposEnd() )
84 if ( ! it->solvablesEmpty() )
90 Pool::size_type Pool::solvablesSize() const
92 // Do not return myPool()->nsolvables;
93 // nsolvables is the array size including
96 for_( it, reposBegin(), reposEnd() )
98 ret += it->solvablesSize();
103 Pool::SolvableIterator Pool::solvablesBegin() const
104 { return SolvableIterator( myPool().getFirstId() ); }
106 Pool::SolvableIterator Pool::solvablesEnd() const
107 { return SolvableIterator(); }
109 Repository Pool::reposInsert( const std::string & alias_r )
111 Repository ret( reposFind( alias_r ) );
115 ret = Repository( myPool()._createRepo( alias_r ) );
116 if ( ret.isSystemRepo() )
118 // autoprovide (dummy) RepoInfo
120 info.setAlias( alias_r );
121 info.setName( alias_r );
122 info.setAutorefresh( true );
123 info.setEnabled( true );
129 Repository Pool::reposFind( const std::string & alias_r ) const
131 for_( it, reposBegin(), reposEnd() )
133 if ( alias_r == it->alias() )
139 Repository Pool::findSystemRepo() const
141 return Repository( myPool().systemRepo() );
144 Repository Pool::systemRepo()
146 if ( myPool().systemRepo() )
147 return Repository( myPool().systemRepo() );
148 return reposInsert( systemRepoAlias() );
151 Repository Pool::addRepoSolv( const Pathname & file_r, const std::string & alias_r )
153 // Using a temporay repo! (The additional parenthesis are required.)
154 AutoDispose<Repository> tmprepo( (Repository::EraseFromPool()) );
155 *tmprepo = reposInsert( alias_r );
156 tmprepo->addSolv( file_r );
158 // no exceptions so we keep it:
159 tmprepo.resetDispose();
163 Repository Pool::addRepoSolv( const Pathname & file_r )
164 { return addRepoSolv( file_r, file_r.basename() ); }
166 Repository Pool::addRepoSolv( const Pathname & file_r, const RepoInfo & info_r )
168 Repository ret( addRepoSolv( file_r, info_r.alias() ) );
169 ret.setInfo( info_r );
173 /////////////////////////////////////////////////////////////////
175 Repository Pool::addRepoHelix( const Pathname & file_r, const std::string & alias_r )
177 // Using a temporay repo! (The additional parenthesis are required.)
178 AutoDispose<Repository> tmprepo( (Repository::EraseFromPool()) );
179 *tmprepo = reposInsert( alias_r );
180 tmprepo->addHelix( file_r );
182 // no exceptions so we keep it:
183 tmprepo.resetDispose();
187 Repository Pool::addRepoHelix( const Pathname & file_r )
188 { return addRepoHelix( file_r, file_r.basename() ); }
190 Repository Pool::addRepoHelix( const Pathname & file_r, const RepoInfo & info_r )
192 Repository ret( addRepoHelix( file_r, info_r.alias() ) );
193 ret.setInfo( info_r );
197 /////////////////////////////////////////////////////////////////
199 void Pool::setTextLocale( const Locale & locale_r )
200 { myPool().setTextLocale( locale_r ); }
202 void Pool::setRequestedLocales( const LocaleSet & locales_r )
203 { myPool().setRequestedLocales( locales_r ); }
205 bool Pool::addRequestedLocale( const Locale & locale_r )
206 { return myPool().addRequestedLocale( locale_r ); }
208 bool Pool::eraseRequestedLocale( const Locale & locale_r )
209 { return myPool().eraseRequestedLocale( locale_r ); }
211 const LocaleSet & Pool::getRequestedLocales() const
212 { return myPool().getRequestedLocales(); }
214 bool Pool::isRequestedLocale( const Locale & locale_r ) const
215 { return myPool().isRequestedLocale( locale_r ); }
217 const LocaleSet & Pool::getAvailableLocales() const
218 { return myPool().getAvailableLocales(); }
220 bool Pool::isAvailableLocale( const Locale & locale_r ) const
221 { return myPool().isAvailableLocale( locale_r ); }
223 bool Pool::multiversionEmpty() const { return myPool().multiversionList().empty(); }
224 size_t Pool::multiversionSize() const { return myPool().multiversionList().size(); }
225 Pool::MultiversionIterator Pool::multiversionBegin() const { return myPool().multiversionList().begin(); }
226 Pool::MultiversionIterator Pool::multiversionEnd() const { return myPool().multiversionList().end(); }
227 bool Pool::isMultiversion( IdString ident_r ) const { return myPool().isMultiversion( ident_r ); }
229 Queue Pool::autoInstalled() const { return myPool().autoInstalled(); }
230 void Pool::setAutoInstalled( const Queue & autoInstalled_r ){ myPool().setAutoInstalled( autoInstalled_r ); }
232 /******************************************************************
234 ** FUNCTION NAME : operator<<
235 ** FUNCTION TYPE : std::ostream &
237 std::ostream & operator<<( std::ostream & str, const Pool & obj )
239 return str << "sat::pool(" << obj.serial() << ")["
240 << obj.capacity() << "]{"
241 << obj.reposSize() << "repos|"
242 << obj.solvablesSize() << "slov}";
245 /////////////////////////////////////////////////////////////////
247 ///////////////////////////////////////////////////////////////////
248 /////////////////////////////////////////////////////////////////
250 ///////////////////////////////////////////////////////////////////