libzypp  15.28.6
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  typedef filter_iterator<detail::ByRepository, sat::detail::SolvableIterator> SolvableIterator;
45 
47 
48  typedef std::string ContentRevision;
49  typedef std::string ContentIdentifier;
50 
51  public:
54  : _id( sat::detail::noRepoId ) {}
55 
57  explicit Repository( IdType id_r )
58  : _id( id_r ) {}
59 
60  public:
62  static const Repository noRepository;
63 
65  explicit operator bool() const
66  { return get() != nullptr; }
67 
69  static const std::string & systemRepoAlias();
70 
72  bool isSystemRepo() const;
73 
74  public:
84  std::string alias() const;
85 
87  std::string name() const;
88 
90  std::string label() const;
91 
93  std::string asUserString() const
94  { return label(); }
95 
96  public:
101 
114 
116  bool hasContentIdentifier( const ContentIdentifier & id_r ) const;
117 
134  Date generatedTimestamp() const;
135 
153 
157  Keywords keywords() const;
158 
160  bool hasKeyword( const std::string & val_r ) const;
161 
170  bool maybeOutdated() const;
171 
178  bool isUpdateRepo() const;
179 
186  bool providesUpdatesFor( const CpeId & cpeid_r ) const;
187 
189  bool solvablesEmpty() const;
190 
192  size_type solvablesSize() const;
193 
196 
199 
202 
203  public:
204 
206  class ProductInfoIterator;
207 
215  ProductInfoIterator compatibleWithProductBegin() const;
216 
222  ProductInfoIterator compatibleWithProductEnd() const;
223 
226 
227 
236  ProductInfoIterator updatesProductBegin() const;
237 
243  ProductInfoIterator updatesProductEnd() const;
244 
247 
248  public:
250  RepoInfo info() const;
251 
257  void setInfo( const RepoInfo & info_r );
258 
260  void clearInfo();
261 
262  public:
264  void eraseFromPool();
265 
267  struct EraseFromPool;
268 
269  public:
271  Repository nextInPool() const;
272 
273  public:
285  void addSolv( const Pathname & file_r );
286 
294  void addHelix( const Pathname & file_r );
295 
297  sat::Solvable::IdType addSolvables( unsigned count_r );
300  { return addSolvables( 1 ); }
302 
303  public:
305  sat::detail::CRepo * get() const;
307  IdType id() const { return _id; }
316  int satInternalPriority() const;
317  int satInternalSubPriority() const;
319 
320  private:
322  };
324 
326  std::ostream & operator<<( std::ostream & str, const Repository & obj );
327 
329  std::ostream & dumpAsXmlOn( std::ostream & str, const Repository & obj );
330 
332  inline bool operator==( const Repository & lhs, const Repository & rhs )
333  { return lhs.get() == rhs.get(); }
334 
336  inline bool operator!=( const Repository & lhs, const Repository & rhs )
337  { return lhs.get() != rhs.get(); }
338 
340  inline bool operator<( const Repository & lhs, const Repository & rhs )
341  { return lhs.get() < rhs.get(); }
342 
344 
363  class Repository::ProductInfoIterator : public boost::iterator_adaptor<
364  Repository::ProductInfoIterator // Derived
365  , sat::LookupAttr::iterator // Base
366  , int // Value
367  , boost::forward_traversal_tag // CategoryOrTraversal
368  , int // Reference
369  >
370  {
371  public:
373  {}
374 
376  std::string label() const;
377 
379  CpeId cpeId() const;
380 
381  private:
382  friend class Repository;
384  explicit ProductInfoIterator( sat::SolvAttr attr_r, Repository repo_r );
385 
386  private:
388  int dereference() const { return 0; }
389  };
391 
394  { return makeIterable( compatibleWithProductBegin(), compatibleWithProductEnd() ); }
395 
398  { return makeIterable( updatesProductBegin(), updatesProductEnd() ); }
399 
401  //
402  // CLASS NAME : Repository::EraseFromPool
403  //
431  {
432  void operator()( Repository repository_r ) const
433  { repository_r.eraseFromPool(); }
434  };
436 
438  namespace detail
439  {
440  //
442  // CLASS NAME : RepositoryIterator
443  //
445  class RepositoryIterator : public boost::iterator_adaptor<
446  RepositoryIterator // Derived
447  , sat::detail::CRepo ** // Base
448  , Repository // Value
449  , boost::forward_traversal_tag // CategoryOrTraversal
450  , Repository // Reference
451  >
452  {
453  public:
455  : RepositoryIterator::iterator_adaptor_( 0 )
456  {}
457 
459  : RepositoryIterator::iterator_adaptor_( p )
460  {}
461 
462  private:
464 
466  { return Repository( *base() ); }
467 
468  void increment();
469  };
472  //
473  // CLASS NAME : ByRepository
474  //
477  {
478  public:
479  ByRepository( const Repository & repository_r ) : _repository( repository_r ) {}
482 
483  bool operator()( const sat::Solvable & slv_r ) const
484  { return slv_r.repository() == _repository; }
485 
486  private:
488  };
491  } // namespace detail
493 
495  { return makeIterable( solvablesBegin(), solvablesEnd() ); }
496 
498 } // namespace zypp
500 
501 // Late include as sat::ArrayAttr requires Repository.h
503 
504 #endif // ZYPP_SAT_REPOSITORY_H
Repository repository() const
The Repository this Solvable belongs to.
Definition: Solvable.cc:351
RepoInfo info() const
Return any associated RepoInfo.
Definition: Repository.cc:273
RepositoryIterator(sat::detail::CRepo **p)
Definition: Repository.h:458
Functor filtering Solvable by Repository.
Definition: Repository.h:476
A Solvable object within the sat Pool.
Definition: Solvable.h:53
sat::ArrayAttr< std::string, std::string > Keywords
Definition: Repository.h:46
std::string alias() const
Short unique string to identify a repo.
Definition: Repository.cc:59
std::string name() const
Label to display for this repo.
Definition: Repository.cc:67
sat::Solvable::IdType addSolvable()
Definition: Repository.h:299
void addSolv(const Pathname &file_r)
Load Solvables from a solv-file.
Definition: Repository.cc:320
IdType id() const
Expert backdoor.
Definition: Repository.h:307
bool operator<(const Repository &lhs, const Repository &rhs)
Definition: Repository.h:340
Iterable< SolvableIterator > solvables() const
Iterate the repositories Solvables.
Definition: Repository.h:494
std::string label() const
Product label.
Definition: Repository.cc:417
::_Repo CRepo
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:88
sat::Solvable::IdType addSolvables(unsigned count_r)
Add count_r new empty Solvable to this Repository.
Definition: Repository.cc:361
bool operator!=(const Repository &lhs, const Repository &rhs)
Definition: Repository.h:336
static const RepoIdType noRepoId(0)
Id to denote Repo::noRepository.
void clearInfo()
Remove any RepoInfo set for this repository.
Definition: Repository.cc:291
SolvableIterator solvablesEnd() const
Iterator behind the last Solvable.
Definition: Repository.cc:241
What is known about a repository.
Definition: RepoInfo.h:72
CRepo * RepoIdType
Id type to connect Repo and sat-repo.
Definition: PoolMember.h:159
Date generatedTimestamp() const
Timestamp when this repository was generated.
Definition: Repository.cc:109
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:592
CpeId cpeId() const
The Common Platform Enumeration name for this product.
Definition: Repository.cc:420
int satInternalSubPriority() const
Definition: Repository.cc:79
bool isSystemRepo() const
Return whether this is the system repository.
Definition: Repository.cc:53
ByRepository(const Repository &repository_r)
Definition: Repository.h:479
std::string ContentRevision
Definition: Repository.h:48
Iterable< ProductInfoIterator > compatibleWithProduct() const
Iterate the repository compatible distros.
Definition: Repository.h:393
filter_iterator< detail::ByRepository, sat::detail::SolvableIterator > SolvableIterator
Definition: Repository.h:42
bool isUpdateRepo() const
Hint whether the Repo may provide updates for a product.
Definition: Repository.cc:194
sat::detail::size_type size_type
Definition: Repository.h:43
bool providesUpdatesFor(const CpeId &cpeid_r) const
Hint whether the Repo may provide updates for a product identified by it's CpeId. ...
Definition: Repository.cc:160
Repository nextInPool() const
Return next Repository in Pool (or noRepository).
Definition: Repository.cc:305
std::string asUserString() const
User string: label (alias or name)
Definition: Repository.h:93
ContentIdentifier contentIdentifier() const
Unique string identifying a repositories content.
Definition: Repository.cc:92
Functor removing Repository from it's Pool.
Definition: Repository.h:430
Store and operate on date (time_t).
Definition: Date.h:32
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
Definition: Repository.cc:231
Solvable attribute keys.
Definition: SolvAttr.h:40
Backlink to the associated PoolImpl.
Definition: PoolMember.h:114
sat::detail::CRepo * get() const
Expert backdoor.
Definition: Repository.cc:42
bool operator()(const sat::Solvable &slv_r) const
Definition: Repository.h:483
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:120
void setInfo(const RepoInfo &info_r)
Set RepoInfo for this repository.
Definition: Repository.cc:279
Date suggestedExpirationTimestamp() const
Suggested expiration timestamp.
Definition: Repository.cc:116
void operator()(Repository repository_r) const
Definition: Repository.h:432
friend class boost::iterator_core_access
Definition: Repository.h:387
Repository(IdType id_r)
PoolImpl ctor.
Definition: Repository.h:57
Query class for Repository related products.
Definition: Repository.h:363
ContentRevision contentRevision() const
Timestamp or arbitrary user supplied string.
Definition: Repository.cc:85
bool hasKeyword(const std::string &val_r) const
Whether val_r is present in keywords.
Definition: Repository.cc:136
Iterable< ProductInfoIterator > updatesProduct() const
Iterate distos the repository provides upadates for.
Definition: Repository.h:397
Keywords keywords() const
repository keywords (tags)
Definition: Repository.cc:130
bool operator==(const Repository &lhs, const Repository &rhs)
Definition: Repository.h:332
bool solvablesEmpty() const
Whether Repository contains solvables.
Definition: Repository.cc:219
ByRepository(sat::detail::RepoIdType id_r)
Definition: Repository.h:480
SolvableIdType size_type
Definition: PoolMember.h:152
bool hasContentIdentifier(const ContentIdentifier &id_r) const
Whether id_r matches this repos content identifier.
Definition: Repository.cc:99
std::string label() const
Alias or name, according to ZConfig::repoLabelIsAlias.
Definition: Repository.cc:70
std::string ContentIdentifier
Definition: Repository.h:49
size_type solvablesSize() const
Number of solvables in Repository.
Definition: Repository.cc:225
void addHelix(const Pathname &file_r)
Load Solvables from a helix-file.
Definition: Repository.cc:339
Repository dereference() const
Definition: Repository.h:465
static const Repository noRepository
Represents no Repository.
Definition: Repository.h:62
int satInternalPriority() const
libsolv internal priorities.
Definition: Repository.cc:73
void eraseFromPool()
Remove this Repository from it's Pool.
Definition: Repository.cc:297
friend class boost::iterator_core_access
Definition: Repository.h:463
ProductInfoIterator updatesProductEnd() const
Get an iterator to the end of distos the repository provides upadates for.
Definition: Repository.cc:268
sat::detail::RepoIdType IdType
Definition: Repository.h:44
static const std::string & systemRepoAlias()
Reserved system repository alias .
Definition: Repository.cc:37
sat::detail::SolvableIdType IdType
Definition: Solvable.h:56
ProductInfoIterator compatibleWithProductEnd() const
Get an iterator to the end of the repository compatible distros.
Definition: Repository.cc:257
ProductInfoIterator updatesProductBegin() const
Get an iterator to the beginning of distos the repository provides upadates for.
Definition: Repository.cc:262
std::ostream & dumpAsXmlOn(std::ostream &str, const Tp &obj, const std::string &name_r)
Definition: Xml.h:185
bool maybeOutdated() const
The suggested expiration date of this repository already passed.
Definition: Repository.cc:144
ProductInfoIterator compatibleWithProductBegin() const
Get an iterator to the beginning of the repository compatible distros.
Definition: Repository.cc:251