1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/sat/Pool.cc
15 #include <satsolver/pool.h>
16 #include <satsolver/repo.h>
20 #include "zypp/base/Easy.h"
21 #include "zypp/base/Logger.h"
22 #include "zypp/base/Gettext.h"
23 #include "zypp/base/Exception.h"
25 #include "zypp/AutoDispose.h"
27 #include "zypp/sat/detail/PoolImpl.h"
28 #include "zypp/sat/Pool.h"
30 ///////////////////////////////////////////////////////////////////
32 { /////////////////////////////////////////////////////////////////
33 ///////////////////////////////////////////////////////////////////
35 { /////////////////////////////////////////////////////////////////
37 const std::string & Pool::systemRepoName()
39 static const std::string _val( "@System" );
43 ::_Pool * Pool::get() const
44 { return myPool().getPool(); }
46 Pool::size_type Pool::capacity() const
47 { return myPool()->nsolvables; }
49 const SerialNumber & Pool::serial() const
50 { return myPool().serial(); }
52 void Pool::prepare() const
53 { return myPool().prepare(); }
55 bool Pool::reposEmpty() const
56 { return myPool()->nrepos; }
58 Pool::size_type Pool::reposSize() const
59 { return myPool()->nrepos; }
61 Pool::RepoIterator Pool::reposBegin() const
62 { return RepoIterator( myPool()->repos ); }
64 Pool::RepoIterator Pool::reposEnd() const
65 { return RepoIterator( myPool()->repos+myPool()->nrepos ); }
67 bool Pool::solvablesEmpty() const
69 // return myPool()->nsolvables;
70 // nsolvables is the array size including
72 for_( it, reposBegin(), reposEnd() )
74 if ( ! it->solvablesEmpty() )
80 Pool::size_type Pool::solvablesSize() const
82 // Do not return myPool()->nsolvables;
83 // nsolvables is the array size including
86 for_( it, reposBegin(), reposEnd() )
88 ret += it->solvablesSize();
93 Pool::SolvableIterator Pool::solvablesBegin() const
94 { return SolvableIterator( myPool().getFirstId() ); }
96 Pool::SolvableIterator Pool::solvablesEnd() const
97 { return SolvableIterator(); }
99 Repo Pool::reposInsert( const std::string & name_r )
101 Repo ret( reposFind( name_r ) );
105 ret = Repo( myPool()._createRepo( name_r ) );
106 if ( name_r == systemRepoName() )
108 // autoprovide (dummy) RepoInfo
109 ret.setInfo( RepoInfo()
112 .setAutorefresh( true )
113 .setEnabled( true ) );
118 Repo Pool::reposFind( const std::string & name_r ) const
120 for_( it, reposBegin(), reposEnd() )
122 if ( name_r == it->name() )
128 Repo Pool::addRepoSolv( const Pathname & file_r, const std::string & name_r )
130 // Using a temporay repo! (The additional parenthesis are required.)
131 AutoDispose<Repo> tmprepo( (Repo::EraseFromPool()) );
132 *tmprepo = reposInsert( name_r );
133 tmprepo->addSolv( file_r );
135 // no exceptions so we keep it:
136 tmprepo.resetDispose();
140 Repo Pool::addRepoSolv( const Pathname & file_r )
141 { return addRepoSolv( file_r, file_r.basename() ); }
143 Repo Pool::addRepoSolv( const Pathname & file_r, const RepoInfo & info_r )
145 Repo ret( addRepoSolv( file_r, info_r.alias() ) );
146 ret.setInfo( info_r );
150 /////////////////////////////////////////////////////////////////
152 void Pool::setRequestedLocales( const LocaleSet & locales_r )
153 { myPool().setRequestedLocales( locales_r ); }
155 bool Pool::addRequestedLocale( const Locale & locale_r )
156 { return myPool().addRequestedLocale( locale_r ); }
158 bool Pool::eraseRequestedLocale( const Locale & locale_r )
159 { return myPool().eraseRequestedLocale( locale_r ); }
161 const LocaleSet & Pool::getRequestedLocales() const
162 { return myPool().getRequestedLocales(); }
164 bool Pool::isRequestedLocale( const Locale & locale_r ) const
165 { return myPool().isRequestedLocale( locale_r ); }
167 const LocaleSet & Pool::getAvailableLocales() const
168 { return myPool().getAvailableLocales(); }
170 bool Pool::isAvailableLocale( const Locale & locale_r ) const
171 { return myPool().isAvailableLocale( locale_r ); }
173 /******************************************************************
175 ** FUNCTION NAME : operator<<
176 ** FUNCTION TYPE : std::ostream &
178 std::ostream & operator<<( std::ostream & str, const Pool & obj )
180 return str << "sat::pool(" << obj.serial() << ")["
181 << obj.capacity() << "]{"
182 << obj.reposSize() << "repos|"
183 << obj.solvablesSize() << "slov}";
186 /////////////////////////////////////////////////////////////////
188 ///////////////////////////////////////////////////////////////////
189 /////////////////////////////////////////////////////////////////
191 ///////////////////////////////////////////////////////////////////