libzypp 17.36.7

onmedialocation.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#include <iostream>
13//#include <zypp/base/Logger.h>
14
15#include <utility>
16#include <zypp-core/OnMediaLocation>
17
18 using std::endl;
19
21 namespace zypp
22{
27 class OnMediaLocation::Impl
28 {
29 public:
30 Impl()
31 {}
32
33 Impl( Pathname filename_r, unsigned medianr_r )
34 : _filename { std::move(filename_r) }
35 , _medianr { medianr_r }
36 {}
37
38 Pathname _filename;
39 unsigned _medianr = 0U;
40
41 bool _optional = false;
42
43 ByteCount _downloadSize;
44 CheckSum _checksum;
45
46 ByteCount _openSize;
47 CheckSum _openChecksum;
48
49 ByteCount _headerSize;
50 CheckSum _headerChecksum;
51
52 Pathname _deltafile;
53
54 public:
56 static shared_ptr<Impl> nullimpl()
57 { static shared_ptr<Impl> _nullimpl( new Impl ); return _nullimpl; }
58 private:
59 friend Impl * rwcowClone<Impl>( const Impl * rhs );
61 Impl * clone() const { return new Impl( *this ); }
62 };
63
65 inline std::ostream & operator<<( std::ostream & str, const OnMediaLocation::Impl & obj )
66 { return str << "[" << obj._medianr << "]" << obj._filename << "{" << obj._downloadSize << "|" << obj._checksum << "|" << obj._deltafile << "}"; }
67
69 inline std::ostream & dumpOn( std::ostream & str, const OnMediaLocation::Impl & obj )
70 { return str << obj; }
71
73 // CLASS NAME : OnMediaLocation
75
76 OnMediaLocation::OnMediaLocation()
77 : _pimpl( Impl::nullimpl() )
78 {}
79
80 OnMediaLocation::OnMediaLocation( Pathname filename_r, unsigned medianr_r )
81 : _pimpl( new Impl( std::move(filename_r), medianr_r ) )
82 {}
83
84 OnMediaLocation::~OnMediaLocation()
85 {}
86
87
88 const Pathname & OnMediaLocation::filename() const
89 { return _pimpl->_filename; }
90
91 unsigned OnMediaLocation::medianr() const
92 { return _pimpl->_medianr; }
93
94 OnMediaLocation & OnMediaLocation::setLocation( Pathname filename_r, unsigned medianr_r )
95 { _pimpl->_filename = std::move(filename_r); _pimpl->_medianr = medianr_r; return *this; }
96
97 OnMediaLocation & OnMediaLocation::unsetLocation()
98 { _pimpl->_filename = Pathname(); _pimpl->_medianr = 0; return *this; }
99
100 OnMediaLocation & OnMediaLocation::changeFilename( Pathname filename_r )
101 { _pimpl->_filename = std::move(filename_r); return *this; }
102
103 OnMediaLocation & OnMediaLocation::changeMedianr( unsigned medianr_r )
104 { _pimpl->_medianr = medianr_r; return *this; }
105
106 OnMediaLocation & OnMediaLocation::prependPath( const Pathname & prefix_r )
107 { if ( ! prefix_r.emptyOrRoot() ) changeFilename( prefix_r / filename() ); return *this; }
108
109 bool OnMediaLocation::optional() const
110 { return _pimpl->_optional; }
111
112 OnMediaLocation & OnMediaLocation::setOptional( bool val_r )
113 { _pimpl->_optional = val_r; return *this; }
114
115 const ByteCount & OnMediaLocation::downloadSize() const
116 { return _pimpl->_downloadSize; }
117
118 OnMediaLocation & OnMediaLocation::setDownloadSize( ByteCount val_r )
119 { _pimpl->_downloadSize = val_r; return *this; }
120
121 const CheckSum & OnMediaLocation::checksum() const
122 { return _pimpl->_checksum; }
123
124 OnMediaLocation & OnMediaLocation::setChecksum( CheckSum val_r )
125 { _pimpl->_checksum = std::move(val_r); return *this; }
126
127 const ByteCount & OnMediaLocation::openSize() const
128 { return _pimpl->_openSize; }
129
130 OnMediaLocation & OnMediaLocation::setOpenSize( ByteCount val_r )
131 { _pimpl->_openSize = val_r; return *this; }
132
133 const CheckSum & OnMediaLocation::openChecksum() const
134 { return _pimpl->_openChecksum; }
135
136 OnMediaLocation & OnMediaLocation::setOpenChecksum( CheckSum val_r )
137 { _pimpl->_openChecksum = std::move(val_r); return *this; }
138
139 const ByteCount & OnMediaLocation::headerSize() const
140 { return _pimpl->_headerSize; }
141
142 OnMediaLocation & OnMediaLocation::setHeaderSize( ByteCount val_r )
143 { _pimpl->_headerSize = val_r; return *this; }
144
145 const CheckSum & OnMediaLocation::headerChecksum() const
146 { return _pimpl->_headerChecksum; }
147
148 OnMediaLocation & OnMediaLocation::setHeaderChecksum( CheckSum val_r )
149 { _pimpl->_headerChecksum = std::move(val_r); return *this; }
150
151 const Pathname &OnMediaLocation::deltafile() const
152 { return _pimpl->_deltafile; }
153
154 OnMediaLocation &OnMediaLocation::setDeltafile( Pathname path )
155 { _pimpl->_deltafile = std::move(path); return *this; }
156
157 std::ostream & operator<<( std::ostream & str, const OnMediaLocation & obj )
158 { return str << *obj._pimpl; }
159
160 std::ostream & dumpOn( std::ostream & str, const OnMediaLocation & obj )
161 { return dumpOn( str, *obj._pimpl ); }
162
163} // namespace zypp
shared_ptr
zypp::ByteCount
Store and operate with byte count.
Definition ByteCount.h:32
zypp::CheckSum
Definition CheckSum.h:34
zypp::OnMediaLocation::Impl
OnMediaLocation implementation.
Definition onmedialocation.cc:28
zypp::OnMediaLocation::Impl::_headerSize
ByteCount _headerSize
Definition onmedialocation.cc:49
zypp::OnMediaLocation::Impl::Impl
Impl()
Definition onmedialocation.cc:30
zypp::OnMediaLocation::Impl::_deltafile
Pathname _deltafile
Definition onmedialocation.cc:52
zypp::OnMediaLocation::Impl::_optional
bool _optional
Definition onmedialocation.cc:41
zypp::OnMediaLocation::Impl::dumpOn
std::ostream & dumpOn(std::ostream &str, const OnMediaLocation::Impl &obj)
Verbose stream output.
Definition onmedialocation.cc:69
zypp::OnMediaLocation::Impl::clone
Impl * clone() const
clone for RWCOW_pointer
Definition onmedialocation.cc:61
zypp::OnMediaLocation::Impl::_checksum
CheckSum _checksum
Definition onmedialocation.cc:44
zypp::OnMediaLocation::Impl::rwcowClone
friend Impl * rwcowClone(const Impl *rhs)
zypp::OnMediaLocation::Impl::Impl
Impl(Pathname filename_r, unsigned medianr_r)
Definition onmedialocation.cc:33
zypp::OnMediaLocation::Impl::_filename
Pathname _filename
Definition onmedialocation.cc:38
zypp::OnMediaLocation::Impl::_openChecksum
CheckSum _openChecksum
Definition onmedialocation.cc:47
zypp::OnMediaLocation::Impl::operator<<
std::ostream & operator<<(std::ostream &str, const OnMediaLocation::Impl &obj)
Stream output.
Definition onmedialocation.cc:65
zypp::OnMediaLocation::Impl::nullimpl
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition onmedialocation.cc:56
zypp::OnMediaLocation::Impl::_medianr
unsigned _medianr
Definition onmedialocation.cc:39
zypp::OnMediaLocation::Impl::_openSize
ByteCount _openSize
Definition onmedialocation.cc:46
zypp::OnMediaLocation::Impl::_downloadSize
ByteCount _downloadSize
Definition onmedialocation.cc:43
zypp::OnMediaLocation::Impl::_headerChecksum
CheckSum _headerChecksum
Definition onmedialocation.cc:50
zypp::OnMediaLocation::optional
bool optional() const
Whether this is an optional resource.
Definition onmedialocation.cc:109
zypp::OnMediaLocation::downloadSize
const ByteCount & downloadSize() const
The size of the resource on the server.
Definition onmedialocation.cc:115
zypp::OnMediaLocation::setDownloadSize
OnMediaLocation & setDownloadSize(ByteCount val_r)
Set the downloadSize.
Definition onmedialocation.cc:118
zypp::OnMediaLocation::filename
const Pathname & filename() const
The path to the resource on the medium.
Definition onmedialocation.cc:88
zypp::OnMediaLocation::setOpenSize
OnMediaLocation & setOpenSize(ByteCount val_r)
Set the openSize.
Definition onmedialocation.cc:130
zypp::OnMediaLocation::changeMedianr
OnMediaLocation & changeMedianr(unsigned medianr_r)
Individual manipulation of medianr (prefer setLocation).
Definition onmedialocation.cc:103
zypp::OnMediaLocation::openSize
const ByteCount & openSize() const
The size of the resource once it has been uncompressed or unpacked.
Definition onmedialocation.cc:127
zypp::OnMediaLocation::deltafile
const Pathname & deltafile() const
The existing deltafile that can be used to reduce download size ( zchunk or metalink )
Definition onmedialocation.cc:151
zypp::OnMediaLocation::headerSize
const ByteCount & headerSize() const
The size of the header prepending the resource (e.g.
Definition onmedialocation.cc:139
zypp::OnMediaLocation::setChecksum
OnMediaLocation & setChecksum(CheckSum val_r)
Set the checksum.
Definition onmedialocation.cc:124
zypp::OnMediaLocation::medianr
unsigned medianr() const
The media number the resource is located on.
Definition onmedialocation.cc:91
zypp::OnMediaLocation::headerChecksum
const CheckSum & headerChecksum() const
The checksum of the header prepending the resource (e.g.
Definition onmedialocation.cc:145
zypp::OnMediaLocation::changeFilename
OnMediaLocation & changeFilename(Pathname filename_r)
Individual manipulation of filename (prefer setLocation).
Definition onmedialocation.cc:100
zypp::OnMediaLocation::_pimpl
RWCOW_pointer< Impl > _pimpl
Implementation class.
Definition onmedialocation.h:126
zypp::OnMediaLocation::setHeaderSize
OnMediaLocation & setHeaderSize(ByteCount val_r)
Set the headerSize.
Definition onmedialocation.cc:142
zypp::OnMediaLocation::checksum
const CheckSum & checksum() const
The checksum of the resource on the server.
Definition onmedialocation.cc:121
zypp::OnMediaLocation::OnMediaLocation
OnMediaLocation()
Default Ctor indicating no media access.
Definition onmedialocation.cc:76
zypp::OnMediaLocation::prependPath
OnMediaLocation & prependPath(const Pathname &prefix_r)
Prepend the filename with prefix_r.
Definition onmedialocation.cc:106
zypp::OnMediaLocation::openChecksum
const CheckSum & openChecksum() const
The checksum of the resource once it has been uncompressed or unpacked.
Definition onmedialocation.cc:133
zypp::OnMediaLocation::unsetLocation
OnMediaLocation & unsetLocation()
Unset filename and set medianr to 0.
Definition onmedialocation.cc:97
zypp::OnMediaLocation::setLocation
OnMediaLocation & setLocation(Pathname filename_r, unsigned medianr_r=1)
Set filename_r and medianr_r (defaults to 1).
Definition onmedialocation.cc:94
zypp::OnMediaLocation::setOpenChecksum
OnMediaLocation & setOpenChecksum(CheckSum val_r)
Set the openChecksum.
Definition onmedialocation.cc:136
zypp::OnMediaLocation::setHeaderChecksum
OnMediaLocation & setHeaderChecksum(CheckSum val_r)
Set the headerChecksum.
Definition onmedialocation.cc:148
zypp::OnMediaLocation::~OnMediaLocation
~OnMediaLocation()
Dtor.
Definition onmedialocation.cc:84
zypp::OnMediaLocation::setOptional
OnMediaLocation & setOptional(bool val)
Set whether the resource is optional.
Definition onmedialocation.cc:112
zypp::OnMediaLocation::setDeltafile
OnMediaLocation & setDeltafile(Pathname path)
Set the deltafile.
Definition onmedialocation.cc:154
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:47
zypp::filesystem::Pathname::emptyOrRoot
bool emptyOrRoot() const
Test for "" or "/".
Definition Pathname.h:123
std
Definition Arch.h:364
str
String related utilities and Regular expression matching.
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::dumpOn
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition Capability.cc:580
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
Definition SerialNumber.cc:52