libzypp 17.37.17
mediafacade.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
9#ifndef ZYPP_NG_MEDIASETFACADE_INCLUDED
10#define ZYPP_NG_MEDIASETFACADE_INCLUDED
11
14#include <zypp-media/ng/Provide>
15#include <zypp-media/ng/LazyMediaHandle>
16#include <zypp/MediaSetAccess.h>
18
19#include <vector>
20
21namespace zyppng {
24
25
27 public:
28
30
32 SyncMediaHandle( AttachedSyncMediaInfo_Ptr dataPtr );
33 MediaSyncFacadeRef parent() const;
34 bool isValid () const;
35 const zypp::Url &baseUrl() const;
36 const std::optional<zypp::Pathname> &localPath() const;
37 const AttachedSyncMediaInfo &info ()const;
38
39 private:
40 AttachedSyncMediaInfo_Ptr _data;
41 };
42
49 {
51 public:
52
54
57
58 class Res {
59 public:
60
62
66 const zypp::Pathname file () const;
67
74 return _res;
75 }
76
77 private:
80 };
81
83 ~MediaSyncFacade() override;
84
87
91
92 expected<Res> provide( const zypp::MirroredOrigin &origin, const ProvideFileSpec &request );
93 expected<Res> provide( const zypp::Url &url, const ProvideFileSpec &request );
94 expected<Res> provide( const MediaHandle &attachHandle, const zypp::Pathname &fileName, const ProvideFileSpec &request );
95 expected<Res> provide( const LazyMediaHandle &attachHandle, const zypp::Pathname &fileName, const ProvideFileSpec &request );
96
97
101 expected<zypp::CheckSum> checksumForFile ( const zypp::Pathname &p, const std::string &algorithm );
102
108
109 static auto copyResultToDest ( MediaSyncFacadeRef provider, const zypp::Pathname &targetPath ) {
110 return [ providerRef=std::move(provider), targetPath = targetPath ]( Res &&file ){
111 zypp::filesystem::assert_dir( targetPath.dirname () );
112 return providerRef->copyFile( std::move(file), targetPath );
113 };
114 }
115
116 protected:
117 void releaseMedium ( const AttachedSyncMediaInfo *ptr );
118
119 private:
120 zypp::MirroredOrigin sanitizeUrls(const zypp::MirroredOrigin &origin) const;
121 std::vector<AttachedSyncMediaInfo_Ptr> _attachedMedia;
122 };
123
125
126 //template <bool async>
127 //using MediaFacade = std::conditional_t<async, MediaAsyncFacade, MediaSyncFacade>;
128}
129
130
131
132#endif
Manages a data source characterized by an authoritative URL and a list of mirror URLs.
Url manipulation class.
Definition Url.h:93
Pathname dirname() const
Return all but the last component od this path.
Definition Pathname.h:126
const zypp::ManagedFile & asManagedFile() const
Definition mediafacade.h:73
Res(MediaHandle hdl, zypp::ManagedFile file)
const zypp::Pathname file() const
friend class AttachedSyncMediaInfo
Definition mediafacade.h:53
expected< zypp::CheckSum > checksumForFile(const zypp::Pathname &p, const std::string &algorithm)
::zyppng::LazyMediaHandle< MediaSyncFacade > LazyMediaHandle
Definition mediafacade.h:56
expected< Res > provide(const zypp::MirroredOrigin &origin, const ProvideFileSpec &request)
expected< LazyMediaHandle > prepareMedia(const zypp::MirroredOrigin &origin, const ProvideMediaSpec &request)
expected< zypp::ManagedFile > copyFile(const zypp::Pathname &source, const zypp::Pathname &target)
SyncMediaHandle MediaHandle
Definition mediafacade.h:55
std::vector< AttachedSyncMediaInfo_Ptr > _attachedMedia
static auto copyResultToDest(MediaSyncFacadeRef provider, const zypp::Pathname &targetPath)
expected< MediaHandle > attachMedia(const zypp::MirroredOrigin &origin, const ProvideMediaSpec &request)
expected< MediaHandle > attachMediaIfNeeded(LazyMediaHandle lazyHandle)
ZYPP_DECL_PRIVATE_CONSTR(MediaSyncFacade)
const std::optional< zypp::Pathname > & localPath() const
MediaSyncFacade ParentType
Definition mediafacade.h:29
const AttachedSyncMediaInfo & info() const
MediaSyncFacadeRef parent() const
const zypp::Url & baseUrl() const
AttachedSyncMediaInfo_Ptr _data
Definition mediafacade.h:40
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
Definition PathInfo.cc:324
Url details namespace.
Definition UrlBase.cc:58
AutoDispose< const Pathname > ManagedFile
A Pathname plus associated cleanup code to be executed when path is no longer needed.
Definition ManagedFile.h:27
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
MediaSyncFacade::Res SyncProvideRes
#define DEFINE_PTR_TYPE(NAME)
Forward declaration of Ptr types.
Definition PtrTypes.h:639
#define ZYPP_ADD_CREATE_FUNC(Class)
Definition zyppglobal.h:205
#define ZYPP_FWD_DECL_TYPE_WITH_REFS(T)
Definition zyppglobal.h:126