libzypp
10.5.0
|
00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00013 #include <iostream> 00014 00015 #include "zypp/base/String.h" 00016 00017 #include "zypp/ZConfig.h" 00018 #include "zypp/ZYppCommitPolicy.h" 00019 00021 namespace zypp 00022 { 00023 00025 // 00026 // CLASS NAME : ZYppCommitPolicy::Impl 00027 // 00029 00030 class ZYppCommitPolicy::Impl 00031 { 00032 public: 00033 Impl() 00034 : _restrictToMedia ( 0 ) 00035 , _dryRun ( false ) 00036 , _downloadMode ( ZConfig::instance().commit_downloadMode() ) 00037 , _rpmInstFlags ( ZConfig::instance().rpmInstallFlags() ) 00038 , _syncPoolAfterCommit ( true ) 00039 {} 00040 00041 public: 00042 unsigned _restrictToMedia; 00043 bool _dryRun; 00044 DownloadMode _downloadMode; 00045 target::rpm::RpmInstFlags _rpmInstFlags; 00046 bool _syncPoolAfterCommit; 00047 00048 private: 00049 friend Impl * rwcowClone<Impl>( const Impl * rhs ); 00051 Impl * clone() const { return new Impl( *this ); } 00052 }; 00053 00055 // 00056 // CLASS NAME : ZYppCommitPolicy 00057 // 00059 00060 ZYppCommitPolicy::ZYppCommitPolicy() 00061 : _pimpl( new Impl ) 00062 {} 00063 00064 00065 ZYppCommitPolicy & ZYppCommitPolicy::restrictToMedia( unsigned mediaNr_r ) 00066 { _pimpl->_restrictToMedia = ( mediaNr_r == 1 ) ? 1 : 0; return *this; } 00067 00068 unsigned ZYppCommitPolicy::restrictToMedia() const 00069 { return _pimpl->_restrictToMedia; } 00070 00071 00072 ZYppCommitPolicy & ZYppCommitPolicy::dryRun( bool yesNo_r ) 00073 { _pimpl->_dryRun = yesNo_r; return *this; } 00074 00075 bool ZYppCommitPolicy::dryRun() const 00076 { return _pimpl->_dryRun; } 00077 00078 00079 ZYppCommitPolicy & ZYppCommitPolicy::downloadMode( DownloadMode val_r ) 00080 { _pimpl->_downloadMode = val_r; return *this; } 00081 00082 DownloadMode ZYppCommitPolicy::downloadMode() const 00083 { return _pimpl->_downloadMode; } 00084 00085 00086 ZYppCommitPolicy & ZYppCommitPolicy::rpmInstFlags( target::rpm::RpmInstFlags newFlags_r ) 00087 { _pimpl->_rpmInstFlags = newFlags_r; return *this; } 00088 00089 ZYppCommitPolicy & ZYppCommitPolicy::rpmNoSignature( bool yesNo_r ) 00090 { _pimpl->_rpmInstFlags.setFlag( target::rpm::RPMINST_NOSIGNATURE, yesNo_r ); return *this; } 00091 00092 ZYppCommitPolicy & ZYppCommitPolicy::rpmExcludeDocs( bool yesNo_r ) 00093 { _pimpl->_rpmInstFlags.setFlag( target::rpm::RPMINST_EXCLUDEDOCS, yesNo_r ); return *this; } 00094 00095 target::rpm::RpmInstFlags ZYppCommitPolicy::rpmInstFlags() const 00096 { return _pimpl->_rpmInstFlags; } 00097 00098 bool ZYppCommitPolicy::rpmNoSignature() const 00099 { return _pimpl->_rpmInstFlags.testFlag( target::rpm::RPMINST_NOSIGNATURE ); } 00100 00101 bool ZYppCommitPolicy::rpmExcludeDocs() const 00102 { return _pimpl->_rpmInstFlags.testFlag( target::rpm::RPMINST_EXCLUDEDOCS ); } 00103 00104 00105 ZYppCommitPolicy & ZYppCommitPolicy::syncPoolAfterCommit( bool yesNo_r ) 00106 { _pimpl->_syncPoolAfterCommit = yesNo_r; return *this; } 00107 00108 bool ZYppCommitPolicy::syncPoolAfterCommit() const 00109 { return _pimpl->_syncPoolAfterCommit; } 00110 00111 00112 std::ostream & operator<<( std::ostream & str, const ZYppCommitPolicy & obj ) 00113 { 00114 str << "CommitPolicy("; 00115 if ( obj.restrictToMedia() ) 00116 str << " restrictToMedia:" << obj.restrictToMedia(); 00117 if ( obj.dryRun() ) 00118 str << " dryRun"; 00119 str << " " << obj.downloadMode(); 00120 if ( obj.syncPoolAfterCommit() ) 00121 str << " syncPoolAfterCommit"; 00122 if ( obj.rpmInstFlags() ) 00123 str << " rpmInstFlags{" << str::hexstring(obj.rpmInstFlags()) << "}"; 00124 return str << " )"; 00125 } 00126 00128 } // namespace zypp