libzypp: zypp-core/onmedialocation.cc Source File

libzypp 17.38.14

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
18using std::endl;
19
21namespace zypp
22{
27 class OnMediaLocation::Impl
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
38 Pathname _filename;
39 unsigned _medianr = 0U;
40
41 bool _optional = false;
42
43 ByteCount _downloadSize;
44 CheckSum _checksum;
45
46 ByteCount _openSize;
47 CheckSum _openChecksum;
48
49 ByteCount _headerSize;
50 CheckSum _headerChecksum;
51
52 Pathname _deltafile;
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
78 OnMediaLocation::OnMediaLocation()
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
86 OnMediaLocation::~OnMediaLocation()
87 {}
88
89
90 const Pathname & OnMediaLocation::filename() const
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
99 OnMediaLocation & OnMediaLocation::unsetLocation()
100 { _pimpl->_filename = Pathname(); _pimpl->_medianr = 0; return *this; }
101
102 OnMediaLocation & OnMediaLocation::changeFilename( Pathname filename_r )
103 { _pimpl->_filename = std::move(filename_r); return *this; }
104
105 OnMediaLocation & OnMediaLocation::changeMedianr( unsigned medianr_r )
106 { _pimpl->_medianr = medianr_r; return *this; }
107
108 OnMediaLocation & OnMediaLocation::prependPath( const Pathname & prefix_r )
109 { if ( ! prefix_r.emptyOrRoot() ) changeFilename( prefix_r / filename() ); return *this; }
110
111 bool OnMediaLocation::optional() const
112 { return _pimpl->_optional; }
113
114 OnMediaLocation & OnMediaLocation::setOptional( bool val_r )
115 { _pimpl->_optional = val_r; return *this; }
116
117 const ByteCount & OnMediaLocation::downloadSize() const
118 { return _pimpl->_downloadSize; }
119
120 OnMediaLocation & OnMediaLocation::setDownloadSize( ByteCount val_r )
121 { _pimpl->_downloadSize = val_r; return *this; }
122
123 const CheckSum & OnMediaLocation::checksum() const
124 { return _pimpl->_checksum; }
125
126 OnMediaLocation & OnMediaLocation::setChecksum( CheckSum val_r )
127 { _pimpl->_checksum = std::move(val_r); return *this; }
128
129 const ByteCount & OnMediaLocation::openSize() const
130 { return _pimpl->_openSize; }
131
132 OnMediaLocation & OnMediaLocation::setOpenSize( ByteCount val_r )
133 { _pimpl->_openSize = val_r; return *this; }
134
135 const CheckSum & OnMediaLocation::openChecksum() const
136 { return _pimpl->_openChecksum; }
137
138 OnMediaLocation & OnMediaLocation::setOpenChecksum( CheckSum val_r )
139 { _pimpl->_openChecksum = std::move(val_r); return *this; }
140
141 const ByteCount & OnMediaLocation::headerSize() const
142 { return _pimpl->_headerSize; }
143
144 OnMediaLocation & OnMediaLocation::setHeaderSize( ByteCount val_r )
145 { _pimpl->_headerSize = val_r; return *this; }
146
147 const CheckSum & OnMediaLocation::headerChecksum() const
148 { return _pimpl->_headerChecksum; }
149
150 OnMediaLocation & OnMediaLocation::setHeaderChecksum( CheckSum val_r )
151 { _pimpl->_headerChecksum = std::move(val_r); return *this; }
152
153 const Pathname &OnMediaLocation::deltafile() const
154 { return _pimpl->_deltafile; }
155
156 OnMediaLocation &OnMediaLocation::setDeltafile( Pathname path )
157 { _pimpl->_deltafile = std::move(path); return *this; }
158
159 bool OnMediaLocation::mirrorsAllowed() const
160 { return _pimpl->_mirrorsAllowed; }
161
162 OnMediaLocation &OnMediaLocation::setMirrorsAllowed(bool set)
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
shared_ptr
zypp::ByteCount
Store and operate with byte count.
Definition ByteCount.h:32
zypp::CheckSum
Definition CheckSum.h:34
zypp::OnMediaLocation::Impl
OnMediaLocation implementation.
Definition onmedialocation.cc:28
zypp::OnMediaLocation::Impl::_headerSize
ByteCount _headerSize
Definition onmedialocation.cc:49
zypp::OnMediaLocation::Impl::Impl
Impl()
Definition onmedialocation.cc:30
zypp::OnMediaLocation::Impl::_deltafile
Pathname _deltafile
Definition onmedialocation.cc:52
zypp::OnMediaLocation::Impl::_optional
bool _optional
Definition onmedialocation.cc:41
zypp::OnMediaLocation::Impl::clone
Impl * clone() const
clone for RWCOW_pointer
Definition onmedialocation.cc:63
zypp::OnMediaLocation::Impl::_checksum
CheckSum _checksum
Definition onmedialocation.cc:44
zypp::OnMediaLocation::Impl::rwcowClone
friend Impl * rwcowClone(const Impl *rhs)
zypp::OnMediaLocation::Impl::Impl
Impl(Pathname filename_r, unsigned medianr_r)
Definition onmedialocation.cc:33
zypp::OnMediaLocation::Impl::_filename
Pathname _filename
Definition onmedialocation.cc:38
zypp::OnMediaLocation::Impl::_openChecksum
CheckSum _openChecksum
Definition onmedialocation.cc:47
zypp::OnMediaLocation::Impl::nullimpl
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition onmedialocation.cc:58
zypp::OnMediaLocation::Impl::_medianr
unsigned _medianr
Definition onmedialocation.cc:39
zypp::OnMediaLocation::Impl::_openSize
ByteCount _openSize
Definition onmedialocation.cc:46
zypp::OnMediaLocation::Impl::_downloadSize
ByteCount _downloadSize
Definition onmedialocation.cc:43
zypp::OnMediaLocation::Impl::_headerChecksum
CheckSum _headerChecksum
Definition onmedialocation.cc:50
zypp::OnMediaLocation::Impl::_mirrorsAllowed
bool _mirrorsAllowed
Definition onmedialocation.cc:54
zypp::OnMediaLocation::optional
bool optional() const
Whether this is an optional resource.
Definition onmedialocation.cc:111
zypp::OnMediaLocation::downloadSize
const ByteCount & downloadSize() const
The size of the resource on the server.
Definition onmedialocation.cc:117
zypp::OnMediaLocation::setDownloadSize
OnMediaLocation & setDownloadSize(ByteCount val_r)
Set the downloadSize.
Definition onmedialocation.cc:120
zypp::OnMediaLocation::filename
const Pathname & filename() const
The path to the resource on the medium.
Definition onmedialocation.cc:90
zypp::OnMediaLocation::setMirrorsAllowed
OnMediaLocation & setMirrorsAllowed(bool set=true)
Enables or disables the use of mirrors when fetching this file.
Definition onmedialocation.cc:162
zypp::OnMediaLocation::setOpenSize
OnMediaLocation & setOpenSize(ByteCount val_r)
Set the openSize.
Definition onmedialocation.cc:132
zypp::OnMediaLocation::changeMedianr
OnMediaLocation & changeMedianr(unsigned medianr_r)
Individual manipulation of medianr (prefer setLocation).
Definition onmedialocation.cc:105
zypp::OnMediaLocation::openSize
const ByteCount & openSize() const
The size of the resource once it has been uncompressed or unpacked.
Definition onmedialocation.cc:129
zypp::OnMediaLocation::deltafile
const Pathname & deltafile() const
The existing deltafile that can be used to reduce download size ( zchunk or metalink ).
Definition onmedialocation.cc:153
zypp::OnMediaLocation::headerSize
const ByteCount & headerSize() const
The size of the header prepending the resource (e.g.
Definition onmedialocation.cc:141
zypp::OnMediaLocation::setChecksum
OnMediaLocation & setChecksum(CheckSum val_r)
Set the checksum.
Definition onmedialocation.cc:126
zypp::OnMediaLocation::medianr
unsigned medianr() const
The media number the resource is located on.
Definition onmedialocation.cc:93
zypp::OnMediaLocation::headerChecksum
const CheckSum & headerChecksum() const
The checksum of the header prepending the resource (e.g.
Definition onmedialocation.cc:147
zypp::OnMediaLocation::changeFilename
OnMediaLocation & changeFilename(Pathname filename_r)
Individual manipulation of filename (prefer setLocation).
Definition onmedialocation.cc:102
zypp::OnMediaLocation::_pimpl
RWCOW_pointer< Impl > _pimpl
Implementation class.
Definition onmedialocation.h:132
zypp::OnMediaLocation::setHeaderSize
OnMediaLocation & setHeaderSize(ByteCount val_r)
Set the headerSize.
Definition onmedialocation.cc:144
zypp::OnMediaLocation::checksum
const CheckSum & checksum() const
The checksum of the resource on the server.
Definition onmedialocation.cc:123
zypp::OnMediaLocation::OnMediaLocation
OnMediaLocation()
Default Ctor indicating no media access.
Definition onmedialocation.cc:78
zypp::OnMediaLocation::prependPath
OnMediaLocation & prependPath(const Pathname &prefix_r)
Prepend the filename with prefix_r.
Definition onmedialocation.cc:108
zypp::OnMediaLocation::openChecksum
const CheckSum & openChecksum() const
The checksum of the resource once it has been uncompressed or unpacked.
Definition onmedialocation.cc:135
zypp::OnMediaLocation::dumpOn
friend std::ostream & dumpOn(std::ostream &str, const OnMediaLocation &obj)
Definition onmedialocation.cc:168
zypp::OnMediaLocation::unsetLocation
OnMediaLocation & unsetLocation()
Unset filename and set medianr to 0.
Definition onmedialocation.cc:99
zypp::OnMediaLocation::setLocation
OnMediaLocation & setLocation(Pathname filename_r, unsigned medianr_r=1)
Set filename_r and medianr_r (defaults to 1).
Definition onmedialocation.cc:96
zypp::OnMediaLocation::setOpenChecksum
OnMediaLocation & setOpenChecksum(CheckSum val_r)
Set the openChecksum.
Definition onmedialocation.cc:138
zypp::OnMediaLocation::setHeaderChecksum
OnMediaLocation & setHeaderChecksum(CheckSum val_r)
Set the headerChecksum.
Definition onmedialocation.cc:150
zypp::OnMediaLocation::~OnMediaLocation
~OnMediaLocation()
Dtor.
Definition onmedialocation.cc:86
zypp::OnMediaLocation::mirrorsAllowed
bool mirrorsAllowed() const
The requested file is allowed to be fetched via mirrors ( defaults to true ).
Definition onmedialocation.cc:159
zypp::OnMediaLocation::operator<<
friend std::ostream & operator<<(std::ostream &str, const OnMediaLocation &obj)
relates: OnMediaLocation Stream output
Definition onmedialocation.cc:165
zypp::OnMediaLocation::setOptional
OnMediaLocation & setOptional(bool val)
Set whether the resource is optional.
Definition onmedialocation.cc:114
zypp::OnMediaLocation::setDeltafile
OnMediaLocation & setDeltafile(Pathname path)
Set the deltafile.
Definition onmedialocation.cc:156
zypp::Pathname::Pathname
Pathname()
Default ctor: an empty path.
Definition Pathname.h:51
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:48
zypp::filesystem::Pathname::emptyOrRoot
bool emptyOrRoot() const
Test for "" or "/".
Definition Pathname.h:127
std
Definition ansi.h:855
str
String related utilities and Regular expression matching.
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::dumpOn
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
relates: Capability Detailed stream output
Definition Capability.cc:589
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const Capabilities &obj)
relates: Capabilities Stream output
Definition Capabilities.cc:65