libzypp 17.37.17
providespec.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12
13#include <iostream>
14#include <utility>
15#include "providespec.h"
16
17using std::endl;
18
19namespace zyppng
20{
32
33
35 {
36 public:
38 {}
39
40 Impl( std::string &&label, zypp::Pathname &&vPath, unsigned medianr )
41 : _label(std::move( label ))
42 , _medianr( medianr )
43 , _verifyDataPath(std::move(vPath))
44 {}
45
46 std::string _label;
47 unsigned _medianr = 0U;
49
50 public:
52 static zypp::shared_ptr<Impl> nullimpl()
53 { static zypp::shared_ptr<Impl> _nullimpl( new Impl ); return _nullimpl; }
54
55 private:
57 Impl * clone() const { return new Impl( *this ); }
58 };
59
61 {
62 public:
64 {}
65
68 bool _checkExistsOnly = false;
69
70 bool _optional = false;
73
76
79
81
82 bool _mirrorsAllowed = true;
83
84 public:
86 static zypp::shared_ptr<Impl> nullimpl()
87 { static zypp::shared_ptr<Impl> _nullimpl( new Impl ); return _nullimpl; }
88
89 private:
91 Impl * clone() const { return new Impl( *this ); }
92 };
93
94
96 : _pimpl( new Impl( std::move(label), std::move(verifyData), medianr ) )
97 {
98
99 }
100
101 const std::string &ProvideMediaSpec::label() const
102 { return _pimpl->_label; }
103
105 {
106 _pimpl->_label = label;
107 return *this;
108 }
109
111 { return _pimpl->_medianr; }
112
114 {
115 _pimpl->_medianr = medianr;
116 return *this;
117 }
118
120 { return _pimpl->_verifyDataPath; }
121
123 {
124 _pimpl->_verifyDataPath = pName;
125 return *this;
126 }
127
129 { return _pimpl->_customHeaders; }
130
132 { return _pimpl->_customHeaders; }
133
135 {
136 _pimpl->_customHeaders.set( key,val );
137 return *this;
138 }
139
141 {
142 _pimpl->_customHeaders.add( key,val );
143 return *this;
144 }
145
147 {
148 // first check if we have the same media data
149 if ( _pimpl->_verifyDataPath != other._pimpl->_verifyDataPath )
150 return false;
151
152 // if the verify file is not empty check the medianr
153 if ( !_pimpl->_verifyDataPath.empty() ) {
154 return _pimpl->_medianr == other._pimpl->_medianr;
155 }
156
157 // can't tell without the URL
158 return zypp::indeterminate;
159 }
160
162 inline std::ostream & operator<<( std::ostream & str, const ProvideFileSpec::Impl & obj )
163 {
164 return str << "{" << obj._destFilenameHint << "{" << obj._downloadSize << "|" << obj._checksum << "|" << obj._deltafile << "}" << "}";
165 }
166
168 inline std::ostream & dumpOn( std::ostream & str, const ProvideFileSpec::Impl & obj )
169 { return str << obj; }
170
171
175
177 : _pimpl( new Impl() )
178 {
180 setOptional( loc.optional() );
181 setChecksum( loc.checksum() );
182 setOpenSize( loc.openSize() );
184 setHeaderSize( loc.headerSize() );
186 setDeltafile( loc.deltafile() );
187 }
188
191
193 { return _pimpl->_destFilenameHint; }
194
196 { _pimpl->_destFilenameHint = filename; return *this; }
197
199 { return _pimpl->_checkExistsOnly; }
200
202 { _pimpl->_checkExistsOnly = set; return *this; }
203
205 { return _pimpl->_optional; }
206
208 { _pimpl->_optional = (val_r); return *this; }
209
211 { return _pimpl->_downloadSize; }
212
214 { _pimpl->_downloadSize = (val_r); return *this; }
215
217 { return _pimpl->_checksum; }
218
220 { _pimpl->_checksum = (val_r); return *this; }
221
223 { return _pimpl->_openSize; }
224
226 { _pimpl->_openSize = (val_r); return *this; }
227
229 { return _pimpl->_openChecksum; }
230
232 { _pimpl->_openChecksum = (val_r); return *this; }
233
235 { return _pimpl->_headerSize; }
236
238 { _pimpl->_headerSize = (val_r); return *this; }
239
241 { return _pimpl->_headerChecksum; }
242
244 { _pimpl->_headerChecksum = (val_r); return *this; }
245
247 { return _pimpl->_deltafile; }
248
250 { _pimpl->_deltafile = (path); return *this; }
251
253 { return _pimpl->_mirrorsAllowed; }
254
256 { _pimpl->_mirrorsAllowed = std::move(set); return *this; }
257
259 { return _pimpl->_customHeaders; }
260
262 { return _pimpl->_customHeaders; }
263
265 {
266 _pimpl->_customHeaders.set( key,val );
267 return *this;
268 }
269
271 {
272 _pimpl->_customHeaders.add( key,val );
273 return *this;
274 }
275
289
290 std::ostream & operator<<( std::ostream & str, const ProvideFileSpec & obj )
291 { return str << *obj._pimpl; }
292
293 std::ostream & dumpOn( std::ostream & str, const ProvideFileSpec & obj )
294 { return dumpOn( str, *obj._pimpl ); }
295
296} // namespace zypp
Store and operate with byte count.
Definition ByteCount.h:32
Describes a resource file located on a medium.
bool optional() const
Whether this is an optional resource.
const ByteCount & downloadSize() const
The size of the resource on the server.
OnMediaLocation & setDownloadSize(ByteCount val_r)
Set the downloadSize.
OnMediaLocation & setMirrorsAllowed(bool set=true)
Enables or disables the use of mirrors when fetching this file.
OnMediaLocation & setOpenSize(ByteCount val_r)
Set the openSize.
const ByteCount & openSize() const
The size of the resource once it has been uncompressed or unpacked.
const Pathname & deltafile() const
The existing deltafile that can be used to reduce download size ( zchunk or metalink )
const ByteCount & headerSize() const
The size of the header prepending the resource (e.g.
OnMediaLocation & setChecksum(CheckSum val_r)
Set the checksum.
const CheckSum & headerChecksum() const
The checksum of the header prepending the resource (e.g.
OnMediaLocation & setHeaderSize(ByteCount val_r)
Set the headerSize.
const CheckSum & checksum() const
The checksum of the resource on the server.
const CheckSum & openChecksum() const
The checksum of the resource once it has been uncompressed or unpacked.
OnMediaLocation & setOpenChecksum(CheckSum val_r)
Set the openChecksum.
OnMediaLocation & setHeaderChecksum(CheckSum val_r)
Set the headerChecksum.
OnMediaLocation & setOptional(bool val)
Set whether the resource is optional.
OnMediaLocation & setDeltafile(Pathname path)
Set the deltafile.
static zypp::shared_ptr< Impl > nullimpl()
Offer default Impl.
bool optional() const
Whether this is an optional resource.
ProvideFileSpec & setHeaderChecksum(const zypp::CheckSum &val_r)
Set the headerChecksum.
const zypp::CheckSum & openChecksum() const
The checksum of the resource once it has been uncompressed or unpacked.
ProvideFileSpec & setCustomHeaderValue(const std::string &key, const HeaderValueMap::Value &val)
ProvideFileSpec & setDeltafile(const zypp::Pathname &path)
Set the deltafile.
ProvideFileSpec & setCheckExistsOnly(const bool set=true)
HeaderValueMap & customHeaders()
const zypp::Pathname & destFilenameHint() const
ProvideFileSpec & setOptional(bool val)
Set whether the resource is optional.
const zypp::ByteCount & downloadSize() const
The size of the resource on the server.
zypp::OnMediaLocation asOnMediaLocation(const zypp::Pathname &path, unsigned int mediaNr) const
ProvideFileSpec & setOpenSize(const zypp::ByteCount &val_r)
Set the openSize.
ProvideFileSpec & setMirrorsAllowed(bool set=true)
Enables or disables the use of mirrors when fetching this file.
ProvideFileSpec & setChecksum(const zypp::CheckSum &val_r)
Set the checksum.
bool mirrorsAllowed() const
The requested file is allowed to be fetched via mirrors ( defaults to true )
const zypp::ByteCount & openSize() const
The size of the resource once it has been uncompressed or unpacked.
ProvideFileSpec & setOpenChecksum(const zypp::CheckSum &val_r)
Set the openChecksum.
const zypp::Pathname & deltafile() const
The existing deltafile that can be used to reduce download size ( zchunk or metalink )
ProvideFileSpec & setDestFilenameHint(const zypp::Pathname &filename)
zypp::RWCOW_pointer< Impl > _pimpl
Implementation class.
const zypp::CheckSum & checksum() const
The checksum of the resource on the server.
ProvideFileSpec & setDownloadSize(const zypp::ByteCount &val_r)
Set the downloadSize.
const zypp::CheckSum & headerChecksum() const
The checksum of the header prepending the resource (e.g.
ProvideFileSpec & setHeaderSize(const zypp::ByteCount &val_r)
Set the headerSize.
ProvideFileSpec & addCustomHeaderValue(const std::string &key, const HeaderValueMap::Value &val)
const zypp::ByteCount & headerSize() const
The size of the header prepending the resource (e.g.
bool checkExistsOnly() const
static zypp::shared_ptr< Impl > nullimpl()
Offer default Impl.
Impl(std::string &&label, zypp::Pathname &&vPath, unsigned medianr)
ProvideMediaSpec & setMedianr(unsigned medianr)
ProvideMediaSpec & setLabel(const std::string &label)
ProvideMediaSpec(std::string label="", zypp::Pathname verifyData=zypp::Pathname(), unsigned medianr=1)
HeaderValueMap & customHeaders()
zypp::TriBool isSameMedium(const ProvideMediaSpec &other) const
unsigned medianr() const
ProvideMediaSpec & setCustomHeaderValue(const std::string &key, const HeaderValueMap::Value &val)
zypp::Pathname mediaFile() const
ProvideMediaSpec & setMediaFile(const zypp::Pathname &pName)
const std::string & label() const
zypp::RWCOW_pointer< Impl > _pimpl
Implementation class.
Definition providespec.h:87
ProvideMediaSpec & addCustomHeaderValue(const std::string &key, const HeaderValueMap::Value &val)
ProvideSpecBasePrivate & operator=(const ProvideSpecBasePrivate &)=delete
ProvideSpecBasePrivate(const ProvideSpecBasePrivate &)=default
ProvideSpecBasePrivate(ProvideSpecBasePrivate &&)=delete
ProvideSpecBasePrivate & operator=(ProvideSpecBasePrivate &&)=delete
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition String.h:31
Definition Arch.h:364
String related utilities and Regular expression matching.
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
D * rwcowClone(const D *rhs)
Clone the underlying object.
Definition PtrTypes.h:453