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::setCandidate( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r )
00092 { return _pimpl->setCandidate( newCandidate_r, causer_r ); }
00093
00094 PoolItem Selectable::setCandidate( ResObject::constPtr newCandidate_r, ResStatus::TransactByValue causer_r )
00095 { return _pimpl->setCandidate( PoolItem( newCandidate_r ), causer_r ); }
00096
00097 bool Selectable::setOnSystem( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r )
00098 {
00099 if ( identicalInstalled( newCandidate_r ) )
00100 return setFate( UNMODIFIED, causer_r );
00101 return setCandidate( newCandidate_r, causer_r ) && setFate( TO_INSTALL, causer_r );
00102 }
00103
00104 PoolItem Selectable::theObj() const
00105 { return _pimpl->theObj(); }
00106
00108
00109 bool Selectable::availableEmpty() const
00110 { return _pimpl->availableEmpty(); }
00111
00112 Selectable::available_size_type Selectable::availableSize() const
00113 { return _pimpl->availableSize(); }
00114
00115 Selectable::available_iterator Selectable::availableBegin() const
00116 { return _pimpl->availableBegin(); }
00117
00118 Selectable::available_iterator Selectable::availableEnd() const
00119 { return _pimpl->availableEnd(); }
00120
00122
00123 bool Selectable::installedEmpty() const
00124 { return _pimpl->installedEmpty(); }
00125
00126 Selectable::installed_size_type Selectable::installedSize() const
00127 { return _pimpl->installedSize(); }
00128
00129 Selectable::installed_iterator Selectable::installedBegin() const
00130 { return _pimpl->installedBegin(); }
00131
00132 Selectable::installed_iterator Selectable::installedEnd() const
00133 { return _pimpl->installedEnd(); }
00134
00136
00137 bool Selectable::picklistEmpty() const
00138 { return _pimpl->picklistEmpty(); }
00139
00140 Selectable::picklist_size_type Selectable::picklistSize() const
00141 { return _pimpl->picklistSize(); }
00142
00143 Selectable::picklist_iterator Selectable::picklistBegin() const
00144 { return _pimpl->picklistBegin(); }
00145
00146 Selectable::picklist_iterator Selectable::picklistEnd() const
00147 { return _pimpl->picklistEnd(); }
00148
00150
00151 bool Selectable::isUnmaintained() const
00152 { return _pimpl->isUnmaintained(); }
00153
00154 bool Selectable::multiversionInstall() const
00155 { return _pimpl->multiversionInstall(); }
00156
00157 bool Selectable::pickInstall( const PoolItem & pi_r, ResStatus::TransactByValue causer_r, bool yesno_r )
00158 { return _pimpl->pickInstall( pi_r, causer_r, yesno_r ); }
00159
00160 bool Selectable::pickDelete( const PoolItem & pi_r, ResStatus::TransactByValue causer_r, bool yesno_r )
00161 { return _pimpl->pickDelete( pi_r, causer_r, yesno_r ); }
00162
00163 Status Selectable::pickStatus( const PoolItem & pi_r ) const
00164 { return _pimpl->pickStatus( pi_r ); }
00165
00166 bool Selectable::setPickStatus( const PoolItem & pi_r, Status state_r, ResStatus::TransactByValue causer_r )
00167 { return _pimpl->setPickStatus( pi_r, state_r, causer_r ); }
00168
00170
00171 bool Selectable::isUndetermined() const
00172 { return _pimpl->isUndetermined(); }
00173
00174 bool Selectable::isRelevant() const
00175 { return _pimpl->isRelevant(); }
00176
00177 bool Selectable::isSatisfied() const
00178 { return _pimpl->isSatisfied(); }
00179
00180 bool Selectable::isBroken() const
00181 { return _pimpl->isBroken(); }
00182
00183 bool Selectable::isNeeded() const
00184 {
00185 return fate() == TO_INSTALL || ( ! locked() && isBroken() );
00186 }
00187
00188 bool Selectable::isUnwanted() const
00189 {
00190 return locked() && isBroken() ;
00191 }
00192
00193 ResStatus::TransactByValue Selectable::modifiedBy() const
00194 { return _pimpl->modifiedBy(); }
00195
00196 bool Selectable::hasLicenceConfirmed() const
00197 { return _pimpl->hasLicenceConfirmed(); }
00198
00199 void Selectable::setLicenceConfirmed( bool val_r )
00200 { _pimpl->setLicenceConfirmed( val_r ); }
00201
00202
00203 Selectable::Fate Selectable::fate() const
00204 {
00205 switch ( status() ) {
00206 case S_Update:
00207 case S_Install:
00208 case S_AutoUpdate:
00209 case S_AutoInstall:
00210 return TO_INSTALL;
00211 break;
00212
00213 case S_Del:
00214 case S_AutoDel:
00215 return TO_DELETE;
00216 break;
00217
00218 case S_Protected:
00219 case S_Taboo:
00220 case S_KeepInstalled:
00221 case S_NoInst:
00222 break;
00223 }
00224 return UNMODIFIED;
00225 };
00226
00227 bool Selectable::setFate( Fate fate_r, ResStatus::TransactByValue causer_r )
00228 {
00229 switch ( fate_r )
00230 {
00231 case TO_INSTALL:
00232 return setStatus( hasInstalledObj() ? S_Update : S_Install, causer_r );
00233 break;
00234
00235 case TO_DELETE:
00236 return setStatus( S_Del, causer_r );
00237 break;
00238
00239 case UNMODIFIED:
00240 switch ( status() ) {
00241 case S_Protected:
00242 case S_Taboo:
00243 return true;
00244 break;
00245 default:
00246 return setStatus( hasInstalledObj() ? S_KeepInstalled : S_NoInst, causer_r );
00247 break;
00248 }
00249 break;
00250 }
00251 return false;
00252 }
00253
00254 bool Selectable::setInstalled( ResStatus::TransactByValue causer_r )
00255 {
00256 return( hasInstalledObj() || setStatus( S_Install, causer_r ) );
00257 }
00258
00259 bool Selectable::setUpToDate( ResStatus::TransactByValue causer_r )
00260 {
00261 if ( ! hasInstalledObj() )
00262 return setStatus( S_Install, causer_r );
00263
00264 PoolItem cand( candidateObj() );
00265 if ( ! cand )
00266 return true;
00267
00268 return( installedObj()->edition() >= cand->edition()
00269 || setStatus( S_Update, causer_r ) );
00270 }
00271
00272 bool Selectable::setDeleted( ResStatus::TransactByValue causer_r )
00273 {
00274 return( ! hasInstalledObj() || setStatus( S_Del, causer_r ) );
00275 }
00276
00277
00278
00279
00280
00281
00282 std::ostream & operator<<( std::ostream & str, const Selectable & obj )
00283 { return str << *(obj._pimpl); }
00284
00285 std::ostream & dumpOn( std::ostream & str, const Selectable & obj )
00286 { return dumpOn( str, *(obj._pimpl) ); }
00287
00289 }
00292 }