1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/ZYppCommitPolicy.cc
15 #include <zypp/base/String.h>
17 #include <zypp/ZConfig.h>
18 #include <zypp/ZYppCommitPolicy.h>
20 ///////////////////////////////////////////////////////////////////
22 { /////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////
26 // CLASS NAME : ZYppCommitPolicy::Impl
28 ///////////////////////////////////////////////////////////////////
30 class ZYppCommitPolicy::Impl
34 : _restrictToMedia ( 0 )
36 , _downloadMode ( ZConfig::instance().commit_downloadMode() )
37 , _rpmInstFlags ( ZConfig::instance().rpmInstallFlags() )
38 , _syncPoolAfterCommit ( true )
42 unsigned _restrictToMedia;
44 DownloadMode _downloadMode;
45 target::rpm::RpmInstFlags _rpmInstFlags;
46 bool _syncPoolAfterCommit;
49 friend Impl * rwcowClone<Impl>( const Impl * rhs );
50 /** clone for RWCOW_pointer */
51 Impl * clone() const { return new Impl( *this ); }
54 ///////////////////////////////////////////////////////////////////
56 // CLASS NAME : ZYppCommitPolicy
58 ///////////////////////////////////////////////////////////////////
60 ZYppCommitPolicy::ZYppCommitPolicy()
65 ZYppCommitPolicy & ZYppCommitPolicy::restrictToMedia( unsigned mediaNr_r )
66 { _pimpl->_restrictToMedia = ( mediaNr_r == 1 ) ? 1 : 0; return *this; }
68 unsigned ZYppCommitPolicy::restrictToMedia() const
69 { return _pimpl->_restrictToMedia; }
72 ZYppCommitPolicy & ZYppCommitPolicy::dryRun( bool yesNo_r )
73 { _pimpl->_dryRun = yesNo_r; return *this; }
75 bool ZYppCommitPolicy::dryRun() const
76 { return _pimpl->_dryRun; }
79 ZYppCommitPolicy & ZYppCommitPolicy::downloadMode( DownloadMode val_r )
80 { _pimpl->_downloadMode = val_r; return *this; }
82 DownloadMode ZYppCommitPolicy::downloadMode() const
83 { return _pimpl->_downloadMode; }
86 ZYppCommitPolicy & ZYppCommitPolicy::rpmInstFlags( target::rpm::RpmInstFlags newFlags_r )
87 { _pimpl->_rpmInstFlags = newFlags_r; return *this; }
89 ZYppCommitPolicy & ZYppCommitPolicy::rpmNoSignature( bool yesNo_r )
90 { _pimpl->_rpmInstFlags.setFlag( target::rpm::RPMINST_NOSIGNATURE, yesNo_r ); return *this; }
92 ZYppCommitPolicy & ZYppCommitPolicy::rpmExcludeDocs( bool yesNo_r )
93 { _pimpl->_rpmInstFlags.setFlag( target::rpm::RPMINST_EXCLUDEDOCS, yesNo_r ); return *this; }
95 target::rpm::RpmInstFlags ZYppCommitPolicy::rpmInstFlags() const
96 { return _pimpl->_rpmInstFlags; }
98 bool ZYppCommitPolicy::rpmNoSignature() const
99 { return _pimpl->_rpmInstFlags.testFlag( target::rpm::RPMINST_NOSIGNATURE ); }
101 bool ZYppCommitPolicy::rpmExcludeDocs() const
102 { return _pimpl->_rpmInstFlags.testFlag( target::rpm::RPMINST_EXCLUDEDOCS ); }
105 ZYppCommitPolicy & ZYppCommitPolicy::syncPoolAfterCommit( bool yesNo_r )
106 { _pimpl->_syncPoolAfterCommit = yesNo_r; return *this; }
108 bool ZYppCommitPolicy::syncPoolAfterCommit() const
109 { return _pimpl->_syncPoolAfterCommit; }
112 std::ostream & operator<<( std::ostream & str, const ZYppCommitPolicy & obj )
114 str << "CommitPolicy(";
115 if ( obj.restrictToMedia() )
116 str << " restrictToMedia:" << obj.restrictToMedia();
119 str << " " << obj.downloadMode();
120 if ( obj.syncPoolAfterCommit() )
121 str << " syncPoolAfterCommit";
122 if ( obj.rpmInstFlags() )
123 str << " rpmInstFlags{" << str::hexstring(obj.rpmInstFlags()) << "}";
127 /////////////////////////////////////////////////////////////////
129 ///////////////////////////////////////////////////////////////////