libzypp  13.10.6
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  namespace sat
38  {
39  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
static const SolvableIdType noSolvableId(0)
Id to denote Solvable::noSolvable.
Simple serial number watcher.
Definition: SerialNumber.h:122
bool isSystemRepo(::_Repo *repo_r) const
Definition: PoolImpl.h:90
int IdType
Generic Id type.
Definition: PoolMember.h:82
const sat::detail::IdType whatProvidesData(unsigned offset_r)
Returns the id stored at offset_r in the internal whatprovidesdata array.
Definition: PoolImpl.h:192
bool eraseRequestedLocale(const Locale &locale_r)
Definition: PoolImpl.cc:449
scoped_ptr< LocaleSet > _availableLocalesPtr
Definition: PoolImpl.h:282
::_Repo * _createRepo(const std::string &name_r)
Creating a new repo named name_r.
Definition: PoolImpl.cc:274
bool validSolvable(const ::_Solvable &slv_r) const
a valid Solvable has a non NULL repo pointer.
Definition: PoolImpl.h:129
::_Pool * getPool() const
Definition: PoolImpl.h:139
bool addRequestedLocale(const Locale &locale_r)
Definition: PoolImpl.cc:438
void setDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate housekeeping data (e.g.
Definition: PoolImpl.cc:210
unsigned whatProvides(Capability cap_r)
Returns offset into the internal whatprovidesdata array.
Definition: PoolImpl.h:198
void prepareForSolving() const
prepare plus some expensive checks done before solving only.
Definition: PoolImpl.cc:259
::_Repo * RepoIdType
Id type to connect Repo and sat-repo.
Definition: PoolMember.h:106
unsigned SolvableIdType
Id type to connect Solvable and sat-solvable.
Definition: PoolMember.h:98
void eraseRepoInfo(RepoIdType id_r)
Definition: PoolImpl.h:185
What is known about a repository.
Definition: RepoInfo.h:66
const std::set< std::string > & requiredFilesystems() const
accessor for etc/sysconfig/storage reading file on demand
Definition: PoolImpl.cc:616
bool isAvailableLocale(const Locale &locale_r) const
Definition: PoolImpl.h:220
Access to the sat-pools string space.
Definition: IdString.h:39
bool validSolvable(SolvableIdType id_r) const
Definition: PoolImpl.h:132
void _deleteRepo(::_Repo *repo_r)
Creating a new repo named name_r.
Definition: PoolImpl.cc:283
const LocaleSet & getRequestedLocales() const
Definition: PoolImpl.h:209
const SerialNumber & serial() const
Serial number changing whenever the content changes.
Definition: PoolImpl.h:63
::_Pool * operator->()
Pointer style access forwarded to sat-pool.
Definition: PoolImpl.h:58
void multiversionListInit() const
Definition: PoolImpl.cc:515
const LocaleSet & getAvailableLocales() const
Definition: PoolImpl.cc:490
int _addSolv(::_Repo *repo_r, FILE *file_r)
Adding solv file to a repo.
Definition: PoolImpl.cc:295
PoolImpl()
Default ctor.
Definition: PoolImpl.cc:175
detail::SolvableIdType _addSolvables(::_Repo *repo_r, unsigned count_r)
Adding Solvables to a repo.
Definition: PoolImpl.cc:362
SolvableIdType getNextId(SolvableIdType id_r) const
Get id of the next valid Solvable.
Definition: PoolImpl.h:168
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
bool isMultiversion(IdString ident_r) const
Definition: PoolImpl.h:240
void setRepoInfo(RepoIdType id_r, const RepoInfo &info_r)
Also adjust repo priority and subpriority accordingly.
Definition: PoolImpl.cc:368
SerialNumberWatcher _watcher
Watch serial number.
Definition: PoolImpl.h:276
void setRequestedLocales(const LocaleSet &locales_r)
Definition: PoolImpl.cc:430
bool isOnSystemByUser(IdString ident_r) const
Definition: PoolImpl.h:259
::_Repo * systemRepo() const
Definition: PoolImpl.h:93
std::tr1::unordered_set< IdString > _locale2Solver
Definition: PoolImpl.h:283
int _addHelix(::_Repo *repo_r, FILE *file_r)
Adding helix file to a repo.
Definition: PoolImpl.cc:304
std::tr1::unordered_set< Locale > LocaleSet
Definition: Locale.h:28
bool validSolvable(const ::_Solvable *slv_r) const
Definition: PoolImpl.h:135
Simple serial number provider.
Definition: SerialNumber.h:44
const OnSystemByUserList & onSystemByUserList() const
Definition: PoolImpl.h:252
SerialNumber _serial
Serial number.
Definition: PoolImpl.h:274
scoped_ptr< MultiversionList > _multiversionListPtr
Definition: PoolImpl.h:287
::_Repo * getRepo(RepoIdType id_r) const
Definition: PoolImpl.h:143
void depSetDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate housekeeping data (e.g.
Definition: PoolImpl.cc:226
SolvableIdType getFirstId() const
Get id of the first valid Solvable.
Definition: PoolImpl.h:160
scoped_ptr< std::set< std::string > > _requiredFilesystemsPtr
filesystems mentioned in /etc/sysconfig/storage
Definition: PoolImpl.h:294
void setTextLocale(const Locale &locale_r)
Definition: PoolImpl.cc:413
std::map< RepoIdType, RepoInfo > _repoinfos
Additional RepoInfo.
Definition: PoolImpl.h:278
A sat capability.
Definition: Capability.h:59
void prepare() const
Update housekeeping data (e.g.
Definition: PoolImpl.cc:237
static const std::string & systemRepoAlias()
Reserved system repository alias .
Definition: PoolImpl.cc:79
::_Solvable * getSolvable(SolvableIdType id_r) const
Return pointer to the sat-solvable or NULL if it is not valid.
Definition: PoolImpl.h:149
IdStringSet MultiversionList
Definition: PoolImpl.h:231
scoped_ptr< OnSystemByUserList > _onSystemByUserListPtr
Definition: PoolImpl.h:291
bool isRequestedLocale(const Locale &locale_r) const
Definition: PoolImpl.h:212
const RepoInfo & repoInfo(RepoIdType id_r)
Definition: PoolImpl.h:180
const MultiversionList & multiversionList() const
Definition: PoolImpl.h:233
void onSystemByUserListInit() const
Definition: PoolImpl.cc:548
IdStringSet OnSystemByUserList
Definition: PoolImpl.h:250
std::tr1::unordered_set< IdString > IdStringSet
Definition: IdString.h:24
void _postRepoAdd(::_Repo *repo_r)
Helper postprocessing the repo after adding solv or helix files.
Definition: PoolImpl.cc:313
sat::detail::IdType id() const
Expert backdoor.
Definition: Capability.h:244
::_Pool * _pool
sat-pool.
Definition: PoolImpl.h:272
static detail::IdType nsCallback(::_Pool *, void *data, detail::IdType lhs, detail::IdType rhs)
Callback to resolve namespace dependencies (language, modalias, filesystem, etc.).
Definition: PoolImpl.cc:105