1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/source/OnMediaLocation.cc
13 //#include "zypp/base/Logger.h"
15 #include "zypp/OnMediaLocation.h"
19 ///////////////////////////////////////////////////////////////////
22 ///////////////////////////////////////////////////////////////////
23 /// \class OnMediaLocation::Impl
24 /// \brief OnMediaLocation implementation.
25 ///////////////////////////////////////////////////////////////////
26 struct OnMediaLocation::Impl
32 Impl( Pathname filename_r, unsigned medianr_r )
33 : _filename { std::move(filename_r) }
34 , _medianr { medianr_r }
38 unsigned _medianr = 0U;
40 bool _optional = false;
42 ByteCount _downloadSize;
46 CheckSum _openChecksum;
48 ByteCount _headerSize;
49 CheckSum _headerChecksum;
52 /** Offer default Impl. */
53 static shared_ptr<Impl> nullimpl()
54 { static shared_ptr<Impl> _nullimpl( new Impl ); return _nullimpl; }
56 friend Impl * rwcowClone<Impl>( const Impl * rhs );
57 /** clone for RWCOW_pointer */
58 Impl * clone() const { return new Impl( *this ); }
61 /** \relates OnMediaLocation::Impl Stream output */
62 inline std::ostream & operator<<( std::ostream & str, const OnMediaLocation::Impl & obj )
63 { return str << "[" << obj._medianr << "]" << obj._filename << "{" << obj._downloadSize << "|" << obj._checksum << "}"; }
65 /** \relates OnMediaLocation::Impl Verbose stream output */
66 inline std::ostream & dumpOn( std::ostream & str, const OnMediaLocation::Impl & obj )
67 { return str << obj; }
69 ///////////////////////////////////////////////////////////////////
70 // CLASS NAME : OnMediaLocation
71 ///////////////////////////////////////////////////////////////////
73 OnMediaLocation::OnMediaLocation()
74 : _pimpl( Impl::nullimpl() )
77 OnMediaLocation::OnMediaLocation( Pathname filename_r, unsigned medianr_r )
78 : _pimpl( new Impl( std::move(filename_r), medianr_r ) )
81 OnMediaLocation::~OnMediaLocation()
85 const Pathname & OnMediaLocation::filename() const
86 { return _pimpl->_filename; }
88 unsigned OnMediaLocation::medianr() const
89 { return _pimpl->_medianr; }
91 OnMediaLocation & OnMediaLocation::setLocation( Pathname filename_r, unsigned medianr_r )
92 { _pimpl->_filename = std::move(filename_r); _pimpl->_medianr = medianr_r; return *this; }
94 OnMediaLocation & OnMediaLocation::unsetLocation()
95 { _pimpl->_filename = Pathname(); _pimpl->_medianr = 0; return *this; }
97 OnMediaLocation & OnMediaLocation::changeFilename( Pathname filename_r )
98 { _pimpl->_filename = std::move(filename_r); return *this; }
100 OnMediaLocation & OnMediaLocation::changeMedianr( unsigned medianr_r )
101 { _pimpl->_medianr = medianr_r; return *this; }
103 OnMediaLocation & OnMediaLocation::prependPath( const Pathname & prefix_r )
104 { if ( ! prefix_r.emptyOrRoot() ) changeFilename( prefix_r / filename() ); return *this; }
106 bool OnMediaLocation::optional() const
107 { return _pimpl->_optional; }
109 OnMediaLocation & OnMediaLocation::setOptional( bool val_r )
110 { _pimpl->_optional = val_r; return *this; }
112 const ByteCount & OnMediaLocation::downloadSize() const
113 { return _pimpl->_downloadSize; }
115 OnMediaLocation & OnMediaLocation::setDownloadSize( ByteCount val_r )
116 { _pimpl->_downloadSize = val_r; return *this; }
118 const CheckSum & OnMediaLocation::checksum() const
119 { return _pimpl->_checksum; }
121 OnMediaLocation & OnMediaLocation::setChecksum( CheckSum val_r )
122 { _pimpl->_checksum = val_r; return *this; }
124 const ByteCount & OnMediaLocation::openSize() const
125 { return _pimpl->_openSize; }
127 OnMediaLocation & OnMediaLocation::setOpenSize( ByteCount val_r )
128 { _pimpl->_openSize = val_r; return *this; }
130 const CheckSum & OnMediaLocation::openChecksum() const
131 { return _pimpl->_openChecksum; }
133 OnMediaLocation & OnMediaLocation::setOpenChecksum( CheckSum val_r )
134 { _pimpl->_openChecksum = val_r; return *this; }
136 const ByteCount & OnMediaLocation::headerSize() const
137 { return _pimpl->_headerSize; }
139 OnMediaLocation & OnMediaLocation::setHeaderSize( ByteCount val_r )
140 { _pimpl->_headerSize = val_r; return *this; }
142 const CheckSum & OnMediaLocation::headerChecksum() const
143 { return _pimpl->_headerChecksum; }
145 OnMediaLocation & OnMediaLocation::setHeaderChecksum( CheckSum val_r )
146 { _pimpl->_headerChecksum = val_r; return *this; }
149 std::ostream & operator<<( std::ostream & str, const OnMediaLocation & obj )
150 { return str << *obj._pimpl; }
152 std::ostream & dumpOn( std::ostream & str, const OnMediaLocation & obj )
153 { return dumpOn( str, *obj._pimpl ); }
156 ///////////////////////////////////////////////////////////////////