libzypp  14.32.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/repo/RepoType.h"
25 
26 #include "zypp/repo/RepoInfoBase.h"
27 
29 namespace zypp
30 {
31 
33  //
34  // CLASS NAME : RepoInfo
35  //
68  {
69  friend std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
70 
71  public:
72  RepoInfo();
73  virtual ~RepoInfo();
74 
76  static const RepoInfo noRepo;
77 
78  public:
82  static unsigned defaultPriority();
87  unsigned priority() const;
93  void setPriority( unsigned newval_r );
94 
95  typedef std::list<Url> url_set;
97  typedef transform_iterator<repo::RepoVariablesUrlReplacer, url_set::const_iterator> urls_const_iterator;
101  bool baseUrlsEmpty() const;
105  bool baseUrlSet() const;
109  urls_size_type baseUrlsSize() const;
113  urls_const_iterator baseUrlsBegin() const;
117  urls_const_iterator baseUrlsEnd() const;
121  Url url() const
122  { return( baseUrlsEmpty() ? Url() : *baseUrlsBegin()); }
130  url_set baseUrls() const;
138  void addBaseUrl( const Url &url );
142  void setBaseUrl( const Url &url );
143 
164  Pathname path() const;
169  void setPath( const Pathname &path );
170 
175  Url mirrorListUrl() const;
180  void setMirrorListUrl( const Url &url );
181 
186  repo::RepoType type() const;
193  void setProbedType( const repo::RepoType &t ) const;
198  void setType( const repo::RepoType &t );
199 
206  Pathname metadataPath() const;
215  void setMetadataPath( const Pathname &path );
216 
220  Pathname packagesPath() const;
226  void setPackagesPath( const Pathname &path );
227 
235  bool gpgCheck() const;
245  void setGpgCheck( bool check );
246 
256  Url gpgKeyUrl() const;
266  void setGpgKeyUrl( const Url &gpgkey );
267 
271  bool keepPackages() const;
281  void setKeepPackages( bool keep );
282 
287  std::string service() const;
291  void setService( const std::string& name );
292 
296  std::string targetDistribution() const;
302  void setTargetDistribution(const std::string & targetDistribution);
303 
305  void addContent( const std::string & keyword_r );
307  template <class _Iterator>
308  void addContentFrom( _Iterator begin_r, _Iterator end_r )
309  { for_( it, begin_r, end_r ) addContent( *it ); }
311  template <class _Container>
312  void addContentFrom( const _Container & container_r )
313  { addContentFrom( container_r.begin(), container_r.end() ); }
314 
320  bool hasContent( const std::string & keyword_r = std::string() ) const;
322  template <class _Iterator>
323  bool hasContentAll( _Iterator begin_r, _Iterator end_r ) const
324  { for_( it, begin_r, end_r ) if ( ! hasContent( *it ) ) return false; return true; }
326  template <class _Container>
327  bool hasContentAll( const _Container & container_r ) const
328  { return hasContentAll( container_r.begin(), container_r.end() ); }
330  template <class _Iterator>
331  bool hasContentAny( _Iterator begin_r, _Iterator end_r ) const
332  { for_( it, begin_r, end_r ) if ( hasContent( *it ) ) return true; return false; }
334  template <class _Container>
335  bool hasContentAny( const _Container & container_r ) const
336  { return hasContentAny( container_r.begin(), container_r.end() ); }
337 
338  public:
343  bool hasLicense() const;
344 
348  bool needToAcceptLicense() const;
349 
351  std::string getLicense( const Locale & lang_r = Locale() ) const;
352  std::string getLicense( const Locale & lang_r = Locale() ); // LEGACY API
353 
360 
366 
367 
368  public:
373  virtual std::ostream & dumpOn( std::ostream & str ) const;
374 
378  virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
379 
387  virtual std::ostream & dumpAsXmlOn( std::ostream & str, const std::string & content = "" ) const;
388 
390  ZYPP_DEPRECATED std::ostream & dumpAsXMLOn( std::ostream & str, const std::string & content = "" ) const { return dumpAsXmlOn( str, content ); }
391 
392  class Impl;
393  private:
396  };
398 
400  typedef shared_ptr<RepoInfo> RepoInfo_Ptr;
402  typedef shared_ptr<const RepoInfo> RepoInfo_constPtr;
404  typedef std::list<RepoInfo> RepoInfoList;
405 
407  std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
408 
409 
411 } // namespace zypp
413 #endif // ZYPP2_REPOSITORYINFO_H
LocaleSet getLicenseLocales() const
Return the locales the license is available for.
Definition: RepoInfo.cc:403
std::string name() const
Repository short label.
std::string targetDistribution() const
Distribution for which is this repository meant.
Definition: RepoInfo.cc:291
bool hasContentAll(const _Container &container_r) const
Definition: RepoInfo.h:327
ZYPP_DEPRECATED std::ostream & dumpAsXMLOn(std::ostream &str, const std::string &content="") const
Definition: RepoInfo.h:390
void setGpgKeyUrl(const Url &gpgkey)
Key to use for gpg checking of this repository.
Definition: RepoInfo.cc:219
static unsigned defaultPriority()
The default priority (99).
Definition: RepoInfo.cc:207
bool hasContentAll(_Iterator begin_r, _Iterator end_r) const
Definition: RepoInfo.h:323
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:308
void setPriority(unsigned newval_r)
Set repository priority for solver.
Definition: RepoInfo.cc:210
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: RepoInfo.h:392
shared_ptr< RepoInfo > RepoInfo_Ptr
Definition: RepoInfo.h:400
void setMirrorListUrl(const Url &url)
Set mirror list url.
Definition: RepoInfo.cc:216
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
Definition: RepoInfo.cc:294
Pathname metadataPath() const
Path where this repo metadata was read from.
Definition: RepoInfo.cc:267
String related utilities and Regular expression matching.
std::list< Url > url_set
Definition: RepoInfo.h:95
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:242
What is known about a repository.
Definition: RepoInfo.h:67
#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:230
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
Definition: RepoInfo.cc:300
shared_ptr< const RepoInfo > RepoInfo_constPtr
Definition: RepoInfo.h:402
Pathname packagesPath() const
Path where this repo packages are cached.
Definition: RepoInfo.cc:270
unsigned priority() const
Repository priority for solver.
Definition: RepoInfo.cc:204
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
Definition: RepoInfo.h:97
RepoInfo implementation.
Definition: RepoInfo.cc:42
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:264
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
Definition: RepoInfo.cc:330
virtual ~RepoInfo()
Definition: RepoInfo.cc:199
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 Urls If empty, the base url will be used.
Definition: RepoInfo.cc:276
Provides API related macros.
void setPath(const Pathname &path)
set the product path.
Definition: RepoInfo.cc:236
void setService(const std::string &name)
sets service which added this repository
Definition: RepoInfo.cc:255
void setMetadataPath(const Pathname &path)
set the path where the local metadata is stored
Definition: RepoInfo.cc:246
bool gpgCheck() const
Whether to check or not this repository with gpg.
Definition: RepoInfo.cc:261
void setType(const repo::RepoType &t)
set the repository type
Definition: RepoInfo.cc:239
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:252
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:288
std::tr1::unordered_set< Locale > LocaleSet
Definition: Locale.h:28
void addBaseUrl(const Url &url)
Add a base url.
Definition: RepoInfo.cc:222
SolvableIdType size_type
Definition: PoolMember.h:99
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
Definition: RepoInfo.cc:249
url_set baseUrls() const
A Url under which the metadata are located, or a set of mirrors.
Definition: RepoInfo.cc:282
bool baseUrlsEmpty() const
whether repository urls are available
Definition: RepoInfo.cc:309
repo::RepoType type() const
Type of repository,.
Definition: RepoInfo.cc:273
url_set::size_type urls_size_type
Definition: RepoInfo.h:96
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
Definition: RepoInfo.cc:258
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:335
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:279
Url url() const
Pars pro toto: The first repository url.
Definition: RepoInfo.h:121
void setGpgCheck(bool check)
Whether to check or not this repository with gpg.
Definition: RepoInfo.cc:213
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
Definition: RepoInfo.h:76
std::list< RepoInfo > RepoInfoList
Definition: RepoInfo.h:404
bool hasContentAny(_Iterator begin_r, _Iterator end_r) const
Definition: RepoInfo.h:331
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:36
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:511
urls_size_type baseUrlsSize() const
number of repository urls
Definition: RepoInfo.cc:306
#define ZYPP_DEPRECATED
The ZYPP_DEPRECATED macro can be used to trigger compile-time warnings with gcc >= 3...
Definition: APIConfig.h:86
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
Url manipulation class.
Definition: Url.h:87
Pathname path() const
Repository path.
Definition: RepoInfo.cc:285
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:542
void addContentFrom(const _Container &container_r)
Definition: RepoInfo.h:312