libzypp  11.13.5
Pool.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
13 #include <iostream>
14 
15 #include "zypp/base/Easy.h"
16 #include "zypp/base/Logger.h"
17 #include "zypp/base/Gettext.h"
18 #include "zypp/base/Exception.h"
19 
20 #include "zypp/AutoDispose.h"
21 
23 #include "zypp/sat/Pool.h"
24 #include "zypp/sat/LookupAttr.h"
25 
27 namespace zypp
28 {
29 
30  namespace sat
31  {
32 
33  const std::string & Pool::systemRepoAlias()
35 
36  ::_Pool * Pool::get() const
37  { return myPool().getPool(); }
38 
40  { return myPool()->nsolvables; }
41 
42  const SerialNumber & Pool::serial() const
43  { return myPool().serial(); }
44 
45  void Pool::prepare() const
46  { return myPool().prepare(); }
47 
49  { return myPool().prepareForSolving(); }
50 
51  bool Pool::reposEmpty() const
52  { return ! myPool()->urepos; }
53 
55  { return myPool()->urepos; }
56 
58  {
59  if ( myPool()->urepos )
60  { // repos[0] == NULL
61  for_( it, myPool()->repos+1, myPool()->repos+myPool()->nrepos )
62  if ( *it )
63  return RepositoryIterator( it );
64  }
65  return reposEnd();
66  }
67 
69  { return RepositoryIterator( myPool()->repos+myPool()->nrepos ); }
70 
71  bool Pool::solvablesEmpty() const
72  {
73  // return myPool()->nsolvables;
74  // nsolvables is the array size including
75  // invalid Solvables.
76  for_( it, reposBegin(), reposEnd() )
77  {
78  if ( ! it->solvablesEmpty() )
79  return false;
80  }
81  return true;
82  }
83 
85  {
86  // Do not return myPool()->nsolvables;
87  // nsolvables is the array size including
88  // invalid Solvables.
89  size_type ret = 0;
90  for_( it, reposBegin(), reposEnd() )
91  {
92  ret += it->solvablesSize();
93  }
94  return ret;
95  }
96 
98  { return SolvableIterator( myPool().getFirstId() ); }
99 
101  { return SolvableIterator(); }
102 
103  Repository Pool::reposInsert( const std::string & alias_r )
104  {
105  Repository ret( reposFind( alias_r ) );
106  if ( ret )
107  return ret;
108 
109  ret = Repository( myPool()._createRepo( alias_r ) );
110  if ( ret.isSystemRepo() )
111  {
112  // autoprovide (dummy) RepoInfo
113  RepoInfo info;
114  info.setAlias( alias_r );
115  info.setName( alias_r );
116  info.setAutorefresh( true );
117  info.setEnabled( true );
118  ret.setInfo( info );
119  }
120  return ret;
121  }
122 
123  Repository Pool::reposFind( const std::string & alias_r ) const
124  {
125  for_( it, reposBegin(), reposEnd() )
126  {
127  if ( alias_r == it->alias() )
128  return *it;
129  }
130  return Repository();
131  }
132 
134  {
135  return Repository( myPool().systemRepo() );
136  }
137 
139  {
140  if ( myPool().systemRepo() )
141  return Repository( myPool().systemRepo() );
142  return reposInsert( systemRepoAlias() );
143  }
144 
145  Repository Pool::addRepoSolv( const Pathname & file_r, const std::string & alias_r )
146  {
147  // Using a temporay repo! (The additional parenthesis are required.)
149  *tmprepo = reposInsert( alias_r );
150  tmprepo->addSolv( file_r );
151 
152  // no exceptions so we keep it:
153  tmprepo.resetDispose();
154  return tmprepo;
155  }
156 
157  Repository Pool::addRepoSolv( const Pathname & file_r )
158  { return addRepoSolv( file_r, file_r.basename() ); }
159 
160  Repository Pool::addRepoSolv( const Pathname & file_r, const RepoInfo & info_r )
161  {
162  Repository ret( addRepoSolv( file_r, info_r.alias() ) );
163  ret.setInfo( info_r );
164  return ret;
165  }
166 
168 
169  Repository Pool::addRepoHelix( const Pathname & file_r, const std::string & alias_r )
170  {
171  // Using a temporay repo! (The additional parenthesis are required.)
173  *tmprepo = reposInsert( alias_r );
174  tmprepo->addHelix( file_r );
175 
176  // no exceptions so we keep it:
177  tmprepo.resetDispose();
178  return tmprepo;
179  }
180 
181  Repository Pool::addRepoHelix( const Pathname & file_r )
182  { return addRepoHelix( file_r, file_r.basename() ); }
183 
184  Repository Pool::addRepoHelix( const Pathname & file_r, const RepoInfo & info_r )
185  {
186  Repository ret( addRepoHelix( file_r, info_r.alias() ) );
187  ret.setInfo( info_r );
188  return ret;
189  }
190 
192 
193  void Pool::setTextLocale( const Locale & locale_r )
194  { myPool().setTextLocale( locale_r ); }
195 
196  void Pool::setRequestedLocales( const LocaleSet & locales_r )
197  { myPool().setRequestedLocales( locales_r ); }
198 
199  bool Pool::addRequestedLocale( const Locale & locale_r )
200  { return myPool().addRequestedLocale( locale_r ); }
201 
202  bool Pool::eraseRequestedLocale( const Locale & locale_r )
203  { return myPool().eraseRequestedLocale( locale_r ); }
204 
206  { return myPool().getRequestedLocales(); }
207 
208  bool Pool::isRequestedLocale( const Locale & locale_r ) const
209  { return myPool().isRequestedLocale( locale_r ); }
210 
212  { return myPool().getAvailableLocales(); }
213 
214  bool Pool::isAvailableLocale( const Locale & locale_r ) const
215  { return myPool().isAvailableLocale( locale_r ); }
216 
217  bool Pool::multiversionEmpty() const { return myPool().multiversionList().empty(); }
218  size_t Pool::multiversionSize() const { return myPool().multiversionList().size(); }
221  bool Pool::isMultiversion( IdString ident_r ) const { return myPool().isMultiversion( ident_r ); }
222 
223  bool Pool::onSystemByUserEmpty() const { return myPool().onSystemByUserList().empty(); }
224  size_t Pool::onSystemByUserSize() const { return myPool().onSystemByUserList().size(); }
227  bool Pool::isOnSystemByUser( IdString ident_r ) const { return myPool().isOnSystemByUser( ident_r ); }
228 
229  /******************************************************************
230  **
231  ** FUNCTION NAME : operator<<
232  ** FUNCTION TYPE : std::ostream &
233  */
234  std::ostream & operator<<( std::ostream & str, const Pool & obj )
235  {
236  return str << "sat::pool(" << obj.serial() << ")["
237  << obj.capacity() << "]{"
238  << obj.reposSize() << "repos|"
239  << obj.solvablesSize() << "slov}";
240  }
241 
243  } // namespace sat
246 } // namespace zypp