libzypp  17.37.18
onmedialocation.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #include <iostream>
13 //#include <zypp-core/base/Logger.h>
14 
15 #include <utility>
16 #include <zypp-core/OnMediaLocation>
17 
18 using std::endl;
19 
21 namespace zypp
22 {
28  {
29  public:
30  Impl()
31  {}
32 
33  Impl( Pathname filename_r, unsigned medianr_r )
34  : _filename { std::move(filename_r) }
35  , _medianr { medianr_r }
36  {}
37 
39  unsigned _medianr = 0U;
40 
41  bool _optional = false;
42 
45 
48 
51 
53 
54  bool _mirrorsAllowed = true;
55 
56  public:
58  static shared_ptr<Impl> nullimpl()
59  { static shared_ptr<Impl> _nullimpl( new Impl ); return _nullimpl; }
60  private:
61  friend Impl * rwcowClone<Impl>( const Impl * rhs );
63  Impl * clone() const { return new Impl( *this ); }
64  };
65 
67  inline std::ostream & operator<<( std::ostream & str, const OnMediaLocation::Impl & obj )
68  { return str << "[" << obj._medianr << "]" << obj._filename << "{" << obj._downloadSize << "|" << obj._checksum << "|" << obj._deltafile << "}"; }
69 
71  inline std::ostream & dumpOn( std::ostream & str, const OnMediaLocation::Impl & obj )
72  { return str << obj; }
73 
75  // CLASS NAME : OnMediaLocation
77 
79  : _pimpl( Impl::nullimpl() )
80  {}
81 
82  OnMediaLocation::OnMediaLocation( Pathname filename_r, unsigned medianr_r )
83  : _pimpl( new Impl( std::move(filename_r), medianr_r ) )
84  {}
85 
87  {}
88 
89 
91  { return _pimpl->_filename; }
92 
93  unsigned OnMediaLocation::medianr() const
94  { return _pimpl->_medianr; }
95 
96  OnMediaLocation & OnMediaLocation::setLocation( Pathname filename_r, unsigned medianr_r )
97  { _pimpl->_filename = std::move(filename_r); _pimpl->_medianr = medianr_r; return *this; }
98 
100  { _pimpl->_filename = Pathname(); _pimpl->_medianr = 0; return *this; }
101 
103  { _pimpl->_filename = std::move(filename_r); return *this; }
104 
106  { _pimpl->_medianr = medianr_r; return *this; }
107 
109  { if ( ! prefix_r.emptyOrRoot() ) changeFilename( prefix_r / filename() ); return *this; }
110 
112  { return _pimpl->_optional; }
113 
115  { _pimpl->_optional = val_r; return *this; }
116 
118  { return _pimpl->_downloadSize; }
119 
121  { _pimpl->_downloadSize = val_r; return *this; }
122 
124  { return _pimpl->_checksum; }
125 
127  { _pimpl->_checksum = std::move(val_r); return *this; }
128 
130  { return _pimpl->_openSize; }
131 
133  { _pimpl->_openSize = val_r; return *this; }
134 
136  { return _pimpl->_openChecksum; }
137 
139  { _pimpl->_openChecksum = std::move(val_r); return *this; }
140 
142  { return _pimpl->_headerSize; }
143 
145  { _pimpl->_headerSize = val_r; return *this; }
146 
148  { return _pimpl->_headerChecksum; }
149 
151  { _pimpl->_headerChecksum = std::move(val_r); return *this; }
152 
154  { return _pimpl->_deltafile; }
155 
157  { _pimpl->_deltafile = std::move(path); return *this; }
158 
160  { return _pimpl->_mirrorsAllowed; }
161 
163  { _pimpl->_mirrorsAllowed = set; return *this; }
164 
165  std::ostream & operator<<( std::ostream & str, const OnMediaLocation & obj )
166  { return str << *obj._pimpl; }
167 
168  std::ostream & dumpOn( std::ostream & str, const OnMediaLocation & obj )
169  { return dumpOn( str, *obj._pimpl ); }
170 
171 } // namespace zypp
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.
const ByteCount & headerSize() const
The size of the header prepending the resource (e.g.
Describes a resource file located on a medium.
std::ostream & operator<<(std::ostream &str, const OnMediaLocation::Impl &obj)
const ByteCount & openSize() const
The size of the resource once it has been uncompressed or unpacked.
OnMediaLocation & prependPath(const Pathname &prefix_r)
Prepend the filename with prefix_r.
Store and operate with byte count.
Definition: ByteCount.h:31
OnMediaLocation implementation.
String related utilities and Regular expression matching.
OnMediaLocation & setChecksum(CheckSum val_r)
Set the checksum.
Definition: ansi.h:854
OnMediaLocation & setMirrorsAllowed(bool set=true)
Enables or disables the use of mirrors when fetching this file.
const CheckSum & checksum() const
The checksum of the resource on the server.
bool mirrorsAllowed() const
The requested file is allowed to be fetched via mirrors ( defaults to true )
unsigned medianr() const
The media number the resource is located on.
bool emptyOrRoot() const
Test for "" or "/".
Definition: Pathname.h:123
OnMediaLocation & setOpenSize(ByteCount val_r)
Set the openSize.
std::ostream & dumpOn(std::ostream &str, const OnMediaLocation &obj)
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:216
const ByteCount & downloadSize() const
The size of the resource on the server.
OnMediaLocation & setHeaderSize(ByteCount val_r)
Set the headerSize.
OnMediaLocation & setLocation(Pathname filename_r, unsigned medianr_r=1)
Set filename_r and medianr_r (defaults to 1).
const Pathname & filename() const
The path to the resource on the medium.
static shared_ptr< Impl > nullimpl()
Offer default Impl.
OnMediaLocation & setDeltafile(Pathname path)
Set the deltafile.
OnMediaLocation()
Default Ctor indicating no media access.
const Pathname & deltafile() const
The existing deltafile that can be used to reduce download size ( zchunk or metalink ) ...
Impl * clone() const
clone for RWCOW_pointer
OnMediaLocation & changeMedianr(unsigned medianr_r)
Individual manipulation of medianr (prefer setLocation).
OnMediaLocation & setDownloadSize(ByteCount val_r)
Set the downloadSize.
std::ostream & dumpOn(std::ostream &str, const OnMediaLocation::Impl &obj)
Impl(Pathname filename_r, unsigned medianr_r)
OnMediaLocation & changeFilename(Pathname filename_r)
Individual manipulation of filename (prefer setLocation).
RWCOW_pointer< Impl > _pimpl
Implementation class.
OnMediaLocation & setOptional(bool val)
Set whether the resource is optional.
bool optional() const
Whether this is an optional resource.
const CheckSum & headerChecksum() const
The checksum of the header prepending the resource (e.g.
OnMediaLocation & unsetLocation()
Unset filename and set medianr to 0.