libzypp  13.10.6
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 
28 namespace zypp
29 {
30 
31  DEFINE_PTR_TYPE(MediaSetAccess);
32 
34  //
35  // CLASS NAME : MediaSetAccess
36  //
78  {
79  friend std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj );
80 
81  public:
89  MediaSetAccess( const Url &url, const Pathname & prefered_attach_point = "" );
91  MediaSetAccess( const std::string & label_r, const Url &url, const Pathname & prefered_attach_point = "" );
93 
97  void setVerifier( unsigned media_nr, media::MediaVerifierRef verifier );
98 
102  const std::string & label() const
103  { return _label; }
104 
108  void setLabel( const std::string & label_r )
109  { _label = label_r; }
110 
112  {
118  };
119  ZYPP_DECLARE_FLAGS(ProvideFileOptions,ProvideFileOption);
120 
148  Pathname provideFile( const OnMediaLocation & resource, ProvideFileOptions options = PROVIDE_DEFAULT, const Pathname &deltafile = Pathname() );
149 
170  Pathname provideFile(const Pathname & file, unsigned media_nr = 1, ProvideFileOptions options = PROVIDE_DEFAULT );
171 
178  void releaseFile( const OnMediaLocation &resource );
179 
180 
188  void releaseFile(const Pathname & file, unsigned media_nr = 1 );
189 
207  Pathname provideDir(const Pathname & dir, bool recursive, unsigned media_nr = 1, ProvideFileOptions options = PROVIDE_DEFAULT );
208 
223  bool doesFileExist(const Pathname & file, unsigned media_nr = 1 );
224 
228  void dirInfo( filesystem::DirContent &retlist, const Pathname &dirname,
229  bool dots = true, unsigned media_nr = 1 );
230 
236  void release();
237 
252  static Url rewriteUrl (const Url & url_r, const media::MediaNr medianr);
253 
254  protected:
270  Pathname provideFileInternal( const OnMediaLocation &resource, ProvideFileOptions options );
271 
272  typedef function<void( media::MediaAccessId, const Pathname & )> ProvideOperation;
273 
274  void provide( ProvideOperation op, const OnMediaLocation &resource, ProvideFileOptions options, const Pathname &deltafile );
275 
277  virtual std::ostream & dumpOn( std::ostream & str ) const;
278 
279  private:
282 
290 
291  std::string _label;
292 
293  typedef std::map<media::MediaNr, media::MediaAccessId> MediaMap;
294  typedef std::map<media::MediaNr, media::MediaVerifierRef > VerifierMap;
295 
300  };
302  ZYPP_DECLARE_OPERATORS_FOR_FLAGS(MediaSetAccess::ProvideFileOptions);
303 
305  inline std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj )
306  { return obj.dumpOn( str ); }
307 
308 
309 } // namespace zypp
311 #endif // ZYPP_SOURCE_MediaSetAccess_H
void setLabel(const std::string &label_r)
Set the label identifing this media set and to be sent in a media change request. ...
void provide(ProvideOperation op, const OnMediaLocation &resource, ProvideFileOptions options, const Pathname &deltafile)
Describes a path on a certain media amongs as the information required to download it...
MediaMap _medias
Mapping between media number and Media Access ID.
Url _url
Media or media set URL.
Pathname provideDir(const Pathname &dir, bool recursive, unsigned media_nr=1, ProvideFileOptions options=PROVIDE_DEFAULT)
Provides direcotry dir from media number media_nr.
bool doesFileExist(const Pathname &file, unsigned media_nr=1)
Checks if a file exists on the specified media, with user callbacks.
Pathname _prefAttachPoint
Prefered mount point.
void release()
Release all attached media of this set.
static Url rewriteUrl(const Url &url_r, const media::MediaNr medianr)
Replaces media number in specified url with given medianr.
ZYPP_DECLARE_FLAGS(ProvideFileOptions, ProvideFileOption)
virtual std::ostream & dumpOn(std::ostream &str) const
Overload to realize std::ostream &amp; operator&lt;&lt;.
std::ostream & operator<<(std::ostream &str, const MediaSetAccess &obj)
std::map< media::MediaNr, media::MediaAccessId > MediaMap
unsigned int MediaAccessId
Media manager access Id type.
Definition: MediaSource.h:29
void releaseFile(const OnMediaLocation &resource)
Release file from media.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
DEFINE_PTR_TYPE(KeyRing)
void dirInfo(filesystem::DirContent &retlist, const Pathname &dirname, bool dots=true, unsigned media_nr=1)
Fills retlist with directory information.
std::list< DirEntry > DirContent
Returned by readdir.
Definition: PathInfo.h:544
zypp::Url url
Definition: MediaCurl.cc:193
Base class for reference counted objects.
std::map< media::MediaNr, media::MediaVerifierRef > VerifierMap
function< void(media::MediaAccessId, const Pathname &)> ProvideOperation
Pathname provideFileInternal(const OnMediaLocation &resource, ProvideFileOptions options)
Provides the file from medium number media_nr and returns its local path.
void setVerifier(unsigned media_nr, media::MediaVerifierRef verifier)
Sets a MediaVerifier verifier for given media number.
MediaVerifierRef verifier
Wrapper for const correct access via Smart pointer types.
Definition: PtrTypes.h:265
friend std::ostream & operator<<(std::ostream &str, const MediaSetAccess &obj)
media::MediaAccessId getMediaAccessId(media::MediaNr medianr)
Pathname provideFile(const OnMediaLocation &resource, ProvideFileOptions options=PROVIDE_DEFAULT, const Pathname &deltafile=Pathname())
Provides a file from a media location.
MediaSetAccess(const Url &url, const Pathname &prefered_attach_point="")
Creates a callback enabled media access for specified url.
ZYPP_DECLARE_OPERATORS_FOR_FLAGS(FetcherJob::Flags)
const std::string & label() const
The label identifing this media set and to be sent in a media change request.
VerifierMap _verifiers
Mapping between media number and corespondent verifier.
Url manipulation class.
Definition: Url.h:87
Media access layer responsible for handling files distributed on a set of media with media change and...
unsigned int MediaNr
Definition: MediaManager.h:40
The user is not asked anything, and the error exception is just propagated.