1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/ui/Selectable.cc
13 //#include "zypp/base/Logger.h"
15 #include "zypp/ui/Selectable.h"
16 #include "zypp/ui/SelectableImpl.h"
17 #include "zypp/ResPool.h"
19 ///////////////////////////////////////////////////////////////////
21 { /////////////////////////////////////////////////////////////////
22 ///////////////////////////////////////////////////////////////////
24 { /////////////////////////////////////////////////////////////////
26 IMPL_PTR_TYPE(Selectable);
28 Selectable::Ptr Selectable::get( const pool::ByIdent & ident_r )
29 { return ResPool::instance().proxy().lookup( ident_r ); }
31 ///////////////////////////////////////////////////////////////////
33 // METHOD NAME : Selectable::Selectable
36 Selectable::Selectable( Impl_Ptr pimpl_r )
40 ///////////////////////////////////////////////////////////////////
42 // METHOD NAME : Selectable::~Selectable
45 Selectable::~Selectable()
48 ///////////////////////////////////////////////////////////////////
50 // Forward to implementation.
51 // Restrict PoolItems to ResObject::constPtr!
53 ///////////////////////////////////////////////////////////////////
55 IdString Selectable::ident() const
56 { return _pimpl->ident(); }
58 ResObject::Kind Selectable::kind() const
59 { return _pimpl->kind(); }
61 const std::string & Selectable::name() const
62 { return _pimpl->name(); }
64 Status Selectable::status() const
65 { return _pimpl->status(); }
67 bool Selectable::setStatus( const Status state_r )
68 { return _pimpl->setStatus( state_r ); }
70 PoolItem Selectable::installedObj() const
71 { return _pimpl->installedObj(); }
73 PoolItem Selectable::candidateObj() const
74 { return _pimpl->candidateObj(); }
76 PoolItem Selectable::setCandidate( ResObject::constPtr byUser_r )
77 { return _pimpl->setCandidate( byUser_r ); }
79 PoolItem Selectable::theObj() const
80 { return _pimpl->theObj(); }
82 ////////////////////////////////////////////////////////////////////////
84 bool Selectable::availableEmpty() const
85 { return _pimpl->availableEmpty(); }
87 Selectable::available_size_type Selectable::availableSize() const
88 { return _pimpl->availableSize(); }
90 Selectable::available_iterator Selectable::availableBegin() const
91 { return _pimpl->availableBegin(); }
93 Selectable::available_iterator Selectable::availableEnd() const
94 { return _pimpl->availableEnd(); }
96 ////////////////////////////////////////////////////////////////////////
98 bool Selectable::installedEmpty() const
99 { return _pimpl->installedEmpty(); }
101 Selectable::installed_size_type Selectable::installedSize() const
102 { return _pimpl->installedSize(); }
104 Selectable::installed_iterator Selectable::installedBegin() const
105 { return _pimpl->installedBegin(); }
107 Selectable::installed_iterator Selectable::installedEnd() const
108 { return _pimpl->installedEnd(); }
111 ////////////////////////////////////////////////////////////////////////
113 bool Selectable::isUnmaintained() const
114 { return _pimpl->isUnmaintained(); }
116 bool Selectable::isUndetermined() const
117 { return _pimpl->isUndetermined(); }
119 bool Selectable::isRelevant() const
120 { return _pimpl->isRelevant(); }
122 bool Selectable::isSatisfied() const
123 { return _pimpl->isSatisfied(); }
125 bool Selectable::isBroken() const
126 { return _pimpl->isBroken(); }
128 bool Selectable::isNeeded() const
130 return fate() == TO_INSTALL || isBroken() ;
133 ResStatus::TransactByValue Selectable::modifiedBy() const
134 { return _pimpl->modifiedBy(); }
136 bool Selectable::hasLicenceConfirmed() const
137 { return _pimpl->hasLicenceConfirmed(); }
139 void Selectable::setLicenceConfirmed( bool val_r )
140 { _pimpl->setLicenceConfirmed( val_r ); }
143 Selectable::Fate Selectable::fate() const
145 switch ( status() ) {
160 case S_KeepInstalled:
167 bool Selectable::setFate( Fate fate_r )
172 return setStatus( hasInstalledObj() ? S_Update : S_Install );
176 return setStatus( S_Del );
180 return setStatus( hasInstalledObj() ? S_KeepInstalled : S_NoInst );
185 bool Selectable::setInstalled()
187 return( hasInstalledObj() || setStatus( S_Install ) );
190 bool Selectable::setUpToDate()
192 if ( ! hasInstalledObj() )
193 return setStatus( S_Install );
195 PoolItem cand( candidateObj() );
199 return( installedObj()->edition() >= cand->edition()
200 || setStatus( S_Update ) );
203 bool Selectable::setDeleted()
205 return( ! hasInstalledObj() || setStatus( S_Del ) );
208 /******************************************************************
210 ** FUNCTION NAME : operator<<
211 ** FUNCTION TYPE : std::ostream &
213 std::ostream & operator<<( std::ostream & str, const Selectable & obj )
214 { return str << *(obj._pimpl); }
216 std::ostream & dumpOn( std::ostream & str, const Selectable & obj )
217 { return dumpOn( str, *(obj._pimpl) ); }
219 /////////////////////////////////////////////////////////////////
221 ///////////////////////////////////////////////////////////////////
222 /////////////////////////////////////////////////////////////////
224 ///////////////////////////////////////////////////////////////////