libzypp  17.30.2
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 <zypp-core/OnMediaLocation>
16 
17 using std::endl;
18 
20 namespace zypp
21 {
27  {
28  public:
29  Impl()
30  {}
31 
32  Impl( Pathname filename_r, unsigned medianr_r )
33  : _filename { std::move(filename_r) }
34  , _medianr { medianr_r }
35  {}
36 
38  unsigned _medianr = 0U;
39 
40  bool _optional = false;
41 
44 
47 
50 
52 
53  public:
55  static shared_ptr<Impl> nullimpl()
56  { static shared_ptr<Impl> _nullimpl( new Impl ); return _nullimpl; }
57  private:
58  friend Impl * rwcowClone<Impl>( const Impl * rhs );
60  Impl * clone() const { return new Impl( *this ); }
61  };
62 
64  inline std::ostream & operator<<( std::ostream & str, const OnMediaLocation::Impl & obj )
65  { return str << "[" << obj._medianr << "]" << obj._filename << "{" << obj._downloadSize << "|" << obj._checksum << "|" << obj._deltafile << "}"; }
66 
68  inline std::ostream & dumpOn( std::ostream & str, const OnMediaLocation::Impl & obj )
69  { return str << obj; }
70 
72  // CLASS NAME : OnMediaLocation
74 
76  : _pimpl( Impl::nullimpl() )
77  {}
78 
79  OnMediaLocation::OnMediaLocation( Pathname filename_r, unsigned medianr_r )
80  : _pimpl( new Impl( std::move(filename_r), medianr_r ) )
81  {}
82 
84  {}
85 
86 
88  { return _pimpl->_filename; }
89 
90  unsigned OnMediaLocation::medianr() const
91  { return _pimpl->_medianr; }
92 
93  OnMediaLocation & OnMediaLocation::setLocation( Pathname filename_r, unsigned medianr_r )
94  { _pimpl->_filename = std::move(filename_r); _pimpl->_medianr = medianr_r; return *this; }
95 
97  { _pimpl->_filename = Pathname(); _pimpl->_medianr = 0; return *this; }
98 
100  { _pimpl->_filename = std::move(filename_r); return *this; }
101 
103  { _pimpl->_medianr = medianr_r; return *this; }
104 
106  { if ( ! prefix_r.emptyOrRoot() ) changeFilename( prefix_r / filename() ); return *this; }
107 
109  { return _pimpl->_optional; }
110 
112  { _pimpl->_optional = val_r; return *this; }
113 
115  { return _pimpl->_downloadSize; }
116 
118  { _pimpl->_downloadSize = val_r; return *this; }
119 
121  { return _pimpl->_checksum; }
122 
124  { _pimpl->_checksum = val_r; return *this; }
125 
127  { return _pimpl->_openSize; }
128 
130  { _pimpl->_openSize = val_r; return *this; }
131 
133  { return _pimpl->_openChecksum; }
134 
136  { _pimpl->_openChecksum = val_r; return *this; }
137 
139  { return _pimpl->_headerSize; }
140 
142  { _pimpl->_headerSize = val_r; return *this; }
143 
145  { return _pimpl->_headerChecksum; }
146 
148  { _pimpl->_headerChecksum = val_r; return *this; }
149 
151  { return _pimpl->_deltafile; }
152 
154  { _pimpl->_deltafile = std::move(path); return *this; }
155 
156  std::ostream & operator<<( std::ostream & str, const OnMediaLocation & obj )
157  { return str << *obj._pimpl; }
158 
159  std::ostream & dumpOn( std::ostream & str, const OnMediaLocation & obj )
160  { return dumpOn( str, *obj._pimpl ); }
161 
162 } // 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.
OnMediaLocation & setDownloadSize(ByteCount val_r)
Set the downloadSize.
const Pathname & filename() const
The path to the resource on the medium.
OnMediaLocation & setOpenSize(ByteCount val_r)
Set the openSize.
OnMediaLocation & changeMedianr(unsigned medianr_r)
Individual manipulation of medianr (prefer setLocation).
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.
unsigned medianr() const
The media number the resource is located on.
const CheckSum & headerChecksum() const
The checksum of the header prepending the resource (e.g.
OnMediaLocation & changeFilename(Pathname filename_r)
Individual manipulation of filename (prefer setLocation).
RWCOW_pointer< Impl > _pimpl
Implementation class.
OnMediaLocation & setHeaderSize(ByteCount val_r)
Set the headerSize.
const CheckSum & checksum() const
The checksum of the resource on the server.
OnMediaLocation()
Default Ctor indicating no media access.
OnMediaLocation & prependPath(const Pathname &prefix_r)
Prepend the filename with prefix_r.
const CheckSum & openChecksum() const
The checksum of the resource once it has been uncompressed or unpacked.
OnMediaLocation & unsetLocation()
Unset filename and set medianr to 0.
OnMediaLocation & setLocation(Pathname filename_r, unsigned medianr_r=1)
Set filename_r and medianr_r (defaults to 1).
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.
bool emptyOrRoot() const
Test for "" or "/".
Definition: Pathname.h:121
Definition: Arch.h:352
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
Definition: SerialNumber.cc:52
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition: Capability.cc:567
OnMediaLocation implementation.
std::ostream & dumpOn(std::ostream &str, const OnMediaLocation::Impl &obj)
Verbose stream output.
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Impl * clone() const
clone for RWCOW_pointer
Impl(Pathname filename_r, unsigned medianr_r)
std::ostream & operator<<(std::ostream &str, const OnMediaLocation::Impl &obj)
Stream output.