libzypp  17.23.5
MediaSetAccess.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
9 
10 #ifndef ZYPP_MediaSetAccess_H
11 #define ZYPP_MediaSetAccess_H
12 
13 #include <iosfwd>
14 #include <string>
15 #include <vector>
16 #include <zypp/base/Function.h>
17 
19 #include <zypp/base/NonCopyable.h>
20 #include <zypp/base/Flags.h>
21 #include <zypp/base/PtrTypes.h>
23 #include <zypp/Pathname.h>
24 #include <zypp/CheckSum.h>
25 #include <zypp/OnMediaLocation.h>
26 #include <zypp/ManagedFile.h>
27 
29 namespace zypp
30 {
31 
32  DEFINE_PTR_TYPE(MediaSetAccess);
33 
35  //
36  // CLASS NAME : MediaSetAccess
37  //
81  {
82  friend std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj );
83 
84  public:
92  MediaSetAccess( const Url &url, const Pathname & prefered_attach_point = "" );
94  MediaSetAccess( const std::string & label_r, const Url &url, const Pathname & prefered_attach_point = "" );
96 
100  void setVerifier( unsigned media_nr, media::MediaVerifierRef verifier );
101 
105  const std::string & label() const
106  { return _label; }
107 
111  void setLabel( const std::string & label_r )
112  { _label = label_r; }
113 
115  {
121  };
122  ZYPP_DECLARE_FLAGS(ProvideFileOptions,ProvideFileOption);
123 
151  Pathname provideFile( const OnMediaLocation & resource, ProvideFileOptions options = PROVIDE_DEFAULT, const Pathname &deltafile = Pathname() );
152 
173  Pathname provideFile(const Pathname & file, unsigned media_nr = 1, ProvideFileOptions options = PROVIDE_DEFAULT );
174 
182  Pathname provideOptionalFile( const Pathname & file, unsigned media_nr = 1 );
183 
201  static ManagedFile provideFileFromUrl( const Url & file_url, ProvideFileOptions options = PROVIDE_DEFAULT );
202 
210  static ManagedFile provideOptionalFileFromUrl( const Url & file_url );
211 
218  void releaseFile( const OnMediaLocation &resource );
219 
220 
228  void releaseFile(const Pathname & file, unsigned media_nr = 1 );
229 
246  {
249  ReleaseFileGuard( MediaSetAccess & media_r, const OnMediaLocation & loc_r )
250  : _media( media_r )
251  , _loc( loc_r )
252  {}
254  { _media.releaseFile( _loc ); }
255  private:
258  };
259 
277  Pathname provideDir(const Pathname & dir, bool recursive, unsigned media_nr = 1, ProvideFileOptions options = PROVIDE_DEFAULT );
278 
293  bool doesFileExist(const Pathname & file, unsigned media_nr = 1 );
294 
298  void dirInfo( filesystem::DirContent &retlist, const Pathname &dirname,
299  bool dots = true, unsigned media_nr = 1 );
300 
306  void release();
307 
322  static Url rewriteUrl (const Url & url_r, const media::MediaNr medianr);
323 
324  protected:
340  Pathname provideFileInternal( const OnMediaLocation &resource, ProvideFileOptions options );
341 
342  typedef function<void( media::MediaAccessId, const Pathname & )> ProvideOperation;
343 
344  void provide( ProvideOperation op, const OnMediaLocation &resource, ProvideFileOptions options, const Pathname &deltafile );
345 
347  virtual std::ostream & dumpOn( std::ostream & str ) const;
348 
349  private:
352 
360 
361  std::string _label;
362 
363  typedef std::map<media::MediaNr, media::MediaAccessId> MediaMap;
364  typedef std::map<media::MediaNr, media::MediaVerifierRef > VerifierMap;
365 
370  };
372  ZYPP_DECLARE_OPERATORS_FOR_FLAGS(MediaSetAccess::ProvideFileOptions);
373 
375  inline std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj )
376  { return obj.dumpOn( str ); }
377 
378 
379 } // namespace zypp
381 #endif // ZYPP_SOURCE_MediaSetAccess_H
zypp::MediaSetAccess::_label
std::string _label
Definition: MediaSetAccess.h:361
zypp::MediaSetAccess::_url
Url _url
Media or media set URL.
Definition: MediaSetAccess.h:351
zypp::MediaSetAccess::operator<<
std::ostream & operator<<(std::ostream &str, const MediaSetAccess &obj)
Definition: MediaSetAccess.h:375
zypp::media::MediaNr
unsigned int MediaNr
Definition: MediaManager.h:40
zypp::MediaSetAccess::PROVIDE_NON_INTERACTIVE
Definition: MediaSetAccess.h:120
zypp::MediaSetAccess::provideOptionalFile
Pathname provideOptionalFile(const Pathname &file, unsigned media_nr=1)
Provides an optional file from media media_nr.
Definition: MediaSetAccess.cc:178
zypp::MediaSetAccess::MediaMap
std::map< media::MediaNr, media::MediaAccessId > MediaMap
Definition: MediaSetAccess.h:363
zypp::DEFINE_PTR_TYPE
DEFINE_PTR_TYPE(Application)
zypp::MediaSetAccess::setLabel
void setLabel(const std::string &label_r)
Set the label identifing this media set and to be sent in a media change request.
Definition: MediaSetAccess.h:111
zypp::MediaSetAccess::_medias
MediaMap _medias
Mapping between media number and Media Access ID.
Definition: MediaSetAccess.h:367
zypp::MediaSetAccess::label
const std::string & label() const
The label identifing this media set and to be sent in a media change request.
Definition: MediaSetAccess.h:105
zypp::MediaSetAccess::provideFileFromUrl
static ManagedFile provideFileFromUrl(const Url &file_url, ProvideFileOptions options=PROVIDE_DEFAULT)
Provides file from url.
Definition: MediaSetAccess.cc:192
zypp::MediaSetAccess::release
void release()
Release all attached media of this set.
Definition: MediaSetAccess.cc:483
zypp::MediaSetAccess::doesFileExist
bool doesFileExist(const Pathname &file, unsigned media_nr=1)
Checks if a file exists on the specified media, with user callbacks.
Definition: MediaSetAccess.cc:223
CheckSum.h
zypp::base::ReferenceCounted
Base class for reference counted objects.
Definition: ReferenceCounted.h:33
zypp::MediaSetAccess::_prefAttachPoint
Pathname _prefAttachPoint
Prefered mount point.
Definition: MediaSetAccess.h:359
zypp::OnMediaLocation
Describes a resource file located on a medium.
Definition: OnMediaLocation.h:38
PtrTypes.h
zypp::MediaSetAccess::ZYPP_DECLARE_FLAGS
ZYPP_DECLARE_FLAGS(ProvideFileOptions, ProvideFileOption)
MediaManager.h
Pathname.h
zypp::MediaSetAccess::rewriteUrl
static Url rewriteUrl(const Url &url_r, const media::MediaNr medianr)
Replaces media number in specified url with given medianr.
Definition: MediaSetAccess.cc:440
zypp::MediaSetAccess::VerifierMap
std::map< media::MediaNr, media::MediaVerifierRef > VerifierMap
Definition: MediaSetAccess.h:364
zypp::media::MediaAccessId
unsigned int MediaAccessId
Media manager access Id type.
Definition: MediaSource.h:29
OnMediaLocation.h
zypp::MediaSetAccess::ReleaseFileGuard::NON_COPYABLE
NON_COPYABLE(ReleaseFileGuard)
zypp::MediaSetAccess::ProvideFileOption
ProvideFileOption
Definition: MediaSetAccess.h:114
zypp::RW_pointer
Wrapper for const correct access via Smart pointer types.
Definition: PtrTypes.h:285
zypp::MediaSetAccess::releaseFile
void releaseFile(const OnMediaLocation &resource)
Release file from media.
Definition: MediaSetAccess.cc:77
zypp::MediaSetAccess::dirInfo
void dirInfo(filesystem::DirContent &retlist, const Pathname &dirname, bool dots=true, unsigned media_nr=1)
Fills retlist with directory information.
Definition: MediaSetAccess.cc:97
zypp::MediaSetAccess::dumpOn
virtual std::ostream & dumpOn(std::ostream &str) const
Overload to realize std::ostream & operator<<.
Definition: MediaSetAccess.cc:491
zypp::MediaSetAccess::ReleaseFileGuard
Definition: MediaSetAccess.h:245
zypp::base::NonCopyable
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
zypp::MediaSetAccess::~MediaSetAccess
~MediaSetAccess()
Definition: MediaSetAccess.cc:46
zypp::ZYPP_DECLARE_OPERATORS_FOR_FLAGS
ZYPP_DECLARE_OPERATORS_FOR_FLAGS(DiskUsageCounter::MountPoint::HintFlags)
zypp::MediaSetAccess::ReleaseFileGuard::NON_MOVABLE
NON_MOVABLE(ReleaseFileGuard)
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
zypp::MediaSetAccess::ReleaseFileGuard::_loc
const OnMediaLocation & _loc
Definition: MediaSetAccess.h:257
zypp::filesystem::DirContent
std::list< DirEntry > DirContent
Returned by readdir.
Definition: PathInfo.h:547
zypp::MediaSetAccess::ProvideOperation
function< void(media::MediaAccessId, const Pathname &)> ProvideOperation
Definition: MediaSetAccess.h:342
zypp::MediaSetAccess::PROVIDE_DEFAULT
The user is not asked anything, and the error exception is just propagated.
Definition: MediaSetAccess.h:119
zypp::MediaSetAccess::ReleaseFileGuard::_media
MediaSetAccess & _media
Definition: MediaSetAccess.h:256
zypp::MediaSetAccess::operator<<
friend std::ostream & operator<<(std::ostream &str, const MediaSetAccess &obj)
zypp::MediaSetAccess::ReleaseFileGuard::~ReleaseFileGuard
~ReleaseFileGuard()
Definition: MediaSetAccess.h:253
zypp::MediaSetAccess::provideFileInternal
Pathname provideFileInternal(const OnMediaLocation &resource, ProvideFileOptions options)
Provides the file from medium number media_nr and returns its local path.
zypp::MediaSetAccess::_verifiers
VerifierMap _verifiers
Mapping between media number and corespondent verifier.
Definition: MediaSetAccess.h:369
zypp::MediaSetAccess::ReleaseFileGuard::ReleaseFileGuard
ReleaseFileGuard(MediaSetAccess &media_r, const OnMediaLocation &loc_r)
Definition: MediaSetAccess.h:249
zypp::MediaSetAccess::setVerifier
void setVerifier(unsigned media_nr, media::MediaVerifierRef verifier)
Sets a MediaVerifier verifier for given media number.
Definition: MediaSetAccess.cc:58
zypp::AutoDispose
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition: AutoDispose.h:92
ReferenceCounted.h
Function.h
zypp::filesystem::Pathname
Pathname.
Definition: Pathname.h:44
verifier
MediaVerifierRef verifier
Definition: MediaManager.cc:104
zypp::MediaSetAccess::provideFile
Pathname provideFile(const OnMediaLocation &resource, ProvideFileOptions options=PROVIDE_DEFAULT, const Pathname &deltafile=Pathname())
Provides a file from a media location.
Definition: MediaSetAccess.cc:161
Flags.h
zypp::MediaSetAccess
Media access layer responsible for handling files distributed on a set of media with media change and...
Definition: MediaSetAccess.h:80
str
String related utilities and Regular expression matching.
ManagedFile.h
zypp::MediaSetAccess::provide
void provide(ProvideOperation op, const OnMediaLocation &resource, ProvideFileOptions options, const Pathname &deltafile)
Definition: MediaSetAccess.cc:232
url
Url url
Definition: MediaCurl.cc:66
zypp::MediaSetAccess::provideDir
Pathname provideDir(const Pathname &dir, bool recursive, unsigned media_nr=1, ProvideFileOptions options=PROVIDE_DEFAULT)
Provides direcotry dir from media number media_nr.
Definition: MediaSetAccess.cc:387
zypp::Url
Url manipulation class.
Definition: Url.h:87
zypp::MediaSetAccess::provideOptionalFileFromUrl
static ManagedFile provideOptionalFileFromUrl(const Url &file_url)
Provides an optional file from url.
Definition: MediaSetAccess.cc:210
zypp::MediaSetAccess::MediaSetAccess
MediaSetAccess(const Url &url, const Pathname &prefered_attach_point="")
Creates a callback enabled media access for specified url.
Definition: MediaSetAccess.cc:32
zypp::MediaSetAccess::getMediaAccessId
media::MediaAccessId getMediaAccessId(media::MediaNr medianr)
Definition: MediaSetAccess.cc:405
NonCopyable.h