libzypp  11.13.5
PoolImpl.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_SAT_DETAIL_POOLIMPL_H
13 #define ZYPP_SAT_DETAIL_POOLIMPL_H
14 extern "C"
15 {
16 #include <solv/pool.h>
17 #include <solv/repo.h>
18 #include <solv/solvable.h>
19 #include <solv/poolarch.h>
20 #include <solv/repo_solv.h>
21 }
22 #include <iosfwd>
23 
24 #include "zypp/base/Tr1hash.h"
25 #include "zypp/base/NonCopyable.h"
26 #include "zypp/base/SerialNumber.h"
28 #include "zypp/RepoInfo.h"
29 #include "zypp/Locale.h"
30 #include "zypp/Capability.h"
31 #include "zypp/IdString.h"
32 
34 namespace zypp
35 {
36 
37  namespace sat
38  {
39 
40  namespace detail
41  {
42 
44  //
45  // CLASS NAME : PoolImpl
46  //
48  class PoolImpl : private base::NonCopyable
49  {
50  public:
52  PoolImpl();
53 
55  ~PoolImpl();
56 
58  ::_Pool * operator->()
59  { return _pool; }
60 
61  public:
63  const SerialNumber & serial() const
64  { return _serial; }
65 
69  void prepare() const;
71  void prepareForSolving() const;
72 
73  private:
77  void setDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
78 
81  void depSetDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
82 
84  static detail::IdType nsCallback( ::_Pool *, void * data, detail::IdType lhs, detail::IdType rhs );
85 
86  public:
88  static const std::string & systemRepoAlias();
89 
90  bool isSystemRepo( ::_Repo * repo_r ) const
91  { return repo_r && _pool->installed == repo_r; }
92 
93  ::_Repo * systemRepo() const
94  { return _pool->installed; }
95 
96  public:
103  ::_Repo * _createRepo( const std::string & name_r );
104 
106  void _deleteRepo( ::_Repo * repo_r );
107 
112  int _addSolv( ::_Repo * repo_r, FILE * file_r );
113 
118  int _addHelix( ::_Repo * repo_r, FILE * file_r );
119 
121  detail::SolvableIdType _addSolvables( ::_Repo * repo_r, unsigned count_r );
123 
125  void _postRepoAdd( ::_Repo * repo_r );
126 
127  public:
129  bool validSolvable( const ::_Solvable & slv_r ) const
130  { return slv_r.repo; }
132  bool validSolvable( SolvableIdType id_r ) const
133  { return id_r < unsigned(_pool->nsolvables) && validSolvable( _pool->solvables[id_r] ); }
135  bool validSolvable( const ::_Solvable * slv_r ) const
136  { return _pool->solvables <= slv_r && slv_r <= _pool->solvables+_pool->nsolvables && validSolvable( *slv_r ); }
137 
138  public:
139  ::_Pool * getPool() const
140  { return _pool; }
141 
143  ::_Repo * getRepo( RepoIdType id_r ) const
144  { return id_r; }
145 
149  ::_Solvable * getSolvable( SolvableIdType id_r ) const
150  {
151  if ( validSolvable( id_r ) )
152  return &_pool->solvables[id_r];
153  return 0;
154  }
155 
156  public:
161  { return getNextId( 1 ); }
162 
169  {
170  for( ++id_r; id_r < unsigned(_pool->nsolvables); ++id_r )
171  {
172  if ( validSolvable( _pool->solvables[id_r] ) )
173  return id_r;
174  }
175  return noSolvableId;
176  }
177 
178  public:
180  const RepoInfo & repoInfo( RepoIdType id_r )
181  { return _repoinfos[id_r]; }
183  void setRepoInfo( RepoIdType id_r, const RepoInfo & info_r );
186  { _repoinfos.erase( id_r ); }
187 
188  public:
192  const sat::detail::IdType whatProvidesData( unsigned offset_r )
193  { return _pool->whatprovidesdata[offset_r]; }
194 
198  unsigned whatProvides( Capability cap_r )
199  { prepare(); return ::pool_whatprovides( _pool, cap_r.id() ); }
200 
201  public:
204  void setTextLocale( const Locale & locale_r );
205  void setRequestedLocales( const LocaleSet & locales_r );
206  bool addRequestedLocale( const Locale & locale_r );
207  bool eraseRequestedLocale( const Locale & locale_r );
208 
210  { return _requestedLocales; }
211 
212  bool isRequestedLocale( const Locale & locale_r ) const
213  {
214  LocaleSet::const_iterator it( _requestedLocales.find( locale_r ) );
215  return it != _requestedLocales.end();
216  }
217 
218  const LocaleSet & getAvailableLocales() const;
219 
220  bool isAvailableLocale( const Locale & locale_r ) const
221  {
222  const LocaleSet & avl( getAvailableLocales() );
223  LocaleSet::const_iterator it( avl.find( locale_r ) );
224  return it != avl.end();
225  }
227 
228  public:
232 
234  {
235  if ( ! _multiversionListPtr )
237  return *_multiversionListPtr;
238  }
239 
240  bool isMultiversion( IdString ident_r ) const
241  {
242  const MultiversionList & l( multiversionList() );
243  return l.find( ident_r ) != l.end();
244  }
246 
247  public:
251 
253  {
254  if ( ! _onSystemByUserListPtr )
256  return *_onSystemByUserListPtr;
257  }
258 
259  bool isOnSystemByUser( IdString ident_r ) const
260  {
261  const OnSystemByUserList & l( onSystemByUserList() );
262  return l.find( ident_r ) != l.end();
263  }
265 
266  public:
268  const std::set<std::string> & requiredFilesystems() const;
269 
270  private:
272  ::_Pool * _pool;
278  std::map<RepoIdType,RepoInfo> _repoinfos;
279 
282  mutable scoped_ptr<LocaleSet> _availableLocalesPtr;
283  mutable std::tr1::unordered_set<IdString> _locale2Solver;
284 
286  void multiversionListInit() const;
287  mutable scoped_ptr<MultiversionList> _multiversionListPtr;
288 
290  void onSystemByUserListInit() const;
291  mutable scoped_ptr<OnSystemByUserList> _onSystemByUserListPtr;
292 
294  mutable scoped_ptr<std::set<std::string> > _requiredFilesystemsPtr;
295  };
297 
299  } // namespace detail
302  } // namespace sat
305 } // namespace zypp
307 #define POOL_SETDIRTY
308 #endif // ZYPP_SAT_DETAIL_POOLIMPL_H