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"
29 #include "zypp/sat/LookupAttr.h"
31 ///////////////////////////////////////////////////////////////////
33 { /////////////////////////////////////////////////////////////////
34 ///////////////////////////////////////////////////////////////////
36 { /////////////////////////////////////////////////////////////////
38 const std::string & Pool::systemRepoName()
40 static const std::string _val( "@System" );
44 ::_Pool * Pool::get() const
45 { return myPool().getPool(); }
47 Pool::size_type Pool::capacity() const
48 { return myPool()->nsolvables; }
50 const SerialNumber & Pool::serial() const
51 { return myPool().serial(); }
53 void Pool::prepare() const
54 { return myPool().prepare(); }
56 bool Pool::reposEmpty() const
57 { return ! myPool()->nrepos; }
59 Pool::size_type Pool::reposSize() const
60 { return myPool()->nrepos; }
62 Pool::RepositoryIterator Pool::reposBegin() const
63 { return RepositoryIterator( myPool()->repos ); }
65 Pool::RepositoryIterator Pool::reposEnd() const
66 { return RepositoryIterator( myPool()->repos+myPool()->nrepos ); }
68 bool Pool::solvablesEmpty() const
70 // return myPool()->nsolvables;
71 // nsolvables is the array size including
73 for_( it, reposBegin(), reposEnd() )
75 if ( ! it->solvablesEmpty() )
81 Pool::size_type Pool::solvablesSize() const
83 // Do not return myPool()->nsolvables;
84 // nsolvables is the array size including
87 for_( it, reposBegin(), reposEnd() )
89 ret += it->solvablesSize();
94 Pool::SolvableIterator Pool::solvablesBegin() const
95 { return SolvableIterator( myPool().getFirstId() ); }
97 Pool::SolvableIterator Pool::solvablesEnd() const
98 { return SolvableIterator(); }
100 Repository Pool::reposInsert( const std::string & name_r )
102 Repository ret( reposFind( name_r ) );
106 ret = Repository( myPool()._createRepo( name_r ) );
107 if ( name_r == systemRepoName() )
109 // autoprovide (dummy) RepoInfo
110 ret.setInfo( RepoInfo()
113 .setAutorefresh( true )
114 .setEnabled( true ) );
119 Repository Pool::reposFind( const std::string & name_r ) const
121 for_( it, reposBegin(), reposEnd() )
123 if ( name_r == it->name() )
129 Repository Pool::addRepoSolv( const Pathname & file_r, const std::string & name_r )
131 // Using a temporay repo! (The additional parenthesis are required.)
132 AutoDispose<Repository> tmprepo( (Repository::EraseFromPool()) );
133 *tmprepo = reposInsert( name_r );
134 tmprepo->addSolv( file_r );
136 // no exceptions so we keep it:
137 tmprepo.resetDispose();
141 Repository Pool::addRepoSolv( const Pathname & file_r )
142 { return addRepoSolv( file_r, file_r.basename() ); }
144 Repository Pool::addRepoSolv( const Pathname & file_r, const RepoInfo & info_r )
146 Repository ret( addRepoSolv( file_r, info_r.alias() ) );
147 ret.setInfo( info_r );
151 /////////////////////////////////////////////////////////////////
153 void Pool::setRequestedLocales( const LocaleSet & locales_r )
154 { myPool().setRequestedLocales( locales_r ); }
156 bool Pool::addRequestedLocale( const Locale & locale_r )
157 { return myPool().addRequestedLocale( locale_r ); }
159 bool Pool::eraseRequestedLocale( const Locale & locale_r )
160 { return myPool().eraseRequestedLocale( locale_r ); }
162 const LocaleSet & Pool::getRequestedLocales() const
163 { return myPool().getRequestedLocales(); }
165 bool Pool::isRequestedLocale( const Locale & locale_r ) const
166 { return myPool().isRequestedLocale( locale_r ); }
168 const LocaleSet & Pool::getAvailableLocales() const
169 { return myPool().getAvailableLocales(); }
171 bool Pool::isAvailableLocale( const Locale & locale_r ) const
172 { return myPool().isAvailableLocale( locale_r ); }
174 /******************************************************************
176 ** FUNCTION NAME : operator<<
177 ** FUNCTION TYPE : std::ostream &
179 std::ostream & operator<<( std::ostream & str, const Pool & obj )
181 return str << "sat::pool(" << obj.serial() << ")["
182 << obj.capacity() << "]{"
183 << obj.reposSize() << "repos|"
184 << obj.solvablesSize() << "slov}";
187 /////////////////////////////////////////////////////////////////
189 ///////////////////////////////////////////////////////////////////
190 /////////////////////////////////////////////////////////////////
192 ///////////////////////////////////////////////////////////////////