libzypp  14.37.1
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/repo/RepoType.h"
25 
26 #include "zypp/repo/RepoInfoBase.h"
27 
29 namespace zypp
30 {
31 
33  //
34  // CLASS NAME : RepoInfo
35  //
71  {
72  friend std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
73 
74  public:
75  RepoInfo();
76  virtual ~RepoInfo();
77 
79  static const RepoInfo noRepo;
80 
81  public:
85  static unsigned defaultPriority();
90  unsigned priority() const;
96  void setPriority( unsigned newval_r );
97 
98  typedef std::list<Url> url_set;
100  typedef transform_iterator<repo::RepoVariablesUrlReplacer, url_set::const_iterator> urls_const_iterator;
104  bool baseUrlsEmpty() const;
109  bool baseUrlSet() const;
113  urls_size_type baseUrlsSize() const;
117  urls_const_iterator baseUrlsBegin() const;
121  urls_const_iterator baseUrlsEnd() const;
122 
126  Url url() const
127  { return( baseUrlsEmpty() ? Url() : *baseUrlsBegin()); }
131  Url rawUrl() const;
132 
139  url_set baseUrls() const;
143  url_set rawBaseUrls() const;
144 
152  void addBaseUrl( const Url &url );
156  void setBaseUrl( const Url &url );
157 
178  Pathname path() const;
183  void setPath( const Pathname &path );
184 
188  Url mirrorListUrl() const;
192  Url rawMirrorListUrl() const;
197  void setMirrorListUrl( const Url &url );
198 
203  repo::RepoType type() const;
210  void setProbedType( const repo::RepoType &t ) const;
215  void setType( const repo::RepoType &t );
216 
223  Pathname metadataPath() const;
232  void setMetadataPath( const Pathname &path );
233 
237  Pathname packagesPath() const;
243  void setPackagesPath( const Pathname &path );
244 
252  bool gpgCheck() const;
262  void setGpgCheck( bool check );
263 
273  Url gpgKeyUrl() const;
277  Url rawGpgKeyUrl() const;
287  void setGpgKeyUrl( const Url &gpgkey );
288 
292  bool keepPackages() const;
302  void setKeepPackages( bool keep );
303 
308  std::string service() const;
312  void setService( const std::string& name );
313 
317  std::string targetDistribution() const;
323  void setTargetDistribution(const std::string & targetDistribution);
324 
326  void addContent( const std::string & keyword_r );
328  template <class _Iterator>
329  void addContentFrom( _Iterator begin_r, _Iterator end_r )
330  { for_( it, begin_r, end_r ) addContent( *it ); }
332  template <class _Container>
333  void addContentFrom( const _Container & container_r )
334  { addContentFrom( container_r.begin(), container_r.end() ); }
335 
341  bool hasContent( const std::string & keyword_r = std::string() ) const;
343  template <class _Iterator>
344  bool hasContentAll( _Iterator begin_r, _Iterator end_r ) const
345  { for_( it, begin_r, end_r ) if ( ! hasContent( *it ) ) return false; return true; }
347  template <class _Container>
348  bool hasContentAll( const _Container & container_r ) const
349  { return hasContentAll( container_r.begin(), container_r.end() ); }
351  template <class _Iterator>
352  bool hasContentAny( _Iterator begin_r, _Iterator end_r ) const
353  { for_( it, begin_r, end_r ) if ( hasContent( *it ) ) return true; return false; }
355  template <class _Container>
356  bool hasContentAny( const _Container & container_r ) const
357  { return hasContentAny( container_r.begin(), container_r.end() ); }
358 
359  public:
364  bool hasLicense() const;
365 
369  bool needToAcceptLicense() const;
370 
372  std::string getLicense( const Locale & lang_r = Locale() ) const;
373  std::string getLicense( const Locale & lang_r = Locale() ); // LEGACY API
374 
381 
387 
388 
389  public:
394  virtual std::ostream & dumpOn( std::ostream & str ) const;
395 
400  virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
401 
410  virtual std::ostream & dumpAsXmlOn( std::ostream & str, const std::string & content = "" ) const;
411 
412  class Impl;
413  private:
416  };
418 
420  typedef shared_ptr<RepoInfo> RepoInfo_Ptr;
422  typedef shared_ptr<const RepoInfo> RepoInfo_constPtr;
424  typedef std::list<RepoInfo> RepoInfoList;
425 
427  std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
428 
429 
431 } // namespace zypp
433 #endif // ZYPP2_REPOSITORYINFO_H
LocaleSet getLicenseLocales() const
Return the locales the license is available for.
Definition: RepoInfo.cc:403
std::string name() const
Repository name.
std::string targetDistribution() const
Distribution for which is this repository meant.
Definition: RepoInfo.cc:294
bool hasContentAll(const _Container &container_r) const
Definition: RepoInfo.h:348
void setGpgKeyUrl(const Url &gpgkey)
Key to use for gpg checking of this repository.
Definition: RepoInfo.cc:213
static unsigned defaultPriority()
The default priority (99).
Definition: RepoInfo.cc:201
bool hasContentAll(_Iterator begin_r, _Iterator end_r) const
Definition: RepoInfo.h:344
Url rawUrl() const
Pars pro toto: The first repository raw url (no variables replaced)
Definition: RepoInfo.cc:297
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Write this RepoInfo object into str in a .repo file format.
Definition: RepoInfo.cc:471
void addContentFrom(_Iterator begin_r, _Iterator end_r)
Definition: RepoInfo.h:329
void setPriority(unsigned newval_r)
Set repository priority for solver.
Definition: RepoInfo.cc:204
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: RepoInfo.h:412
shared_ptr< RepoInfo > RepoInfo_Ptr
Definition: RepoInfo.h:420
void setMirrorListUrl(const Url &url)
Set mirror list url.
Definition: RepoInfo.cc:210
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
Definition: RepoInfo.cc:300
Pathname metadataPath() const
Path where this repo metadata was read from.
Definition: RepoInfo.cc:261
String related utilities and Regular expression matching.
std::list< Url > url_set
Definition: RepoInfo.h:98
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:236
What is known about a repository.
Definition: RepoInfo.h:70
#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:224
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
Definition: RepoInfo.cc:303
shared_ptr< const RepoInfo > RepoInfo_constPtr
Definition: RepoInfo.h:422
Pathname packagesPath() const
Path where this repo packages are cached.
Definition: RepoInfo.cc:264
unsigned priority() const
Repository priority for solver.
Definition: RepoInfo.cc:198
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
Definition: RepoInfo.h:100
RepoInfo implementation.
Definition: RepoInfo.cc:42
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:258
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
Definition: RepoInfo.cc:330
Url rawMirrorListUrl() const
The raw mirrorListUrl (no variables replaced).
Definition: RepoInfo.cc:273
virtual ~RepoInfo()
Definition: RepoInfo.cc:193
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:120
Url mirrorListUrl() const
Url of a file which contains a list of repository urls.
Definition: RepoInfo.cc:270
Provides API related macros.
void setPath(const Pathname &path)
set the product path.
Definition: RepoInfo.cc:230
void setService(const std::string &name)
sets service which added this repository
Definition: RepoInfo.cc:249
void setMetadataPath(const Pathname &path)
set the path where the local metadata is stored
Definition: RepoInfo.cc:240
bool gpgCheck() const
Whether to check or not this repository with gpg.
Definition: RepoInfo.cc:255
void setType(const repo::RepoType &t)
set the repository type
Definition: RepoInfo.cc:233
bool baseUrlSet() const
Whether there are manualy configured repository urls.
Definition: RepoInfo.cc:312
void setKeepPackages(bool keep)
Set if packaqes downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:246
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:291
std::tr1::unordered_set< Locale > LocaleSet
Definition: Locale.h:28
void addBaseUrl(const Url &url)
Add a base url.
Definition: RepoInfo.cc:216
SolvableIdType size_type
Definition: PoolMember.h:99
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
Definition: RepoInfo.cc:243
url_set baseUrls() const
The complete set of repository urls.
Definition: RepoInfo.cc:282
url_set rawBaseUrls() const
The complete set of raw repository urls (no variables replaced)
Definition: RepoInfo.cc:285
bool baseUrlsEmpty() const
whether repository urls are available
Definition: RepoInfo.cc:309
repo::RepoType type() const
Type of repository,.
Definition: RepoInfo.cc:267
url_set::size_type urls_size_type
Definition: RepoInfo.h:99
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
Definition: RepoInfo.cc:252
std::string getLicense(const Locale &lang_r=Locale()) const
Return the best license for the current (or a specified) locale.
Definition: RepoInfo.cc:361
bool hasContentAny(const _Container &container_r) const
Definition: RepoInfo.h:356
bool hasLicense() const
Whether there is a license associated with the repo.
Definition: RepoInfo.cc:324
bool hasContent(const std::string &keyword_r=std::string()) const
Check for content keywords.
Definition: RepoInfo.cc:319
Url gpgKeyUrl() const
Key to use for gpg checking of this repository.
Definition: RepoInfo.cc:276
Url url() const
Pars pro toto: The first repository url.
Definition: RepoInfo.h:126
void setGpgCheck(bool check)
Whether to check or not this repository with gpg.
Definition: RepoInfo.cc:207
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
Definition: RepoInfo.h:79
std::list< RepoInfo > RepoInfoList
Definition: RepoInfo.h:424
bool hasContentAny(_Iterator begin_r, _Iterator end_r) const
Definition: RepoInfo.h:352
bool check(const std::string &sequenceinfo_r, bool quick_r)
Check via sequence info.
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:316
virtual std::ostream & dumpAsXmlOn(std::ostream &str, const std::string &content="") const
Write an XML representation of this RepoInfo object.
Definition: RepoInfo.cc:512
urls_size_type baseUrlsSize() const
number of repository urls
Definition: RepoInfo.cc:306
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
Url rawGpgKeyUrl() const
The raw gpgKeyUrl (no variables replaced).
Definition: RepoInfo.cc:279
Url manipulation class.
Definition: Url.h:87
Pathname path() const
Repository path.
Definition: RepoInfo.cc:288
virtual std::ostream & dumpOn(std::ostream &str) const
Write a human-readable representation of this RepoInfo object into the str stream.
Definition: RepoInfo.cc:436
Repository type enumeration.
Definition: RepoType.h:27
friend std::ostream & operator<<(std::ostream &str, const RepoInfo &obj)
Definition: RepoInfo.cc:543
void addContentFrom(const _Container &container_r)
Definition: RepoInfo.h:333