libzypp  11.13.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/SafeBool.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 
25 namespace zypp
26 {
27 
28  namespace detail
29  {
30  struct ByRepository;
31  }
32 
34  //
35  // CLASS NAME : Repository
36  //
39  private base::SafeBool<Repository>
40  {
41  public:
42  typedef filter_iterator<detail::ByRepository, sat::detail::SolvableIterator> SolvableIterator;
45 
47 
48  public:
51  : _id( sat::detail::noRepoId ) {}
52 
54  explicit Repository( IdType id_r )
55  : _id( id_r ) {}
56 
57  public:
59  static const Repository noRepository;
60 
61 #ifndef SWIG // Swig treats it as syntax error
62 
64 #endif
65 
66  static const std::string & systemRepoAlias();
67 
69  bool isSystemRepo() const;
70 
71  public:
81  std::string alias() const;
82 
84  std::string name() const;
85 
102  Date generatedTimestamp() const;
103 
121 
125  Keywords keywords() const;
126 
135  bool maybeOutdated() const;
136 
145  bool isUpdateRepo() const;
146 
156  bool providesUpdatesFor( const std::string &cpeid ) const;
157 
159  bool solvablesEmpty() const;
160 
162  size_type solvablesSize() const;
163 
166 
169 
170  public:
171 
173  class ProductInfoIterator;
174 
183 
190 
197 
204 
205  public:
207  RepoInfo info() const;
208 
214  void setInfo( const RepoInfo & info_r );
215 
217  void clearInfo();
218 
219  public:
221  void eraseFromPool();
222 
224  struct EraseFromPool;
225 
226  public:
228  Repository nextInPool() const;
229 
230  public:
242  void addSolv( const Pathname & file_r );
243 
251  void addHelix( const Pathname & file_r );
252 
254  sat::Solvable::IdType addSolvables( unsigned count_r );
257  { return addSolvables( 1 ); }
259 
260  public:
262  ::_Repo * get() const;
264  IdType id() const { return _id; }
273  int satInternalPriority() const;
274  int satInternalSubPriority() const;
276  private:
277 #ifndef SWIG // Swig treats it as syntax error
279 #endif
280  bool boolTest() const { return get(); }
281  private:
283  };
285 
287  std::ostream & operator<<( std::ostream & str, const Repository & obj );
288 
290  inline bool operator==( const Repository & lhs, const Repository & rhs )
291  { return lhs.get() == rhs.get(); }
292 
294  inline bool operator!=( const Repository & lhs, const Repository & rhs )
295  { return lhs.get() != rhs.get(); }
296 
298  inline bool operator<( const Repository & lhs, const Repository & rhs )
299  { return lhs.get() < rhs.get(); }
300 
302 
318  class Repository::ProductInfoIterator : public boost::iterator_adaptor<
319  Repository::ProductInfoIterator // Derived
320  , sat::LookupAttr::iterator // Base
321  , int // Value
322  , boost::forward_traversal_tag // CategoryOrTraversal
323  , int // Reference
324  >
325  {
326  public:
328  {}
329 
333  std::string label() const;
334 
341  std::string cpeId() const;
342 
343  private:
344  friend class Repository;
346  explicit ProductInfoIterator( sat::SolvAttr attr_r, Repository repo_r );
347 
348  private:
350  int dereference() const { return 0; }
351  };
353 
355  //
356  // CLASS NAME : Repository::EraseFromPool
357  //
385  {
386  void operator()( Repository repository_r ) const
387  { repository_r.eraseFromPool(); }
388  };
390 
392  namespace detail
393  {
394 
395  //
396  // CLASS NAME : RepositoryIterator
397  //
399  class RepositoryIterator : public boost::iterator_adaptor<
400  RepositoryIterator // Derived
401  , ::_Repo ** // Base
402  , Repository // Value
403  , boost::forward_traversal_tag // CategoryOrTraversal
404  , Repository // Reference
405  >
406  {
407  public:
409  : RepositoryIterator::iterator_adaptor_( 0 )
410  {}
411 
412  explicit RepositoryIterator( ::_Repo ** p )
413  : RepositoryIterator::iterator_adaptor_( p )
414  {}
415 
416  private:
418 
420  { return Repository( *base() ); }
421 
422  void increment();
423  };
426  //
427  // CLASS NAME : ByRepository
428  //
431  {
432  public:
433  ByRepository( const Repository & repository_r ) : _repository( repository_r ) {}
436 
437  bool operator()( const sat::Solvable & slv_r ) const
438  { return slv_r.repository() == _repository; }
439 
440  private:
442  };
445  } // namespace detail
448 } // namespace zypp
450 
451 // Late include as sat::ArrayAttr requires Repository.h
453 
454 #endif // ZYPP_SAT_REPOSITORY_H