libzypp  15.3.0
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 #include "zypp/CpeId.h"
23 
25 namespace zypp
26 {
27 
28  namespace detail
29  {
30  struct ByRepository;
31  }
32 
34  //
35  // CLASS NAME : Repository
36  //
39  {
40  public:
41  typedef filter_iterator<detail::ByRepository, sat::detail::SolvableIterator> SolvableIterator;
44 
46 
47  typedef std::string ContentRevision;
48  typedef std::string ContentIdentifier;
49 
50  public:
53  : _id( sat::detail::noRepoId ) {}
54 
56  explicit Repository( IdType id_r )
57  : _id( id_r ) {}
58 
59  public:
61  static const Repository noRepository;
62 
64  explicit operator bool() const
65  { return get() != nullptr; }
66 
68  static const std::string & systemRepoAlias();
69 
71  bool isSystemRepo() const;
72 
73  public:
83  std::string alias() const;
84 
86  std::string name() const;
87 
89  std::string label() const;
90 
92  std::string asUserString() const
93  { return label(); }
94 
95  public:
99  ContentRevision contentRevision() const;
100 
112  ContentIdentifier contentIdentifier() const;
113 
115  bool hasContentIdentifier( const ContentIdentifier & id_r ) const;
116 
133  Date generatedTimestamp() const;
134 
151  Date suggestedExpirationTimestamp() const;
152 
156  Keywords keywords() const;
157 
159  bool hasKeyword( const std::string & val_r ) const;
160 
169  bool maybeOutdated() const;
170 
177  bool isUpdateRepo() const;
178 
185  bool providesUpdatesFor( const CpeId & cpeid_r ) const;
186 
188  bool solvablesEmpty() const;
189 
191  size_type solvablesSize() const;
192 
194  SolvableIterator solvablesBegin() const;
195 
197  SolvableIterator solvablesEnd() const;
198 
199  public:
200 
202  class ProductInfoIterator;
203 
211  ProductInfoIterator compatibleWithProductBegin() const;
212 
218  ProductInfoIterator compatibleWithProductEnd() const;
219 
228  ProductInfoIterator updatesProductBegin() const;
229 
235  ProductInfoIterator updatesProductEnd() const;
236 
237  public:
239  RepoInfo info() const;
240 
246  void setInfo( const RepoInfo & info_r );
247 
249  void clearInfo();
250 
251  public:
253  void eraseFromPool();
254 
256  struct EraseFromPool;
257 
258  public:
260  Repository nextInPool() const;
261 
262  public:
274  void addSolv( const Pathname & file_r );
275 
283  void addHelix( const Pathname & file_r );
284 
286  sat::Solvable::IdType addSolvables( unsigned count_r );
289  { return addSolvables( 1 ); }
291 
292  public:
294  ::_Repo * get() const;
296  IdType id() const { return _id; }
305  int satInternalPriority() const;
306  int satInternalSubPriority() const;
308 
309  private:
310  IdType _id;
311  };
313 
315  std::ostream & operator<<( std::ostream & str, const Repository & obj );
316 
318  std::ostream & dumpAsXmlOn( std::ostream & str, const Repository & obj );
319 
321  inline bool operator==( const Repository & lhs, const Repository & rhs )
322  { return lhs.get() == rhs.get(); }
323 
325  inline bool operator!=( const Repository & lhs, const Repository & rhs )
326  { return lhs.get() != rhs.get(); }
327 
329  inline bool operator<( const Repository & lhs, const Repository & rhs )
330  { return lhs.get() < rhs.get(); }
331 
333 
352  class Repository::ProductInfoIterator : public boost::iterator_adaptor<
353  Repository::ProductInfoIterator // Derived
354  , sat::LookupAttr::iterator // Base
355  , int // Value
356  , boost::forward_traversal_tag // CategoryOrTraversal
357  , int // Reference
358  >
359  {
360  public:
362  {}
363 
365  std::string label() const;
366 
368  CpeId cpeId() const;
369 
370  private:
371  friend class Repository;
373  explicit ProductInfoIterator( sat::SolvAttr attr_r, Repository repo_r );
374 
375  private:
376  friend class boost::iterator_core_access;
377  int dereference() const { return 0; }
378  };
380 
382  //
383  // CLASS NAME : Repository::EraseFromPool
384  //
412  {
413  void operator()( Repository repository_r ) const
414  { repository_r.eraseFromPool(); }
415  };
417 
419  namespace detail
420  {
421  //
423  // CLASS NAME : RepositoryIterator
424  //
426  class RepositoryIterator : public boost::iterator_adaptor<
427  RepositoryIterator // Derived
428  , ::_Repo ** // Base
429  , Repository // Value
430  , boost::forward_traversal_tag // CategoryOrTraversal
431  , Repository // Reference
432  >
433  {
434  public:
436  : RepositoryIterator::iterator_adaptor_( 0 )
437  {}
438 
439  explicit RepositoryIterator( ::_Repo ** p )
440  : RepositoryIterator::iterator_adaptor_( p )
441  {}
442 
443  private:
444  friend class boost::iterator_core_access;
445 
447  { return Repository( *base() ); }
448 
449  void increment();
450  };
453  //
454  // CLASS NAME : ByRepository
455  //
458  {
459  public:
460  ByRepository( const Repository & repository_r ) : _repository( repository_r ) {}
461  ByRepository( sat::detail::RepoIdType id_r ) : _repository( id_r ) {}
463 
464  bool operator()( const sat::Solvable & slv_r ) const
465  { return slv_r.repository() == _repository; }
466 
467  private:
469  };
472  } // namespace detail
475 } // namespace zypp
477 
478 // Late include as sat::ArrayAttr requires Repository.h
480 
481 #endif // ZYPP_SAT_REPOSITORY_H
Repository repository() const
The Repository this Solvable belongs to.
Definition: Solvable.cc:121
Functor filtering Solvable by Repository.
Definition: Repository.h:457
A Solvable object within the sat Pool.
Definition: Solvable.h:55
sat::ArrayAttr< std::string, std::string > Keywords
Definition: Repository.h:45
sat::Solvable::IdType addSolvable()
Definition: Repository.h:288
IdType id() const
Expert backdoor.
Definition: Repository.h:296
bool operator<(const Repository &lhs, const Repository &rhs)
Definition: Repository.h:329
::_Repo * RepoIdType
Id type to connect Repo and sat-repo.
Definition: PoolMember.h:106
bool operator!=(const Repository &lhs, const Repository &rhs)
Definition: Repository.h:325
static const RepoIdType noRepoId(0)
Id to denote Repo::noRepository.
String related utilities and Regular expression matching.
What is known about a repository.
Definition: RepoInfo.h:71
std::ostream & operator<<(std::ostream &str, const Dump< _Tp > &obj)
Definition: LogTools.h:379
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:52
LookupAttr::transformIterator based container to retrieve list attributes.
Definition: LookupAttr.h:595
ByRepository(const Repository &repository_r)
Definition: Repository.h:460
std::string ContentRevision
Definition: Repository.h:47
filter_iterator< detail::ByRepository, sat::detail::SolvableIterator > SolvableIterator
Definition: Repository.h:41
sat::detail::size_type size_type
Definition: Repository.h:42
std::string asUserString() const
User string: label (alias or name)
Definition: Repository.h:92
Functor removing Repository from it&#39;s Pool.
Definition: Repository.h:411
Store and operate on date (time_t).
Definition: Date.h:32
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:464
void operator()(Repository repository_r) const
Definition: Repository.h:413
Repository(IdType id_r)
PoolImpl ctor.
Definition: Repository.h:56
Query class for Repository related products.
Definition: Repository.h:352
bool operator==(const Repository &lhs, const Repository &rhs)
Definition: Repository.h:321
::_Repo * get() const
Expert backdoor.
Definition: Repository.cc:42
ByRepository(sat::detail::RepoIdType id_r)
Definition: Repository.h:461
SolvableIdType size_type
Definition: PoolMember.h:99
std::string ContentIdentifier
Definition: Repository.h:48
Repository dereference() const
Definition: Repository.h:446
static const Repository noRepository
Represents no Repository.
Definition: Repository.h:61
void eraseFromPool()
Remove this Repository from it&#39;s Pool.
Definition: Repository.cc:297
sat::detail::RepoIdType IdType
Definition: Repository.h:43
sat::detail::SolvableIdType IdType
Definition: Solvable.h:58
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
std::ostream & dumpAsXmlOn(std::ostream &str, const _Tp &obj, const std::string &name_r)
Definition: Xml.h:185