libzypp  14.29.1
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/sat/Queue.h"
29 #include "zypp/RepoInfo.h"
30 #include "zypp/Locale.h"
31 #include "zypp/Capability.h"
32 #include "zypp/IdString.h"
33 
35 namespace zypp
36 {
37  namespace sat
39  {
40  namespace detail
42  {
43 
45  //
46  // CLASS NAME : PoolImpl
47  //
49  class PoolImpl : private base::NonCopyable
50  {
51  public:
53  PoolImpl();
54 
56  ~PoolImpl();
57 
59  ::_Pool * operator->()
60  { return _pool; }
61 
62  public:
64  const SerialNumber & serial() const
65  { return _serial; }
66 
70  void prepare() const;
72  void prepareForSolving() const;
73 
74  private:
78  void setDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
79 
82  void depSetDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 );
83 
85  static detail::IdType nsCallback( ::_Pool *, void * data, detail::IdType lhs, detail::IdType rhs );
86 
87  public:
89  static const std::string & systemRepoAlias();
90 
91  bool isSystemRepo( ::_Repo * repo_r ) const
92  { return repo_r && _pool->installed == repo_r; }
93 
94  ::_Repo * systemRepo() const
95  { return _pool->installed; }
96 
97  public:
104  ::_Repo * _createRepo( const std::string & name_r );
105 
107  void _deleteRepo( ::_Repo * repo_r );
108 
113  int _addSolv( ::_Repo * repo_r, FILE * file_r );
114 
119  int _addHelix( ::_Repo * repo_r, FILE * file_r );
120 
122  detail::SolvableIdType _addSolvables( ::_Repo * repo_r, unsigned count_r );
124 
126  void _postRepoAdd( ::_Repo * repo_r );
127 
128  public:
130  bool validSolvable( const ::_Solvable & slv_r ) const
131  { return slv_r.repo; }
133  bool validSolvable( SolvableIdType id_r ) const
134  { return id_r < unsigned(_pool->nsolvables) && validSolvable( _pool->solvables[id_r] ); }
136  bool validSolvable( const ::_Solvable * slv_r ) const
137  { return _pool->solvables <= slv_r && slv_r <= _pool->solvables+_pool->nsolvables && validSolvable( *slv_r ); }
138 
139  public:
140  ::_Pool * getPool() const
141  { return _pool; }
142 
144  ::_Repo * getRepo( RepoIdType id_r ) const
145  { return id_r; }
146 
150  ::_Solvable * getSolvable( SolvableIdType id_r ) const
151  {
152  if ( validSolvable( id_r ) )
153  return &_pool->solvables[id_r];
154  return 0;
155  }
156 
157  public:
162  { return getNextId( 1 ); }
163 
170  {
171  for( ++id_r; id_r < unsigned(_pool->nsolvables); ++id_r )
172  {
173  if ( validSolvable( _pool->solvables[id_r] ) )
174  return id_r;
175  }
176  return noSolvableId;
177  }
178 
179  public:
181  const RepoInfo & repoInfo( RepoIdType id_r )
182  { return _repoinfos[id_r]; }
184  void setRepoInfo( RepoIdType id_r, const RepoInfo & info_r );
187  { _repoinfos.erase( id_r ); }
188 
189  public:
193  const sat::detail::IdType whatProvidesData( unsigned offset_r )
194  { return _pool->whatprovidesdata[offset_r]; }
195 
199  unsigned whatProvides( Capability cap_r )
200  { prepare(); return ::pool_whatprovides( _pool, cap_r.id() ); }
201 
202  public:
205  void setTextLocale( const Locale & locale_r );
206  void setRequestedLocales( const LocaleSet & locales_r );
207  bool addRequestedLocale( const Locale & locale_r );
208  bool eraseRequestedLocale( const Locale & locale_r );
209 
211  { return _requestedLocales; }
212 
213  bool isRequestedLocale( const Locale & locale_r ) const
214  {
215  LocaleSet::const_iterator it( _requestedLocales.find( locale_r ) );
216  return it != _requestedLocales.end();
217  }
218 
219  const LocaleSet & getAvailableLocales() const;
220 
221  bool isAvailableLocale( const Locale & locale_r ) const
222  {
223  const LocaleSet & avl( getAvailableLocales() );
224  LocaleSet::const_iterator it( avl.find( locale_r ) );
225  return it != avl.end();
226  }
228 
229  public:
233 
234  const MultiversionList & multiversionList() const
235  {
236  if ( ! _multiversionListPtr )
238  return *_multiversionListPtr;
239  }
240 
241  bool isMultiversion( IdString ident_r ) const
242  {
243  const MultiversionList & l( multiversionList() );
244  return l.find( ident_r ) != l.end();
245  }
247 
248  public:
253  { return _autoinstalled; }
254 
256  void setAutoInstalled( const StringQueue & autoInstalled_r )
257  { _autoinstalled = autoInstalled_r; }
258 
259  bool isOnSystemByUser( IdString ident_r ) const
260  { return !_autoinstalled.contains( ident_r.id() ); }
262 
263  public:
265  const std::set<std::string> & requiredFilesystems() const;
266 
267  private:
269  ::_Pool * _pool;
275  std::map<RepoIdType,RepoInfo> _repoinfos;
276 
279  mutable scoped_ptr<LocaleSet> _availableLocalesPtr;
280  mutable std::tr1::unordered_set<IdString> _locale2Solver;
281 
283  void multiversionListInit() const;
284  mutable scoped_ptr<MultiversionList> _multiversionListPtr;
285 
288 
290  mutable scoped_ptr<std::set<std::string> > _requiredFilesystemsPtr;
291  };
293 
295  } // namespace detail
298  } // namespace sat
301 } // namespace zypp
303 #define POOL_SETDIRTY
304 #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:91
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:193
bool eraseRequestedLocale(const Locale &locale_r)
Definition: PoolImpl.cc:451
scoped_ptr< LocaleSet > _availableLocalesPtr
Definition: PoolImpl.h:279
::_Repo * _createRepo(const std::string &name_r)
Creating a new repo named name_r.
Definition: PoolImpl.cc:284
bool validSolvable(const ::_Solvable &slv_r) const
a valid Solvable has a non NULL repo pointer.
Definition: PoolImpl.h:130
::_Pool * getPool() const
Definition: PoolImpl.h:140
IdType id() const
Expert backdoor.
Definition: IdString.h:103
bool addRequestedLocale(const Locale &locale_r)
Definition: PoolImpl.cc:440
void setDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate housekeeping data (e.g.
Definition: PoolImpl.cc:220
unsigned whatProvides(Capability cap_r)
Returns offset into the internal whatprovidesdata array.
Definition: PoolImpl.h:199
void prepareForSolving() const
prepare plus some expensive checks done before solving only.
Definition: PoolImpl.cc:269
::_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:186
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:550
bool isAvailableLocale(const Locale &locale_r) const
Definition: PoolImpl.h:221
Access to the sat-pools string space.
Definition: IdString.h:39
bool validSolvable(SolvableIdType id_r) const
Definition: PoolImpl.h:133
void _deleteRepo(::_Repo *repo_r)
Creating a new repo named name_r.
Definition: PoolImpl.cc:293
const LocaleSet & getRequestedLocales() const
Definition: PoolImpl.h:210
const SerialNumber & serial() const
Serial number changing whenever the content changes.
Definition: PoolImpl.h:64
::_Pool * operator->()
Pointer style access forwarded to sat-pool.
Definition: PoolImpl.h:59
void multiversionListInit() const
Definition: PoolImpl.cc:517
const LocaleSet & getAvailableLocales() const
Definition: PoolImpl.cc:492
int _addSolv(::_Repo *repo_r, FILE *file_r)
Adding solv file to a repo.
Definition: PoolImpl.cc:302
PoolImpl()
Default ctor.
Definition: PoolImpl.cc:178
detail::SolvableIdType _addSolvables(::_Repo *repo_r, unsigned count_r)
Adding Solvables to a repo.
Definition: PoolImpl.cc:364
SolvableIdType getNextId(SolvableIdType id_r) const
Get id of the next valid Solvable.
Definition: PoolImpl.h:169
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
bool isMultiversion(IdString ident_r) const
Definition: PoolImpl.h:241
void setRepoInfo(RepoIdType id_r, const RepoInfo &info_r)
Also adjust repo priority and subpriority accordingly.
Definition: PoolImpl.cc:370
SerialNumberWatcher _watcher
Watch serial number.
Definition: PoolImpl.h:273
void setRequestedLocales(const LocaleSet &locales_r)
Definition: PoolImpl.cc:432
bool isOnSystemByUser(IdString ident_r) const
Definition: PoolImpl.h:259
::_Repo * systemRepo() const
Definition: PoolImpl.h:94
std::tr1::unordered_set< IdString > _locale2Solver
Definition: PoolImpl.h:280
sat::StringQueue _autoinstalled
Definition: PoolImpl.h:287
int _addHelix(::_Repo *repo_r, FILE *file_r)
Adding helix file to a repo.
Definition: PoolImpl.cc:311
std::tr1::unordered_set< Locale > LocaleSet
Definition: Locale.h:28
StringQueue autoInstalled() const
Get ident list of all autoinstalled solvables.
Definition: PoolImpl.h:252
bool validSolvable(const ::_Solvable *slv_r) const
Definition: PoolImpl.h:136
Simple serial number provider.
Definition: SerialNumber.h:44
SerialNumber _serial
Serial number.
Definition: PoolImpl.h:271
scoped_ptr< MultiversionList > _multiversionListPtr
Definition: PoolImpl.h:284
Libsolv Id queue wrapper.
Definition: Queue.h:38
::_Repo * getRepo(RepoIdType id_r) const
Definition: PoolImpl.h:144
void depSetDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate housekeeping data (e.g.
Definition: PoolImpl.cc:236
SolvableIdType getFirstId() const
Get id of the first valid Solvable.
Definition: PoolImpl.h:161
scoped_ptr< std::set< std::string > > _requiredFilesystemsPtr
filesystems mentioned in /etc/sysconfig/storage
Definition: PoolImpl.h:290
void setTextLocale(const Locale &locale_r)
Definition: PoolImpl.cc:415
std::map< RepoIdType, RepoInfo > _repoinfos
Additional RepoInfo.
Definition: PoolImpl.h:275
A sat capability.
Definition: Capability.h:59
void prepare() const
Update housekeeping data (e.g.
Definition: PoolImpl.cc:247
static const std::string & systemRepoAlias()
Reserved system repository alias .
Definition: PoolImpl.cc:89
::_Solvable * getSolvable(SolvableIdType id_r) const
Return pointer to the sat-solvable or NULL if it is not valid.
Definition: PoolImpl.h:150
IdStringSet MultiversionList
Definition: PoolImpl.h:232
bool isRequestedLocale(const Locale &locale_r) const
Definition: PoolImpl.h:213
const RepoInfo & repoInfo(RepoIdType id_r)
Definition: PoolImpl.h:181
const MultiversionList & multiversionList() const
Definition: PoolImpl.h:234
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
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:320
void setAutoInstalled(const StringQueue &autoInstalled_r)
Set ident list of all autoinstalled solvables.
Definition: PoolImpl.h:256
sat::detail::IdType id() const
Expert backdoor.
Definition: Capability.h:244
::_Pool * _pool
sat-pool.
Definition: PoolImpl.h:269
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:115
bool contains(value_type val_r) const
Return whether the Queue contais at lest one element with value val_r.
Definition: Queue.h:61