libzypp: zypp/Repository.h Source File

libzypp 17.25.10

Repository.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_SAT_REPOSITORY_H
13 #define ZYPP_SAT_REPOSITORY_H
14
15 #include <iosfwd>
16 #include <zypp/base/Iterator.h>
17 #include <zypp/Pathname.h>
18 #include <zypp/sat/detail/PoolMember.h>
19 #include <zypp/sat/LookupAttr.h> // LookupAttrTools.h included at EOF
20 #include <zypp/sat/Solvable.h>
21 #include <zypp/RepoInfo.h>
22 #include <zypp/Date.h>
23 #include <zypp/CpeId.h>
24
26 namespace zypp
27 {
28
29 namespace detail
30 {
31 struct ByRepository;
32 }
33
35 //
36 // CLASS NAME : Repository
37 //
39 class Repository : protected sat::detail::PoolMember
40 {
41 public:
42 typedef filter_iterator<detail::ByRepository, sat::detail::SolvableIterator> SolvableIterator;
43 typedef sat::detail::size_type size_type;
44 typedef sat::detail::RepoIdType IdType;
45
46 typedef sat::ArrayAttr<std::string,std::string> Keywords;
47
48 typedef std::string ContentRevision;
49 typedef std::string ContentIdentifier;
50
51 public:
53 Repository()
54 : _id( sat::detail::noRepoId ) {}
55
57 explicit Repository( IdType id_r )
58 : _id( id_r ) {}
59
60 public:
62 static const Repository noRepository;
63
65 explicit operator bool() const
66 { return get() != nullptr; }
67
69 static const std::string & systemRepoAlias();
70
72 bool isSystemRepo() const;
73
74 public:
84 std::string alias() const;
85
87 std::string name() const;
88
90 std::string label() const;
91
93 std::string asUserString() const
94 { return label(); }
95
96 public:
100 ContentRevision contentRevision() const;
101
113 ContentIdentifier contentIdentifier() const;
114
116 bool hasContentIdentifier( const ContentIdentifier & id_r ) const;
117
134 Date generatedTimestamp() const;
135
152 Date suggestedExpirationTimestamp() const;
153
157 Keywords keywords() const;
158
160 bool hasKeyword( const std::string & val_r ) const;
161
170 bool maybeOutdated() const;
171
178 bool isUpdateRepo() const;
179
186 bool providesUpdatesFor( const CpeId & cpeid_r ) const;
187
189 bool solvablesEmpty() const;
190
192 size_type solvablesSize() const;
193
195 SolvableIterator solvablesBegin() const;
196
198 SolvableIterator solvablesEnd() const;
199
201 Iterable<SolvableIterator> solvables() const;
202
203 public:
204
206 class ProductInfoIterator;
207
215 ProductInfoIterator compatibleWithProductBegin() const;
216
222 ProductInfoIterator compatibleWithProductEnd() const;
223
225 Iterable<ProductInfoIterator> compatibleWithProduct() const;
226
227
236 ProductInfoIterator updatesProductBegin() const;
237
243 ProductInfoIterator updatesProductEnd() const;
244
246 Iterable<ProductInfoIterator> updatesProduct() const;
247
248 public:
250 RepoInfo info() const;
251
257 void setInfo( const RepoInfo & info_r );
258
260 void clearInfo();
261
262 public:
264 void eraseFromPool();
265
267 struct EraseFromPool;
268
269 public:
271 Repository nextInPool() const;
272
273 public:
285 void addSolv( const Pathname & file_r );
286
294 void addHelix( const Pathname & file_r );
295
303 void addTesttags(const Pathname &file_r);
304
306 sat::Solvable::IdType addSolvables( unsigned count_r );
308 sat::Solvable::IdType addSolvable()
309 { return addSolvables( 1 ); }
311
312 public:
314 sat::detail::CRepo * get() const;
316 IdType id() const { return _id; }
325 int satInternalPriority() const;
326 int satInternalSubPriority() const;
328 private:
329 IdType _id;
330 };
332
334 std::ostream & operator<<( std::ostream & str, const Repository & obj );
335
337 std::ostream & dumpAsXmlOn( std::ostream & str, const Repository & obj );
338
340 inline bool operator==( const Repository & lhs, const Repository & rhs )
341 { return lhs.get() == rhs.get(); }
342
344 inline bool operator!=( const Repository & lhs, const Repository & rhs )
345 { return lhs.get() != rhs.get(); }
346
348 inline bool operator<( const Repository & lhs, const Repository & rhs )
349 { return lhs.get() < rhs.get(); }
350
352
371 class Repository::ProductInfoIterator : public boost::iterator_adaptor<
372 Repository::ProductInfoIterator // Derived
373 , sat::LookupAttr::iterator // Base
374 , int // Value
375 , boost::forward_traversal_tag // CategoryOrTraversal
376 , int // Reference
377 >
378 {
379 public:
380 ProductInfoIterator()
381 {}
382
384 std::string label() const;
385
387 CpeId cpeId() const;
388
389 private:
390 friend class Repository;
392 explicit ProductInfoIterator( sat::SolvAttr attr_r, Repository repo_r );
393
394 private:
395 friend class boost::iterator_core_access;
396 int dereference() const { return 0; }
397 };
399
401 inline Iterable<Repository::ProductInfoIterator> Repository::compatibleWithProduct() const
402 { return makeIterable( compatibleWithProductBegin(), compatibleWithProductEnd() ); }
403
405 inline Iterable<Repository::ProductInfoIterator> Repository::updatesProduct() const
406 { return makeIterable( updatesProductBegin(), updatesProductEnd() ); }
407
409 //
410 // CLASS NAME : Repository::EraseFromPool
411 //
438 struct Repository::EraseFromPool
439 {
440 void operator()( Repository repository_r ) const
441 { repository_r.eraseFromPool(); }
442 };
444
446 namespace detail
447 {
449 //
450 // CLASS NAME : RepositoryIterator
451 //
453 class RepositoryIterator : public boost::iterator_adaptor<
454 RepositoryIterator // Derived
455 , sat::detail::CRepo ** // Base
456 , Repository // Value
457 , boost::forward_traversal_tag // CategoryOrTraversal
458 , Repository // Reference
459 >
460 {
461 public:
462 RepositoryIterator()
463 : RepositoryIterator::iterator_adaptor_( 0 )
464 {}
465
466 explicit RepositoryIterator( sat::detail::CRepo ** p )
467 : RepositoryIterator::iterator_adaptor_( p )
468 {}
469
470 private:
471 friend class boost::iterator_core_access;
472
473 Repository dereference() const
474 { return Repository( *base() ); }
475
476 void increment();
477 };
480 //
481 // CLASS NAME : ByRepository
482 //
484 struct ByRepository
485 {
486 public:
487 ByRepository( const Repository & repository_r ) : _repository( repository_r ) {}
488 ByRepository( sat::detail::RepoIdType id_r ) : _repository( id_r ) {}
489 ByRepository() {}
490
491 bool operator()( const sat::Solvable & slv_r ) const
492 { return slv_r.repository() == _repository; }
493
494 private:
495 Repository _repository;
496 };
499 } // namespace detail
501
502 inline Iterable<Repository::SolvableIterator> Repository::solvables() const
503 { return makeIterable( solvablesBegin(), solvablesEnd() ); }
504
506 } // namespace zypp
508
509 // Late include as sat::ArrayAttr requires Repository.h
510 #include <zypp/sat/LookupAttrTools.h>
511
512 #endif // ZYPP_SAT_REPOSITORY_H
CpeId.h
Date.h
Iterator.h
LookupAttrTools.h
LookupAttr.h
Pathname.h
PoolMember.h
RepoInfo.h
Solvable.h
zypp::CpeId
Common Platform Enumearation (2.3) See http://cpe.mitre.org/ for more information on the Common Platf...
Definition: CpeId.h:32
zypp::Date
Store and operate on date (time_t).
Definition: Date.h:33
zypp::Iterable
Definition: Iterable.h:37
zypp::RepoInfo
What is known about a repository.
Definition: RepoInfo.h:72
zypp::Repository::ProductInfoIterator
Query class for Repository related products.
Definition: Repository.h:378
zypp::Repository::ProductInfoIterator::label
std::string label() const
Product label.
Definition: Repository.cc:439
zypp::Repository::ProductInfoIterator::ProductInfoIterator
ProductInfoIterator()
Definition: Repository.h:380
zypp::Repository::ProductInfoIterator::dereference
int dereference() const
Definition: Repository.h:396
zypp::Repository::ProductInfoIterator::cpeId
CpeId cpeId() const
The Common Platform Enumeration name for this product.
Definition: Repository.cc:442
zypp::Repository::ProductInfoIterator::iterator_core_access
friend class boost::iterator_core_access
Definition: Repository.h:395
zypp::Repository
Definition: Repository.h:40
zypp::Repository::nextInPool
Repository nextInPool() const
Return next Repository in Pool (or noRepository).
Definition: Repository.cc:305
zypp::Repository::satInternalSubPriority
int satInternalSubPriority() const
Definition: Repository.cc:79
zypp::Repository::noRepository
static const Repository noRepository
Represents no Repository.
Definition: Repository.h:62
zypp::Repository::addHelix
void addHelix(const Pathname &file_r)
Load Solvables from a helix-file.
Definition: Repository.cc:339
zypp::Repository::Repository
Repository()
Default ctor creates noRepository.
Definition: Repository.h:53
zypp::Repository::hasKeyword
bool hasKeyword(const std::string &val_r) const
Whether val_r is present in keywords.
Definition: Repository.cc:136
zypp::Repository::ContentIdentifier
std::string ContentIdentifier
Definition: Repository.h:49
zypp::Repository::isUpdateRepo
bool isUpdateRepo() const
Hint whether the Repo may provide updates for a product.
Definition: Repository.cc:194
zypp::Repository::keywords
Keywords keywords() const
repository keywords (tags)
Definition: Repository.cc:130
zypp::Repository::get
sat::detail::CRepo * get() const
Expert backdoor.
Definition: Repository.cc:42
zypp::Repository::operator==
bool operator==(const Repository &lhs, const Repository &rhs)
Definition: Repository.h:340
zypp::Repository::IdType
sat::detail::RepoIdType IdType
Definition: Repository.h:44
zypp::Repository::solvablesEmpty
bool solvablesEmpty() const
Whether Repository contains solvables.
Definition: Repository.cc:219
zypp::Repository::label
std::string label() const
Alias or name, according to ZConfig::repoLabelIsAlias.
Definition: Repository.cc:70
zypp::Repository::suggestedExpirationTimestamp
Date suggestedExpirationTimestamp() const
Suggested expiration timestamp.
Definition: Repository.cc:116
zypp::Repository::solvablesEnd
SolvableIterator solvablesEnd() const
Iterator behind the last Solvable.
Definition: Repository.cc:241
zypp::Repository::Repository
Repository(IdType id_r)
PoolImpl ctor.
Definition: Repository.h:57
zypp::Repository::compatibleWithProductEnd
ProductInfoIterator compatibleWithProductEnd() const
Get an iterator to the end of the repository compatible distros.
Definition: Repository.cc:257
zypp::Repository::satInternalPriority
int satInternalPriority() const
libsolv internal priorities.
Definition: Repository.cc:73
zypp::Repository::clearInfo
void clearInfo()
Remove any RepoInfo set for this repository.
Definition: Repository.cc:291
zypp::Repository::addSolvables
sat::Solvable::IdType addSolvables(unsigned count_r)
Add count_r new empty Solvable to this Repository.
Definition: Repository.cc:383
zypp::Repository::providesUpdatesFor
bool providesUpdatesFor(const CpeId &cpeid_r) const
Hint whether the Repo may provide updates for a product identified by it's CpeId.
Definition: Repository.cc:160
zypp::Repository::solvablesBegin
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
Definition: Repository.cc:231
zypp::Repository::addTesttags
void addTesttags(const Pathname &file_r)
Load Solvables from a libsolv testtags-file.
Definition: Repository.cc:361
zypp::Repository::updatesProductEnd
ProductInfoIterator updatesProductEnd() const
Get an iterator to the end of distos the repository provides upadates for.
Definition: Repository.cc:268
zypp::Repository::contentIdentifier
ContentIdentifier contentIdentifier() const
Unique string identifying a repositories content.
Definition: Repository.cc:92
zypp::Repository::maybeOutdated
bool maybeOutdated() const
The suggested expiration date of this repository already passed.
Definition: Repository.cc:144
zypp::Repository::compatibleWithProductBegin
ProductInfoIterator compatibleWithProductBegin() const
Get an iterator to the beginning of the repository compatible distros.
Definition: Repository.cc:251
zypp::Repository::alias
std::string alias() const
Short unique string to identify a repo.
Definition: Repository.cc:59
zypp::Repository::hasContentIdentifier
bool hasContentIdentifier(const ContentIdentifier &id_r) const
Whether id_r matches this repos content identifier.
Definition: Repository.cc:99
zypp::Repository::solvablesSize
size_type solvablesSize() const
Number of solvables in Repository.
Definition: Repository.cc:225
zypp::Repository::updatesProduct
Iterable< ProductInfoIterator > updatesProduct() const
Iterate distos the repository provides upadates for.
Definition: Repository.h:405
zypp::Repository::id
IdType id() const
Expert backdoor.
Definition: Repository.h:316
zypp::Repository::setInfo
void setInfo(const RepoInfo &info_r)
Set RepoInfo for this repository.
Definition: Repository.cc:279
zypp::Repository::addSolvable
sat::Solvable::IdType addSolvable()
Definition: Repository.h:308
zypp::Repository::name
std::string name() const
Label to display for this repo.
Definition: Repository.cc:67
zypp::Repository::operator<
bool operator<(const Repository &lhs, const Repository &rhs)
Definition: Repository.h:348
zypp::Repository::operator!=
bool operator!=(const Repository &lhs, const Repository &rhs)
Definition: Repository.h:344
zypp::Repository::addSolv
void addSolv(const Pathname &file_r)
Load Solvables from a solv-file.
Definition: Repository.cc:320
zypp::Repository::contentRevision
ContentRevision contentRevision() const
Timestamp or arbitrary user supplied string.
Definition: Repository.cc:85
zypp::Repository::size_type
sat::detail::size_type size_type
Definition: Repository.h:43
zypp::Repository::SolvableIterator
filter_iterator< detail::ByRepository, sat::detail::SolvableIterator > SolvableIterator
Definition: Repository.h:42
zypp::Repository::compatibleWithProduct
Iterable< ProductInfoIterator > compatibleWithProduct() const
Iterate the repository compatible distros.
Definition: Repository.h:401
zypp::Repository::solvables
Iterable< SolvableIterator > solvables() const
Iterate the repositories Solvables.
Definition: Repository.h:502
zypp::Repository::generatedTimestamp
Date generatedTimestamp() const
Timestamp when this repository was generated.
Definition: Repository.cc:109
zypp::Repository::updatesProductBegin
ProductInfoIterator updatesProductBegin() const
Get an iterator to the beginning of distos the repository provides upadates for.
Definition: Repository.cc:262
zypp::Repository::ContentRevision
std::string ContentRevision
Definition: Repository.h:48
zypp::Repository::asUserString
std::string asUserString() const
User string: label (alias or name)
Definition: Repository.h:93
zypp::Repository::Keywords
sat::ArrayAttr< std::string, std::string > Keywords
Definition: Repository.h:46
zypp::Repository::systemRepoAlias
static const std::string & systemRepoAlias()
Reserved system repository alias @System .
Definition: Repository.cc:37
zypp::Repository::info
RepoInfo info() const
Return any associated RepoInfo.
Definition: Repository.cc:273
zypp::Repository::_id
IdType _id
Definition: Repository.h:329
zypp::Repository::eraseFromPool
void eraseFromPool()
Remove this Repository from it's Pool.
Definition: Repository.cc:297
zypp::Repository::isSystemRepo
bool isSystemRepo() const
Return whether this is the system repository.
Definition: Repository.cc:53
zypp::detail::RepositoryIterator
Definition: Repository.h:460
zypp::detail::RepositoryIterator::RepositoryIterator
RepositoryIterator()
Definition: Repository.h:462
zypp::detail::RepositoryIterator::dereference
Repository dereference() const
Definition: Repository.h:473
zypp::detail::RepositoryIterator::RepositoryIterator
RepositoryIterator(sat::detail::CRepo **p)
Definition: Repository.h:466
zypp::detail::RepositoryIterator::iterator_core_access
friend class boost::iterator_core_access
Definition: Repository.h:471
zypp::detail::RepositoryIterator::increment
void increment()
Definition: Repository.cc:417
zypp::filesystem::Pathname
Pathname.
Definition: Pathname.h:45
zypp::sat::ArrayAttr
LookupAttr::TransformIterator based container to retrieve list attributes.
Definition: LookupAttrTools.h:155
zypp::sat::SolvAttr
Solvable attribute keys.
Definition: SolvAttr.h:41
zypp::sat::Solvable
A Solvable object within the sat Pool.
Definition: Solvable.h:54
zypp::sat::Solvable::IdType
sat::detail::SolvableIdType IdType
Definition: Solvable.h:56
zypp::sat::Solvable::repository
Repository repository() const
The Repository this Solvable belongs to.
Definition: Solvable.cc:362
str
String related utilities and Regular expression matching.
zypp::sat::detail::noRepoId
static const RepoIdType noRepoId(0)
Id to denote Repo::noRepository.
zypp::sat::detail::size_type
SolvableIdType size_type
Definition: PoolMember.h:126
zypp::sat::detail::CRepo
::s_Repo CRepo
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:63
zypp::sat::detail::RepoIdType
CRepo * RepoIdType
Id type to connect Repo and sat-repo.
Definition: PoolMember.h:133
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:147
zypp::dumpAsXmlOn
std::ostream & dumpAsXmlOn(std::ostream &str, const Tp &obj, const std::string &name_r)
Definition: Xml.h:213
zypp::Repository::EraseFromPool
Functor removing Repository from it's Pool.
Definition: Repository.h:439
zypp::Repository::EraseFromPool::operator()
void operator()(Repository repository_r) const
Definition: Repository.h:440
zypp::detail::ByRepository
Functor filtering Solvable by Repository.
Definition: Repository.h:485
zypp::detail::ByRepository::ByRepository
ByRepository(sat::detail::RepoIdType id_r)
Definition: Repository.h:488
zypp::detail::ByRepository::ByRepository
ByRepository()
Definition: Repository.h:489
zypp::detail::ByRepository::ByRepository
ByRepository(const Repository &repository_r)
Definition: Repository.h:487
zypp::detail::ByRepository::operator()
bool operator()(const sat::Solvable &slv_r) const
Definition: Repository.h:491
zypp::detail::ByRepository::_repository
Repository _repository
Definition: Repository.h:495
zypp::sat::detail::PoolMember
Backlink to the associated PoolImpl.
Definition: PoolMember.h:89