libzypp 17.32.5
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
13#include <zypp-media/ng/Provide>
14#include <zypp/MediaSetAccess.h>
16
17
18#include <vector>
19
20namespace zyppng {
23
24
26 public:
27
29
31 SyncMediaHandle( AttachedSyncMediaInfo_Ptr dataPtr );
32 MediaSyncFacadeRef parent() const;
33 bool isValid () const;
34 const zypp::Url &baseUrl() const;
35 const std::optional<zypp::Pathname> &localPath() const;
36 const AttachedSyncMediaInfo &info ()const;
37
38 private:
39 AttachedSyncMediaInfo_Ptr _data;
40 };
41
47 class MediaSyncFacade : public Base
48 {
50 public:
51
53
55
56 class Res {
57 public:
58
60
64 const zypp::Pathname file () const;
65
72 return _res;
73 }
74
75 private:
78 };
79
81 ~MediaSyncFacade() override;
82
83 expected<MediaHandle> attachMedia( const std::vector<zypp::Url> &urls, const ProvideMediaSpec &request );
85
86 expected<Res> provide( const std::vector<zypp::Url> &urls, const ProvideFileSpec &request );
89
90
95
100 expected<zypp::ManagedFile> copyFile ( Res source, const zypp::Pathname &target );
101
102 static auto copyResultToDest ( MediaSyncFacadeRef provider, const zypp::Pathname &targetPath ) {
103 return [ providerRef=std::move(provider), targetPath = targetPath ]( Res &&file ){
104 zypp::filesystem::assert_dir( targetPath.dirname () );
105 return providerRef->copyFile( std::move(file), targetPath );
106 };
107 }
108
109 protected:
111
112 private:
113 std::vector<AttachedSyncMediaInfo_Ptr> _attachedMedia;
114 };
115
117
118 //template <bool async>
119 //using MediaFacade = std::conditional_t<async, MediaAsyncFacade, MediaSyncFacade>;
120}
121
122
123
124#endif
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition AutoDispose.h:95
Url manipulation class.
Definition Url.h:92
Pathname dirname() const
Return all but the last component od this path.
Definition Pathname.h:124
const zypp::ManagedFile & asManagedFile() const
Definition mediafacade.h:71
Res(MediaHandle hdl, zypp::ManagedFile file)
const zypp::Pathname file() const
expected< Res > provide(const std::vector< zypp::Url > &urls, const ProvideFileSpec &request)
expected< MediaHandle > attachMedia(const std::vector< zypp::Url > &urls, const ProvideMediaSpec &request)
expected< zypp::CheckSum > checksumForFile(const zypp::Pathname &p, const std::string &algorithm)
expected< zypp::ManagedFile > copyFile(const zypp::Pathname &source, const zypp::Pathname &target)
ZYPP_ADD_CREATE_FUNC(MediaSyncFacade)
std::vector< AttachedSyncMediaInfo_Ptr > _attachedMedia
static auto copyResultToDest(MediaSyncFacadeRef provider, const zypp::Pathname &targetPath)
ZYPP_DECL_PRIVATE_CONSTR(MediaSyncFacade)
void releaseMedium(const AttachedSyncMediaInfo *ptr)
const std::optional< zypp::Pathname > & localPath() const
const AttachedSyncMediaInfo & info() const
MediaSyncFacadeRef parent() const
const zypp::Url & baseUrl() const
AttachedSyncMediaInfo_Ptr _data
Definition mediafacade.h:39
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
Definition PathInfo.cc:320
#define DEFINE_PTR_TYPE(NAME)
Forward declaration of Ptr types.
Definition PtrTypes.h:638
#define ZYPP_FWD_DECL_TYPE_WITH_REFS(T)
Definition zyppglobal.h:117