libzypp: zypp/OnMediaLocation.cc Source File

libzypp 17.25.10

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/OnMediaLocation.h>
16
17 using std::endl;
18
20 namespace zypp
21 {
26 struct OnMediaLocation::Impl
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
37 Pathname _filename;
38 unsigned _medianr = 0U;
39
40 bool _optional = false;
41
42 ByteCount _downloadSize;
43 CheckSum _checksum;
44
45 ByteCount _openSize;
46 CheckSum _openChecksum;
47
48 ByteCount _headerSize;
49 CheckSum _headerChecksum;
50
51 public:
53 static shared_ptr<Impl> nullimpl()
54 { static shared_ptr<Impl> _nullimpl( new Impl ); return _nullimpl; }
55 private:
56 friend Impl * rwcowClone<Impl>( const Impl * rhs );
58 Impl * clone() const { return new Impl( *this ); }
59 };
60
62 inline std::ostream & operator<<( std::ostream & str, const OnMediaLocation::Impl & obj )
63 { return str << "[" << obj._medianr << "]" << obj._filename << "{" << obj._downloadSize << "|" << obj._checksum << "}"; }
64
66 inline std::ostream & dumpOn( std::ostream & str, const OnMediaLocation::Impl & obj )
67 { return str << obj; }
68
70 // CLASS NAME : OnMediaLocation
72
73 OnMediaLocation::OnMediaLocation()
74 : _pimpl( Impl::nullimpl() )
75 {}
76
77 OnMediaLocation::OnMediaLocation( Pathname filename_r, unsigned medianr_r )
78 : _pimpl( new Impl( std::move(filename_r), medianr_r ) )
79 {}
80
81 OnMediaLocation::~OnMediaLocation()
82 {}
83
84
85 const Pathname & OnMediaLocation::filename() const
86 { return _pimpl->_filename; }
87
88 unsigned OnMediaLocation::medianr() const
89 { return _pimpl->_medianr; }
90
91 OnMediaLocation & OnMediaLocation::setLocation( Pathname filename_r, unsigned medianr_r )
92 { _pimpl->_filename = std::move(filename_r); _pimpl->_medianr = medianr_r; return *this; }
93
94 OnMediaLocation & OnMediaLocation::unsetLocation()
95 { _pimpl->_filename = Pathname(); _pimpl->_medianr = 0; return *this; }
96
97 OnMediaLocation & OnMediaLocation::changeFilename( Pathname filename_r )
98 { _pimpl->_filename = std::move(filename_r); return *this; }
99
100 OnMediaLocation & OnMediaLocation::changeMedianr( unsigned medianr_r )
101 { _pimpl->_medianr = medianr_r; return *this; }
102
103 OnMediaLocation & OnMediaLocation::prependPath( const Pathname & prefix_r )
104 { if ( ! prefix_r.emptyOrRoot() ) changeFilename( prefix_r / filename() ); return *this; }
105
106 bool OnMediaLocation::optional() const
107 { return _pimpl->_optional; }
108
109 OnMediaLocation & OnMediaLocation::setOptional( bool val_r )
110 { _pimpl->_optional = val_r; return *this; }
111
112 const ByteCount & OnMediaLocation::downloadSize() const
113 { return _pimpl->_downloadSize; }
114
115 OnMediaLocation & OnMediaLocation::setDownloadSize( ByteCount val_r )
116 { _pimpl->_downloadSize = val_r; return *this; }
117
118 const CheckSum & OnMediaLocation::checksum() const
119 { return _pimpl->_checksum; }
120
121 OnMediaLocation & OnMediaLocation::setChecksum( CheckSum val_r )
122 { _pimpl->_checksum = val_r; return *this; }
123
124 const ByteCount & OnMediaLocation::openSize() const
125 { return _pimpl->_openSize; }
126
127 OnMediaLocation & OnMediaLocation::setOpenSize( ByteCount val_r )
128 { _pimpl->_openSize = val_r; return *this; }
129
130 const CheckSum & OnMediaLocation::openChecksum() const
131 { return _pimpl->_openChecksum; }
132
133 OnMediaLocation & OnMediaLocation::setOpenChecksum( CheckSum val_r )
134 { _pimpl->_openChecksum = val_r; return *this; }
135
136 const ByteCount & OnMediaLocation::headerSize() const
137 { return _pimpl->_headerSize; }
138
139 OnMediaLocation & OnMediaLocation::setHeaderSize( ByteCount val_r )
140 { _pimpl->_headerSize = val_r; return *this; }
141
142 const CheckSum & OnMediaLocation::headerChecksum() const
143 { return _pimpl->_headerChecksum; }
144
145 OnMediaLocation & OnMediaLocation::setHeaderChecksum( CheckSum val_r )
146 { _pimpl->_headerChecksum = val_r; return *this; }
147
148
149 std::ostream & operator<<( std::ostream & str, const OnMediaLocation & obj )
150 { return str << *obj._pimpl; }
151
152 std::ostream & dumpOn( std::ostream & str, const OnMediaLocation & obj )
153 { return dumpOn( str, *obj._pimpl ); }
154
155 } // namespace zypp
OnMediaLocation.h
zypp::ByteCount
Store and operate with byte count.
Definition: ByteCount.h:31
zypp::CheckSum
Definition: CheckSum.h:34
zypp::OnMediaLocation
Describes a resource file located on a medium.
Definition: OnMediaLocation.h:39
zypp::OnMediaLocation::optional
bool optional() const
Whether this is an optional resource.
Definition: OnMediaLocation.cc:106
zypp::OnMediaLocation::downloadSize
const ByteCount & downloadSize() const
The size of the resource on the server.
Definition: OnMediaLocation.cc:112
zypp::OnMediaLocation::setDownloadSize
OnMediaLocation & setDownloadSize(ByteCount val_r)
Set the downloadSize.
Definition: OnMediaLocation.cc:115
zypp::OnMediaLocation::filename
const Pathname & filename() const
The path to the resource on the medium.
Definition: OnMediaLocation.cc:85
zypp::OnMediaLocation::setOpenSize
OnMediaLocation & setOpenSize(ByteCount val_r)
Set the openSize.
Definition: OnMediaLocation.cc:127
zypp::OnMediaLocation::changeMedianr
OnMediaLocation & changeMedianr(unsigned medianr_r)
Individual manipulation of medianr (prefer setLocation).
Definition: OnMediaLocation.cc:100
zypp::OnMediaLocation::openSize
const ByteCount & openSize() const
The size of the resource once it has been uncompressed or unpacked.
Definition: OnMediaLocation.cc:124
zypp::OnMediaLocation::headerSize
const ByteCount & headerSize() const
The size of the header prepending the resource (e.g.
Definition: OnMediaLocation.cc:136
zypp::OnMediaLocation::setChecksum
OnMediaLocation & setChecksum(CheckSum val_r)
Set the checksum.
Definition: OnMediaLocation.cc:121
zypp::OnMediaLocation::medianr
unsigned medianr() const
The media number the resource is located on.
Definition: OnMediaLocation.cc:88
zypp::OnMediaLocation::headerChecksum
const CheckSum & headerChecksum() const
The checksum of the header prepending the resource (e.g.
Definition: OnMediaLocation.cc:142
zypp::OnMediaLocation::changeFilename
OnMediaLocation & changeFilename(Pathname filename_r)
Individual manipulation of filename (prefer setLocation).
Definition: OnMediaLocation.cc:97
zypp::OnMediaLocation::_pimpl
RWCOW_pointer< Impl > _pimpl
Implementation class.
Definition: OnMediaLocation.h:120
zypp::OnMediaLocation::setHeaderSize
OnMediaLocation & setHeaderSize(ByteCount val_r)
Set the headerSize.
Definition: OnMediaLocation.cc:139
zypp::OnMediaLocation::checksum
const CheckSum & checksum() const
The checksum of the resource on the server.
Definition: OnMediaLocation.cc:118
zypp::OnMediaLocation::OnMediaLocation
OnMediaLocation()
Default Ctor indicating no media access.
Definition: OnMediaLocation.cc:73
zypp::OnMediaLocation::prependPath
OnMediaLocation & prependPath(const Pathname &prefix_r)
Prepend the filename with prefix_r.
Definition: OnMediaLocation.cc:103
zypp::OnMediaLocation::openChecksum
const CheckSum & openChecksum() const
The checksum of the resource once it has been uncompressed or unpacked.
Definition: OnMediaLocation.cc:130
zypp::OnMediaLocation::unsetLocation
OnMediaLocation & unsetLocation()
Unset filename and set medianr to 0.
Definition: OnMediaLocation.cc:94
zypp::OnMediaLocation::setLocation
OnMediaLocation & setLocation(Pathname filename_r, unsigned medianr_r=1)
Set filename_r and medianr_r (defaults to 1).
Definition: OnMediaLocation.cc:91
zypp::OnMediaLocation::setOpenChecksum
OnMediaLocation & setOpenChecksum(CheckSum val_r)
Set the openChecksum.
Definition: OnMediaLocation.cc:133
zypp::OnMediaLocation::setHeaderChecksum
OnMediaLocation & setHeaderChecksum(CheckSum val_r)
Set the headerChecksum.
Definition: OnMediaLocation.cc:145
zypp::OnMediaLocation::~OnMediaLocation
~OnMediaLocation()
Dtor.
Definition: OnMediaLocation.cc:81
zypp::OnMediaLocation::setOptional
OnMediaLocation & setOptional(bool val)
Set whether the resource is optional.
Definition: OnMediaLocation.cc:109
zypp::filesystem::Pathname
Pathname.
Definition: Pathname.h:45
zypp::filesystem::Pathname::emptyOrRoot
bool emptyOrRoot() const
Test for "" or "/".
Definition: Pathname.h:121
std
Definition: Arch.h:348
str
String related utilities and Regular expression matching.
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:147
zypp::dumpOn
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition: Capability.cc:444
zypp::OnMediaLocation::Impl
OnMediaLocation implementation.
Definition: OnMediaLocation.cc:27
zypp::OnMediaLocation::Impl::_headerSize
ByteCount _headerSize
Definition: OnMediaLocation.cc:48
zypp::OnMediaLocation::Impl::Impl
Impl()
Definition: OnMediaLocation.cc:29
zypp::OnMediaLocation::Impl::_optional
bool _optional
Definition: OnMediaLocation.cc:40
zypp::OnMediaLocation::Impl::dumpOn
std::ostream & dumpOn(std::ostream &str, const OnMediaLocation::Impl &obj)
Verbose stream output.
Definition: OnMediaLocation.cc:66
zypp::OnMediaLocation::Impl::_checksum
CheckSum _checksum
Definition: OnMediaLocation.cc:43
zypp::OnMediaLocation::Impl::nullimpl
static shared_ptr< Impl > nullimpl()
Offer default Impl.
Definition: OnMediaLocation.cc:53
zypp::OnMediaLocation::Impl::clone
Impl * clone() const
clone for RWCOW_pointer
Definition: OnMediaLocation.cc:58
zypp::OnMediaLocation::Impl::Impl
Impl(Pathname filename_r, unsigned medianr_r)
Definition: OnMediaLocation.cc:32
zypp::OnMediaLocation::Impl::_filename
Pathname _filename
Definition: OnMediaLocation.cc:37
zypp::OnMediaLocation::Impl::_openChecksum
CheckSum _openChecksum
Definition: OnMediaLocation.cc:46
zypp::OnMediaLocation::Impl::operator<<
std::ostream & operator<<(std::ostream &str, const OnMediaLocation::Impl &obj)
Stream output.
Definition: OnMediaLocation.cc:62
zypp::OnMediaLocation::Impl::_medianr
unsigned _medianr
Definition: OnMediaLocation.cc:38
zypp::OnMediaLocation::Impl::_openSize
ByteCount _openSize
Definition: OnMediaLocation.cc:45
zypp::OnMediaLocation::Impl::_downloadSize
ByteCount _downloadSize
Definition: OnMediaLocation.cc:42
zypp::OnMediaLocation::Impl::_headerChecksum
CheckSum _headerChecksum
Definition: OnMediaLocation.cc:49