libzypp 17.25.7
Selectable.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#include <iostream>
13//#include <zypp/base/Logger.h>
14
15#include <zypp/ui/Selectable.h>
17#include <zypp/ResPool.h>
18
20namespace zypp
21{
23 namespace ui
24 {
25
27
29 { return ResPool::instance().proxy().lookup( ident_r ); }
30
32 //
33 // METHOD NAME : Selectable::Selectable
34 // METHOD TYPE : Ctor
35 //
37 : _pimpl( pimpl_r )
38 {}
39
41 //
42 // METHOD NAME : Selectable::~Selectable
43 // METHOD TYPE : Dtor
44 //
46 {}
47
49 //
50 // Forward to implementation.
51 // Restrict PoolItems to ResObject::constPtr!
52 //
54
56 { return _pimpl->ident(); }
57
59 { return _pimpl->kind(); }
60
61 const std::string & Selectable::name() const
62 { return _pimpl->name(); }
63
65 { return _pimpl->status(); }
66
68 { return _pimpl->setStatus( state_r, causer_r ); }
69
71 { return _pimpl->installedObj(); }
72
74 { return _pimpl->candidateObj(); }
75
77 { return _pimpl->candidateObjFrom( repo_r ); }
78
80 { return _pimpl->updateCandidateObj(); }
81
84
86 { return _pimpl->identIsAutoInstalled(); }
87
88 bool Selectable::identicalAvailable( const PoolItem & rhs ) const
89 { return _pimpl->identicalAvailable( rhs ); }
90
91 bool Selectable::identicalInstalled( const PoolItem & rhs ) const
92 { return _pimpl->identicalInstalled( rhs ); }
93
95 { return _pimpl->identicalAvailableObj( rhs ); }
96
98 { return _pimpl->identicalInstalledObj( rhs ); }
99
101 { return _pimpl->setCandidate( newCandidate_r, causer_r ); }
102
104 { return _pimpl->setCandidate( PoolItem( newCandidate_r ), causer_r ); }
105
106 bool Selectable::setOnSystem( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r )
107 {
108 if ( identicalInstalled( newCandidate_r ) )
109 return setFate( UNMODIFIED, causer_r );
110 return setCandidate( newCandidate_r, causer_r ) && setFate( TO_INSTALL, causer_r );
111 }
112
114 { return _pimpl->theObj(); }
115
117
119 { return _pimpl->availableEmpty(); }
120
122 { return _pimpl->availableSize(); }
123
125 { return _pimpl->availableBegin(); }
126
128 { return _pimpl->availableEnd(); }
129
131
133 { return _pimpl->installedEmpty(); }
134
136 { return _pimpl->installedSize(); }
137
139 { return _pimpl->installedBegin(); }
140
142 { return _pimpl->installedEnd(); }
143
145
147 { return _pimpl->picklistEmpty(); }
148
150 { return _pimpl->picklistSize(); }
151
153 { return _pimpl->picklistBegin(); }
154
156 { return _pimpl->picklistEnd(); }
157
159 { return picklistPos( pi_r.satSolvable() ); }
160
162 {
164 for ( const auto & pi : picklist() )
165 {
166 if ( pi == solv_r )
167 return idx;
168 ++idx;
169 }
170 return picklistNoPos;
171 }
172
174
176 { return _pimpl->hasRetracted(); }
177
179 { return _pimpl->hasRetractedInstalled(); }
180
182 { return _pimpl->isUnmaintained(); }
183
185 { return _pimpl->multiversionInstall(); }
186
187 bool Selectable::pickInstall( const PoolItem & pi_r, ResStatus::TransactByValue causer_r, bool yesno_r )
188 { return _pimpl->pickInstall( pi_r, causer_r, yesno_r ); }
189
190 bool Selectable::pickDelete( const PoolItem & pi_r, ResStatus::TransactByValue causer_r, bool yesno_r )
191 { return _pimpl->pickDelete( pi_r, causer_r, yesno_r ); }
192
194 { return _pimpl->pickStatus( pi_r ); }
195
197 { return _pimpl->setPickStatus( pi_r, state_r, causer_r ); }
198
200
202 { return _pimpl->isUndetermined(); }
203
205 { return _pimpl->isRelevant(); }
206
208 { return _pimpl->isSatisfied(); }
209
211 { return _pimpl->isBroken(); }
212
214 {
215 return fate() == TO_INSTALL || ( ! locked() && isBroken() );
216 }
217
219 {
220 return locked() && isBroken() ;
221 }
222
224 { return _pimpl->modifiedBy(); }
225
227 { return _pimpl->hasLicenceConfirmed(); }
228
230 { _pimpl->setLicenceConfirmed( val_r ); }
231
233 { return _pimpl->hasLocks(); }
234
236 {
237 switch ( status() ) {
238 case S_Update:
239 case S_Install:
240 case S_AutoUpdate:
241 case S_AutoInstall:
242 return TO_INSTALL;
243 break;
244
245 case S_Del:
246 case S_AutoDel:
247 return TO_DELETE;
248 break;
249
250 case S_Protected:
251 case S_Taboo:
252 case S_KeepInstalled:
253 case S_NoInst:
254 break;
255 }
256 return UNMODIFIED;
257 };
258
260 {
261 switch ( fate_r )
262 {
263 case TO_INSTALL:
264 return setStatus( hasInstalledObj() ? S_Update : S_Install, causer_r );
265 break;
266
267 case TO_DELETE:
268 return setStatus( S_Del, causer_r );
269 break;
270
271 case UNMODIFIED:
272 switch ( status() ) {
273 case S_Protected:
274 case S_Taboo:
275 return true;
276 break;
277 default:
278 return setStatus( hasInstalledObj() ? S_KeepInstalled : S_NoInst, causer_r );
279 break;
280 }
281 break;
282 }
283 return false;
284 }
285
287 {
288 return( hasInstalledObj() || setStatus( S_Install, causer_r ) );
289 }
290
292 {
293 if ( ! hasInstalledObj() )
294 return setStatus( S_Install, causer_r );
295
296 PoolItem cand( candidateObj() );
297 if ( ! cand )
298 return true;
299
300 return( installedObj()->edition() >= cand->edition()
301 || setStatus( S_Update, causer_r ) );
302 }
303
305 {
306 return( ! hasInstalledObj() || setStatus( S_Del, causer_r ) );
307 }
308
309 /******************************************************************
310 **
311 ** FUNCTION NAME : operator<<
312 ** FUNCTION TYPE : std::ostream &
313 */
314 std::ostream & operator<<( std::ostream & str, const Selectable & obj )
315 { return str << *(obj._pimpl); }
316
317 std::ostream & dumpOn( std::ostream & str, const Selectable & obj )
318 { return dumpOn( str, *(obj._pimpl) ); }
319
321 } // namespace ui
324} // namespace zypp
Access to the sat-pools string space.
Definition: IdString.h:43
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:51
Resolvable kinds.
Definition: ResKind.h:33
TraitsType::constPtrType constPtr
Definition: ResObject.h:43
ui::Selectable::Ptr lookup(const pool::ByIdent &ident_r) const
static ResPool instance()
Singleton ctor.
Definition: ResPool.cc:37
ResPoolProxy proxy() const
preliminary
Definition: ResPool.cc:58
Main filter selecting PoolItems by name and kind.
Definition: ByIdent.h:27
A Solvable object within the sat Pool.
Definition: Solvable.h:54
Collects PoolItems of same kind and name.
Definition: Selectable.h:52
bool hasRetractedInstalled() const
True if this Selectable contains an installed retracted item.
Definition: Selectable.cc:178
bool setStatus(Status state_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Try to set a new Status.
Definition: Selectable.cc:67
available_iterator availableEnd() const
Definition: Selectable.cc:127
SelectableTraits::available_size_type available_size_type
Definition: Selectable.h:62
installed_size_type installedSize() const
Definition: Selectable.cc:135
SelectableTraits::picklist_iterator picklist_iterator
Definition: Selectable.h:67
picklist_iterator picklistBegin() const
Definition: Selectable.cc:152
bool multiversionInstall() const
Whether at least one of the available packages has multiversionInstall set.
Definition: Selectable.cc:184
Iterable< picklist_iterator > picklist() const
Definition: Selectable.h:283
Status pickStatus(const PoolItem &pi_r) const
Compute the ui::Status for an individual PoolItem.
Definition: Selectable.cc:193
bool isUnmaintained() const
True if this package has no replacement from the available repositories.
Definition: Selectable.cc:181
picklist_size_type picklistSize() const
Definition: Selectable.cc:149
bool setDeleted(ResStatus::TransactByValue causer_r=ResStatus::USER)
Take care the item gets deleted if it is installed.
Definition: Selectable.cc:304
bool isSatisfied() const
Whether a relevant patchs requirements are met.
Definition: Selectable.cc:207
static Ptr get(const pool::ByIdent &ident_r)
Get the Selctable.
Definition: Selectable.cc:28
installed_iterator installedBegin() const
Definition: Selectable.cc:138
bool locked() const
True if locked (subclass of unmodified).
Definition: Selectable.h:457
available_size_type availableSize() const
Definition: Selectable.cc:121
intrusive_ptr< Selectable > Ptr
Definition: Selectable.h:57
static constexpr const picklist_size_type picklistNoPos
Returned by picklistPos if the Item does not belong to the picklist.
Definition: Selectable.h:287
void setLicenceConfirmed(bool val_r=true)
Set LicenceConfirmed bit.
Definition: Selectable.cc:229
ResStatus::TransactByValue modifiedBy() const
Return who caused the modification.
Definition: Selectable.cc:223
SelectableTraits::installed_size_type installed_size_type
Definition: Selectable.h:65
PoolItem installedObj() const
The last Installed object.
Definition: Selectable.cc:70
PoolItem highestAvailableVersionObj() const
Simply the highest available version, ignoring priorities and policies.
Definition: Selectable.cc:82
bool hasLocks() const
True if it includes locked items (don't mix this with the locked status).
Definition: Selectable.cc:232
bool hasRetracted() const
True if this Selectable contains a retracted item.
Definition: Selectable.cc:175
picklist_iterator picklistEnd() const
Definition: Selectable.cc:155
bool setInstalled(ResStatus::TransactByValue causer_r=ResStatus::USER)
Take care the item gets installed if it is not.
Definition: Selectable.cc:286
Selectable(Impl_Ptr pimpl_r)
Default ctor.
Definition: Selectable.cc:36
RW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: Selectable.h:551
IdString ident() const
The identifier.
Definition: Selectable.cc:55
installed_iterator installedEnd() const
Definition: Selectable.cc:141
PoolItem updateCandidateObj() const
The best candidate for update, if there is one.
Definition: Selectable.cc:79
PoolItem candidateObjFrom(Repository repo_r) const
The best candidate provided by a specific Repository, if there is one.
Definition: Selectable.cc:76
bool setUpToDate(ResStatus::TransactByValue causer_r=ResStatus::USER)
Take care the item gets installed if it is not, or is older.
Definition: Selectable.cc:291
const std::string & name() const
The ResObjects name.
Definition: Selectable.cc:61
SelectableTraits::installed_iterator installed_iterator
Definition: Selectable.h:64
Fate fate() const
Definition: Selectable.cc:235
SelectableTraits::available_iterator available_iterator
Iterates over ResObject::constPtr.
Definition: Selectable.h:61
PoolItem theObj() const
An object you could use as pars pro toto.
Definition: Selectable.cc:113
bool availableEmpty() const
Definition: Selectable.cc:118
shared_ptr< Impl > Impl_Ptr
Definition: Selectable.h:543
bool identIsAutoInstalled() const
Whether this ident is flagged as AutoInstalled.
Definition: Selectable.cc:85
available_iterator availableBegin() const
Definition: Selectable.cc:124
bool pickInstall(const PoolItem &pi_r, ResStatus::TransactByValue causer_r=ResStatus::USER, bool yesno_r=true)
Select a specific available item for installation.
Definition: Selectable.cc:187
bool setOnSystem(const PoolItem &newCandidate_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Arrange the specified candidate (out of available objects) to be on system after commit.
Definition: Selectable.cc:106
PoolItem setCandidate(const PoolItem &newCandidate_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Set a candidate (out of available objects).
Definition: Selectable.cc:100
bool isRelevant() const
Returns true if the patch is relevant which means that at least one package of the patch is installed...
Definition: Selectable.cc:204
bool isUnwanted() const
Broken (needed) but locked patches.
Definition: Selectable.cc:218
PoolItem candidateObj() const
The 'best' or 'most interesting' among all available objects.
Definition: Selectable.cc:73
bool identicalAvailable(const PoolItem &rhs) const
True if rhs is installed and one with the same content is available.
Definition: Selectable.cc:88
bool isBroken() const
Whether a relevant patchs requirements are broken.
Definition: Selectable.cc:210
bool hasInstalledObj() const
True if installed object is present.
Definition: Selectable.h:310
bool setPickStatus(const PoolItem &pi_r, Status state_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Assign a new status to a specific item.
Definition: Selectable.cc:196
Status status() const
Return the current Status.
Definition: Selectable.cc:64
bool hasLicenceConfirmed() const
Return value of LicenceConfirmed bit.
Definition: Selectable.cc:226
bool identicalInstalled(const PoolItem &rhs) const
True if rhs has the same content as an installed one.
Definition: Selectable.cc:91
PoolItem identicalAvailableObj(const PoolItem &rhs) const
Return an available Object with the same content as rhs.
Definition: Selectable.cc:94
bool isUndetermined() const
Returns true for packages, because packages are not classified by the solver.
Definition: Selectable.cc:201
ResKind kind() const
The ResObjects kind.
Definition: Selectable.cc:58
bool setFate(Fate fate_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Definition: Selectable.cc:259
bool pickDelete(const PoolItem &pi_r, ResStatus::TransactByValue causer_r=ResStatus::USER, bool yesno_r=true)
Select a specific installed item for deletion.
Definition: Selectable.cc:190
bool isNeeded() const
This includes unlocked broken patches, as well as those already selected to be installed.
Definition: Selectable.cc:213
bool picklistEmpty() const
Definition: Selectable.cc:146
SelectableTraits::picklist_size_type picklist_size_type
Definition: Selectable.h:68
PoolItem identicalInstalledObj(const PoolItem &rhs) const
\Return an installed Object with the same content as rhs.
Definition: Selectable.cc:97
bool installedEmpty() const
Definition: Selectable.cc:132
picklist_size_type picklistPos(const PoolItem &pi_r) const
Return the position of pi_r in the piclist or picklistNoPos.
Definition: Selectable.cc:158
String related utilities and Regular expression matching.
Status
UI status Status values calculated by Selectable.
Definition: Status.h:35
@ S_AutoUpdate
Definition: Status.h:44
@ S_Taboo
Definition: Status.h:37
@ S_AutoInstall
Definition: Status.h:45
@ S_Install
Definition: Status.h:41
@ S_AutoDel
Definition: Status.h:43
@ S_NoInst
Definition: Status.h:48
@ S_Protected
Definition: Status.h:36
@ S_KeepInstalled
Definition: Status.h:47
@ S_Del
Definition: Status.h:39
@ S_Update
Definition: Status.h:40
IMPL_PTR_TYPE(Selectable)
std::ostream & operator<<(std::ostream &str, const Selectable &obj)
Definition: Selectable.cc:314
std::ostream & dumpOn(std::ostream &str, const Selectable &obj)
Definition: Selectable.cc:317
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57
Edition edition() const
Definition: SolvableType.h:71
PoolItem installedObj() const
Installed object (transacting ot highest version).
PoolItem theObj() const
Best among all objects.
installed_iterator installedEnd() const
bool setPickStatus(const PoolItem &pi_r, Status state_r, ResStatus::TransactByValue causer_r)
const std::string & name() const
available_iterator availableBegin() const
bool identicalInstalled(const PoolItem &rhs) const
True if rhs has the same content as an installed one.
installed_iterator installedBegin() const
PoolItem identicalAvailableObj(const PoolItem &rhs) const
Return an available Object with the same content as rhs.
picklist_iterator picklistBegin() const
available_iterator availableEnd() const
PoolItem updateCandidateObj() const
The best candidate for update, if there is one.
bool pickInstall(const PoolItem &pi_r, ResStatus::TransactByValue causer_r, bool yesno_r)
picklist_size_type picklistSize() const
PoolItem identicalInstalledObj(const PoolItem &rhs) const
\Return an installed Object with the same content as rhs.
picklist_iterator picklistEnd() const
bool setStatus(Status state_r, ResStatus::TransactByValue causer_r)
ResStatus::TransactByValue modifiedBy() const
Return who caused the modification.
PoolItem candidateObj() const
Best among available objects.
Status pickStatus(const PoolItem &pi_r) const
bool identicalAvailable(const PoolItem &rhs) const
True if rhs is installed and one with the same content is available.
PoolItem highestAvailableVersionObj() const
Simply the highest available version, ignoring priorities and policies.
void setLicenceConfirmed(bool val_r)
Set LicenceConfirmed bit.
PoolItem setCandidate(const PoolItem &newCandidate_r, ResStatus::TransactByValue causer_r)
Set a userCandidate (out of available objects).
PoolItem candidateObjFrom(Repository repo_r) const
The best candidate provided by a specific Repository, if there is one.
bool hasLicenceConfirmed() const
Return value of LicenceConfirmed bit.
bool identIsAutoInstalled() const
Whether this ident is flagged as AutoInstalled.
available_size_type availableSize() const
bool hasRetractedInstalled() const
bool pickDelete(const PoolItem &pi_r, ResStatus::TransactByValue causer_r, bool yesno_r)
bool hasLocks() const
True if it includes locked items (don't mix this with the locked status).
installed_size_type installedSize() const