libzypp  17.38.7
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>
18 #include <zypp-core/Pathname.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>
27 
29 namespace 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:
55  using size_type = unsigned int;
57 
58  //using Keywords = sat::ArrayAttr<std::string, std::string>;
59 
60  using ContentRevision = std::string;
61  using ContentIdentifier = std::string;
62 
63  public:
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:
118 
131 
133  bool hasContentIdentifier( const ContentIdentifier & id_r ) const;
134 
152 
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:
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 );
320  { return addSolvables( 1 ); }
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:
343 
346 
347  private:
349  };
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  //
462  {
463  void operator()( Repository repository_r ) const
464  { repository_r.eraseFromPool(); }
465  };
467 
469  namespace detail
470  {
476  {
477  public:
478  using iterator_category = std::forward_iterator_tag;
480  using difference_type = std::ptrdiff_t;
481  using pointer = void;
483 
485  : _base( nullptr )
486  {}
487 
489  : _base( p )
490  {}
491 
493  { return Repository( *_base ); }
494 
496  { increment(); return *this; }
497 
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 
514  };
515 
518  //
519  // CLASS NAME : ByRepository
520  //
523  {
524  public:
525  ByRepository( const Repository & repository_r ) : _repository( repository_r ) {}
528 
529  bool operator()( const sat::Solvable & slv_r ) const
530  { return slv_r.repository() == _repository.id(); }
531 
532  private:
534  };
537  } // namespace detail
539 
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
A Solvable object within the sat Pool.
Definition: solvable.h:64
std::string alias() const
Short unique string to identify a repo.
Definition: repository.cc:74
bool operator!=(const RepositoryIterator &rhs) const
Definition: repository.h:504
RepositoryIterator operator++(int)
Definition: repository.h:498
ContentIdentifier contentIdentifier() const
Unique string identifying a repositories content.
Definition: repository.cc:101
bool operator==(const Capability &lhs, const Capability &rhs)
relates: Capability
Definition: capability.h:311
Pool & poolFromType(T &)
Repository nextInPool() const
Return next Repository in Pool (or noRepository).
Definition: repository.cc:199
detail::RepoIdType IdType
Definition: repository.h:56
Iterable< TIterator > makeIterable(TIterator &&begin_r, TIterator &&end_r)
relates: Iterable convenient construction.
Definition: Iterable.h:88
bool solvablesEmpty() const
Hint whether the Repo may provide updates for a product.
Definition: repository.cc:159
A simple forward iterator that filters a base range according to a predicate.
Definition: iterators.h:39
static const RepoIdType noRepoId(0)
Id to denote Repo::noRepository.
SolvableIterable solvables() const
Iterate the repositories Solvables.
Definition: repository.h:540
void addSolv(const zypp::Pathname &file_r)
Load Solvables from a solv-file.
Definition: repository.cc:215
std::string ContentRevision
Definition: repository.h:60
void addHelix(const zypp::Pathname &file_r)
Load Solvables from a helix-file.
Definition: repository.cc:234
static const std::string & systemRepoAlias()
Reserved system repository alias .
Definition: repository.cc:52
void operator()(Repository repository_r) const
Definition: repository.h:463
bool operator==(const RepositoryIterator &rhs) const
Definition: repository.h:501
zypp::Iterable< SolvableIterator > SolvableIterable
Definition: repository.h:54
RepositoryIterator & operator++()
Definition: repository.h:495
Store and operate on date (time_t).
Definition: Date.h:32
int satInternalPriority() const
libsolv internal priorities.
Definition: repository.cc:82
detail::CRepo * get() const
Expert backdoor.
Definition: repository.cc:57
Query class for Repository related products.
Definition: repository.h:461
static const Repository noRepository
Represents no Repository.
Definition: repository.h:79
void addTesttags(const zypp::Pathname &file_r)
Load Solvables from a libsolv testtags-file.
Definition: repository.cc:258
SolvableIterator solvablesEnd() const
Iterator behind the last Solvable.
Definition: repository.cc:181
sat::Solvable::IdType addSolvable()
Definition: repository.h:319
ByRepository(sat::detail::RepoIdType id_r)
Definition: repository.h:526
Repository()
Default ctor creates noRepository.
Definition: repository.h:65
bool operator!=(const Capability &lhs, const Capability &rhs)
relates: Capability
Definition: capability.h:315
void eraseFromPool()
Query class for Repository related products.
Definition: repository.cc:191
ByRepository(const Repository &repository_r)
Definition: repository.h:525
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
Definition: repository.cc:171
zypp::sat::detail::CRepo CRepo
Definition: poolconstants.h:38
ContentRevision contentRevision() const
Label to display for this repo.
Definition: repository.cc:94
zypp::Date suggestedExpirationTimestamp() const
Suggested expiration timestamp.
Definition: repository.cc:128
RepositoryIterator(sat::detail::CRepo **p)
Definition: repository.h:488
unsigned int size_type
Definition: repository.h:55
detail::RepoIdType repository() const
The repo id this Solvable belongs to.
Definition: solvable.cc:273
int satInternalSubPriority() const
Definition: repository.cc:88
IdType id() const
Expert backdoor.
Definition: repository.h:327
detail::SolvableIdType IdType
Definition: solvable.h:67
zypp::Date generatedTimestamp() const
Timestamp when this repository was generated.
Definition: repository.cc:120
size_type solvablesSize() const
Number of solvables in Repository.
Definition: repository.cc:165
sat::Solvable::IdType addSolvables(unsigned count_r)
Add count_r new empty Solvable to this Repository.
Definition: repository.cc:282
bool operator()(const sat::Solvable &slv_r) const
Definition: repository.h:529
zyppng::FilterIterator< detail::ByRepository, sat::detail::SolvableIterator > SolvableIterator
Definition: repository.h:53
bool operator<(const Capability &lhs, const Capability &rhs)
relates: Capability Arbitrary order.
Definition: capability.h:319
bool maybeOutdated() const
repository keywords (tags)
Definition: repository.cc:143
std::string ContentIdentifier
Definition: repository.h:61
sat::detail::CRepo **const & base() const
Definition: repository.h:507
bool isSystemRepo() const
Return whether this is the system repository.
Definition: repository.cc:68
std::forward_iterator_tag iterator_category
Definition: repository.h:478
bool hasContentIdentifier(const ContentIdentifier &id_r) const
Whether id_r matches this repos content identifier.
Definition: repository.cc:108
zypp::sat::detail::RepoIdType RepoIdType
Definition: poolconstants.h:45
Functor filtering Solvable by Repository.
Definition: repository.h:522