libzypp  17.34.1
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:
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:
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 ) 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:
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 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:
468  : RepositoryIterator::iterator_adaptor_( 0 )
469  {}
470 
472  : RepositoryIterator::iterator_adaptor_( p )
473  {}
474 
475  private:
476  friend class boost::iterator_core_access;
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
RepositoryIterator(sat::detail::CRepo **p)
Definition: Repository.h:471
Functor filtering Solvable by Repository.
Definition: Repository.h:489
A Solvable object within the sat Pool.
Definition: Solvable.h:53
sat::Solvable::IdType addSolvable()
Definition: Repository.h:313
bool operator<(const Repository &lhs, const Repository &rhs)
Definition: Repository.h:353
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
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
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:32
Repository()
Default ctor creates noRepository.
Definition: Repository.h:53
LookupAttr::TransformIterator based container to retrieve list attributes.
Definition: LookupAttr.h:599
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
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
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition: ResTraits.h:93
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
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
Definition: Repository.cc:232
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
sat::detail::RepoIdType IdType
Definition: Repository.h:44
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
CRepo * RepoIdType
Id type to connect Repo and sat-repo.
Definition: PoolMember.h:133
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
Repository dereference() const
Definition: Repository.h:478
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