libzypp  15.3.0
RepoInfo.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP2_REPOSITORYINFO_H
13 #define ZYPP2_REPOSITORYINFO_H
14 
15 #include <list>
16 #include <set>
17 
18 #include "zypp/base/Iterator.h"
19 #include "zypp/APIConfig.h"
20 
21 #include "zypp/Url.h"
22 #include "zypp/Locale.h"
23 #include "zypp/TriBool.h"
24 #include "zypp/repo/RepoType.h"
26 
27 #include "zypp/repo/RepoInfoBase.h"
28 
30 namespace zypp
31 {
32 
34  //
35  // CLASS NAME : RepoInfo
36  //
72  {
73  friend std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
74 
75  public:
76  RepoInfo();
77  virtual ~RepoInfo();
78 
80  static const RepoInfo noRepo;
81 
82  public:
86  static unsigned defaultPriority();
91  unsigned priority() const;
97  void setPriority( unsigned newval_r );
98 
99  typedef std::list<Url> url_set;
101  typedef transform_iterator<repo::RepoVariablesUrlReplacer, url_set::const_iterator> urls_const_iterator;
105  bool baseUrlsEmpty() const;
110  bool baseUrlSet() const;
114  urls_size_type baseUrlsSize() const;
118  urls_const_iterator baseUrlsBegin() const;
122  urls_const_iterator baseUrlsEnd() const;
123 
127  Url url() const
128  { return( baseUrlsEmpty() ? Url() : *baseUrlsBegin()); }
132  Url rawUrl() const;
133 
140  url_set baseUrls() const;
144  url_set rawBaseUrls() const;
145 
153  void addBaseUrl( const Url &url );
157  void setBaseUrl( const Url &url );
158 
179  Pathname path() const;
184  void setPath( const Pathname &path );
185 
189  Url mirrorListUrl() const;
193  Url rawMirrorListUrl() const;
198  void setMirrorListUrl( const Url &url );
202  void setMetalinkUrl( const Url &url );
203 
208  repo::RepoType type() const;
215  void setProbedType( const repo::RepoType &t ) const;
220  void setType( const repo::RepoType &t );
221 
228  Pathname metadataPath() const;
237  void setMetadataPath( const Pathname &path );
238 
242  Pathname packagesPath() const;
248  void setPackagesPath( const Pathname &path );
249 
250 
258  bool gpgCheck() const;
260  void setGpgCheck( TriBool value_r );
262  void setGpgCheck( bool value_r );
263 
267  bool repoGpgCheck() const;
269  void setRepoGpgCheck( TriBool value_r );
270 
274  bool pkgGpgCheck() const;
276  void setPkgGpgCheck( TriBool value_r );
277 
281  TriBool validRepoSignature() const;
283  void setValidRepoSignature( TriBool value_r );
284 
294  Url gpgKeyUrl() const;
298  Url rawGpgKeyUrl() const;
308  void setGpgKeyUrl( const Url &gpgkey );
309 
313  bool keepPackages() const;
323  void setKeepPackages( bool keep );
324 
329  std::string service() const;
333  void setService( const std::string& name );
334 
338  std::string targetDistribution() const;
344  void setTargetDistribution(const std::string & targetDistribution);
345 
347  void addContent( const std::string & keyword_r );
349  template <class _Iterator>
350  void addContentFrom( _Iterator begin_r, _Iterator end_r )
351  { for_( it, begin_r, end_r ) addContent( *it ); }
353  template <class _Container>
354  void addContentFrom( const _Container & container_r )
355  { addContentFrom( container_r.begin(), container_r.end() ); }
356 
362  bool hasContent( const std::string & keyword_r = std::string() ) const;
364  template <class _Iterator>
365  bool hasContentAll( _Iterator begin_r, _Iterator end_r ) const
366  { for_( it, begin_r, end_r ) if ( ! hasContent( *it ) ) return false; return true; }
368  template <class _Container>
369  bool hasContentAll( const _Container & container_r ) const
370  { return hasContentAll( container_r.begin(), container_r.end() ); }
372  template <class _Iterator>
373  bool hasContentAny( _Iterator begin_r, _Iterator end_r ) const
374  { for_( it, begin_r, end_r ) if ( hasContent( *it ) ) return true; return false; }
376  template <class _Container>
377  bool hasContentAny( const _Container & container_r ) const
378  { return hasContentAny( container_r.begin(), container_r.end() ); }
379 
380  public:
385  bool hasLicense() const;
386 
390  bool needToAcceptLicense() const;
391 
393  std::string getLicense( const Locale & lang_r = Locale() ) const;
394  std::string getLicense( const Locale & lang_r = Locale() ); // LEGACY API
395 
402 
403  public:
408  virtual std::ostream & dumpOn( std::ostream & str ) const;
409 
414  virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
415 
424  virtual std::ostream & dumpAsXmlOn( std::ostream & str, const std::string & content = "" ) const;
425 
426  class Impl;
427  private:
430  };
432 
434  typedef shared_ptr<RepoInfo> RepoInfo_Ptr;
436  typedef shared_ptr<const RepoInfo> RepoInfo_constPtr;
438  typedef std::list<RepoInfo> RepoInfoList;
439 
441  std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
442 
443 
445 } // namespace zypp
447 #endif // ZYPP2_REPOSITORYINFO_H
LocaleSet getLicenseLocales() const
Return the locales the license is available for.
Definition: RepoInfo.cc:504
std::string name() const
Repository name.
std::string targetDistribution() const
Distribution for which is this repository meant.
Definition: RepoInfo.cc:395
bool hasContentAll(const _Container &container_r) const
Definition: RepoInfo.h:369
void setGpgKeyUrl(const Url &gpgkey)
Key to use for gpg checking of this repository.
Definition: RepoInfo.cc:317
static unsigned defaultPriority()
The default priority (99).
Definition: RepoInfo.cc:258
bool hasContentAll(_Iterator begin_r, _Iterator end_r) const
Definition: RepoInfo.h:365
Url rawUrl() const
Pars pro toto: The first repository raw url (no variables replaced)
Definition: RepoInfo.cc:398
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Write this RepoInfo object into str in a .repo file format.
Definition: RepoInfo.cc:581
void addContentFrom(_Iterator begin_r, _Iterator end_r)
Definition: RepoInfo.h:350
void setPriority(unsigned newval_r)
Set repository priority for solver.
Definition: RepoInfo.cc:261
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: RepoInfo.h:426
shared_ptr< RepoInfo > RepoInfo_Ptr
Definition: RepoInfo.h:434
void setMirrorListUrl(const Url &url)
Set mirror list url.
Definition: RepoInfo.cc:311
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
Definition: RepoInfo.cc:401
Pathname metadataPath() const
Path where this repo metadata was read from.
Definition: RepoInfo.cc:362
String related utilities and Regular expression matching.
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
Definition: RepoInfo.cc:286
std::list< Url > url_set
Definition: RepoInfo.h:99
void setProbedType(const repo::RepoType &t) const
This allows to adjust the RepoType lazy, from NONE to some probed value, even for const objects...
Definition: RepoInfo.cc:340
What is known about a repository.
Definition: RepoInfo.h:71
void setGpgCheck(TriBool value_r)
Set the value for gpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:268
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:27
void setBaseUrl(const Url &url)
Clears current base URL list and adds url.
Definition: RepoInfo.cc:328
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
Definition: RepoInfo.cc:404
shared_ptr< const RepoInfo > RepoInfo_constPtr
Definition: RepoInfo.h:436
Pathname packagesPath() const
Path where this repo packages are cached.
Definition: RepoInfo.cc:365
unsigned priority() const
Repository priority for solver.
Definition: RepoInfo.cc:255
void setValidRepoSignature(TriBool value_r)
Set the value for validRepoSignature (or indeterminate if unsigned).
Definition: RepoInfo.cc:307
bool repoGpgCheck() const
Whether the signature of repo metadata should be checked for this repo.
Definition: RepoInfo.cc:275
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition: String.h:29
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
Definition: RepoInfo.h:101
RepoInfo implementation.
Definition: RepoInfo.cc:43
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:359
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
Definition: RepoInfo.cc:431
Url rawMirrorListUrl() const
The raw mirrorListUrl (no variables replaced).
Definition: RepoInfo.cc:374
virtual ~RepoInfo()
Definition: RepoInfo.cc:252
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:120
void setRepoGpgCheck(TriBool value_r)
Set the value for repoGpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:282
Url mirrorListUrl() const
Url of a file which contains a list of repository urls.
Definition: RepoInfo.cc:371
Provides API related macros.
void setPath(const Pathname &path)
set the product path.
Definition: RepoInfo.cc:334
void setService(const std::string &name)
sets service which added this repository
Definition: RepoInfo.cc:353
void setMetadataPath(const Pathname &path)
set the path where the local metadata is stored
Definition: RepoInfo.cc:344
bool gpgCheck() const
Whether default signature checking should be performed for this repo.
Definition: RepoInfo.cc:265
void setType(const repo::RepoType &t)
set the repository type
Definition: RepoInfo.cc:337
bool baseUrlSet() const
Whether there are manualy configured repository urls.
Definition: RepoInfo.cc:413
void setKeepPackages(bool keep)
Set if packaqes downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:350
std::string service() const
Gets name of the service to which this repository belongs or empty string if it has been added manual...
Definition: RepoInfo.cc:392
std::tr1::unordered_set< Locale > LocaleSet
Definition: Locale.h:28
void addBaseUrl(const Url &url)
Add a base url.
Definition: RepoInfo.cc:320
SolvableIdType size_type
Definition: PoolMember.h:99
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
Definition: RepoInfo.cc:347
url_set baseUrls() const
The complete set of repository urls.
Definition: RepoInfo.cc:383
url_set rawBaseUrls() const
The complete set of raw repository urls (no variables replaced)
Definition: RepoInfo.cc:386
void setMetalinkUrl(const Url &url)
Like setMirrorListUrl but expect metalink format.
Definition: RepoInfo.cc:314
bool baseUrlsEmpty() const
whether repository urls are available
Definition: RepoInfo.cc:410
repo::RepoType type() const
Type of repository,.
Definition: RepoInfo.cc:368
url_set::size_type urls_size_type
Definition: RepoInfo.h:100
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
Definition: RepoInfo.cc:356
std::string getLicense(const Locale &lang_r=Locale()) const
Return the best license for the current (or a specified) locale.
Definition: RepoInfo.cc:462
bool hasContentAny(const _Container &container_r) const
Definition: RepoInfo.h:377
bool hasLicense() const
Whether there is a license associated with the repo.
Definition: RepoInfo.cc:425
bool hasContent(const std::string &keyword_r=std::string()) const
Check for content keywords.
Definition: RepoInfo.cc:420
Url gpgKeyUrl() const
Key to use for gpg checking of this repository.
Definition: RepoInfo.cc:377
Url url() const
Pars pro toto: The first repository url.
Definition: RepoInfo.h:127
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
Definition: RepoInfo.h:80
std::list< RepoInfo > RepoInfoList
Definition: RepoInfo.h:438
bool hasContentAny(_Iterator begin_r, _Iterator end_r) const
Definition: RepoInfo.h:373
Base class implementing common features of RepoInfo and ServiceInfo.
Definition: RepoInfoBase.h:39
void addContent(const std::string &keyword_r)
Add content keywords.
Definition: RepoInfo.cc:417
virtual std::ostream & dumpAsXmlOn(std::ostream &str, const std::string &content="") const
Write an XML representation of this RepoInfo object.
Definition: RepoInfo.cc:628
TriBool validRepoSignature() const
Whether the repo metadata are signed and successfully validated or indeterminate if unsigned...
Definition: RepoInfo.cc:298
urls_size_type baseUrlsSize() const
number of repository urls
Definition: RepoInfo.cc:407
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
void setPkgGpgCheck(TriBool value_r)
Set the value for pkgGpgCheck (or indeterminate to use the default).
Definition: RepoInfo.cc:294
Url rawGpgKeyUrl() const
The raw gpgKeyUrl (no variables replaced).
Definition: RepoInfo.cc:380
Url manipulation class.
Definition: Url.h:87
Pathname path() const
Repository path.
Definition: RepoInfo.cc:389
virtual std::ostream & dumpOn(std::ostream &str) const
Write a human-readable representation of this RepoInfo object into the str stream.
Definition: RepoInfo.cc:537
Repository type enumeration.
Definition: RepoType.h:27
friend std::ostream & operator<<(std::ostream &str, const RepoInfo &obj)
Definition: RepoInfo.cc:661
void addContentFrom(const _Container &container_r)
Definition: RepoInfo.h:354