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"
24 #include "zypp/OnMediaLocation.h"
26 ///////////////////////////////////////////////////////////////////
28 { /////////////////////////////////////////////////////////////////
30 DEFINE_PTR_TYPE(MediaSetAccess);
32 typedef boost::function<bool ( const Pathname &file )> FileChecker;
37 bool operator()( const Pathname &file );
40 class ChecksumFileChecker
43 ChecksumFileChecker( const CheckSum &checksum );
44 bool operator()( const Pathname &file );
49 ///////////////////////////////////////////////////////////////////
51 // CLASS NAME : SourceCache
56 class MediaSetAccess : public base::ReferenceCounted, private base::NonCopyable
58 friend std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj );
62 * creates a callback enabled media access for \param url and \param path.
63 * with only 1 media no verified
65 MediaSetAccess( const Url &url, const Pathname &path );
69 * Sets a \ref MediaVerifierRef verifier for given media number
71 void setVerifier( unsigned media_nr, media::MediaVerifierRef verifier );
74 * provide a file from a media location.
76 Pathname provideFile( const OnMediaLocation & on_media_file );
78 Pathname provideFile(const Pathname & file, unsigned media_nr = 1 );
79 Pathname provideFile(const Pathname & file, unsigned media_nr, const FileChecker checker );
82 Pathname provideFileInternal(const Pathname & file, unsigned media_nr, bool checkonly, bool cached);
83 Url rewriteUrl (const Url & url_r, const media::MediaNr medianr);
84 media::MediaAccessId getMediaAccessId (media::MediaNr medianr);
85 virtual std::ostream & dumpOn( std::ostream & str ) const;
89 typedef std::map<media::MediaNr, media::MediaAccessId> MediaMap;
90 typedef std::map<media::MediaNr, media::MediaVerifierRef > VerifierMap;
91 /** Mapping between each CD and Media Access ID */
93 VerifierMap _verifiers;
95 ///////////////////////////////////////////////////////////////////
97 /** \relates MediaSetAccess Stream output */
98 inline std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj )
99 { return obj.dumpOn( str ); }
103 ///////////////////////////////////////////////////////////////////
104 #endif // ZYPP_SOURCE_MediaSetAccess_H