libzypp  14.29.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  //
67  {
68  friend std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
69 
70  public:
71  RepoInfo();
72  virtual ~RepoInfo();
73 
75  static const RepoInfo noRepo;
76 
77  public:
81  static unsigned defaultPriority();
86  unsigned priority() const;
92  void setPriority( unsigned newval_r );
93 
94  typedef std::set<Url> url_set;
96  typedef transform_iterator<repo::RepoVariablesUrlReplacer, url_set::const_iterator> urls_const_iterator;
100  bool baseUrlsEmpty() const;
104  bool baseUrlSet() const;
108  urls_size_type baseUrlsSize() const;
112  urls_const_iterator baseUrlsBegin() const;
116  urls_const_iterator baseUrlsEnd() const;
120  Url url() const
121  { return( baseUrlsEmpty() ? Url() : *baseUrlsBegin()); }
131  std::set<Url> baseUrls() const;
139  void addBaseUrl( const Url &url );
143  void setBaseUrl( const Url &url );
144 
165  Pathname path() const;
170  void setPath( const Pathname &path );
171 
176  Url mirrorListUrl() const;
181  void setMirrorListUrl( const Url &url );
182 
187  repo::RepoType type() const;
194  void setProbedType( const repo::RepoType &t ) const;
199  void setType( const repo::RepoType &t );
200 
207  Pathname metadataPath() const;
216  void setMetadataPath( const Pathname &path );
217 
221  Pathname packagesPath() const;
227  void setPackagesPath( const Pathname &path );
228 
236  bool gpgCheck() const;
246  void setGpgCheck( bool check );
247 
257  Url gpgKeyUrl() const;
267  void setGpgKeyUrl( const Url &gpgkey );
268 
272  bool keepPackages() const;
282  void setKeepPackages( bool keep );
283 
288  std::string service() const;
292  void setService( const std::string& name );
293 
297  std::string targetDistribution() const;
303  void setTargetDistribution(const std::string & targetDistribution);
304 
306  void addContent( const std::string & keyword_r );
308  template <class _Iterator>
309  void addContentFrom( _Iterator begin_r, _Iterator end_r )
310  { for_( it, begin_r, end_r ) addContent( *it ); }
312  template <class _Container>
313  void addContentFrom( const _Container & container_r )
314  { addContentFrom( container_r.begin(), container_r.end() ); }
315 
321  bool hasContent( const std::string & keyword_r = std::string() ) const;
323  template <class _Iterator>
324  bool hasContentAll( _Iterator begin_r, _Iterator end_r ) const
325  { for_( it, begin_r, end_r ) if ( ! hasContent( *it ) ) return false; return true; }
327  template <class _Container>
328  bool hasContentAll( const _Container & container_r ) const
329  { return hasContentAll( container_r.begin(), container_r.end() ); }
331  template <class _Iterator>
332  bool hasContentAny( _Iterator begin_r, _Iterator end_r ) const
333  { for_( it, begin_r, end_r ) if ( hasContent( *it ) ) return true; return false; }
335  template <class _Container>
336  bool hasContentAny( const _Container & container_r ) const
337  { return hasContentAny( container_r.begin(), container_r.end() ); }
338 
339  public:
344  bool hasLicense() const;
345 
349  bool needToAcceptLicense() const;
350 
352  std::string getLicense( const Locale & lang_r = Locale() );
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:418
std::string name() const
Repository short label.
std::string targetDistribution() const
Distribution for which is this repository meant.
Definition: RepoInfo.cc:304
bool hasContentAll(const _Container &container_r) const
Definition: RepoInfo.h:328
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:228
static unsigned defaultPriority()
The default priority (99).
Definition: RepoInfo.cc:216
bool hasContentAll(_Iterator begin_r, _Iterator end_r) const
Definition: RepoInfo.h:324
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Write this RepoInfo object into str in a .repo file format.
Definition: RepoInfo.cc:488
void addContentFrom(_Iterator begin_r, _Iterator end_r)
Definition: RepoInfo.h:309
void setPriority(unsigned newval_r)
Set repository priority for solver.
Definition: RepoInfo.cc:219
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:225
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
Definition: RepoInfo.cc:307
std::string getLicense(const Locale &lang_r=Locale())
Return the best license for the current (or a specified) locale.
Definition: RepoInfo.cc:376
Pathname metadataPath() const
Path where this repo metadata was read from.
Definition: RepoInfo.cc:271
String related utilities and Regular expression matching.
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:246
What is known about a repository.
Definition: RepoInfo.h:66
#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:234
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
Definition: RepoInfo.cc:314
shared_ptr< const RepoInfo > RepoInfo_constPtr
Definition: RepoInfo.h:402
Pathname packagesPath() const
Path where this repo packages are cached.
Definition: RepoInfo.cc:274
unsigned priority() const
Repository priority for solver.
Definition: RepoInfo.cc:213
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
Definition: RepoInfo.h:96
RepoInfo implementation.
Definition: RepoInfo.cc:42
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:268
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
Definition: RepoInfo.cc:348
virtual ~RepoInfo()
Definition: RepoInfo.cc:208
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:280
Provides API related macros.
void setPath(const Pathname &path)
set the product path.
Definition: RepoInfo.cc:240
void setService(const std::string &name)
sets service which added this repository
Definition: RepoInfo.cc:259
void setMetadataPath(const Pathname &path)
set the path where the local metadata is stored
Definition: RepoInfo.cc:250
bool gpgCheck() const
Whether to check or not this repository with gpg.
Definition: RepoInfo.cc:265
void setType(const repo::RepoType &t)
set the repository type
Definition: RepoInfo.cc:243
bool baseUrlSet() const
whether there are manualy configured repository urls
Definition: RepoInfo.cc:327
void setKeepPackages(bool keep)
Set if packaqes downloaded from this repository will be kept in local cache.
Definition: RepoInfo.cc:256
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:301
std::tr1::unordered_set< Locale > LocaleSet
Definition: Locale.h:28
void addBaseUrl(const Url &url)
Add a base url.
Definition: RepoInfo.cc:231
SolvableIdType size_type
Definition: PoolMember.h:99
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
Definition: RepoInfo.cc:253
bool baseUrlsEmpty() const
whether repository urls are available
Definition: RepoInfo.cc:324
repo::RepoType type() const
Type of repository,.
Definition: RepoInfo.cc:277
url_set::size_type urls_size_type
Definition: RepoInfo.h:95
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
Definition: RepoInfo.cc:262
bool hasContentAny(const _Container &container_r) const
Definition: RepoInfo.h:336
std::set< Url > baseUrls() const
A Url under which the metadata are located, or a set of mirrors.
Definition: RepoInfo.cc:286
bool hasLicense() const
Whether there is a license associated with the repo.
Definition: RepoInfo.cc:339
bool hasContent(const std::string &keyword_r=std::string()) const
Check for content keywords.
Definition: RepoInfo.cc:334
Url gpgKeyUrl() const
Key to use for gpg checking of this repository.
Definition: RepoInfo.cc:283
Url url() const
Pars pro toto: The first repository url.
Definition: RepoInfo.h:120
void setGpgCheck(bool check)
Whether to check or not this repository with gpg.
Definition: RepoInfo.cc:222
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
Definition: RepoInfo.h:75
std::list< RepoInfo > RepoInfoList
Definition: RepoInfo.h:404
bool hasContentAny(_Iterator begin_r, _Iterator end_r) const
Definition: RepoInfo.h:332
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:331
virtual std::ostream & dumpAsXmlOn(std::ostream &str, const std::string &content="") const
Write an XML representation of this RepoInfo object.
Definition: RepoInfo.cc:528
urls_size_type baseUrlsSize() const
number of repository urls
Definition: RepoInfo.cc:321
#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:298
virtual std::ostream & dumpOn(std::ostream &str) const
Write a human-readable representation of this RepoInfo object into the str stream.
Definition: RepoInfo.cc:451
Repository type enumeration.
Definition: RepoType.h:27
friend std::ostream & operator<<(std::ostream &str, const RepoInfo &obj)
Definition: RepoInfo.cc:560
void addContentFrom(const _Container &container_r)
Definition: RepoInfo.h:313
std::set< Url > url_set
Definition: RepoInfo.h:94