libzypp  17.36.3
providespec.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
13 #include <iostream>
14 #include <utility>
15 #include "providespec.h"
16 
17 using std::endl;
18 
19 namespace zyppng
20 {
22  {
23  public:
31  };
32 
33 
35  {
36  public:
37  Impl()
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:
56  friend ProvideMediaSpec::Impl * zypp::rwcowClone<ProvideMediaSpec::Impl>( const ProvideMediaSpec::Impl * rhs );
57  Impl * clone() const { return new Impl( *this ); }
58  };
59 
61  {
62  public:
63  Impl()
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:
89  friend ProvideFileSpec::Impl * zypp::rwcowClone<ProvideFileSpec::Impl>( const ProvideFileSpec::Impl * rhs );
90  Impl * clone() const { return new Impl( *this ); }
91  };
92 
93 
94  ProvideMediaSpec::ProvideMediaSpec( std::string label, zypp::filesystem::Pathname verifyData, unsigned medianr )
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 
103  ProvideMediaSpec &ProvideMediaSpec::setLabel(const std::string &label)
104  {
105  _pimpl->_label = label;
106  return *this;
107  }
108 
109  unsigned ProvideMediaSpec::medianr() const
110  { return _pimpl->_medianr; }
111 
113  {
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 
172  : _pimpl( new Impl() )
173  {}
174 
176  : _pimpl( new Impl() )
177  {
178  setDownloadSize( loc.downloadSize() );
179  setOptional( loc.optional() );
180  setChecksum( loc.checksum() );
181  setOpenSize( loc.openSize() );
182  setOpenChecksum( loc.openChecksum() );
183  setHeaderSize( loc.headerSize() );
185  setDeltafile( loc.deltafile() );
186  }
187 
189  {}
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 
270  {
271  return zypp::OnMediaLocation( path, mediaNr )
273  .setOptional( optional() )
274  .setChecksum( checksum() )
275  .setOpenSize( openSize() )
279  .setDeltafile( deltafile() );
280  }
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
ProvideFileSpec & setHeaderChecksum(const zypp::CheckSum &val_r)
Set the headerChecksum.
Definition: providespec.cc:242
void add(const std::string &key, const Value &val)
OnMediaLocation & setOpenChecksum(CheckSum val_r)
Set the openChecksum.
OnMediaLocation & setHeaderChecksum(CheckSum val_r)
Set the headerChecksum.
const CheckSum & openChecksum() const
The checksum of the resource once it has been uncompressed or unpacked.
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition: String.h:30
ProvideFileSpec & setOptional(bool val)
Set whether the resource is optional.
Definition: providespec.cc:206
const ByteCount & headerSize() const
The size of the header prepending the resource (e.g.
Describes a resource file located on a medium.
const zypp::ByteCount & openSize() const
The size of the resource once it has been uncompressed or unpacked.
Definition: providespec.cc:221
const ByteCount & openSize() const
The size of the resource once it has been uncompressed or unpacked.
zypp::RWCOW_pointer< Impl > _pimpl
Implementation class.
Definition: providespec.h:85
zypp::CheckSum _headerChecksum
Definition: providespec.cc:78
Store and operate with byte count.
Definition: ByteCount.h:31
const zypp::CheckSum & openChecksum() const
The checksum of the resource once it has been uncompressed or unpacked.
Definition: providespec.cc:227
static zypp::shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition: providespec.cc:52
ProvideSpecBasePrivate & operator=(const ProvideSpecBasePrivate &)=delete
std::ostream & dumpOn(std::ostream &str, const ProvideFileSpec &obj)
Definition: providespec.cc:285
zypp::RWCOW_pointer< Impl > _pimpl
Implementation class.
Definition: providespec.h:193
ProvideMediaSpec & setMedianr(unsigned medianr)
Definition: providespec.cc:112
String related utilities and Regular expression matching.
const zypp::Pathname & deltafile() const
The existing deltafile that can be used to reduce download size ( zchunk or metalink ) ...
Definition: providespec.cc:245
OnMediaLocation & setChecksum(CheckSum val_r)
Set the checksum.
Definition: Arch.h:363
const std::string & label() const
Definition: providespec.cc:100
ProvideFileSpec & setOpenChecksum(const zypp::CheckSum &val_r)
Set the openChecksum.
Definition: providespec.cc:230
const CheckSum & checksum() const
The checksum of the resource on the server.
zypp::OnMediaLocation asOnMediaLocation(const zypp::Pathname &path, unsigned int mediaNr) const
Definition: providespec.cc:269
ProvideFileSpec & setDestFilenameHint(const zypp::Pathname &filename)
Definition: providespec.cc:194
bool empty() const
Test for an empty path.
Definition: Pathname.h:116
OnMediaLocation & setOpenSize(ByteCount val_r)
Set the openSize.
unsigned medianr() const
Definition: providespec.cc:109
zypp::Pathname _destFilenameHint
Definition: providespec.cc:66
const zypp::CheckSum & checksum() const
The checksum of the resource on the server.
Definition: providespec.cc:215
zypp::Pathname mediaFile() const
Definition: providespec.cc:118
ProvideFileSpec & setDeltafile(const zypp::Pathname &path)
Set the deltafile.
Definition: providespec.cc:248
const ByteCount & downloadSize() const
The size of the resource on the server.
OnMediaLocation & setHeaderSize(ByteCount val_r)
Set the headerSize.
zypp::TriBool isSameMedium(const ProvideMediaSpec &other)
Definition: providespec.cc:145
const zypp::CheckSum & headerChecksum() const
The checksum of the header prepending the resource (e.g.
Definition: providespec.cc:239
ProvideFileSpec & setHeaderSize(const zypp::ByteCount &val_r)
Set the headerSize.
Definition: providespec.cc:236
ProvideFileSpec & addCustomHeaderValue(const std::string &key, const HeaderValueMap::Value &val)
Definition: providespec.cc:263
const zypp::ByteCount & downloadSize() const
The size of the resource on the server.
Definition: providespec.cc:209
void set(const std::string &key, Value val)
const zypp::Pathname & destFilenameHint() const
Definition: providespec.cc:191
ProvideFileSpec & setOpenSize(const zypp::ByteCount &val_r)
Set the openSize.
Definition: providespec.cc:224
OnMediaLocation & setDeltafile(Pathname path)
Set the deltafile.
ProvideMediaSpec & addCustomHeaderValue(const std::string &key, const HeaderValueMap::Value &val)
Definition: providespec.cc:139
const Pathname & deltafile() const
The existing deltafile that can be used to reduce download size ( zchunk or metalink ) ...
OnMediaLocation & setDownloadSize(ByteCount val_r)
Set the downloadSize.
HeaderValueMap & customHeaders()
Definition: providespec.cc:127
ProvideFileSpec & setChecksum(const zypp::CheckSum &val_r)
Set the checksum.
Definition: providespec.cc:218
ProvideMediaSpec & setLabel(const std::string &label)
Definition: providespec.cc:103
ProvideMediaSpec & setCustomHeaderValue(const std::string &key, const HeaderValueMap::Value &val)
Definition: providespec.cc:133
static zypp::shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition: providespec.cc:85
ProvideMediaSpec & setMediaFile(const zypp::Pathname &pName)
Definition: providespec.cc:121
ProvideFileSpec & setDownloadSize(const zypp::ByteCount &val_r)
Set the downloadSize.
Definition: providespec.cc:212
bool optional() const
Whether this is an optional resource.
Definition: providespec.cc:203
zypp::ByteCount _downloadSize
Definition: providespec.cc:71
Impl(std::string &&label, zypp::Pathname &&vPath, unsigned medianr)
Definition: providespec.cc:40
ProvideFileSpec & setCheckExistsOnly(const bool set=true)
Definition: providespec.cc:200
std::ostream & operator<<(std::ostream &str, zypp::RepoManagerFlags::RawMetadataRefreshPolicy obj)
Definition: repomanager.cc:101
OnMediaLocation & setOptional(bool val)
Set whether the resource is optional.
ProvideFileSpec & setCustomHeaderValue(const std::string &key, const HeaderValueMap::Value &val)
Definition: providespec.cc:257
const zypp::ByteCount & headerSize() const
The size of the header prepending the resource (e.g.
Definition: providespec.cc:233
bool optional() const
Whether this is an optional resource.
HeaderValueMap & customHeaders()
Definition: providespec.cc:251
ProvideMediaSpec(std::string label="", zypp::Pathname verifyData=zypp::Pathname(), unsigned medianr=1)
Definition: providespec.cc:94
bool checkExistsOnly() const
Definition: providespec.cc:197
const CheckSum & headerChecksum() const
The checksum of the header prepending the resource (e.g.