libzypp 17.38.6
pool.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8----------------------------------------------------------------------/
9*
10* This file contains private API, this might break at any time between releases.
11* You have been warned!
12*
13*/
14#ifndef ZYPPNG_SAT_POOL_H_INCLUDED
15#define ZYPPNG_SAT_POOL_H_INCLUDED
16
18#include <zypp-core/Pathname.h>
20
21#include <zypp/ng/arch.h>
27#include <zypp/ng/sat/queue.h>
29
30namespace zyppng::sat {
31
36 class Pool
37 {
38 friend class Repository;
39 friend class Solvable;
40
41 public:
44
45 public:
46
48 Pool();
49
50 Pool(const Pool &) = delete;
51 Pool(Pool &&) = delete;
52 Pool &operator=(const Pool &) = delete;
53 Pool &operator=(Pool &&) = delete;
54
56 ~Pool();
57
60 { return _pool; }
61
63 const SerialNumber & serial() const
64 { return _serial; }
65
67 const SerialNumber & serialIDs() const
68 { return _serialIDs; }
69
74
75
77
81 void setDirty( PoolInvalidation invalidation, std::initializer_list<std::string_view> reasons );
82
87 void clear();
88
89 public:
92
93 static const std::string & systemRepoAlias();
94
98 Repository reposFind( const std::string & alias_r ) const;
99
104 Repository reposInsert( const std::string & alias_r );
105
107 void reposErase( const std::string & alias_r )
108 { reposFind( alias_r ).eraseFromPool(); }
109
115 { while ( ! reposEmpty() ) reposErase( repos().begin()->alias() ); }
116
118 bool reposEmpty() const;
119
122
125
128
131
132 bool isSystemRepo( detail::CRepo * repo_r ) const
133 { return repo_r && _pool->installed == repo_r; }
134
135 private:
137 { return _pool->installed; }
138
139
140 public:
143
144 bool solvablesEmpty() const;
145
148
152
153 public:
156 {
157 const char * rd = ::pool_get_rootdir( _pool );
158 return( rd ? rd : "/" );
159 }
160
162 void rootDir( const zypp::Pathname & root_r )
163 {
164 if ( root_r.empty() || root_r == "/" )
165 ::pool_set_rootdir( _pool, nullptr );
166 else
167 ::pool_set_rootdir( _pool, root_r.c_str() );
168 }
169
170 private:
176
177 detail::CRepo * _createRepo( const std::string & name_r );
178
180 void _deleteRepo( detail::CRepo * repo_r );
181
186 int _addSolv( detail::CRepo * repo_r, FILE * file_r );
187
192 int _addHelix( detail::CRepo * repo_r, FILE * file_r );
193
198 int _addTesttags( detail::CRepo * repo_r, FILE * file_r );
199
201 detail::SolvableIdType _addSolvables( detail::CRepo * repo_r, unsigned count_r );
203
205 void _postRepoAdd( detail::CRepo * repo_r );
206
208 bool validSolvable( const detail::CSolvable & slv_r ) const
209 { return slv_r.repo; }
210
212 { return id_r < unsigned(_pool->nsolvables) && validSolvable( _pool->solvables[id_r] ); }
213
214 bool validSolvable( const detail::CSolvable * slv_r ) const
215 { return _pool->solvables <= slv_r && slv_r <= _pool->solvables+_pool->nsolvables && validSolvable( *slv_r ); }
216
218 { return _pool; }
219
222 { return id_r; }
223
228 {
229 if ( validSolvable( id_r ) )
230 return &_pool->solvables[id_r];
231 return 0;
232 }
233
234 public:
236 detail::IdType parserpmrichdep( const char * capstr_r )
237 { return ::pool_parserpmrichdep( _pool, capstr_r ); }
238
243 { return getNextId( 1 ); }
244
251 {
252 for( ++id_r; id_r < unsigned(_pool->nsolvables); ++id_r )
253 {
254 if ( validSolvable( _pool->solvables[id_r] ) )
255 return id_r;
256 }
258 }
259
263 const PoolComponentSet & components() const { return _componentsSet; }
264
265 template <typename T>
266 T & component() { return _componentsSet.assertComponent<T>(); }
267
268 template <typename T>
269 const T * findComponent() const { return _componentsSet.findComponent<T>(); }
271
272 private:
283#ifndef NDEBUG
285 bool _preparing = false;
286#endif
287 };
288}
289
290#endif
Simple serial number watcher.
Simple serial number provider.
const char * c_str() const
String representation.
Definition Pathname.h:113
bool empty() const
Test for an empty path.
Definition Pathname.h:117
Registry and dispatcher for all pool components.
~Pool()
Dtor.
Definition pool.cc:97
const SerialNumber & serialIDs() const
Serial number changing whenever resusePoolIDs==true was used.
Definition pool.h:67
void _postRepoAdd(detail::CRepo *repo_r)
Helper postprocessing the repo after adding solv or helix files.
Definition pool.cc:324
bool _preparing
True while prepare() is running — setDirty() is illegal in this window.
Definition pool.h:285
detail::CRepo * _createRepo(const std::string &name_r)
Creating a new repo named name_r.
Definition pool.cc:266
void reposErase(const std::string &alias_r)
Remove a Repository named alias_r.
Definition pool.h:107
SolvableIterable solvables() const
Iterator to the first Solvable.
Definition pool.cc:258
const PoolComponentSet & components() const
Definition pool.h:263
void _deleteRepo(detail::CRepo *repo_r)
Delete repo repo_r from pool.
Definition pool.cc:277
detail::CPool * get() const
Expert backdoor.
Definition pool.h:59
bool validSolvable(const detail::CSolvable &slv_r) const
a valid Solvable has a non NULL repo pointer.
Definition pool.h:208
SerialNumber _serialIDs
Serial number of IDs - changes whenever resusePoolIDs==true - ResPool must also invalidate its PoolIt...
Definition pool.h:278
zypp::Iterable< detail::RepositoryIterator > RepositoryIterable
Definition pool.h:42
detail::CRepo * _systemRepoPtr() const
Definition pool.h:136
Repository systemRepo()
Return the system repository, create it if missing.
Definition pool.cc:225
bool validSolvable(const detail::CSolvable *slv_r) const
Definition pool.h:214
int _addTesttags(detail::CRepo *repo_r, FILE *file_r)
Adding testtags file to a repo.
Definition pool.cc:309
zypp::Iterable< detail::SolvableIterator > SolvableIterable
Definition pool.h:43
const SerialNumber & serial() const
Serial number changing whenever the content changes.
Definition pool.h:63
SerialNumberWatcher _watcher
Watch serial number.
Definition pool.h:280
void clear()
Reset the pool by removing all repositories and solvables.
Definition pool.cc:143
detail::size_type solvablesSize() const
Number of solvables in Pool.
Definition pool.cc:245
int _addHelix(detail::CRepo *repo_r, FILE *file_r)
Adding helix file to a repo.
Definition pool.cc:300
void rootDir(const zypp::Pathname &root_r)
Set rootdir (for file conflicts check).
Definition pool.h:162
PoolComponentSet _componentsSet
Component set managing modular pool logic.
Definition pool.h:282
detail::SolvableIdType getFirstId() const
Get id of the first valid Solvable.
Definition pool.h:242
detail::CRepo * getRepo(detail::RepoIdType id_r) const
Definition pool.h:221
detail::CSolvable * getSolvable(detail::SolvableIdType id_r) const
Return pointer to the sat-solvable or NULL if it is not valid.
Definition pool.h:227
Pool()
Default ctor.
Definition pool.cc:89
Repository reposFind(const std::string &alias_r) const
Find a Repository named alias_r.
Definition pool.cc:184
bool solvablesEmpty() const
Whether Pool contains solvables.
Definition pool.cc:232
int _addSolv(detail::CRepo *repo_r, FILE *file_r)
Adding solv file to a repo.
Definition pool.cc:291
bool validSolvable(detail::SolvableIdType id_r) const
Definition pool.h:211
void setDirty(PoolInvalidation invalidation, std::initializer_list< std::string_view > reasons)
Invalidate everything.
Definition pool.cc:152
void reposEraseAll()
Remove all repos from the pool.
Definition pool.h:114
detail::CPool * getPool() const
Definition pool.h:217
detail::CPool * _pool
sat-pool.
Definition pool.h:274
Repository findSystemRepo() const
Return the system repository if it is on the pool.
Definition pool.cc:222
PoolComponentSet & components()
Get rootdir (for file conflicts check).
Definition pool.h:262
bool reposEmpty() const
Whether Pool contains repos.
Definition pool.cc:202
Pool & operator=(const Pool &)=delete
detail::size_type reposSize() const
Number of repos in Pool.
Definition pool.cc:205
friend class Repository
Definition pool.h:38
PreparedPool prepare()
Update housekeeping data (e.g.
Definition pool.cc:106
Pool(Pool &&)=delete
friend class Solvable
Definition pool.h:39
T & component()
Definition pool.h:266
detail::SolvableIdType getNextId(detail::SolvableIdType id_r) const
Get id of the next valid Solvable.
Definition pool.h:250
Repository reposInsert(const std::string &alias_r)
Return a Repository named alias_r.
Definition pool.cc:194
SerialNumber _serial
Serial number - changes with each Pool content change.
Definition pool.h:276
Pool & operator=(Pool &&)=delete
bool isSystemRepo(detail::CRepo *repo_r) const
Definition pool.h:132
Pool(const Pool &)=delete
zypp::Pathname rootDir() const
Definition pool.h:155
RepositoryIterable repos() const
Iteratable to the repositories.
Definition pool.cc:208
static const std::string & systemRepoAlias()
Reserved system repository alias @System .
Definition pool.cc:178
detail::size_type capacity() const
Definition pool.cc:103
const T * findComponent() const
Definition pool.h:269
detail::IdType parserpmrichdep(const char *capstr_r)
libsolv capability parser
Definition pool.h:236
detail::SolvableIdType _addSolvables(detail::CRepo *repo_r, unsigned count_r)
Adding Solvables to a repo.
Definition pool.cc:318
A move-only, non-owning view of a Pool that guarantees the whatprovides index is valid.
void eraseFromPool()
Query class for Repository related products.
zypp::sat::detail::CSolvable CSolvable
zypp::sat::detail::RepoIdType RepoIdType
zypp::sat::detail::CPool CPool
zypp::sat::detail::SolvableIdType SolvableIdType
static const SolvableIdType noSolvableId(0)
Id to denote Solvable::noSolvable.
zypp::sat::detail::IdType IdType
zypp::sat::detail::CRepo CRepo
SolvableIdType size_type
This file contains private API, this might break at any time between releases.
PoolInvalidation
Defines the scope of an invalidation request for the Pool.