MediaSetAccess.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef ZYPP_MediaSetAccess_H
00011 #define ZYPP_MediaSetAccess_H
00012
00013 #include <iosfwd>
00014 #include <string>
00015 #include <vector>
00016 #include <zypp/base/Function.h>
00017
00018 #include "zypp/base/ReferenceCounted.h"
00019 #include "zypp/base/NonCopyable.h"
00020 #include "zypp/base/Flags.h"
00021 #include "zypp/base/PtrTypes.h"
00022 #include "zypp/media/MediaManager.h"
00023 #include "zypp/Pathname.h"
00024 #include "zypp/CheckSum.h"
00025 #include "zypp/OnMediaLocation.h"
00026
00028 namespace zypp
00029 {
00030
00031 DEFINE_PTR_TYPE(MediaSetAccess);
00032
00034
00035
00036
00077 class MediaSetAccess : public base::ReferenceCounted, private base::NonCopyable
00078 {
00079 friend std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj );
00080
00081 public:
00089 MediaSetAccess( const Url &url, const Pathname & prefered_attach_point = "" );
00091 MediaSetAccess( const std::string & label_r, const Url &url, const Pathname & prefered_attach_point = "" );
00092 ~MediaSetAccess();
00093
00097 void setVerifier( unsigned media_nr, media::MediaVerifierRef verifier );
00098
00102 const std::string & label() const
00103 { return _label; }
00104
00108 void setLabel( const std::string & label_r )
00109 { _label = label_r; }
00110
00111 enum ProvideFileOption
00112 {
00116 PROVIDE_DEFAULT = 0x0,
00117 PROVIDE_NON_INTERACTIVE = 0x1
00118 };
00119 ZYPP_DECLARE_FLAGS(ProvideFileOptions,ProvideFileOption);
00120
00145 Pathname provideFile( const OnMediaLocation & resource, ProvideFileOptions options = PROVIDE_DEFAULT );
00146
00167 Pathname provideFile(const Pathname & file, unsigned media_nr = 1, ProvideFileOptions options = PROVIDE_DEFAULT );
00168
00175 void releaseFile( const OnMediaLocation &resource );
00176
00177
00185 void releaseFile(const Pathname & file, unsigned media_nr = 1 );
00186
00204 Pathname provideDir(const Pathname & dir, bool recursive, unsigned media_nr = 1, ProvideFileOptions options = PROVIDE_DEFAULT );
00205
00220 bool doesFileExist(const Pathname & file, unsigned media_nr = 1 );
00221
00225 void dirInfo( filesystem::DirContent &retlist, const Pathname &dirname,
00226 bool dots = true, unsigned media_nr = 1 );
00227
00233 void release();
00234
00249 static Url rewriteUrl (const Url & url_r, const media::MediaNr medianr);
00250
00251 protected:
00267 Pathname provideFileInternal( const OnMediaLocation &resource, ProvideFileOptions options );
00268
00269 typedef function<void( media::MediaAccessId, const Pathname & )> ProvideOperation;
00270
00271 void provide( ProvideOperation op, const OnMediaLocation &resource, ProvideFileOptions options );
00272
00273 media::MediaAccessId getMediaAccessId (media::MediaNr medianr);
00274 virtual std::ostream & dumpOn( std::ostream & str ) const;
00275
00276 private:
00278 Url _url;
00279
00286 Pathname _prefAttachPoint;
00287
00288 std::string _label;
00289
00290 typedef std::map<media::MediaNr, media::MediaAccessId> MediaMap;
00291 typedef std::map<media::MediaNr, media::MediaVerifierRef > VerifierMap;
00292
00294 MediaMap _medias;
00296 VerifierMap _verifiers;
00297 };
00299 ZYPP_DECLARE_OPERATORS_FOR_FLAGS(MediaSetAccess::ProvideFileOptions);
00300
00302 inline std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj )
00303 { return obj.dumpOn( str ); }
00304
00305
00306 }
00308 #endif // ZYPP_SOURCE_MediaSetAccess_H