libzypp  17.32.5
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 
26 namespace zypp
27 {
28 
29  namespace detail
30  {
31  struct ByRepository;
32  }
33 
35  //
36  // CLASS NAME : Repository
37  //
40  {
41  public:
42  using SolvableIterator = filter_iterator<detail::ByRepository, sat::detail::SolvableIterator>;
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:
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:
106 
119 
121  bool hasContentIdentifier( const ContentIdentifier & id_r ) const;
122 
139  Date generatedTimestamp() const;
140 
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 
201 
204 
207 
208  public:
209 
211  class ProductInfoIterator;
212 
220  ProductInfoIterator compatibleWithProductBegin() const;
221 
227  ProductInfoIterator compatibleWithProductEnd() const;
228 
231 
232 
241  ProductInfoIterator updatesProductBegin() const;
242 
248  ProductInfoIterator updatesProductEnd() const;
249 
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:
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 );
314  { return addSolvables( 1 ); }
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  };
337 
339  std::ostream & operator<<( std::ostream & str, const Repository & obj );
340 
342  std::ostream & dumpAsXmlOn( std::ostream & str, const Repository & obj );
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:
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:
401  int dereference() const { return 0; }
402  };
404 
407  { return makeIterable( compatibleWithProductBegin(), compatibleWithProductEnd() ); }
408 
411  { return makeIterable( updatesProductBegin(), updatesProductEnd() ); }
412 
414  //
415  // CLASS NAME : Repository::EraseFromPool
416  //
444  {
445  void operator()( Repository repository_r ) const
446  { repository_r.eraseFromPool(); }
447  };
449 
451  namespace detail
452  {
453  //
455  // CLASS NAME : RepositoryIterator
456  //
458  class 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:
477 
479  { return Repository( *base() ); }
480 
481  void increment();
482  };
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  };
504  } // namespace detail
506 
508  { return makeIterable( solvablesBegin(), solvablesEnd() ); }
509 
511 } // namespace zypp
513 
514 // Late include as sat::ArrayAttr requires Repository.h
516 
517 #endif // ZYPP_SAT_REPOSITORY_H
int satInternalSubPriority() const
Definition: Repository.cc:80
RepositoryIterator(sat::detail::CRepo **p)
Definition: Repository.h:471
ContentIdentifier contentIdentifier() const
Unique string identifying a repositories content.
Definition: Repository.cc:93
Functor filtering Solvable by Repository.
Definition: Repository.h:489
bool isUpdateRepo() const
Hint whether the Repo may provide updates for a product.
Definition: Repository.cc:195
A Solvable object within the sat Pool.
Definition: Solvable.h:53
Date suggestedExpirationTimestamp() const
Suggested expiration timestamp.
Definition: Repository.cc:117
bool isSystemRepo() const
Return whether this is the system repository.
Definition: Repository.cc:54
sat::Solvable::IdType addSolvable()
Definition: Repository.h:313
void addSolv(const Pathname &file_r)
Load Solvables from a solv-file.
Definition: Repository.cc:321
bool operator<(const Repository &lhs, const Repository &rhs)
Definition: Repository.h:353
bool providesUpdatesFor(const CpeId &cpeid_r) const
Hint whether the Repo may provide updates for a product identified by its CpeId.
Definition: Repository.cc:161
ProductInfoIterator compatibleWithProductBegin() const
Get an iterator to the beginning of the repository compatible distros.
Definition: Repository.cc:252
::s_Repo CRepo
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:63
void operator()(Repository repository_r) const
Definition: Repository.h:445
sat::Solvable::IdType addSolvables(unsigned count_r)
Add count_r new empty Solvable to this Repository.
Definition: Repository.cc:384
std::string name() const
Label to display for this repo.
Definition: Repository.cc:68
bool operator!=(const Repository &lhs, const Repository &rhs)
Definition: Repository.h:349
static const RepoIdType noRepoId(0)
Id to denote Repo::noRepository.
std::string ContentRevision
Definition: Repository.h:48
void clearInfo()
Remove any RepoInfo set for this repository.
Definition: Repository.cc:292
ProductInfoIterator compatibleWithProductEnd() const
Get an iterator to the end of the repository compatible distros.
Definition: Repository.cc:258
String related utilities and Regular expression matching.
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
Definition: SerialNumber.cc:52
What is known about a repository.
Definition: RepoInfo.h:71
Common Platform Enumearation (2.3) See http://cpe.mitre.org/ for more information on the Common Platf...
Definition: CpeId.h:31
Repository()
Default ctor creates noRepository.
Definition: Repository.h:53
LookupAttr::TransformIterator based container to retrieve list attributes.
Definition: LookupAttr.h:598
bool maybeOutdated() const
The suggested expiration date of this repository already passed.
Definition: Repository.cc:145
std::string label() const
Product label.
Definition: Repository.cc:440
filter_iterator< detail::ByRepository, sat::detail::SolvableIterator > SolvableIterator
Definition: Repository.h:42
Iterable< SolvableIterator > solvables() const
Iterate the repositories Solvables.
Definition: Repository.h:507
ByRepository(const Repository &repository_r)
Definition: Repository.h:492
sat::detail::size_type size_type
Definition: Repository.h:43
void addTesttags(const Pathname &file_r)
Load Solvables from a libsolv testtags-file.
Definition: Repository.cc:362
CpeId cpeId() const
The Common Platform Enumeration name for this product.
Definition: Repository.cc:443
Repository repository() const
The Repository this Solvable belongs to.
Definition: Solvable.cc:364
Functor removing Repository from its Pool.
Definition: Repository.h:443
Store and operate on date (time_t).
Definition: Date.h:32
SolvableIterator solvablesEnd() const
Iterator behind the last Solvable.
Definition: Repository.cc:242
std::ostream & dumpAsXmlOn(std::ostream &str, const Repository &obj)
Definition: Repository.cc:407
Solvable attribute keys.
Definition: SolvAttr.h:40
Backlink to the associated PoolImpl.
Definition: PoolMember.h:88
sat::detail::CRepo * get() const
Expert backdoor.
Definition: Repository.cc:43
void setInfo(const RepoInfo &info_r)
Set RepoInfo for this repository.
Definition: Repository.cc:280
friend class boost::iterator_core_access
Definition: Repository.h:400
Iterable< ProductInfoIterator > updatesProduct() const
Iterate distos the repository provides upadates for.
Definition: Repository.h:410
RepoInfo info() const
Return any associated RepoInfo.
Definition: Repository.cc:274
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
Definition: Repository.cc:232
Keywords keywords() const
repository keywords (tags)
Definition: Repository.cc:131
bool hasKeyword(const std::string &val_r) const
Whether val_r is present in keywords.
Definition: Repository.cc:137
Query class for Repository related products.
Definition: Repository.h:376
Iterable< ProductInfoIterator > compatibleWithProduct() const
Iterate the repository compatible distros.
Definition: Repository.h:406
bool operator()(const sat::Solvable &slv_r) const
Definition: Repository.h:496
std::string ContentIdentifier
Definition: Repository.h:49
Date generatedTimestamp() const
Timestamp when this repository was generated.
Definition: Repository.cc:110
sat::detail::RepoIdType IdType
Definition: Repository.h:44
int satInternalPriority() const
libsolv internal priorities.
Definition: Repository.cc:74
bool operator==(const Repository &lhs, const Repository &rhs)
Definition: Repository.h:345
ProductInfoIterator updatesProductBegin() const
Get an iterator to the beginning of distos the repository provides upadates for.
Definition: Repository.cc:263
std::string asUserString() const
User string: label (alias or name)
Definition: Repository.h:98
ByRepository(sat::detail::RepoIdType id_r)
Definition: Repository.h:493
bool hasContentIdentifier(const ContentIdentifier &id_r) const
Whether id_r matches this repos content identifier.
Definition: Repository.cc:100
sat::ArrayAttr< std::string, std::string > Keywords
Definition: Repository.h:46
Repository nextInPool() const
Return next Repository in Pool (or noRepository).
Definition: Repository.cc:306
void addHelix(const Pathname &file_r)
Load Solvables from a helix-file.
Definition: Repository.cc:340
CRepo * RepoIdType
Id type to connect Repo and sat-repo.
Definition: PoolMember.h:133
std::string alias() const
Short unique string to identify a repo.
Definition: Repository.cc:60
ContentRevision contentRevision() const
Timestamp or arbitrary user supplied string.
Definition: Repository.cc:86
static const Repository noRepository
Represents no Repository.
Definition: Repository.h:67
ProductInfoIterator updatesProductEnd() const
Get an iterator to the end of distos the repository provides upadates for.
Definition: Repository.cc:269
sat::detail::SolvableIdType IdType
Definition: Solvable.h:56
void eraseFromPool()
Remove this Repository from its Pool.
Definition: Repository.cc:298
friend class boost::iterator_core_access
Definition: Repository.h:476
Repository dereference() const
Definition: Repository.h:478
bool solvablesEmpty() const
Whether Repository contains solvables.
Definition: Repository.cc:220
static const std::string & systemRepoAlias()
Reserved system repository alias .
Definition: Repository.cc:38
size_type solvablesSize() const
Number of solvables in Repository.
Definition: Repository.cc:226
IdType id() const
Expert backdoor.
Definition: Repository.h:321
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
SolvableIdType size_type
Definition: PoolMember.h:126
std::string label() const
Alias or name, according to ZConfig::repoLabelIsAlias.
Definition: Repository.cc:71