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