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

libzypp 17.38.14

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#include <zypp-core/ng/base/iterators.h>
27
29namespace zyppng
30{
31 namespace sat
32 {
33 namespace detail
34 {
35 struct ByRepository;
36 }
37
38 class Repository;
39
40 namespace detail {
41 template<> Pool & poolFromType( Repository & );
42 template<> const Pool & poolFromType( const Repository & );
43 }
44
46 //
47 // CLASS NAME : Repository
48 //
50 class Repository : public PoolMember<Repository>
51 {
52 public:
53 using SolvableIterator = zyppng::FilterIterator<detail::ByRepository, sat::detail::SolvableIterator>;
54 using SolvableIterable = zypp::Iterable<SolvableIterator>;
55 using size_type = unsigned int;
56 using IdType = detail::RepoIdType;
57
58 //using Keywords = sat::ArrayAttr<std::string, std::string>;
59
60 using ContentRevision = std::string;
61 using ContentIdentifier = std::string;
62
63 public:
65 Repository()
66 : _id( detail::noRepoId ) {}
67
68 Repository(const Repository &) = default;
69 Repository(Repository &&) noexcept = default;
70 Repository &operator=(const Repository &) = default;
71 Repository &operator=(Repository &&) noexcept = default;
72
74 explicit Repository( IdType id_r )
75 : _id( id_r ) {}
76
77 public:
79 static const Repository noRepository;
80
82 explicit operator bool() const
83 { return get() != nullptr; }
84
86 static const std::string & systemRepoAlias();
87
89 bool isSystemRepo() const;
90
91 public:
101 std::string alias() const;
102
104 //std::string name() const;
105
107 //std::string label() const;
108
110 //std::string asUserString() const
111 //{ return label(); }
112
113 public:
117 ContentRevision contentRevision() const;
118
130 ContentIdentifier contentIdentifier() const;
131
133 bool hasContentIdentifier( const ContentIdentifier & id_r ) const;
134
151 zypp::Date generatedTimestamp() const;
152
169 zypp::Date suggestedExpirationTimestamp() const;
170
174 //Keywords keywords() const;
175
177 //bool hasKeyword( const std::string & val_r ) const;
178
187 bool maybeOutdated() const;
188
195 //bool isUpdateRepo() const;
196
203 //bool providesUpdatesFor( const CpeId & cpeid_r ) const;
204
206 bool solvablesEmpty() const;
207
209 size_type solvablesSize() const;
210
212 SolvableIterable solvables() const;
213
214 public:
215
217 //class ProductInfoIterator;
218
226 //ProductInfoIterator compatibleWithProductBegin() const;
227
233 //ProductInfoIterator compatibleWithProductEnd() const;
234
236 //Iterable<ProductInfoIterator> compatibleWithProduct() const;
237
238
247 //ProductInfoIterator updatesProductBegin() const;
248
254 //ProductInfoIterator updatesProductEnd() const;
255
257 //Iterable<ProductInfoIterator> updatesProduct() const;
258
259 public:
261 //RepoInfo info() const;
262
268 //void setInfo( const RepoInfo & info_r );
269
271 //void clearInfo();
272
273 public:
275 void eraseFromPool();
276
278 struct EraseFromPool;
279
280 public:
282 Repository nextInPool() const;
283
284 public:
290
296 void addSolv( const zypp::Pathname & file_r );
297
305 void addHelix( const zypp::Pathname & file_r );
306
314 void addTesttags(const zypp::Pathname &file_r);
315
317 sat::Solvable::IdType addSolvables( unsigned count_r );
319 sat::Solvable::IdType addSolvable()
320 { return addSolvables( 1 ); }
321
322
323 public:
325 detail::CRepo * get() const;
327 IdType id() const { return _id; }
336 int satInternalPriority() const;
337 int satInternalSubPriority() const;
339
340 private:
342 SolvableIterator solvablesBegin() const;
343
345 SolvableIterator solvablesEnd() const;
346
347 private:
348 IdType _id;
349 };
350
351
352 //std::ostream & operator<<( std::ostream & str, const Repository & obj );
353
354 //std::ostream & dumpAsXmlOn( std::ostream & str, const Repository & obj );
355
357 inline bool operator==( const Repository & lhs, const Repository & rhs )
358 { return lhs.get() == rhs.get(); }
359
361 inline bool operator!=( const Repository & lhs, const Repository & rhs )
362 { return !( lhs == rhs ); }
363
365 inline bool operator<( const Repository & lhs, const Repository & rhs )
366 { return lhs.get() < rhs.get(); }
367
369
388 /*
389 class Repository::ProductInfoIterator : public boost::iterator_adaptor<
390 Repository::ProductInfoIterator // Derived
391 , sat::LookupAttr::iterator // Base
392 , int // Value
393 , boost::forward_traversal_tag // CategoryOrTraversal
394 , int // Reference
395 >
396 {
397 public:
398 ProductInfoIterator()
399 {}
400
401 // Product label
402 std::string label() const;
403
404 // The Common Platform Enumeration name for this product.
405 CpeId cpeId() const;
406
407 private:
408 friend class Repository;
409 // Hide ctor as just a limited set of attributes is valid.
410 explicit ProductInfoIterator( sat::SolvAttr attr_r, Repository repo_r );
411
412 private:
413 friend class boost::iterator_core_access;
414 int dereference() const { return 0; }
415 };
416 */
418
420 /*
421 inline Iterable<Repository::ProductInfoIterator> Repository::compatibleWithProduct() const
422 { return makeIterable( compatibleWithProductBegin(), compatibleWithProductEnd() ); }
423 */
424
426 /*
427 inline Iterable<Repository::ProductInfoIterator> Repository::updatesProduct() const
428 { return makeIterable( updatesProductBegin(), updatesProductEnd() ); }
429 */
430
432 //
433 // CLASS NAME : Repository::EraseFromPool
434 //
461 struct Repository::EraseFromPool
462 {
463 void operator()( Repository repository_r ) const
464 { repository_r.eraseFromPool(); }
465 };
466
467
469 namespace detail
470 {
474
475 class RepositoryIterator
476 {
477 public:
478 using iterator_category = std::forward_iterator_tag;
479 using value_type = Repository;
480 using difference_type = std::ptrdiff_t;
481 using pointer = void;
482 using reference = Repository;
483
484 RepositoryIterator()
485 : _base( nullptr )
486 {}
487
488 explicit RepositoryIterator( sat::detail::CRepo ** p )
489 : _base( p )
490 {}
491
492 reference operator*() const
493 { return Repository( *_base ); }
494
495 RepositoryIterator & operator++()
496 { increment(); return *this; }
497
498 RepositoryIterator operator++(int)
499 { RepositoryIterator tmp = *this; increment(); return tmp; }
500
501 bool operator==( const RepositoryIterator & rhs ) const
502 { return _base == rhs._base; }
503
504 bool operator!=( const RepositoryIterator & rhs ) const
505 { return !(*this == rhs); }
506
507 sat::detail::CRepo ** const & base() const
508 { return _base; }
509
510 private:
511 void increment();
512
513 sat::detail::CRepo ** _base;
514 };
515
518 //
519 // CLASS NAME : ByRepository
520 //
522 struct ByRepository
523 {
524 public:
525 ByRepository( const Repository & repository_r ) : _repository( repository_r ) {}
526 ByRepository( sat::detail::RepoIdType id_r ) : _repository( id_r ) {}
527 ByRepository() : _repository( detail::noRepoId ) {}
528
529 bool operator()( const sat::Solvable & slv_r ) const
530 { return slv_r.repository() == _repository.id(); }
531
532 private:
533 Repository _repository;
534 };
535
537 } // namespace detail
539
540 inline zypp::Iterable<Repository::SolvableIterator> Repository::solvables() const
541 { return zypp::makeIterable( solvablesBegin(), solvablesEnd() ); }
542
543 } // namespace sat
544} // namespace zyppng
546
547// Late include as sat::ArrayAttr requires Repository.h
548//#include <zypp/sat/LookupAttrTools.h>
549
550#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::FilterIterator
A simple forward iterator that filters a base range according to a predicate.
Definition iterators.h:39
zyppng::sat::PoolMember
Definition poolmember.h:28
zyppng::sat::Repository
Definition repository.h:51
zyppng::sat::Repository::satInternalSubPriority
int satInternalSubPriority() const
Definition repository.cc:89
zyppng::sat::Repository::addSolv
void addSolv(const zypp::Pathname &file_r)
Load Solvables from a solv-file.
Definition repository.cc:214
zyppng::sat::Repository::eraseFromPool
void eraseFromPool()
Query class for Repository related products.
Definition repository.cc:190
zyppng::sat::Repository::Repository
Repository()
Default ctor creates noRepository.
Definition repository.h:65
zyppng::sat::Repository::addHelix
void addHelix(const zypp::Pathname &file_r)
Load Solvables from a helix-file.
Definition repository.cc:233
zyppng::sat::Repository::isSystemRepo
bool isSystemRepo() const
Return whether this is the system repository.
Definition repository.cc:69
zyppng::sat::Repository::noRepository
static const Repository noRepository
Represents no Repository.
Definition repository.h:79
zyppng::sat::Repository::addTesttags
void addTesttags(const zypp::Pathname &file_r)
Load Solvables from a libsolv testtags-file.
Definition repository.cc:257
zyppng::sat::Repository::hasContentIdentifier
bool hasContentIdentifier(const ContentIdentifier &id_r) const
Whether id_r matches this repos content identifier.
Definition repository.cc:109
zyppng::sat::Repository::alias
std::string alias() const
Short unique string to identify a repo.
Definition repository.cc:75
zyppng::sat::Repository::_id
IdType _id
Definition repository.h:348
zyppng::sat::Repository::addSolvables
sat::Solvable::IdType addSolvables(unsigned count_r)
Add count_r new empty Solvable to this Repository.
Definition repository.cc:281
zyppng::sat::Repository::id
IdType id() const
Expert backdoor.
Definition repository.h:327
zyppng::sat::Repository::generatedTimestamp
zypp::Date generatedTimestamp() const
Timestamp when this repository was generated.
Definition repository.cc:119
zyppng::sat::Repository::Repository
Repository(const Repository &)=default
zyppng::sat::Repository::contentRevision
ContentRevision contentRevision() const
Label to display for this repo.
Definition repository.cc:95
zyppng::sat::Repository::ContentRevision
std::string ContentRevision
Definition repository.h:60
zyppng::sat::Repository::contentIdentifier
ContentIdentifier contentIdentifier() const
Unique string identifying a repositories content.
Definition repository.cc:102
zyppng::sat::Repository::satInternalPriority
int satInternalPriority() const
libsolv internal priorities.
Definition repository.cc:83
zyppng::sat::Repository::maybeOutdated
bool maybeOutdated() const
repository keywords (tags)
Definition repository.cc:142
zyppng::sat::Repository::solvables
SolvableIterable solvables() const
Iterate the repositories Solvables.
Definition repository.h:540
zyppng::sat::Repository::solvablesEmpty
bool solvablesEmpty() const
Hint whether the Repo may provide updates for a product.
Definition repository.cc:158
zyppng::sat::Repository::solvablesEnd
SolvableIterator solvablesEnd() const
Iterator behind the last Solvable.
Definition repository.cc:180
zyppng::sat::Repository::addSolvable
sat::Solvable::IdType addSolvable()
Definition repository.h:319
zyppng::sat::Repository::solvablesSize
size_type solvablesSize() const
Number of solvables in Repository.
Definition repository.cc:164
zyppng::sat::Repository::solvablesBegin
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
Definition repository.cc:170
zyppng::sat::Repository::SolvableIterator
zyppng::FilterIterator< detail::ByRepository, sat::detail::SolvableIterator > SolvableIterator
Definition repository.h:53
zyppng::sat::Repository::get
detail::CRepo * get() const
Expert backdoor.
Definition repository.cc:58
zyppng::sat::Repository::IdType
detail::RepoIdType IdType
Definition repository.h:56
zyppng::sat::Repository::ContentIdentifier
std::string ContentIdentifier
Definition repository.h:61
zyppng::sat::Repository::Repository
Repository(Repository &&) noexcept=default
zyppng::sat::Repository::size_type
unsigned int size_type
Definition repository.h:55
zyppng::sat::Repository::SolvableIterable
zypp::Iterable< SolvableIterator > SolvableIterable
Definition repository.h:54
zyppng::sat::Repository::systemRepoAlias
static const std::string & systemRepoAlias()
Reserved system repository alias @System .
Definition repository.cc:53
zyppng::sat::Repository::nextInPool
Repository nextInPool() const
Return next Repository in Pool (or noRepository).
Definition repository.cc:198
zyppng::sat::Repository::suggestedExpirationTimestamp
zypp::Date suggestedExpirationTimestamp() const
Suggested expiration timestamp.
Definition repository.cc:127
zyppng::sat::Solvable
A Solvable object within the sat Pool.
Definition solvable.h:66
zyppng::sat::Solvable::IdType
detail::SolvableIdType IdType
Definition solvable.h:68
zyppng::sat::Solvable::repository
detail::RepoIdType repository() const
The repo id this Solvable belongs to.
Definition solvable.cc:273
zyppng::sat::detail::RepositoryIterator::value_type
Repository value_type
Definition repository.h:479
zyppng::sat::detail::RepositoryIterator::pointer
void pointer
Definition repository.h:481
zyppng::sat::detail::RepositoryIterator::operator++
RepositoryIterator operator++(int)
Definition repository.h:498
zyppng::sat::detail::RepositoryIterator::RepositoryIterator
RepositoryIterator()
Definition repository.h:484
zyppng::sat::detail::RepositoryIterator::_base
sat::detail::CRepo ** _base
Definition repository.h:513
zyppng::sat::detail::RepositoryIterator::base
sat::detail::CRepo **const & base() const
Definition repository.h:507
zyppng::sat::detail::RepositoryIterator::operator*
reference operator*() const
Definition repository.h:492
zyppng::sat::detail::RepositoryIterator::operator!=
bool operator!=(const RepositoryIterator &rhs) const
Definition repository.h:504
zyppng::sat::detail::RepositoryIterator::reference
Repository reference
Definition repository.h:482
zyppng::sat::detail::RepositoryIterator::increment
void increment()
Definition repository.cc:289
zyppng::sat::detail::RepositoryIterator::operator++
RepositoryIterator & operator++()
Definition repository.h:495
zyppng::sat::detail::RepositoryIterator::iterator_category
std::forward_iterator_tag iterator_category
Definition repository.h:478
zyppng::sat::detail::RepositoryIterator::difference_type
std::ptrdiff_t difference_type
Definition repository.h:480
zyppng::sat::detail::RepositoryIterator::operator==
bool operator==(const RepositoryIterator &rhs) const
Definition repository.h:501
zyppng::sat::detail::RepositoryIterator::RepositoryIterator
RepositoryIterator(sat::detail::CRepo **p)
Definition repository.h:488
cpeid.h
iterators.h
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::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::sat::operator==
bool operator==(const Capability &lhs, const Capability &rhs)
relates: Capability
Definition capability.h:311
zyppng::sat::operator!=
bool operator!=(const Capability &lhs, const Capability &rhs)
relates: Capability
Definition capability.h:315
zyppng::sat::operator<
bool operator<(const Capability &lhs, const Capability &rhs)
relates: Capability Arbitrary order.
Definition capability.h:319
zyppng
Definition MediaNetworkRequestExecutor.h:16
poolconstants.h
poolmember.h
solvable.h
zyppng::sat::Repository::EraseFromPool
Query class for Repository related products.
Definition repository.h:462
zyppng::sat::Repository::EraseFromPool::operator()
void operator()(Repository repository_r) const
Definition repository.h:463
zyppng::sat::detail::ByRepository
Functor filtering Solvable by Repository.
Definition repository.h:523
zyppng::sat::detail::ByRepository::ByRepository
ByRepository(const Repository &repository_r)
Definition repository.h:525
zyppng::sat::detail::ByRepository::ByRepository
ByRepository()
Definition repository.h:527
zyppng::sat::detail::ByRepository::_repository
Repository _repository
Definition repository.h:533
zyppng::sat::detail::ByRepository::ByRepository
ByRepository(sat::detail::RepoIdType id_r)
Definition repository.h:526
zyppng::sat::detail::ByRepository::operator()
bool operator()(const sat::Solvable &slv_r) const
Definition repository.h:529