libzypp 17.31.23
providespec.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
13#include <iostream>
14#include "providespec.h"
15
16using std::endl;
17
18namespace zyppng
19{
21 {
22 public:
26 };
27
28
30 {
31 public:
33 {}
34
35 Impl( const std::string &label, const zypp::Pathname &vPath, unsigned medianr )
36 : _label( label )
37 , _medianr( medianr )
38 , _verifyDataPath(vPath)
39 {}
40
41 std::string _label;
42 unsigned _medianr = 0U;
44
45 public:
47 static zypp::shared_ptr<Impl> nullimpl()
48 { static zypp::shared_ptr<Impl> _nullimpl( new Impl ); return _nullimpl; }
49
50 private:
51 friend ProvideMediaSpec::Impl * zypp::rwcowClone<ProvideMediaSpec::Impl>( const ProvideMediaSpec::Impl * rhs );
52 Impl * clone() const { return new Impl( *this ); }
53 };
54
56 {
57 public:
59 {}
60
63 bool _checkExistsOnly = false;
64
65 bool _optional = false;
68
71
74
76
77
78 public:
80 static zypp::shared_ptr<Impl> nullimpl()
81 { static zypp::shared_ptr<Impl> _nullimpl( new Impl ); return _nullimpl; }
82
83 private:
84 friend ProvideFileSpec::Impl * zypp::rwcowClone<ProvideFileSpec::Impl>( const ProvideFileSpec::Impl * rhs );
85 Impl * clone() const { return new Impl( *this ); }
86 };
87
88
89 ProvideMediaSpec::ProvideMediaSpec( const std::string &label, const zypp::filesystem::Pathname &verifyData, unsigned medianr )
90 : _pimpl( new Impl( label, verifyData, medianr ) )
91 {
92
93 }
94
95 const std::string &ProvideMediaSpec::label() const
96 { return _pimpl->_label; }
97
99 {
100 _pimpl->_label = label;
101 return *this;
102 }
103
105 { return _pimpl->_medianr; }
106
108 {
109 _pimpl->_medianr = medianr;
110 return *this;
111 }
112
114 { return _pimpl->_verifyDataPath; }
115
117 {
118 _pimpl->_verifyDataPath = pName;
119 return *this;
120 }
121
123 { return _pimpl->_customHeaders; }
124
126 { return _pimpl->_customHeaders; }
127
129 {
130 _pimpl->_customHeaders.set( key,val );
131 return *this;
132 }
133
135 {
136 _pimpl->_customHeaders.add( key,val );
137 return *this;
138 }
139
141 {
142 // first check if we have the same media data
143 if ( _pimpl->_verifyDataPath != other._pimpl->_verifyDataPath )
144 return false;
145
146 // if the verify file is not empty check the medianr
147 if ( !_pimpl->_verifyDataPath.empty() ) {
148 return _pimpl->_medianr == other._pimpl->_medianr;
149 }
150
151 // can't tell without the URL
152 return zypp::indeterminate;
153 }
154
156 inline std::ostream & operator<<( std::ostream & str, const ProvideFileSpec::Impl & obj )
157 {
158 return str << "{" << obj._destFilenameHint << "{" << obj._downloadSize << "|" << obj._checksum << "|" << obj._deltafile << "}" << "}";
159 }
160
162 inline std::ostream & dumpOn( std::ostream & str, const ProvideFileSpec::Impl & obj )
163 { return str << obj; }
164
165
167 : _pimpl( new Impl() )
168 {}
169
171 : _pimpl( new Impl() )
172 {
174 setOptional( loc.optional() );
175 setChecksum( loc.checksum() );
176 setOpenSize( loc.openSize() );
178 setHeaderSize( loc.headerSize() );
180 setDeltafile( loc.deltafile() );
181 }
182
184 {}
185
187 { return _pimpl->_destFilenameHint; }
188
190 { _pimpl->_destFilenameHint = filename; return *this; }
191
193 { return _pimpl->_checkExistsOnly; }
194
196 { _pimpl->_checkExistsOnly = set; return *this; }
197
199 { return _pimpl->_optional; }
200
202 { _pimpl->_optional = (val_r); return *this; }
203
205 { return _pimpl->_downloadSize; }
206
208 { _pimpl->_downloadSize = (val_r); return *this; }
209
211 { return _pimpl->_checksum; }
212
214 { _pimpl->_checksum = (val_r); return *this; }
215
217 { return _pimpl->_openSize; }
218
220 { _pimpl->_openSize = (val_r); return *this; }
221
223 { return _pimpl->_openChecksum; }
224
226 { _pimpl->_openChecksum = (val_r); return *this; }
227
229 { return _pimpl->_headerSize; }
230
232 { _pimpl->_headerSize = (val_r); return *this; }
233
235 { return _pimpl->_headerChecksum; }
236
238 { _pimpl->_headerChecksum = (val_r); return *this; }
239
241 { return _pimpl->_deltafile; }
242
244 { _pimpl->_deltafile = (path); return *this; }
245
247 { return _pimpl->_customHeaders; }
248
250 { return _pimpl->_customHeaders; }
251
253 {
254 _pimpl->_customHeaders.set( key,val );
255 return *this;
256 }
257
259 {
260 _pimpl->_customHeaders.add( key,val );
261 return *this;
262 }
263
264 std::ostream & operator<<( std::ostream & str, const ProvideFileSpec & obj )
265 { return str << *obj._pimpl; }
266
267 std::ostream & dumpOn( std::ostream & str, const ProvideFileSpec & obj )
268 { return dumpOn( str, *obj._pimpl ); }
269
270} // namespace zypp
Store and operate with byte count.
Definition: ByteCount.h:31
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.
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.
const CheckSum & headerChecksum() const
The checksum of the header prepending the resource (e.g.
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.
zypp::ByteCount _downloadSize
Definition: providespec.cc:66
zypp::CheckSum _headerChecksum
Definition: providespec.cc:73
static zypp::shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition: providespec.cc:80
zypp::Pathname _destFilenameHint
Definition: providespec.cc:61
bool optional() const
Whether this is an optional resource.
Definition: providespec.cc:198
ProvideFileSpec & setHeaderChecksum(const zypp::CheckSum &val_r)
Set the headerChecksum.
Definition: providespec.cc:237
const zypp::CheckSum & openChecksum() const
The checksum of the resource once it has been uncompressed or unpacked.
Definition: providespec.cc:222
ProvideFileSpec & setCustomHeaderValue(const std::string &key, const HeaderValueMap::Value &val)
Definition: providespec.cc:252
ProvideFileSpec & setDeltafile(const zypp::Pathname &path)
Set the deltafile.
Definition: providespec.cc:243
ProvideFileSpec & setCheckExistsOnly(const bool set=true)
Definition: providespec.cc:195
HeaderValueMap & customHeaders()
Definition: providespec.cc:246
const zypp::Pathname & destFilenameHint() const
Definition: providespec.cc:186
ProvideFileSpec & setOptional(bool val)
Set whether the resource is optional.
Definition: providespec.cc:201
const zypp::ByteCount & downloadSize() const
The size of the resource on the server.
Definition: providespec.cc:204
ProvideFileSpec & setOpenSize(const zypp::ByteCount &val_r)
Set the openSize.
Definition: providespec.cc:219
ProvideFileSpec & setChecksum(const zypp::CheckSum &val_r)
Set the checksum.
Definition: providespec.cc:213
const zypp::ByteCount & openSize() const
The size of the resource once it has been uncompressed or unpacked.
Definition: providespec.cc:216
ProvideFileSpec & setOpenChecksum(const zypp::CheckSum &val_r)
Set the openChecksum.
Definition: providespec.cc:225
const zypp::Pathname & deltafile() const
The existing deltafile that can be used to reduce download size ( zchunk or metalink )
Definition: providespec.cc:240
ProvideFileSpec & setDestFilenameHint(const zypp::Pathname &filename)
Definition: providespec.cc:189
zypp::RWCOW_pointer< Impl > _pimpl
Implementation class.
Definition: providespec.h:187
const zypp::CheckSum & checksum() const
The checksum of the resource on the server.
Definition: providespec.cc:210
ProvideFileSpec & setDownloadSize(const zypp::ByteCount &val_r)
Set the downloadSize.
Definition: providespec.cc:207
const zypp::CheckSum & headerChecksum() const
The checksum of the header prepending the resource (e.g.
Definition: providespec.cc:234
ProvideFileSpec & setHeaderSize(const zypp::ByteCount &val_r)
Set the headerSize.
Definition: providespec.cc:231
ProvideFileSpec & addCustomHeaderValue(const std::string &key, const HeaderValueMap::Value &val)
Definition: providespec.cc:258
const zypp::ByteCount & headerSize() const
The size of the header prepending the resource (e.g.
Definition: providespec.cc:228
bool checkExistsOnly() const
Definition: providespec.cc:192
static zypp::shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition: providespec.cc:47
Impl(const std::string &label, const zypp::Pathname &vPath, unsigned medianr)
Definition: providespec.cc:35
ProvideMediaSpec & setMedianr(unsigned medianr)
Definition: providespec.cc:107
zypp::TriBool isSameMedium(const ProvideMediaSpec &other)
Definition: providespec.cc:140
ProvideMediaSpec & setLabel(const std::string &label)
Definition: providespec.cc:98
HeaderValueMap & customHeaders()
Definition: providespec.cc:122
unsigned medianr() const
Definition: providespec.cc:104
ProvideMediaSpec & setCustomHeaderValue(const std::string &key, const HeaderValueMap::Value &val)
Definition: providespec.cc:128
zypp::Pathname mediaFile() const
Definition: providespec.cc:113
ProvideMediaSpec(const std::string &label, const zypp::Pathname &verifyData=zypp::Pathname(), unsigned medianr=1)
Definition: providespec.cc:89
ProvideMediaSpec & setMediaFile(const zypp::Pathname &pName)
Definition: providespec.cc:116
const std::string & label() const
Definition: providespec.cc:95
zypp::RWCOW_pointer< Impl > _pimpl
Implementation class.
Definition: providespec.h:87
ProvideMediaSpec & addCustomHeaderValue(const std::string &key, const HeaderValueMap::Value &val)
Definition: providespec.cc:134
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition: String.h:30
String related utilities and Regular expression matching.
std::ostream & operator<<(std::ostream &str, const MediaDataVerifierRef &obj)
std::ostream & dumpOn(std::ostream &str, const ProvideFileSpec &obj)
Definition: providespec.cc:267