libzypp 17.36.3
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
83 public:
85 static zypp::shared_ptr<Impl> nullimpl()
86 { static zypp::shared_ptr<Impl> _nullimpl( new Impl ); return _nullimpl; }
87
88 private:
90 Impl * clone() const { return new Impl( *this ); }
91 };
92
93
95 : _pimpl( new Impl( std::move(label), std::move(verifyData), medianr ) )
96 {
97
98 }
99
100 const std::string &ProvideMediaSpec::label() const
101 { return _pimpl->_label; }
102
104 {
105 _pimpl->_label = label;
106 return *this;
107 }
108
110 { return _pimpl->_medianr; }
111
113 {
114 _pimpl->_medianr = medianr;
115 return *this;
116 }
117
119 { return _pimpl->_verifyDataPath; }
120
122 {
123 _pimpl->_verifyDataPath = pName;
124 return *this;
125 }
126
128 { return _pimpl->_customHeaders; }
129
131 { return _pimpl->_customHeaders; }
132
134 {
135 _pimpl->_customHeaders.set( key,val );
136 return *this;
137 }
138
140 {
141 _pimpl->_customHeaders.add( key,val );
142 return *this;
143 }
144
146 {
147 // first check if we have the same media data
148 if ( _pimpl->_verifyDataPath != other._pimpl->_verifyDataPath )
149 return false;
150
151 // if the verify file is not empty check the medianr
152 if ( !_pimpl->_verifyDataPath.empty() ) {
153 return _pimpl->_medianr == other._pimpl->_medianr;
154 }
155
156 // can't tell without the URL
157 return zypp::indeterminate;
158 }
159
161 inline std::ostream & operator<<( std::ostream & str, const ProvideFileSpec::Impl & obj )
162 {
163 return str << "{" << obj._destFilenameHint << "{" << obj._downloadSize << "|" << obj._checksum << "|" << obj._deltafile << "}" << "}";
164 }
165
167 inline std::ostream & dumpOn( std::ostream & str, const ProvideFileSpec::Impl & obj )
168 { return str << obj; }
169
170
174
176 : _pimpl( new Impl() )
177 {
179 setOptional( loc.optional() );
180 setChecksum( loc.checksum() );
181 setOpenSize( loc.openSize() );
183 setHeaderSize( loc.headerSize() );
185 setDeltafile( loc.deltafile() );
186 }
187
190
192 { return _pimpl->_destFilenameHint; }
193
195 { _pimpl->_destFilenameHint = filename; return *this; }
196
198 { return _pimpl->_checkExistsOnly; }
199
201 { _pimpl->_checkExistsOnly = set; return *this; }
202
204 { return _pimpl->_optional; }
205
207 { _pimpl->_optional = (val_r); return *this; }
208
210 { return _pimpl->_downloadSize; }
211
213 { _pimpl->_downloadSize = (val_r); return *this; }
214
216 { return _pimpl->_checksum; }
217
219 { _pimpl->_checksum = (val_r); return *this; }
220
222 { return _pimpl->_openSize; }
223
225 { _pimpl->_openSize = (val_r); return *this; }
226
228 { return _pimpl->_openChecksum; }
229
231 { _pimpl->_openChecksum = (val_r); return *this; }
232
234 { return _pimpl->_headerSize; }
235
237 { _pimpl->_headerSize = (val_r); return *this; }
238
240 { return _pimpl->_headerChecksum; }
241
243 { _pimpl->_headerChecksum = (val_r); return *this; }
244
246 { return _pimpl->_deltafile; }
247
249 { _pimpl->_deltafile = (path); return *this; }
250
252 { return _pimpl->_customHeaders; }
253
255 { return _pimpl->_customHeaders; }
256
258 {
259 _pimpl->_customHeaders.set( key,val );
260 return *this;
261 }
262
264 {
265 _pimpl->_customHeaders.add( key,val );
266 return *this;
267 }
268
281
282 std::ostream & operator<<( std::ostream & str, const ProvideFileSpec & obj )
283 { return str << *obj._pimpl; }
284
285 std::ostream & dumpOn( std::ostream & str, const ProvideFileSpec & obj )
286 { return dumpOn( str, *obj._pimpl ); }
287
288} // 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 & 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 & setChecksum(const zypp::CheckSum &val_r)
Set the checksum.
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)
zypp::TriBool isSameMedium(const ProvideMediaSpec &other)
ProvideMediaSpec & setLabel(const std::string &label)
ProvideMediaSpec(std::string label="", zypp::Pathname verifyData=zypp::Pathname(), unsigned medianr=1)
HeaderValueMap & customHeaders()
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
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)
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition String.h:30
D * rwcowClone(const D *rhs)
Clone the underlying object.
Definition PtrTypes.h:453