libzypp: zypp/ng/sat/repository.h Source File

libzypp 17.38.6

repository.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_NG_SAT_REPOSITORY_H
13#define ZYPP_NG_SAT_REPOSITORY_H
14
15#include <iosfwd>
16#include <zypp-core/base/Iterator.h>
17#include <zypp-core/base/Iterable.h>
18#include <zypp-core/Pathname.h>
19#include <zypp/ng/sat/poolconstants.h>
20#include <zypp/ng/sat/poolmember.h>
21//#include <zypp/sat/LookupAttr.h> // LookupAttrTools.h included at EOF
22#include <zypp/ng/sat/solvable.h>
23//#include <zypp/RepoInfo.h>
24#include <zypp-core/Date.h>
25#include <zypp/ng/cpeid.h>
26
28namespace zyppng
29{
30 namespace sat
31 {
32 namespace detail
33 {
34 struct ByRepository;
35 }
36
37 class Repository;
38
39 namespace detail {
40 template<> Pool & poolFromType( Repository & );
41 template<> const Pool & poolFromType( const Repository & );
42 }
43
45 //
46 // CLASS NAME : Repository
47 //
49 class Repository : public PoolMember<Repository>
50 {
51 public:
52 using SolvableIterator = boost::filter_iterator<detail::ByRepository, sat::detail::SolvableIterator>;
53 using SolvableIterable = zypp::Iterable<SolvableIterator>;
54 using size_type = unsigned int;
55 using IdType = detail::RepoIdType;
56
57 //using Keywords = sat::ArrayAttr<std::string, std::string>;
58
59 using ContentRevision = std::string;
60 using ContentIdentifier = std::string;
61
62 public:
64 Repository()
65 : _id( detail::noRepoId ) {}
66
67 Repository(const Repository &) = default;
68 Repository(Repository &&) noexcept = default;
69 Repository &operator=(const Repository &) = default;
70 Repository &operator=(Repository &&) noexcept = default;
71
73 explicit Repository( IdType id_r )
74 : _id( id_r ) {}
75
76 public:
78 static const Repository noRepository;
79
81 explicit operator bool() const
82 { return get() != nullptr; }
83
85 static const std::string & systemRepoAlias();
86
88 bool isSystemRepo() const;
89
90 public:
100 std::string alias() const;
101
103 //std::string name() const;
104
106 //std::string label() const;
107
109 //std::string asUserString() const
110 //{ return label(); }
111
112 public:
116 ContentRevision contentRevision() const;
117
129 ContentIdentifier contentIdentifier() const;
130
132 bool hasContentIdentifier( const ContentIdentifier & id_r ) const;
133
150 zypp::Date generatedTimestamp() const;
151
168 zypp::Date suggestedExpirationTimestamp() const;
169
173 //Keywords keywords() const;
174
176 //bool hasKeyword( const std::string & val_r ) const;
177
186 bool maybeOutdated() const;
187
194 //bool isUpdateRepo() const;
195
202 //bool providesUpdatesFor( const CpeId & cpeid_r ) const;
203
205 bool solvablesEmpty() const;
206
208 size_type solvablesSize() const;
209
211 SolvableIterable solvables() const;
212
213 public:
214
216 //class ProductInfoIterator;
217
225 //ProductInfoIterator compatibleWithProductBegin() const;
226
232 //ProductInfoIterator compatibleWithProductEnd() const;
233
235 //Iterable<ProductInfoIterator> compatibleWithProduct() const;
236
237
246 //ProductInfoIterator updatesProductBegin() const;
247
253 //ProductInfoIterator updatesProductEnd() const;
254
256 //Iterable<ProductInfoIterator> updatesProduct() const;
257
258 public:
260 //RepoInfo info() const;
261
267 //void setInfo( const RepoInfo & info_r );
268
270 //void clearInfo();
271
272 public:
274 void eraseFromPool();
275
277 struct EraseFromPool;
278
279 public:
281 Repository nextInPool() const;
282
283 public:
289
295 void addSolv( const zypp::Pathname & file_r );
296
304 void addHelix( const zypp::Pathname & file_r );
305
313 void addTesttags(const zypp::Pathname &file_r);
314
316 sat::Solvable::IdType addSolvables( unsigned count_r );
318 sat::Solvable::IdType addSolvable()
319 { return addSolvables( 1 ); }
320
321
322 public:
324 detail::CRepo * get() const;
326 IdType id() const { return _id; }
335 int satInternalPriority() const;
336 int satInternalSubPriority() const;
338
339 private:
341 SolvableIterator solvablesBegin() const;
342
344 SolvableIterator solvablesEnd() const;
345
346 private:
347 IdType _id;
348 };
349
350
351 //std::ostream & operator<<( std::ostream & str, const Repository & obj );
352
353 //std::ostream & dumpAsXmlOn( std::ostream & str, const Repository & obj );
354
356 inline bool operator==( const Repository & lhs, const Repository & rhs )
357 { return lhs.get() == rhs.get(); }
358
360 inline bool operator!=( const Repository & lhs, const Repository & rhs )
361 { return !( lhs == rhs ); }
362
364 inline bool operator<( const Repository & lhs, const Repository & rhs )
365 { return lhs.get() < rhs.get(); }
366
368
387 /*
388 class Repository::ProductInfoIterator : public boost::iterator_adaptor<
389 Repository::ProductInfoIterator // Derived
390 , sat::LookupAttr::iterator // Base
391 , int // Value
392 , boost::forward_traversal_tag // CategoryOrTraversal
393 , int // Reference
394 >
395 {
396 public:
397 ProductInfoIterator()
398 {}
399
400 // Product label
401 std::string label() const;
402
403 // The Common Platform Enumeration name for this product.
404 CpeId cpeId() const;
405
406 private:
407 friend class Repository;
408 // Hide ctor as just a limited set of attributes is valid.
409 explicit ProductInfoIterator( sat::SolvAttr attr_r, Repository repo_r );
410
411 private:
412 friend class boost::iterator_core_access;
413 int dereference() const { return 0; }
414 };
415 */
417
419 /*
420 inline Iterable<Repository::ProductInfoIterator> Repository::compatibleWithProduct() const
421 { return makeIterable( compatibleWithProductBegin(), compatibleWithProductEnd() ); }
422 */
423
425 /*
426 inline Iterable<Repository::ProductInfoIterator> Repository::updatesProduct() const
427 { return makeIterable( updatesProductBegin(), updatesProductEnd() ); }
428 */
429
431 //
432 // CLASS NAME : Repository::EraseFromPool
433 //
460 struct Repository::EraseFromPool
461 {
462 void operator()( Repository repository_r ) const
463 { repository_r.eraseFromPool(); }
464 };
465
466
468 namespace detail
469 {
473
474 class RepositoryIterator : public boost::iterator_adaptor<
475 RepositoryIterator // Derived
476 , sat::detail::CRepo ** // Base
477 , Repository // Value
478 , boost::forward_traversal_tag // CategoryOrTraversal
479 , Repository // Reference
480 >
481 {
482 public:
483 RepositoryIterator()
484 : RepositoryIterator::iterator_adaptor_( 0 )
485 {}
486
487 explicit RepositoryIterator( sat::detail::CRepo ** p )
488 : RepositoryIterator::iterator_adaptor_( p )
489 {}
490
491 private:
492 friend class boost::iterator_core_access;
493
494 Repository dereference() const
495 { return Repository( *base() ); }
496
497 void increment();
498 };
499
502 //
503 // CLASS NAME : ByRepository
504 //
506 struct ByRepository
507 {
508 public:
509 ByRepository( const Repository & repository_r ) : _repository( repository_r ) {}
510 ByRepository( sat::detail::RepoIdType id_r ) : _repository( id_r ) {}
511 ByRepository() : _repository( detail::noRepoId ) {}
512
513 bool operator()( const sat::Solvable & slv_r ) const
514 { return slv_r.repository() == _repository.id(); }
515
516 private:
517 Repository _repository;
518 };
519
521 } // namespace detail
523
524 inline zypp::Iterable<Repository::SolvableIterator> Repository::solvables() const
525 { return zypp::makeIterable( solvablesBegin(), solvablesEnd() ); }
526
527 } // namespace sat
528} // namespace zyppng
530
531// Late include as sat::ArrayAttr requires Repository.h
532//#include <zypp/sat/LookupAttrTools.h>
533
534#endif // ZYPP_SAT_REPOSITORY_H
Date.h
Iterable.h
Iterator.h
Pathname.h
bool
zypp::Date
Store and operate on date (time_t).
Definition Date.h:33
zypp::Iterable
Definition Iterable.h:37
zypp::Repository::solvables
Iterable< SolvableIterator > solvables() const
Iterate the repositories Solvables.
Definition Repository.h:507
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:48
zyppng::sat::PoolMember
Definition poolmember.h:28
zyppng::sat::Repository
Definition repository.h:50
zyppng::sat::Repository::satInternalSubPriority
int satInternalSubPriority() const
Definition repository.cc:88
zyppng::sat::Repository::addSolv
void addSolv(const zypp::Pathname &file_r)
Load Solvables from a solv-file.
Definition repository.cc:215
zyppng::sat::Repository::eraseFromPool
void eraseFromPool()
Query class for Repository related products.
Definition repository.cc:191
zyppng::sat::Repository::Repository
Repository()
Default ctor creates noRepository.
Definition repository.h:64
zyppng::sat::Repository::addHelix
void addHelix(const zypp::Pathname &file_r)
Load Solvables from a helix-file.
Definition repository.cc:234
zyppng::sat::Repository::isSystemRepo
bool isSystemRepo() const
Return whether this is the system repository.
Definition repository.cc:68
zyppng::sat::Repository::noRepository
static const Repository noRepository
Represents no Repository.
Definition repository.h:78
zyppng::sat::Repository::addTesttags
void addTesttags(const zypp::Pathname &file_r)
Load Solvables from a libsolv testtags-file.
Definition repository.cc:258
zyppng::sat::Repository::hasContentIdentifier
bool hasContentIdentifier(const ContentIdentifier &id_r) const
Whether id_r matches this repos content identifier.
Definition repository.cc:108
zyppng::sat::Repository::alias
std::string alias() const
Short unique string to identify a repo.
Definition repository.cc:74
zyppng::sat::Repository::_id
IdType _id
Definition repository.h:347
zyppng::sat::Repository::addSolvables
sat::Solvable::IdType addSolvables(unsigned count_r)
Add count_r new empty Solvable to this Repository.
Definition repository.cc:282
zyppng::sat::Repository::id
IdType id() const
Expert backdoor.
Definition repository.h:326
zyppng::sat::Repository::generatedTimestamp
zypp::Date generatedTimestamp() const
Timestamp when this repository was generated.
Definition repository.cc:120
zyppng::sat::Repository::SolvableIterator
boost::filter_iterator< detail::ByRepository, sat::detail::SolvableIterator > SolvableIterator
Definition repository.h:52
zyppng::sat::Repository::Repository
Repository(const Repository &)=default
zyppng::sat::Repository::contentRevision
ContentRevision contentRevision() const
Label to display for this repo.
Definition repository.cc:94
zyppng::sat::Repository::ContentRevision
std::string ContentRevision
Definition repository.h:59
zyppng::sat::Repository::contentIdentifier
ContentIdentifier contentIdentifier() const
Unique string identifying a repositories content.
Definition repository.cc:101
zyppng::sat::Repository::satInternalPriority
int satInternalPriority() const
libsolv internal priorities.
Definition repository.cc:82
zyppng::sat::Repository::maybeOutdated
bool maybeOutdated() const
repository keywords (tags)
Definition repository.cc:143
zyppng::sat::Repository::solvables
SolvableIterable solvables() const
Iterate the repositories Solvables.
Definition repository.h:524
zyppng::sat::Repository::solvablesEmpty
bool solvablesEmpty() const
Hint whether the Repo may provide updates for a product.
Definition repository.cc:159
zyppng::sat::Repository::solvablesEnd
SolvableIterator solvablesEnd() const
Iterator behind the last Solvable.
Definition repository.cc:181
zyppng::sat::Repository::addSolvable
sat::Solvable::IdType addSolvable()
Definition repository.h:318
zyppng::sat::Repository::solvablesSize
size_type solvablesSize() const
Number of solvables in Repository.
Definition repository.cc:165
zyppng::sat::Repository::solvablesBegin
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
Definition repository.cc:171
zyppng::sat::Repository::get
detail::CRepo * get() const
Expert backdoor.
Definition repository.cc:57
zyppng::sat::Repository::IdType
detail::RepoIdType IdType
Definition repository.h:55
zyppng::sat::Repository::ContentIdentifier
std::string ContentIdentifier
Definition repository.h:60
zyppng::sat::Repository::Repository
Repository(Repository &&) noexcept=default
zyppng::sat::Repository::size_type
unsigned int size_type
Definition repository.h:54
zyppng::sat::Repository::SolvableIterable
zypp::Iterable< SolvableIterator > SolvableIterable
Definition repository.h:53
zyppng::sat::Repository::systemRepoAlias
static const std::string & systemRepoAlias()
Reserved system repository alias @System .
Definition repository.cc:52
zyppng::sat::Repository::nextInPool
Repository nextInPool() const
Return next Repository in Pool (or noRepository).
Definition repository.cc:199
zyppng::sat::Repository::suggestedExpirationTimestamp
zypp::Date suggestedExpirationTimestamp() const
Suggested expiration timestamp.
Definition repository.cc:128
zyppng::sat::Solvable
A Solvable object within the sat Pool.
Definition solvable.h:65
zyppng::sat::Solvable::IdType
detail::SolvableIdType IdType
Definition solvable.h:67
zyppng::sat::Solvable::repository
detail::RepoIdType repository() const
The repo id this Solvable belongs to.
Definition solvable.cc:272
zyppng::sat::detail::RepositoryIterator::RepositoryIterator
RepositoryIterator()
Definition repository.h:483
zyppng::sat::detail::RepositoryIterator::increment
void increment()
Definition repository.cc:290
zyppng::sat::detail::RepositoryIterator::dereference
Repository dereference() const
Definition repository.h:494
zyppng::sat::detail::RepositoryIterator::iterator_core_access
friend class boost::iterator_core_access
Definition repository.h:492
zyppng::sat::detail::RepositoryIterator::RepositoryIterator
RepositoryIterator(sat::detail::CRepo **p)
Definition repository.h:487
cpeid.h
zypp::base
Definition Random.cc:7
zypp::sat::operator!=
bool operator!=(const FileConflicts &lhs, const FileConflicts &rhs)
relates: FileConflicts
Definition FileConflicts.h:89
zypp::sat::operator<
bool operator<(const LocaleSupport &lhs, const LocaleSupport &rhs)
relates: LocaleSupport
Definition LocaleSupport.h:120
zypp::sat::operator==
bool operator==(const FileConflicts &lhs, const FileConflicts &rhs)
relates: FileConflicts
Definition FileConflicts.h:85
zypp::makeIterable
Iterable< TIterator > makeIterable(TIterator &&begin_r, TIterator &&end_r)
relates: Iterable convenient construction.
Definition Iterable.h:88
zyppng::sat::detail
CLASS NAME : detail::DIWrap.
Definition cap2str.cc:14
zyppng::sat::detail::RepoIdType
zypp::sat::detail::RepoIdType RepoIdType
Definition poolconstants.h:45
zyppng::sat::detail::poolFromType
Pool & poolFromType(T &)
zyppng::sat::detail::noRepoId
static const RepoIdType noRepoId(0)
Id to denote Repo::noRepository.
zyppng::sat::detail::CRepo
zypp::sat::detail::CRepo CRepo
Definition poolconstants.h:38
zyppng::sat
This file contains private API, this might break at any time between releases.
Definition capabilities.h:22
zyppng
Definition MediaNetworkRequestExecutor.h:16
poolconstants.h
poolmember.h
solvable.h
zyppng::sat::Repository::EraseFromPool
Query class for Repository related products.
Definition repository.h:461
zyppng::sat::Repository::EraseFromPool::operator()
void operator()(Repository repository_r) const
Definition repository.h:462
zyppng::sat::detail::ByRepository
Functor filtering Solvable by Repository.
Definition repository.h:507
zyppng::sat::detail::ByRepository::ByRepository
ByRepository(const Repository &repository_r)
Definition repository.h:509
zyppng::sat::detail::ByRepository::ByRepository
ByRepository()
Definition repository.h:511
zyppng::sat::detail::ByRepository::_repository
Repository _repository
Definition repository.h:517
zyppng::sat::detail::ByRepository::ByRepository
ByRepository(sat::detail::RepoIdType id_r)
Definition repository.h:510
zyppng::sat::detail::ByRepository::operator()
bool operator()(const sat::Solvable &slv_r) const
Definition repository.h:513