libzypp 17.37.10

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
18#include <zypp/base/ReferenceCounted.h>
19#include <zypp/base/NonCopyable.h>
20#include <zypp/base/Flags.h>
21#include <zypp/base/PtrTypes.h>
22#include <zypp/media/MediaManager.h>
23#include <zypp/Pathname.h>
24#include <zypp/CheckSum.h>
25#include <zypp-core/OnMediaLocation>
26#include <zypp/ManagedFile.h>
27#include <zypp-core/MirroredOrigin.h>
28
30 namespace zypp
31{
32
33 DEFINE_PTR_TYPE(MediaSetAccess);
34
36 //
37 // CLASS NAME : MediaSetAccess
38 //
81 class ZYPP_API MediaSetAccess : public base::ReferenceCounted, private base::NonCopyable
82 {
83 friend std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj );
84
85 public:
93 MediaSetAccess( Url url, Pathname prefered_attach_point = "" );
95 MediaSetAccess( std::string label_r, Url url, Pathname prefered_attach_point = "" );
96
104 MediaSetAccess( MirroredOrigin origin, Pathname prefered_attach_point = "" );
106 MediaSetAccess( std::string label_r, MirroredOrigin origin, Pathname prefered_attach_point = "" );
107
108
109 MediaSetAccess(const MediaSetAccess &) = delete;
110 MediaSetAccess(MediaSetAccess &&) = delete;
111 MediaSetAccess &operator=(const MediaSetAccess &) = delete;
112 MediaSetAccess &operator=(MediaSetAccess &&) = delete;
113
114 ~MediaSetAccess() override;
115
119 void setVerifier( unsigned media_nr, const media::MediaVerifierRef& verifier );
120
124 const std::string & label() const;
125
129 void setLabel( const std::string & label_r );
130
131 enum ProvideFileOption
132 {
136 PROVIDE_DEFAULT = 0x0,
137 PROVIDE_NON_INTERACTIVE = 0x1
138 };
139 ZYPP_DECLARE_FLAGS(ProvideFileOptions,ProvideFileOption);
140
151 void precacheFiles(const std::vector<OnMediaLocation> &files);
152
180 Pathname provideFile( const OnMediaLocation & resource, ProvideFileOptions options = PROVIDE_DEFAULT );
181
185 ZYPP_DEPRECATED Pathname provideFile( const OnMediaLocation & resource, ProvideFileOptions options, const Pathname &deltafile );
186
207 Pathname provideFile(const Pathname & file, unsigned media_nr = 1, ProvideFileOptions options = PROVIDE_DEFAULT );
208
216 Pathname provideOptionalFile( const Pathname & file, unsigned media_nr = 1 );
217
235 static ManagedFile provideFileFromUrl( const Url & file_url, ProvideFileOptions options = PROVIDE_DEFAULT );
236
244 static ManagedFile provideOptionalFileFromUrl( const Url & file_url );
245
252 void releaseFile( const OnMediaLocation &resource );
253
254
262 void releaseFile(const Pathname & file, unsigned media_nr = 1 );
263
279 struct ReleaseFileGuard
280 {
281 NON_COPYABLE( ReleaseFileGuard );
282 NON_MOVABLE( ReleaseFileGuard );
283 ReleaseFileGuard( MediaSetAccess & media_r, const OnMediaLocation & loc_r )
284 : _media( media_r )
285 , _loc( loc_r )
286 {}
287 ~ReleaseFileGuard()
288 { _media.releaseFile( _loc ); }
289 private:
290 MediaSetAccess & _media;
291 const OnMediaLocation & _loc;
292 };
293
311 Pathname provideDir(const Pathname & dir, bool recursive, unsigned media_nr = 1, ProvideFileOptions options = PROVIDE_DEFAULT );
312
327 bool doesFileExist(const Pathname & file, unsigned media_nr = 1 );
328
332 void dirInfo( filesystem::DirContent &retlist, const Pathname &dirname,
333 bool dots = true, unsigned media_nr = 1 );
334
340 void release();
341
356 static Url rewriteUrl (const Url & url_r, const media::MediaNr medianr);
357
358 protected:
374 Pathname provideFileInternal( const OnMediaLocation &resource, ProvideFileOptions options );
375
376 using ProvideOperation = function<void (media::MediaAccessId, const OnMediaLocation &)>;
377
378 void provide( const ProvideOperation& op, const OnMediaLocation &resource, ProvideFileOptions options );
379
380 media::MediaAccessId getMediaAccessId (media::MediaNr medianr);
381 std::ostream & dumpOn( std::ostream & str ) const override;
382
383 private:
384 class Impl;
386 std::unique_ptr<Impl> _pimpl;
387 };
388
389 ZYPP_DECLARE_OPERATORS_FOR_FLAGS(MediaSetAccess::ProvideFileOptions);
390
392 inline std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj )
393 { return obj.dumpOn( str ); }
394
395
396} // namespace zypp
398#endif // ZYPP_SOURCE_MediaSetAccess_H
MediaManager.h
MirroredOrigin.h
zypp::MediaSetAccess::Impl
Definition MediaSetAccess.cc:35
zypp::MediaSetAccess
Media access layer responsible for handling files distributed on a set of media with media change and...
Definition MediaSetAccess.h:82
zypp::MediaSetAccess::MediaSetAccess
MediaSetAccess(const MediaSetAccess &)=delete
zypp::MediaSetAccess::ZYPP_DECLARE_FLAGS
ZYPP_DECLARE_FLAGS(ProvideFileOptions, ProvideFileOption)
zypp::MediaSetAccess::getMediaAccessId
media::MediaAccessId getMediaAccessId(media::MediaNr medianr)
Definition MediaSetAccess.cc:460
zypp::MediaSetAccess::provideDir
Pathname provideDir(const Pathname &dir, bool recursive, unsigned media_nr=1, ProvideFileOptions options=PROVIDE_DEFAULT)
Provides direcotry dir from media number media_nr.
Definition MediaSetAccess.cc:443
zypp::MediaSetAccess::precacheFiles
void precacheFiles(const std::vector< OnMediaLocation > &files)
Tries to fetch the given files and precaches them.
Definition MediaSetAccess.cc:280
zypp::MediaSetAccess::operator<<
friend std::ostream & operator<<(std::ostream &str, const MediaSetAccess &obj)
zypp::MediaSetAccess::setVerifier
void setVerifier(unsigned media_nr, const media::MediaVerifierRef &verifier)
Sets a MediaVerifier verifier for given media number.
Definition MediaSetAccess.cc:101
zypp::MediaSetAccess::MediaSetAccess
MediaSetAccess(Url url, Pathname prefered_attach_point="")
Creates a callback enabled media access for specified url.
Definition MediaSetAccess.cc:73
zypp::MediaSetAccess::operator=
MediaSetAccess & operator=(const MediaSetAccess &)=delete
zypp::MediaSetAccess::provideFileFromUrl
static ManagedFile provideFileFromUrl(const Url &file_url, ProvideFileOptions options=PROVIDE_DEFAULT)
Provides file from url.
Definition MediaSetAccess.cc:239
zypp::MediaSetAccess::provide
void provide(const ProvideOperation &op, const OnMediaLocation &resource, ProvideFileOptions options)
Definition MediaSetAccess.cc:300
zypp::MediaSetAccess::_pimpl
std::unique_ptr< Impl > _pimpl
Pointer to implementation.
Definition MediaSetAccess.h:386
zypp::MediaSetAccess::ProvideFileOption
ProvideFileOption
Definition MediaSetAccess.h:132
zypp::MediaSetAccess::PROVIDE_DEFAULT
@ PROVIDE_DEFAULT
The user is not asked anything, and the error exception is just propagated.
Definition MediaSetAccess.h:136
zypp::MediaSetAccess::PROVIDE_NON_INTERACTIVE
@ PROVIDE_NON_INTERACTIVE
Definition MediaSetAccess.h:137
zypp::MediaSetAccess::provideFile
Pathname provideFile(const OnMediaLocation &resource, ProvideFileOptions options=PROVIDE_DEFAULT)
Provides a file from a media location.
Definition MediaSetAccess.cc:207
zypp::MediaSetAccess::setLabel
void setLabel(const std::string &label_r)
Set the label identifing this media set and to be sent in a media change request.
Definition MediaSetAccess.cc:123
zypp::MediaSetAccess::provideOptionalFile
Pathname provideOptionalFile(const Pathname &file, unsigned media_nr=1)
Provides an optional file from media media_nr.
Definition MediaSetAccess.cc:224
zypp::MediaSetAccess::provideOptionalFileFromUrl
static ManagedFile provideOptionalFileFromUrl(const Url &file_url)
Provides an optional file from url.
Definition MediaSetAccess.cc:259
zypp::MediaSetAccess::doesFileExist
bool doesFileExist(const Pathname &file, unsigned media_nr=1)
Checks if a file exists on the specified media, with user callbacks.
Definition MediaSetAccess.cc:272
zypp::MediaSetAccess::dirInfo
void dirInfo(filesystem::DirContent &retlist, const Pathname &dirname, bool dots=true, unsigned media_nr=1)
Fills retlist with directory information.
Definition MediaSetAccess.cc:144
zypp::MediaSetAccess::operator=
MediaSetAccess & operator=(MediaSetAccess &&)=delete
zypp::MediaSetAccess::release
void release()
Release all attached media of this set.
Definition MediaSetAccess.cc:543
zypp::MediaSetAccess::provideFileInternal
Pathname provideFileInternal(const OnMediaLocation &resource, ProvideFileOptions options)
Provides the file from medium number media_nr and returns its local path.
zypp::MediaSetAccess::ProvideOperation
function< void(media::MediaAccessId, const OnMediaLocation &)> ProvideOperation
Definition MediaSetAccess.h:376
zypp::MediaSetAccess::rewriteUrl
static Url rewriteUrl(const Url &url_r, const media::MediaNr medianr)
Replaces media number in specified url with given medianr.
Definition MediaSetAccess.cc:500
zypp::MediaSetAccess::MediaSetAccess
MediaSetAccess(MediaSetAccess &&)=delete
zypp::MediaSetAccess::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload to realize std::ostream & operator<<.
Definition MediaSetAccess.cc:551
zypp::MediaSetAccess::releaseFile
void releaseFile(const OnMediaLocation &resource)
Release file from media.
Definition MediaSetAccess.cc:126
zypp::MediaSetAccess::label
const std::string & label() const
The label identifing this media set and to be sent in a media change request.
Definition MediaSetAccess.cc:120
zypp::MirroredOrigin
Manages a data source characterized by an authoritative URL and a list of mirror URLs.
Definition MirroredOrigin.h:170
zypp::OnMediaLocation
Describes a resource file located on a medium.
Definition onmedialocation.h:37
zypp::Url
Url manipulation class.
Definition Url.h:93
zypp::base::ReferenceCounted
Base class for reference counted objects.
Definition ReferenceCounted.h:35
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:47
str
String related utilities and Regular expression matching.
zypp::base::NonCopyable
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition NonCopyable.h:26
zypp::filesystem::DirContent
std::list< DirEntry > DirContent
Returned by readdir.
Definition PathInfo.h:526
zypp::media::MediaNr
unsigned int MediaNr
Definition MediaManager.h:32
zypp::media::MediaAccessId
unsigned int MediaAccessId
Media manager access Id type.
Definition MediaSource.h:30
zypp::media::MediaVerifierRef
zypp::RW_pointer< MediaVerifierBase > MediaVerifierRef
A shared reference to the MediaVerifier implementation.
Definition MediaManager.h:107
zypp::url
Url details namespace.
Definition UrlBase.cc:58
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::ManagedFile
AutoDispose< const Pathname > ManagedFile
A Pathname plus associated cleanup code to be executed when path is no longer needed.
Definition ManagedFile.h:27
zypp::dumpOn
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition Capability.cc:580
zypp::ZYPP_API
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
zypp::MediaSetAccess::ReleaseFileGuard::~ReleaseFileGuard
~ReleaseFileGuard()
Definition MediaSetAccess.h:287
zypp::MediaSetAccess::ReleaseFileGuard::NON_COPYABLE
NON_COPYABLE(ReleaseFileGuard)
zypp::MediaSetAccess::ReleaseFileGuard::_media
MediaSetAccess & _media
Definition MediaSetAccess.h:290
zypp::MediaSetAccess::ReleaseFileGuard::ReleaseFileGuard
ReleaseFileGuard(MediaSetAccess &media_r, const OnMediaLocation &loc_r)
Definition MediaSetAccess.h:283
zypp::MediaSetAccess::ReleaseFileGuard::NON_MOVABLE
NON_MOVABLE(ReleaseFileGuard)
zypp::MediaSetAccess::ReleaseFileGuard::_loc
const OnMediaLocation & _loc
Definition MediaSetAccess.h:291
ZYPP_DEPRECATED
#define ZYPP_DEPRECATED
The ZYPP_DEPRECATED macro can be used to trigger compile-time warnings with gcc >= 3....
Definition Globals.h:112
ZYPP_DECLARE_OPERATORS_FOR_FLAGS
#define ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Name)
Definition Flags.h:177
DEFINE_PTR_TYPE
#define DEFINE_PTR_TYPE(NAME)
Forward declaration of Ptr types.
Definition PtrTypes.h:639
CheckSum.h
ManagedFile.h
Pathname.h
Flags.h
Function.h
NonCopyable.h
PtrTypes.h
ReferenceCounted.h