libzypp 17.37.17
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>
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
26namespace zypp
27{
28
29 namespace detail
30 {
31 struct ByRepository;
32 }
33
35 //
36 // CLASS NAME : Repository
37 //
40 {
41 public:
45
47
48 using ContentRevision = std::string;
49 using ContentIdentifier = std::string;
50
51 public:
54 : _id( sat::detail::noRepoId ) {}
55
56 Repository(const Repository &) = default;
57 Repository(Repository &&) noexcept = default;
58 Repository &operator=(const Repository &) = default;
59 Repository &operator=(Repository &&) noexcept = default;
60
62 explicit Repository( IdType id_r )
63 : _id( id_r ) {}
64
65 public:
68
70 explicit operator bool() const
71 { return get() != nullptr; }
72
74 static const std::string & systemRepoAlias();
75
77 bool isSystemRepo() const;
78
79 public:
89 std::string alias() const;
90
92 std::string name() const;
93
95 std::string label() const;
96
98 std::string asUserString() const
99 { return label(); }
100
101 public:
105 ContentRevision contentRevision() const;
106
118 ContentIdentifier contentIdentifier() const;
119
121 bool hasContentIdentifier( const ContentIdentifier & id_r ) const;
122
139 Date generatedTimestamp() const;
140
157 Date suggestedExpirationTimestamp() const;
158
162 Keywords keywords() const;
163
165 bool hasKeyword( const std::string & val_r ) const;
166
175 bool maybeOutdated() const;
176
183 bool isUpdateRepo() const;
184
191 bool providesUpdatesFor( const CpeId & cpeid_r ) const;
192
194 bool solvablesEmpty() const;
195
197 size_type solvablesSize() const;
198
200 SolvableIterator solvablesBegin() const;
201
203 SolvableIterator solvablesEnd() const;
204
206 Iterable<SolvableIterator> solvables() const;
207
208 public:
209
211 class ProductInfoIterator;
212
220 ProductInfoIterator compatibleWithProductBegin() const;
221
227 ProductInfoIterator compatibleWithProductEnd() const;
228
230 Iterable<ProductInfoIterator> compatibleWithProduct() const;
231
232
241 ProductInfoIterator updatesProductBegin() const;
242
248 ProductInfoIterator updatesProductEnd() const;
249
251 Iterable<ProductInfoIterator> updatesProduct() const;
252
253 public:
255 RepoInfo info() const;
256
262 void setInfo( const RepoInfo & info_r );
263
265 void clearInfo();
266
267 public:
269 void eraseFromPool();
270
272 struct EraseFromPool;
273
274 public:
276 Repository nextInPool() const;
277
278 public:
284
290 void addSolv( const Pathname & file_r );
291
299 void addHelix( const Pathname & file_r );
300
308 void addTesttags(const Pathname &file_r);
309
311 sat::Solvable::IdType addSolvables( unsigned count_r );
315
316
317 public:
319 sat::detail::CRepo * get() const;
321 IdType id() const { return _id; }
330 int satInternalPriority() const;
331 int satInternalSubPriority() const;
333 private:
335 };
336
337
339 std::ostream & operator<<( std::ostream & str, const Repository & obj ) ZYPP_API;
340
342 std::ostream & dumpAsXmlOn( std::ostream & str, const Repository & obj ) ZYPP_API;
343
345 inline bool operator==( const Repository & lhs, const Repository & rhs )
346 { return lhs.get() == rhs.get(); }
347
349 inline bool operator!=( const Repository & lhs, const Repository & rhs )
350 { return lhs.get() != rhs.get(); }
351
353 inline bool operator<( const Repository & lhs, const Repository & rhs )
354 { return lhs.get() < rhs.get(); }
355
357
376 class Repository::ProductInfoIterator : public boost::iterator_adaptor<
377 Repository::ProductInfoIterator // Derived
378 , sat::LookupAttr::iterator // Base
379 , int // Value
380 , boost::forward_traversal_tag // CategoryOrTraversal
381 , int // Reference
382 >
383 {
384 public:
387
389 std::string label() const;
390
392 CpeId cpeId() const;
393
394 private:
395 friend class Repository;
397 explicit ProductInfoIterator( sat::SolvAttr attr_r, Repository repo_r );
398
399 private:
401 int dereference() const { return 0; }
402 };
403
404
408
412
414 //
415 // CLASS NAME : Repository::EraseFromPool
416 //
444 {
445 void operator()( Repository repository_r ) const
446 { repository_r.eraseFromPool(); }
447 };
448
449
451 namespace detail
452 {
454 //
455 // CLASS NAME : RepositoryIterator
456 //
458 class ZYPP_API RepositoryIterator : public boost::iterator_adaptor<
459 RepositoryIterator // Derived
460 , sat::detail::CRepo ** // Base
461 , Repository // Value
462 , boost::forward_traversal_tag // CategoryOrTraversal
463 , Repository // Reference
464 >
465 {
466 public:
468 : RepositoryIterator::iterator_adaptor_( 0 )
469 {}
470
472 : RepositoryIterator::iterator_adaptor_( p )
473 {}
474
475 private:
476 friend class boost::iterator_core_access;
477
479 { return Repository( *base() ); }
480
481 void increment();
482 };
483
485 //
486 // CLASS NAME : ByRepository
487 //
490 {
491 public:
492 ByRepository( const Repository & repository_r ) : _repository( repository_r ) {}
495
496 bool operator()( const sat::Solvable & slv_r ) const
497 { return slv_r.repository() == _repository; }
498
499 private:
501 };
502
504 } // namespace detail
506
509
511} // namespace zypp
513
514// Late include as sat::ArrayAttr requires Repository.h
516
517#endif // ZYPP_SAT_REPOSITORY_H
An iterator over the subset of elements of some sequence which satisfy a given predicate.
Common Platform Enumearation (2.3) See http://cpe.mitre.org/ for more information on the Common Platf...
Definition CpeId.h:33
Store and operate on date (time_t).
Definition Date.h:33
Iterable< TIterator > makeIterable(TIterator &&begin_r, TIterator &&end_r)
convenient construction.
Definition Iterable.h:88
What is known about a repository.
Definition RepoInfo.h:72
Query class for Repository related products.
Definition Repository.h:383
std::string label() const
Product label.
CpeId cpeId() const
The Common Platform Enumeration name for this product.
friend class boost::iterator_core_access
Definition Repository.h:400
static const Repository noRepository
Represents no Repository.
Definition Repository.h:67
Repository()
Default ctor creates noRepository.
Definition Repository.h:53
Repository(Repository &&) noexcept=default
sat::detail::CRepo * get() const
Expert backdoor.
Definition Repository.cc:43
bool operator==(const Repository &lhs, const Repository &rhs)
Definition Repository.h:345
std::string label() const
Alias or name, according to ZConfig::repoLabelIsAlias.
Definition Repository.cc:71
filter_iterator< detail::ByRepository, sat::detail::SolvableIterator > SolvableIterator
Definition Repository.h:42
SolvableIterator solvablesEnd() const
Iterator behind the last Solvable.
ProductInfoIterator compatibleWithProductEnd() const
Get an iterator to the end of the repository compatible distros.
sat::detail::size_type size_type
Definition Repository.h:43
sat::Solvable::IdType addSolvables(unsigned count_r)
Add count_r new empty Solvable to this Repository.
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
std::string ContentRevision
Definition Repository.h:48
ProductInfoIterator updatesProductEnd() const
Get an iterator to the end of distos the repository provides upadates for.
ProductInfoIterator compatibleWithProductBegin() const
Get an iterator to the beginning of the repository compatible distros.
Iterable< ProductInfoIterator > updatesProduct() const
Iterate distos the repository provides upadates for.
Definition Repository.h:410
IdType id() const
Expert backdoor.
Definition Repository.h:321
sat::Solvable::IdType addSolvable()
Definition Repository.h:313
bool operator<(const Repository &lhs, const Repository &rhs)
Definition Repository.h:353
sat::detail::RepoIdType IdType
Definition Repository.h:44
bool operator!=(const Repository &lhs, const Repository &rhs)
Definition Repository.h:349
Repository(const Repository &)=default
Iterable< ProductInfoIterator > compatibleWithProduct() const
Iterate the repository compatible distros.
Definition Repository.h:406
Iterable< SolvableIterator > solvables() const
Iterate the repositories Solvables.
Definition Repository.h:507
sat::ArrayAttr< std::string, std::string > Keywords
Definition Repository.h:46
ProductInfoIterator updatesProductBegin() const
Get an iterator to the beginning of distos the repository provides upadates for.
std::string ContentIdentifier
Definition Repository.h:49
std::string asUserString() const
User string: label (alias or name)
Definition Repository.h:98
void eraseFromPool()
Remove this Repository from its Pool.
Repository dereference() const
Definition Repository.h:478
RepositoryIterator(sat::detail::CRepo **p)
Definition Repository.h:471
LookupAttr::TransformIterator based container to retrieve list attributes.
Solvable attribute keys.
Definition SolvAttr.h:41
A Solvable object within the sat Pool.
Definition Solvable.h:54
Repository repository() const
The Repository this Solvable belongs to.
Definition Solvable.cc:364
sat::detail::SolvableIdType IdType
Definition Solvable.h:56
String related utilities and Regular expression matching.
SolvableIdType size_type
Definition PoolMember.h:126
::s_Repo CRepo
Wrapped libsolv C data type exposed as backdoor.
Definition PoolMember.h:63
CRepo * RepoIdType
Id type to connect Repo and sat-repo.
Definition PoolMember.h:133
Libsolv interface
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
std::ostream & dumpAsXmlOn(std::ostream &str, const Repository &obj)
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
Functor removing Repository from its Pool.
Definition Repository.h:444
void operator()(Repository repository_r) const
Definition Repository.h:445
Functor filtering Solvable by Repository.
Definition Repository.h:490
ByRepository(sat::detail::RepoIdType id_r)
Definition Repository.h:493
ByRepository(const Repository &repository_r)
Definition Repository.h:492
bool operator()(const sat::Solvable &slv_r) const
Definition Repository.h:496
Backlink to the associated PoolImpl.
Definition PoolMember.h:89