libzypp  13.10.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/Pathname.h"
18 #include "zypp/sat/LookupAttr.h" // LookupAttrTools.h included at EOF
19 #include "zypp/sat/Solvable.h"
20 #include "zypp/RepoInfo.h"
21 #include "zypp/Date.h"
22 
24 namespace zypp
25 {
26 
27  namespace detail
28  {
29  struct ByRepository;
30  }
31 
33  //
34  // CLASS NAME : Repository
35  //
38  {
39  public:
40  typedef filter_iterator<detail::ByRepository, sat::detail::SolvableIterator> SolvableIterator;
43 
45 
46  public:
49  : _id( sat::detail::noRepoId ) {}
50 
52  explicit Repository( IdType id_r )
53  : _id( id_r ) {}
54 
55  public:
57  static const Repository noRepository;
58 
60  explicit operator bool() const
61  { return get() != nullptr; }
62 
64  static const std::string & systemRepoAlias();
65 
67  bool isSystemRepo() const;
68 
69  public:
79  std::string alias() const;
80 
82  std::string name() const;
83 
85  std::string asUserString() const
86  { return name(); }
87 
104  Date generatedTimestamp() const;
105 
123 
127  Keywords keywords() const;
128 
137  bool maybeOutdated() const;
138 
147  bool isUpdateRepo() const;
148 
158  bool providesUpdatesFor( const std::string &cpeid ) const;
159 
161  bool solvablesEmpty() const;
162 
164  size_type solvablesSize() const;
165 
168 
171 
172  public:
173 
175  class ProductInfoIterator;
176 
184  ProductInfoIterator compatibleWithProductBegin() const;
185 
191  ProductInfoIterator compatibleWithProductEnd() const;
192 
198  ProductInfoIterator updatesProductBegin() const;
199 
205  ProductInfoIterator updatesProductEnd() const;
206 
207  public:
209  RepoInfo info() const;
210 
216  void setInfo( const RepoInfo & info_r );
217 
219  void clearInfo();
220 
221  public:
223  void eraseFromPool();
224 
226  struct EraseFromPool;
227 
228  public:
230  Repository nextInPool() const;
231 
232  public:
244  void addSolv( const Pathname & file_r );
245 
253  void addHelix( const Pathname & file_r );
254 
256  sat::Solvable::IdType addSolvables( unsigned count_r );
259  { return addSolvables( 1 ); }
261 
262  public:
264  ::_Repo * get() const;
266  IdType id() const { return _id; }
275  int satInternalPriority() const;
276  int satInternalSubPriority() const;
278 
279  private:
281  };
283 
285  std::ostream & operator<<( std::ostream & str, const Repository & obj );
286 
288  std::ostream & dumpAsXmlOn( std::ostream & str, const Repository & obj );
289 
291  inline bool operator==( const Repository & lhs, const Repository & rhs )
292  { return lhs.get() == rhs.get(); }
293 
295  inline bool operator!=( const Repository & lhs, const Repository & rhs )
296  { return lhs.get() != rhs.get(); }
297 
299  inline bool operator<( const Repository & lhs, const Repository & rhs )
300  { return lhs.get() < rhs.get(); }
301 
303 
319  class Repository::ProductInfoIterator : public boost::iterator_adaptor<
320  Repository::ProductInfoIterator // Derived
321  , sat::LookupAttr::iterator // Base
322  , int // Value
323  , boost::forward_traversal_tag // CategoryOrTraversal
324  , int // Reference
325  >
326  {
327  public:
329  {}
330 
334  std::string label() const;
335 
342  std::string cpeId() const;
343 
344  private:
345  friend class Repository;
347  explicit ProductInfoIterator( sat::SolvAttr attr_r, Repository repo_r );
348 
349  private:
351  int dereference() const { return 0; }
352  };
354 
356  //
357  // CLASS NAME : Repository::EraseFromPool
358  //
386  {
387  void operator()( Repository repository_r ) const
388  { repository_r.eraseFromPool(); }
389  };
391 
393  namespace detail
394  {
395  //
397  // CLASS NAME : RepositoryIterator
398  //
400  class RepositoryIterator : public boost::iterator_adaptor<
401  RepositoryIterator // Derived
402  , ::_Repo ** // Base
403  , Repository // Value
404  , boost::forward_traversal_tag // CategoryOrTraversal
405  , Repository // Reference
406  >
407  {
408  public:
410  : RepositoryIterator::iterator_adaptor_( 0 )
411  {}
412 
413  explicit RepositoryIterator( ::_Repo ** p )
414  : RepositoryIterator::iterator_adaptor_( p )
415  {}
416 
417  private:
419 
421  { return Repository( *base() ); }
422 
423  void increment();
424  };
427  //
428  // CLASS NAME : ByRepository
429  //
432  {
433  public:
434  ByRepository( const Repository & repository_r ) : _repository( repository_r ) {}
437 
438  bool operator()( const sat::Solvable & slv_r ) const
439  { return slv_r.repository() == _repository; }
440 
441  private:
443  };
446  } // namespace detail
449 } // namespace zypp
451 
452 // Late include as sat::ArrayAttr requires Repository.h
454 
455 #endif // ZYPP_SAT_REPOSITORY_H
Repository repository() const
The Repository this Solvable belongs to.
Definition: Solvable.cc:148
RepoInfo info() const
Return any associated RepoInfo.
Definition: Repository.cc:201
Functor filtering Solvable by Repository.
Definition: Repository.h:431
A Solvable object within the sat Pool.
Definition: Solvable.h:55
sat::ArrayAttr< std::string, std::string > Keywords
Definition: Repository.h:44
std::string alias() const
Short unique string to identify a repo.
Definition: Repository.cc:57
std::string name() const
Label to display for this repo.
Definition: Repository.cc:65
sat::Solvable::IdType addSolvable()
Definition: Repository.h:258
void addSolv(const Pathname &file_r)
Load Solvables from a solv-file.
Definition: Repository.cc:248
IdType id() const
Expert backdoor.
Definition: Repository.h:266
bool operator<(const Repository &lhs, const Repository &rhs)
Definition: Repository.h:299
std::string label() const
Product label.
Definition: Repository.cc:345
std::ostream & dumpAsXmlOn(std::ostream &str, const CheckSum &obj)
Definition: CheckSum.cc:157
::_Repo * RepoIdType
Id type to connect Repo and sat-repo.
Definition: PoolMember.h:106
sat::Solvable::IdType addSolvables(unsigned count_r)
Add count_r new empty Solvable to this Repository.
Definition: Repository.cc:289
bool operator!=(const Repository &lhs, const Repository &rhs)
Definition: Repository.h:295
static const RepoIdType noRepoId(0)
Id to denote Repo::noRepository.
void clearInfo()
Remove any RepoInfo set for this repository.
Definition: Repository.cc:219
SolvableIterator solvablesEnd() const
Iterator behind the last Solvable.
Definition: Repository.cc:169
What is known about a repository.
Definition: RepoInfo.h:66
Date generatedTimestamp() const
Timestamp when this repository was generated.
Definition: Repository.cc:81
Repository()
Default ctor creates noRepository.
Definition: Repository.h:48
LookupAttr::transformIterator based container to retrieve list attributes.
Definition: LookupAttr.h:595
int satInternalSubPriority() const
Definition: Repository.cc:74
bool isSystemRepo() const
Return whether this is the system repository.
Definition: Repository.cc:51
bool providesUpdatesFor(const std::string &cpeid) const
whether the repository claims to update something prod with key cpeid
Definition: Repository.cc:124
ByRepository(const Repository &repository_r)
Definition: Repository.h:434
filter_iterator< detail::ByRepository, sat::detail::SolvableIterator > SolvableIterator
Definition: Repository.h:40
bool isUpdateRepo() const
if the repository claims to update something then it is an update repository
Definition: Repository.cc:141
sat::detail::size_type size_type
Definition: Repository.h:41
Repository nextInPool() const
Return next Repository in Pool (or noRepository).
Definition: Repository.cc:233
std::string asUserString() const
User string.
Definition: Repository.h:85
Functor removing Repository from it&#39;s Pool.
Definition: Repository.h:385
Store and operate on date (time_t).
Definition: Date.h:31
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
Definition: Repository.cc:159
Solvable attribute keys.
Definition: SolvAttr.h:40
Backlink to the associated PoolImpl.
Definition: PoolMember.h:66
bool operator()(const sat::Solvable &slv_r) const
Definition: Repository.h:438
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:207
Date suggestedExpirationTimestamp() const
Suggested expiration timestamp.
Definition: Repository.cc:88
void operator()(Repository repository_r) const
Definition: Repository.h:387
friend class boost::iterator_core_access
Definition: Repository.h:350
Repository(IdType id_r)
PoolImpl ctor.
Definition: Repository.h:52
Query class for Repository related products.
Definition: Repository.h:319
Keywords keywords() const
repository keywords (tags)
Definition: Repository.cc:102
bool operator==(const Repository &lhs, const Repository &rhs)
Definition: Repository.h:291
::_Repo * get() const
Expert backdoor.
Definition: Repository.cc:40
bool solvablesEmpty() const
Whether Repository contains solvables.
Definition: Repository.cc:147
ByRepository(sat::detail::RepoIdType id_r)
Definition: Repository.h:435
std::string cpeId() const
The Common Platform Enumeration name for this product.
Definition: Repository.cc:348
SolvableIdType size_type
Definition: PoolMember.h:99
size_type solvablesSize() const
Number of solvables in Repository.
Definition: Repository.cc:153
void addHelix(const Pathname &file_r)
Load Solvables from a helix-file.
Definition: Repository.cc:267
Repository dereference() const
Definition: Repository.h:420
static const Repository noRepository
Represents no Repository.
Definition: Repository.h:57
int satInternalPriority() const
libsolv internal priorities.
Definition: Repository.cc:68
void eraseFromPool()
Remove this Repository from it&#39;s Pool.
Definition: Repository.cc:225
friend class boost::iterator_core_access
Definition: Repository.h:418
ProductInfoIterator updatesProductEnd() const
Get an iterator to the end of the repository compatible distros.
Definition: Repository.cc:196
sat::detail::RepoIdType IdType
Definition: Repository.h:42
static const std::string & systemRepoAlias()
Reserved system repository alias .
Definition: Repository.cc:35
sat::detail::SolvableIdType IdType
Definition: Solvable.h:58
ProductInfoIterator compatibleWithProductEnd() const
Get an iterator to the end of the repository compatible distros.
Definition: Repository.cc:185
ProductInfoIterator updatesProductBegin() const
Get an iterator to the beginning of the repository compatible distros.
Definition: Repository.cc:190
bool maybeOutdated() const
The suggested expiration date of this repository already passed.
Definition: Repository.cc:108
ProductInfoIterator compatibleWithProductBegin() const
Get an iterator to the beginning of the repository compatible distros.
Definition: Repository.cc:179