libzypp  12.16.5
RepoManager.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_REPOMANAGER_H
13 #define ZYPP_REPOMANAGER_H
14 
15 #include <iosfwd>
16 #include <list>
17 
18 #include "zypp/base/PtrTypes.h"
19 #include "zypp/base/Iterator.h"
20 
21 #include "zypp/Pathname.h"
22 #include "zypp/ZConfig.h"
23 #include "zypp/RepoInfo.h"
25 #include "zypp/repo/RepoType.h"
26 #include "zypp/repo/ServiceType.h"
27 #include "zypp/ServiceInfo.h"
28 #include "zypp/RepoStatus.h"
29 #include "zypp/ProgressData.h"
30 
32 namespace zypp
33 {
34 
46  std::list<RepoInfo> readRepoFile(const Url & repo_file);
47 
53  {
65  RepoManagerOptions( const Pathname & root_r = Pathname() );
66 
76  static RepoManagerOptions makeTestSetup( const Pathname & root_r );
77 
78  Pathname repoCachePath;
79  Pathname repoRawCachePath;
82  Pathname knownReposPath;
84  Pathname pluginsPath;
85  bool probe;
96  std::string servicesTargetDistro;
97 
99  Pathname rootDir;
100  };
101 
102 
103 
109  {
110  friend std::ostream & operator<<( std::ostream & str, const RepoManager & obj );
111 
112  public:
114  class Impl;
115 
117  typedef std::set<ServiceInfo> ServiceSet;
118  typedef ServiceSet::const_iterator ServiceConstIterator;
120 
122  typedef std::set<RepoInfo> RepoSet;
123  typedef RepoSet::const_iterator RepoConstIterator;
125 
126  public:
127  RepoManager( const RepoManagerOptions &options = RepoManagerOptions() );
129  ~RepoManager();
130 
132  {
136  };
137 
139  {
142  };
143 
145  {
146 
147  };
148 
156  bool repoEmpty() const;
157  RepoSizeType repoSize() const;
159  RepoConstIterator repoEnd() const;
160 
162  std::list<RepoInfo> knownRepositories() const
163  { return std::list<RepoInfo>(repoBegin(),repoEnd()); }
164 
166  RepoInfo getRepo( const std::string & alias ) const;
168  RepoInfo getRepo( const RepoInfo & info_r ) const
169  { return getRepo( info_r.alias() ); }
170 
172  bool hasRepo( const std::string & alias ) const;
174  bool hasRepo( const RepoInfo & info_r ) const
175  { return hasRepo( info_r.alias() ); }
176 
180  static std::string makeStupidAlias( const Url & url_r = Url() );
182 
186  RepoStatus metadataStatus( const RepoInfo &info ) const;
187 
195  };
196 
252  const Url &url,
254 
265  Pathname metadataPath( const RepoInfo &info ) const;
266 
267 
278  Pathname packagesPath( const RepoInfo &info ) const;
279 
280 
295  void refreshMetadata( const RepoInfo &info,
297  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
298 
307  void cleanMetadata( const RepoInfo &info,
308  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
309 
318  void cleanPackages( const RepoInfo &info,
319  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
320 
324  RepoStatus cacheStatus( const RepoInfo &info ) const;
325 
344  void buildCache( const RepoInfo &info,
346  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
347 
360  void cleanCache( const RepoInfo &info,
361  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
362 
368  bool isCached( const RepoInfo &info ) const;
369 
370 
380  void loadFromCache( const RepoInfo &info,
381  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
382 
391 
399  repo::RepoType probe( const Url & url, const Pathname & path ) const;
403  repo::RepoType probe( const Url & url ) const;
404 
405 
420  void addRepository( const RepoInfo &info,
421  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
422 
435  void addRepositories( const Url &url,
436  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
442  void removeRepository( const RepoInfo & info,
443  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
444 
454  void modifyRepository( const std::string &alias,
455  const RepoInfo & newinfo,
456  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
458  void modifyRepository( const RepoInfo & newinfo,
459  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() )
460  { modifyRepository( newinfo.alias(), newinfo, progressrcv ); }
461 
475  RepoInfo getRepositoryInfo( const std::string &alias,
476  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
477 
497  RepoInfo getRepositoryInfo( const Url & url,
498  const url::ViewOption & urlview = url::ViewOption::DEFAULTS,
499  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
500 
501 
514  bool serviceEmpty() const;
515 
522 
529 
535 
537  std::list<ServiceInfo> knownServices() const
538  { return std::list<ServiceInfo>(serviceBegin(),serviceEnd()); }
539 
546  ServiceInfo getService( const std::string & alias ) const;
547 
549  bool hasService( const std::string & alias ) const;
551 
555  repo::ServiceType probeService( const Url &url ) const;
556 
565  void addService( const std::string & alias, const Url& url );
566 
574  void addService( const ServiceInfo & service );
575 
584  void removeService( const std::string & alias );
586  void removeService( const ServiceInfo & service );
587 
588 
594  void refreshServices();
595 
604  void refreshService( const std::string & alias );
606  void refreshService( const ServiceInfo & service );
607 
624  void modifyService( const std::string & oldAlias, const ServiceInfo & service );
626  void modifyService( const ServiceInfo & service )
627  { modifyService( service.alias(), service ); }
628 
629  private:
634  {
635  public:
636  MatchServiceAlias( const std::string & alias_ ) : alias(alias_) {}
637  bool operator()( const RepoInfo & info ) const
638  { return info.service() == alias; }
639  private:
640  std::string alias;
641  };
642 
643  public:
644 
677  template<typename OutputIterator>
678  void getRepositoriesInService( const std::string & alias,
679  OutputIterator out ) const
680  {
681  MatchServiceAlias filter(alias);
682 
683  std::copy( boost::make_filter_iterator( filter, repoBegin(), repoEnd() ),
684  boost::make_filter_iterator( filter, repoEnd(), repoEnd() ),
685  out);
686  }
687 
688  private:
691  };
693 
695  std::ostream & operator<<( std::ostream & str, const RepoManager & obj );
696 
698 } // namespace zypp
700 #endif // ZYPP2_REPOMANAGER_H