libzypp  17.1.3
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  //
80  {
81  friend std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj );
82 
83  public:
91  MediaSetAccess( const Url &url, const Pathname & prefered_attach_point = "" );
93  MediaSetAccess( const std::string & label_r, const Url &url, const Pathname & prefered_attach_point = "" );
95 
99  void setVerifier( unsigned media_nr, media::MediaVerifierRef verifier );
100 
104  const std::string & label() const
105  { return _label; }
106 
110  void setLabel( const std::string & label_r )
111  { _label = label_r; }
112 
114  {
120  };
121  ZYPP_DECLARE_FLAGS(ProvideFileOptions,ProvideFileOption);
122 
150  Pathname provideFile( const OnMediaLocation & resource, ProvideFileOptions options = PROVIDE_DEFAULT, const Pathname &deltafile = Pathname() );
151 
172  Pathname provideFile(const Pathname & file, unsigned media_nr = 1, ProvideFileOptions options = PROVIDE_DEFAULT );
173 
181  Pathname provideOptionalFile( const Pathname & file, unsigned media_nr = 1 );
182 
189  void releaseFile( const OnMediaLocation &resource );
190 
191 
199  void releaseFile(const Pathname & file, unsigned media_nr = 1 );
200 
218  Pathname provideDir(const Pathname & dir, bool recursive, unsigned media_nr = 1, ProvideFileOptions options = PROVIDE_DEFAULT );
219 
234  bool doesFileExist(const Pathname & file, unsigned media_nr = 1 );
235 
239  void dirInfo( filesystem::DirContent &retlist, const Pathname &dirname,
240  bool dots = true, unsigned media_nr = 1 );
241 
247  void release();
248 
263  static Url rewriteUrl (const Url & url_r, const media::MediaNr medianr);
264 
265  protected:
281  Pathname provideFileInternal( const OnMediaLocation &resource, ProvideFileOptions options );
282 
283  typedef function<void( media::MediaAccessId, const Pathname & )> ProvideOperation;
284 
285  void provide( ProvideOperation op, const OnMediaLocation &resource, ProvideFileOptions options, const Pathname &deltafile );
286 
288  virtual std::ostream & dumpOn( std::ostream & str ) const;
289 
290  private:
293 
301 
302  std::string _label;
303 
304  typedef std::map<media::MediaNr, media::MediaAccessId> MediaMap;
305  typedef std::map<media::MediaNr, media::MediaVerifierRef > VerifierMap;
306 
308  MediaMap _medias;
310  VerifierMap _verifiers;
311  };
313  ZYPP_DECLARE_OPERATORS_FOR_FLAGS(MediaSetAccess::ProvideFileOptions);
314 
316  inline std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj )
317  { return obj.dumpOn( str ); }
318 
319 
320 } // namespace zypp
322 #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 provideOptionalFile(const Pathname &file, unsigned media_nr=1)
Provides an optional file from media media_nr.
Pathname provideDir(const Pathname &dir, bool recursive, unsigned media_nr=1, ProvideFileOptions options=PROVIDE_DEFAULT)
Provides direcotry dir from media number media_nr.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload to realize std::ostream & operator<<.
ZYPP_DECLARE_OPERATORS_FOR_FLAGS(DiskUsageCounter::MountPoint::HintFlags)
String related utilities and Regular expression matching.
bool doesFileExist(const Pathname &file, unsigned media_nr=1)
Checks if a file exists on the specified media, with user callbacks.
Url url
Definition: MediaCurl.cc:196
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)
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
void dirInfo(filesystem::DirContent &retlist, const Pathname &dirname, bool dots=true, unsigned media_nr=1)
Fills retlist with directory information.
DEFINE_PTR_TYPE(Application)
std::list< DirEntry > DirContent
Returned by readdir.
Definition: PathInfo.h:547
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:285
friend std::ostream & operator<<(std::ostream &str, const MediaSetAccess &obj)
media::MediaAccessId getMediaAccessId(media::MediaNr medianr)
const std::string & label() const
The label identifing this media set and to be sent in a media change request.
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
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.
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.