1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
10 #ifndef ZYPP_MediaSetAccess_H
11 #define ZYPP_MediaSetAccess_H
16 #include <boost/function.hpp>
18 #include "zypp/base/ReferenceCounted.h"
19 #include "zypp/base/NonCopyable.h"
20 #include "zypp/base/PtrTypes.h"
21 #include "zypp/media/MediaManager.h"
22 #include "zypp/Pathname.h"
23 #include "zypp/CheckSum.h"
25 ///////////////////////////////////////////////////////////////////
27 { /////////////////////////////////////////////////////////////////
29 DEFINE_PTR_TYPE(MediaSetAccess);
32 class MediaVerifier : public zypp::media::MediaVerifierBase
36 MediaVerifier(const std::string & vendor_r, const std::string & id_r, const media::MediaNr media_nr = 1);
38 * Check if the specified attached media contains
39 * the desired media number (e.g. SLES10 CD1).
41 virtual bool isDesiredMedia(const media::MediaAccessRef &ref);
43 std::string _media_vendor;
44 std::string _media_id;
45 media::MediaNr _media_nr;
57 typedef boost::function<bool ( const Pathname &file )> FileChecker;
62 bool operator()( const Pathname &file );
65 class ChecksumFileChecker
68 ChecksumFileChecker( const CheckSum &checksum );
69 bool operator()( const Pathname &file );
74 ///////////////////////////////////////////////////////////////////
76 // CLASS NAME : SourceCache
78 class MediaSetAccess : public base::ReferenceCounted, private base::NonCopyable
80 friend std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj );
84 * creates a callback enabled media access for \param url and \param path.
85 * with only media no verified
87 MediaSetAccess( const Url &url, const Pathname &path );
90 * the media change callbacks depend on the verifiers given for each media.
92 void setVerifiers( const std::vector<media::MediaVerifierRef> &verifiers );
93 Pathname provideFile(const Pathname & file, unsigned media_nr = 1 );
94 Pathname provideFile(const Pathname & file, unsigned media_nr, const FileChecker checker );
95 void providePossiblyCachedMetadataFile( const Pathname &file_to_download, unsigned medianr, const Pathname &destination, const Pathname &cached_file, const CheckSum &checksum );
97 Pathname provideFileInternal(const Pathname & file, unsigned media_nr, bool checkonly, bool cached);
98 Url rewriteUrl (const Url & url_r, const media::MediaNr medianr);
99 media::MediaAccessId getMediaAccessId (media::MediaNr medianr);
100 virtual std::ostream & dumpOn( std::ostream & str ) const;
104 std::vector<media::MediaVerifierRef> _verifiers;
105 typedef std::map<media::MediaNr, media::MediaAccessId> MediaMap;
106 /** Mapping between each CD and Media Access ID */
109 ///////////////////////////////////////////////////////////////////
111 /** \relates MediaSetAccess Stream output */
112 inline std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj )
113 { return obj.dumpOn( str ); }
117 ///////////////////////////////////////////////////////////////////
118 #endif // ZYPP_SOURCE_MediaSetAccess_H