Selectable.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00012 #include <iostream>
00013
00014
00015 #include "zypp/ui/Selectable.h"
00016 #include "zypp/ui/SelectableImpl.h"
00017 #include "zypp/ResPool.h"
00018
00020 namespace zypp
00021 {
00022
00023 namespace ui
00024 {
00025
00026 IMPL_PTR_TYPE(Selectable);
00027
00028 Selectable::Ptr Selectable::get( const pool::ByIdent & ident_r )
00029 { return ResPool::instance().proxy().lookup( ident_r ); }
00030
00032
00033
00034
00035
00036 Selectable::Selectable( Impl_Ptr pimpl_r )
00037 : _pimpl( pimpl_r )
00038 {}
00039
00041
00042
00043
00044
00045 Selectable::~Selectable()
00046 {}
00047
00049
00050
00051
00052
00054
00055 IdString Selectable::ident() const
00056 { return _pimpl->ident(); }
00057
00058 ResObject::Kind Selectable::kind() const
00059 { return _pimpl->kind(); }
00060
00061 const std::string & Selectable::name() const
00062 { return _pimpl->name(); }
00063
00064 Status Selectable::status() const
00065 { return _pimpl->status(); }
00066
00067 bool Selectable::setStatus( Status state_r, ResStatus::TransactByValue causer_r )
00068 { return _pimpl->setStatus( state_r, causer_r ); }
00069
00070 PoolItem Selectable::installedObj() const
00071 { return _pimpl->installedObj(); }
00072
00073 PoolItem Selectable::candidateObj() const
00074 { return _pimpl->candidateObj(); }
00075
00076 PoolItem Selectable::candidateObjFrom( Repository repo_r ) const
00077 { return _pimpl->candidateObjFrom( repo_r ); }
00078
00079 PoolItem Selectable::updateCandidateObj() const
00080 { return _pimpl->updateCandidateObj(); }
00081
00082 PoolItem Selectable::highestAvailableVersionObj() const
00083 { return _pimpl->highestAvailableVersionObj(); }
00084
00085 bool Selectable::identicalAvailable( const PoolItem & rhs ) const
00086 { return _pimpl->identicalAvailable( rhs ); }
00087
00088 bool Selectable::identicalInstalled( const PoolItem & rhs ) const
00089 { return _pimpl->identicalInstalled( rhs ); }
00090
00091 PoolItem Selectable::identicalAvailableObj( const PoolItem & rhs ) const
00092 { return _pimpl->identicalAvailableObj( rhs ); }
00093
00094 PoolItem Selectable::identicalInstalledObj( const PoolItem & rhs ) const
00095 { return _pimpl->identicalInstalledObj( rhs ); }
00096
00097 PoolItem Selectable::setCandidate( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r )
00098 { return _pimpl->setCandidate( newCandidate_r, causer_r ); }
00099
00100 PoolItem Selectable::setCandidate( ResObject::constPtr newCandidate_r, ResStatus::TransactByValue causer_r )
00101 { return _pimpl->setCandidate( PoolItem( newCandidate_r ), causer_r ); }
00102
00103 bool Selectable::setOnSystem( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r )
00104 {
00105 if ( identicalInstalled( newCandidate_r ) )
00106 return setFate( UNMODIFIED, causer_r );
00107 return setCandidate( newCandidate_r, causer_r ) && setFate( TO_INSTALL, causer_r );
00108 }
00109
00110 PoolItem Selectable::theObj() const
00111 { return _pimpl->theObj(); }
00112
00114
00115 bool Selectable::availableEmpty() const
00116 { return _pimpl->availableEmpty(); }
00117
00118 Selectable::available_size_type Selectable::availableSize() const
00119 { return _pimpl->availableSize(); }
00120
00121 Selectable::available_iterator Selectable::availableBegin() const
00122 { return _pimpl->availableBegin(); }
00123
00124 Selectable::available_iterator Selectable::availableEnd() const
00125 { return _pimpl->availableEnd(); }
00126
00128
00129 bool Selectable::installedEmpty() const
00130 { return _pimpl->installedEmpty(); }
00131
00132 Selectable::installed_size_type Selectable::installedSize() const
00133 { return _pimpl->installedSize(); }
00134
00135 Selectable::installed_iterator Selectable::installedBegin() const
00136 { return _pimpl->installedBegin(); }
00137
00138 Selectable::installed_iterator Selectable::installedEnd() const
00139 { return _pimpl->installedEnd(); }
00140
00142
00143 bool Selectable::picklistEmpty() const
00144 { return _pimpl->picklistEmpty(); }
00145
00146 Selectable::picklist_size_type Selectable::picklistSize() const
00147 { return _pimpl->picklistSize(); }
00148
00149 Selectable::picklist_iterator Selectable::picklistBegin() const
00150 { return _pimpl->picklistBegin(); }
00151
00152 Selectable::picklist_iterator Selectable::picklistEnd() const
00153 { return _pimpl->picklistEnd(); }
00154
00156
00157 bool Selectable::isUnmaintained() const
00158 { return _pimpl->isUnmaintained(); }
00159
00160 bool Selectable::multiversionInstall() const
00161 { return _pimpl->multiversionInstall(); }
00162
00163 bool Selectable::pickInstall( const PoolItem & pi_r, ResStatus::TransactByValue causer_r, bool yesno_r )
00164 { return _pimpl->pickInstall( pi_r, causer_r, yesno_r ); }
00165
00166 bool Selectable::pickDelete( const PoolItem & pi_r, ResStatus::TransactByValue causer_r, bool yesno_r )
00167 { return _pimpl->pickDelete( pi_r, causer_r, yesno_r ); }
00168
00169 Status Selectable::pickStatus( const PoolItem & pi_r ) const
00170 { return _pimpl->pickStatus( pi_r ); }
00171
00172 bool Selectable::setPickStatus( const PoolItem & pi_r, Status state_r, ResStatus::TransactByValue causer_r )
00173 { return _pimpl->setPickStatus( pi_r, state_r, causer_r ); }
00174
00176
00177 bool Selectable::isUndetermined() const
00178 { return _pimpl->isUndetermined(); }
00179
00180 bool Selectable::isRelevant() const
00181 { return _pimpl->isRelevant(); }
00182
00183 bool Selectable::isSatisfied() const
00184 { return _pimpl->isSatisfied(); }
00185
00186 bool Selectable::isBroken() const
00187 { return _pimpl->isBroken(); }
00188
00189 bool Selectable::isNeeded() const
00190 {
00191 return fate() == TO_INSTALL || ( ! locked() && isBroken() );
00192 }
00193
00194 bool Selectable::isUnwanted() const
00195 {
00196 return locked() && isBroken() ;
00197 }
00198
00199 ResStatus::TransactByValue Selectable::modifiedBy() const
00200 { return _pimpl->modifiedBy(); }
00201
00202 bool Selectable::hasLicenceConfirmed() const
00203 { return _pimpl->hasLicenceConfirmed(); }
00204
00205 void Selectable::setLicenceConfirmed( bool val_r )
00206 { _pimpl->setLicenceConfirmed( val_r ); }
00207
00208
00209 Selectable::Fate Selectable::fate() const
00210 {
00211 switch ( status() ) {
00212 case S_Update:
00213 case S_Install:
00214 case S_AutoUpdate:
00215 case S_AutoInstall:
00216 return TO_INSTALL;
00217 break;
00218
00219 case S_Del:
00220 case S_AutoDel:
00221 return TO_DELETE;
00222 break;
00223
00224 case S_Protected:
00225 case S_Taboo:
00226 case S_KeepInstalled:
00227 case S_NoInst:
00228 break;
00229 }
00230 return UNMODIFIED;
00231 };
00232
00233 bool Selectable::setFate( Fate fate_r, ResStatus::TransactByValue causer_r )
00234 {
00235 switch ( fate_r )
00236 {
00237 case TO_INSTALL:
00238 return setStatus( hasInstalledObj() ? S_Update : S_Install, causer_r );
00239 break;
00240
00241 case TO_DELETE:
00242 return setStatus( S_Del, causer_r );
00243 break;
00244
00245 case UNMODIFIED:
00246 switch ( status() ) {
00247 case S_Protected:
00248 case S_Taboo:
00249 return true;
00250 break;
00251 default:
00252 return setStatus( hasInstalledObj() ? S_KeepInstalled : S_NoInst, causer_r );
00253 break;
00254 }
00255 break;
00256 }
00257 return false;
00258 }
00259
00260 bool Selectable::setInstalled( ResStatus::TransactByValue causer_r )
00261 {
00262 return( hasInstalledObj() || setStatus( S_Install, causer_r ) );
00263 }
00264
00265 bool Selectable::setUpToDate( ResStatus::TransactByValue causer_r )
00266 {
00267 if ( ! hasInstalledObj() )
00268 return setStatus( S_Install, causer_r );
00269
00270 PoolItem cand( candidateObj() );
00271 if ( ! cand )
00272 return true;
00273
00274 return( installedObj()->edition() >= cand->edition()
00275 || setStatus( S_Update, causer_r ) );
00276 }
00277
00278 bool Selectable::setDeleted( ResStatus::TransactByValue causer_r )
00279 {
00280 return( ! hasInstalledObj() || setStatus( S_Del, causer_r ) );
00281 }
00282
00283
00284
00285
00286
00287
00288 std::ostream & operator<<( std::ostream & str, const Selectable & obj )
00289 { return str << *(obj._pimpl); }
00290
00291 std::ostream & dumpOn( std::ostream & str, const Selectable & obj )
00292 { return dumpOn( str, *(obj._pimpl) ); }
00293
00295 }
00298 }