libzypp 17.37.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 ZYPP_API Repository : protected sat::detail::PoolMember
40 {
41 public:
42 using SolvableIterator = filter_iterator<detail::ByRepository, sat::detail::SolvableIterator>;
43 using size_type = sat::detail::size_type;
44 using IdType = sat::detail::RepoIdType;
45
46 using Keywords = sat::ArrayAttr<std::string, std::string>;
47
48 using ContentRevision = std::string;
49 using ContentIdentifier = std::string;
50
51 public:
53 Repository()
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:
67 static const Repository noRepository;
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 );
313 sat::Solvable::IdType addSolvable()
314 { return addSolvables( 1 ); }
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:
334 IdType _id;
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:
385 ProductInfoIterator()
386 {}
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:
400 friend class boost::iterator_core_access;
401 int dereference() const { return 0; }
402 };
403
404
406 inline Iterable<Repository::ProductInfoIterator> Repository::compatibleWithProduct() const
407 { return makeIterable( compatibleWithProductBegin(), compatibleWithProductEnd() ); }
408
410 inline Iterable<Repository::ProductInfoIterator> Repository::updatesProduct() const
411 { return makeIterable( updatesProductBegin(), updatesProductEnd() ); }
412
414 //
415 // CLASS NAME : Repository::EraseFromPool
416 //
443 struct Repository::EraseFromPool
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:
467 RepositoryIterator()
468 : RepositoryIterator::iterator_adaptor_( 0 )
469 {}
470
471 explicit RepositoryIterator( sat::detail::CRepo ** p )
472 : RepositoryIterator::iterator_adaptor_( p )
473 {}
474
475 private:
476 friend class boost::iterator_core_access;
477
478 Repository dereference() const
479 { return Repository( *base() ); }
480
481 void increment();
482 };
483
485 //
486 // CLASS NAME : ByRepository
487 //
489 struct ByRepository
490 {
491 public:
492 ByRepository( const Repository & repository_r ) : _repository( repository_r ) {}
493 ByRepository( sat::detail::RepoIdType id_r ) : _repository( id_r ) {}
494 ByRepository() {}
495
496 bool operator()( const sat::Solvable & slv_r ) const
497 { return slv_r.repository() == _repository; }
498
499 private:
500 Repository _repository;
501 };
502
504 } // namespace detail
506
507 inline Iterable<Repository::SolvableIterator> Repository::solvables() const
508 { return makeIterable( solvablesBegin(), solvablesEnd() ); }
509
511} // namespace zypp
513
514// Late include as sat::ArrayAttr requires Repository.h
515#include <zypp/sat/LookupAttrTools.h>
516
517#endif // ZYPP_SAT_REPOSITORY_H
CpeId.h
LookupAttrTools.h
LookupAttr.h
PoolMember.h
RepoInfo.h
Solvable.h
bool
filter_iterator
An iterator over the subset of elements of some sequence which satisfy a given predicate.
zypp::CpeId
Common Platform Enumearation (2.3) See http://cpe.mitre.org/ for more information on the Common Platf...
Definition CpeId.h:33
zypp::Date
Store and operate on date (time_t).
Definition Date.h:33
zypp::Iterable
Definition Iterable.h:37
zypp::Iterable::makeIterable
Iterable< TIterator > makeIterable(TIterator &&begin_r, TIterator &&end_r)
convenient construction.
Definition Iterable.h:88
zypp::RepoInfo
What is known about a repository.
Definition RepoInfo.h:72
zypp::Repository::ProductInfoIterator
Query class for Repository related products.
Definition Repository.h:383
zypp::Repository::ProductInfoIterator::label
std::string label() const
Product label.
Definition Repository.cc:440
zypp::Repository::ProductInfoIterator::ProductInfoIterator
ProductInfoIterator()
Definition Repository.h:385
zypp::Repository::ProductInfoIterator::dereference
int dereference() const
Definition Repository.h:401
zypp::Repository::ProductInfoIterator::cpeId
CpeId cpeId() const
The Common Platform Enumeration name for this product.
Definition Repository.cc:443
zypp::Repository::ProductInfoIterator::Repository
friend class Repository
Definition Repository.h:395
zypp::Repository::ProductInfoIterator::iterator_core_access
friend class boost::iterator_core_access
Definition Repository.h:400
zypp::Repository
Definition Repository.h:40
zypp::Repository::noRepository
static const Repository noRepository
Represents no Repository.
Definition Repository.h:67
zypp::Repository::Repository
Repository()
Default ctor creates noRepository.
Definition Repository.h:53
zypp::Repository::Repository
Repository(Repository &&) noexcept=default
zypp::Repository::get
sat::detail::CRepo * get() const
Expert backdoor.
Definition Repository.cc:43
zypp::Repository::operator==
bool operator==(const Repository &lhs, const Repository &rhs)
Definition Repository.h:345
zypp::Repository::label
std::string label() const
Alias or name, according to ZConfig::repoLabelIsAlias.
Definition Repository.cc:71
zypp::Repository::SolvableIterator
filter_iterator< detail::ByRepository, sat::detail::SolvableIterator > SolvableIterator
Definition Repository.h:42
zypp::Repository::solvablesEnd
SolvableIterator solvablesEnd() const
Iterator behind the last Solvable.
Definition Repository.cc:242
zypp::Repository::compatibleWithProductEnd
ProductInfoIterator compatibleWithProductEnd() const
Get an iterator to the end of the repository compatible distros.
Definition Repository.cc:258
zypp::Repository::size_type
sat::detail::size_type size_type
Definition Repository.h:43
zypp::Repository::addSolvables
sat::Solvable::IdType addSolvables(unsigned count_r)
Add count_r new empty Solvable to this Repository.
Definition Repository.cc:384
zypp::Repository::solvablesBegin
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
Definition Repository.cc:232
zypp::Repository::ContentRevision
std::string ContentRevision
Definition Repository.h:48
zypp::Repository::updatesProductEnd
ProductInfoIterator updatesProductEnd() const
Get an iterator to the end of distos the repository provides upadates for.
Definition Repository.cc:269
zypp::Repository::compatibleWithProductBegin
ProductInfoIterator compatibleWithProductBegin() const
Get an iterator to the beginning of the repository compatible distros.
Definition Repository.cc:252
zypp::Repository::updatesProduct
Iterable< ProductInfoIterator > updatesProduct() const
Iterate distos the repository provides upadates for.
Definition Repository.h:410
zypp::Repository::id
IdType id() const
Expert backdoor.
Definition Repository.h:321
zypp::Repository::addSolvable
sat::Solvable::IdType addSolvable()
Definition Repository.h:313
zypp::Repository::operator<
bool operator<(const Repository &lhs, const Repository &rhs)
Definition Repository.h:353
zypp::Repository::IdType
sat::detail::RepoIdType IdType
Definition Repository.h:44
zypp::Repository::operator!=
bool operator!=(const Repository &lhs, const Repository &rhs)
Definition Repository.h:349
zypp::Repository::Repository
Repository(const Repository &)=default
zypp::Repository::compatibleWithProduct
Iterable< ProductInfoIterator > compatibleWithProduct() const
Iterate the repository compatible distros.
Definition Repository.h:406
zypp::Repository::solvables
Iterable< SolvableIterator > solvables() const
Iterate the repositories Solvables.
Definition Repository.h:507
zypp::Repository::Keywords
sat::ArrayAttr< std::string, std::string > Keywords
Definition Repository.h:46
zypp::Repository::updatesProductBegin
ProductInfoIterator updatesProductBegin() const
Get an iterator to the beginning of distos the repository provides upadates for.
Definition Repository.cc:263
zypp::Repository::ContentIdentifier
std::string ContentIdentifier
Definition Repository.h:49
zypp::Repository::asUserString
std::string asUserString() const
User string: label (alias or name)
Definition Repository.h:98
zypp::Repository::_id
IdType _id
Definition Repository.h:334
zypp::Repository::eraseFromPool
void eraseFromPool()
Remove this Repository from its Pool.
Definition Repository.cc:298
zypp::detail::RepositoryIterator::RepositoryIterator
RepositoryIterator()
Definition Repository.h:467
zypp::detail::RepositoryIterator::dereference
Repository dereference() const
Definition Repository.h:478
zypp::detail::RepositoryIterator::RepositoryIterator
RepositoryIterator(sat::detail::CRepo **p)
Definition Repository.h:471
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:47
zypp::sat::ArrayAttr
LookupAttr::TransformIterator based container to retrieve list attributes.
Definition LookupAttrTools.h:157
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::repository
Repository repository() const
The Repository this Solvable belongs to.
Definition Solvable.cc:364
zypp::sat::Solvable::IdType
sat::detail::SolvableIdType IdType
Definition Solvable.h:56
str
String related utilities and Regular expression matching.
zypp::base
Definition Random.cc:7
zypp::detail
Definition PoolQuery.cc:1509
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::sat
Definition Resolver.h:28
zypp::solver::detail
Definition PoolImpl.h:110
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
Definition SerialNumber.cc:52
zypp::dumpAsXmlOn
std::ostream & dumpAsXmlOn(std::ostream &str, const Repository &obj)
Definition Repository.cc:407
zypp::ZYPP_API
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
zypp::Repository::EraseFromPool
Functor removing Repository from its Pool.
Definition Repository.h:444
zypp::Repository::EraseFromPool::operator()
void operator()(Repository repository_r) const
Definition Repository.h:445
zypp::detail::ByRepository
Functor filtering Solvable by Repository.
Definition Repository.h:490
zypp::detail::ByRepository::ByRepository
ByRepository(sat::detail::RepoIdType id_r)
Definition Repository.h:493
zypp::detail::ByRepository::ByRepository
ByRepository()
Definition Repository.h:494
zypp::detail::ByRepository::ByRepository
ByRepository(const Repository &repository_r)
Definition Repository.h:492
zypp::detail::ByRepository::operator()
bool operator()(const sat::Solvable &slv_r) const
Definition Repository.h:496
zypp::detail::ByRepository::_repository
Repository _repository
Definition Repository.h:500
zypp::sat::detail::PoolMember
Backlink to the associated PoolImpl.
Definition PoolMember.h:89
Date.h
Pathname.h
Iterator.h