libzypp 17.32.3
Selectable.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_UI_SELECTABLE_H
13#define ZYPP_UI_SELECTABLE_H
14
15#include <iosfwd>
16#include <utility>
17
20#include <zypp/base/PtrTypes.h>
21#include <zypp/base/Iterator.h>
22
24#include <zypp/ui/Status.h>
25
27namespace zypp
28{
29
31 namespace ui
32 {
33
35
37 //
38 // CLASS NAME : Selectable
39 //
53 {
54 friend std::ostream & operator<<( std::ostream & str, const Selectable & obj );
55 friend std::ostream & dumpOn( std::ostream & str, const Selectable & obj );
56
57 public:
58 using Ptr = intrusive_ptr<Selectable>;
59 using constPtr = intrusive_ptr<const Selectable>;
60
64
67
70
71 public:
82 static Ptr get( const pool::ByIdent & ident_r );
83
85 static Ptr get( IdString ident_r )
86 { return get( pool::ByIdent( ident_r ) ); }
87
89 static Ptr get( ResKind kind_r, const std::string & name_r )
90 { return get( pool::ByIdent( std::move(kind_r), name_r ) ); }
91
93 static Ptr get( const std::string & name_r )
94 { return get( pool::ByIdent( ResKind::package, name_r ) ); }
95
97 static Ptr get( const sat::Solvable & solv_r )
98 { return get( pool::ByIdent( solv_r ) ); }
99
101 static Ptr get( const ResObject::constPtr & resolvable_r )
102 { return resolvable_r ? get( resolvable_r->satSolvable() ) : Ptr(); }
103
105 static Ptr get( const PoolItem & pi_r )
106 { return get( pi_r.satSolvable() ); }
108
109 public:
115 IdString ident() const;
116
118 ResKind kind() const;
119
121 const std::string & name() const;
122
124 PoolItem installedObj() const;
125
132 PoolItem candidateObj() const;
133
140 PoolItem candidateObjFrom( Repository repo_r ) const;
141
151
159
161 bool identIsAutoInstalled() const;
162
167 bool identicalAvailable( const PoolItem & rhs ) const;
168
173 bool identicalInstalled( const PoolItem & rhs ) const;
174
180
186
191 PoolItem identicalAvailableObj( const PoolItem & rhs ) const;
192
197 PoolItem identicalInstalledObj( const PoolItem & rhs ) const;
198
205 template<class TRes>
207 { return asKind<TRes>( candidateObj() ); }
208
215 template<class TRes>
217 { return asKind<TRes>( candidateObj() ); }
218
227 PoolItem setCandidate( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
230
237 bool setOnSystem( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
238
244 PoolItem theObj() const;
245
250 std::vector<std::string> supersededBy() const;
251
253
258 bool availableEmpty() const;
263 { return makeIterable( availableBegin(), availableEnd() ); }
265
267
272 bool installedEmpty() const;
277 { return makeIterable( installedBegin(), installedEnd() ); }
279
281
287 bool picklistEmpty() const;
292 { return makeIterable( picklistBegin(), picklistEnd() ); }
293
296
301 picklist_size_type picklistPos( const PoolItem & pi_r ) const;
302
304 picklist_size_type picklistPos( const sat::Solvable & solv_r ) const;
306
308
309 public:
314 bool hasObject() const
315 { return (! installedEmpty()) || candidateObj(); }
316
318 bool hasInstalledObj() const
319 { return ! installedEmpty(); }
320
322 bool hasCandidateObj() const
323 { return bool(candidateObj()); }
324
326 bool hasBothObjects() const
327 { return (! installedEmpty()) && candidateObj(); }
328
331 { return (! installedEmpty()) && ! candidateObj(); }
332
335 { return ( installedEmpty() ) && candidateObj(); }
336
337
339 bool hasBlacklisted() const;
340
342 bool hasBlacklistedInstalled() const;
343
345 bool hasRetracted() const;
346
348 bool hasRetractedInstalled() const;
349
351 bool hasPtf() const;
352
354 bool hasPtfInstalled() const;
356
361 bool isUnmaintained() const;
362
374 bool multiversionInstall() const;
375
378 bool pickInstall( const PoolItem & pi_r, ResStatus::TransactByValue causer_r = ResStatus::USER, bool yesno_r = true );
379
383 { return pickInstall( pi_r, causer_r, false ); }
384
387 bool pickDelete( const PoolItem & pi_r, ResStatus::TransactByValue causer_r = ResStatus::USER, bool yesno_r = true );
388
392 { return pickDelete( pi_r, causer_r, false ); }
393
417 Status pickStatus( const PoolItem & pi_r ) const;
418
420 bool setPickStatus( const PoolItem & pi_r, Status state_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
422
432 bool isUndetermined() const;
433
437 bool isRelevant() const;
438
440 bool isSatisfied() const;
441
443 bool isBroken() const;
444
450 bool isNeeded() const;
451
453 bool isUnwanted() const;
455
456 public:
460 enum Fate {
463 TO_INSTALL = 1
464 };
466 Fate fate() const;
467
469 bool unmodified() const
470 { return fate() == UNMODIFIED; }
471
478 bool locked() const
479 { Status st( status() ); return( st == S_Protected || st == S_Taboo ); }
480
486 bool hasLocks() const;
487
489 bool toModify() const
490 { return fate() != UNMODIFIED; }
491
493 bool toDelete() const
494 { return fate() == TO_DELETE; }
495
497 bool toInstall() const
498 { return fate() == TO_INSTALL; }
499
501 bool onSystem() const
502 { return( ( hasInstalledObj() && !toDelete() )
503 ||( hasCandidateObj() && toInstall() ) ); }
504
506 bool offSystem() const
507 { return ! onSystem(); }
508
510 bool setFate( Fate fate_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
511
514 { return setFate( TO_INSTALL, causer_r ); }
515
518
521
524 { return setFate( TO_DELETE, causer_r ); }
525
528
531 { return setFate( UNMODIFIED, causer_r ); }
533
534 public:
543 Status status() const;
544
550
553
555 bool hasLicenceConfirmed() const;
556
558 void setLicenceConfirmed( bool val_r = true );
560
561 public:
563 struct Impl;
564 using Impl_Ptr = shared_ptr<Impl>;
566 Selectable( Impl_Ptr pimpl_r );
567 private:
569 ~Selectable() override;
570 private:
573 };
575
577 std::ostream & operator<<( std::ostream & str, const Selectable & obj );
578
580 std::ostream & dumpOn( std::ostream & str, const Selectable & obj );
581
587 {
588 using result_type = Selectable_Ptr;
589
590 Selectable_Ptr operator()( const sat::Solvable & solv_r ) const;
591
592 Selectable_Ptr operator()( const PoolItem & pi_r ) const
593 { return operator()( pi_r.satSolvable() ); }
594 };
595
597 } // namespace ui
600} // namespace zypp
602#endif // ZYPP_UI_SELECTABLE_H
RepoManager implementation.
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
static const ResKind package
Definition ResKind.h:40
TraitsType::constPtrType constPtr
Definition ResObject.h:43
Base class for reference counted objects.
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.
bool onSystem() const
True if would be on system after commit.
Definition Selectable.h:501
SelectableTraits::installed_size_type installed_size_type
Definition Selectable.h:66
static Ptr get(ResKind kind_r, const std::string &name_r)
Get the Selctable by kind and name.
Definition Selectable.h:89
bool pickNoInstall(const PoolItem &pi_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Deselect a specific available item from installation.
Definition Selectable.h:382
SelectableTraits::installed_iterator installed_iterator
Definition Selectable.h:65
ResTraits< TRes >::constPtrType installedAsKind() const
Return the installedObj resolvable casted to a specific kind.
Definition Selectable.h:206
bool offSystem() const
True if would be off system after commit.
Definition Selectable.h:506
std::vector< std::string > supersededBy() const
The name(s) of the successor package if vendorSupport is VendorSupportSuperseded.
installed_size_type installedSize() const
bool toModify() const
True if either to delete or to install.
Definition Selectable.h:489
picklist_iterator picklistBegin() const
bool hasCandidateObj() const
True if candidate object is present.
Definition Selectable.h:322
bool multiversionInstall() const
Whether at least one of the available packages has multiversionInstall set.
Iterable< picklist_iterator > picklist() const
Definition Selectable.h:291
ResTraits< TRes >::constPtrType candidateAsKind() const
Return the candidateObj resolvable casted to a specific kind.
Definition Selectable.h:216
Status pickStatus(const PoolItem &pi_r) const
Compute the ui::Status for an individual PoolItem.
bool toDelete() const
True if to delete.
Definition Selectable.h:493
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 std::string &name_r)
Get the Package Selctable by name.
Definition Selectable.h:93
bool hasCandidateObjOnly() const
True if candidate object is present but no installed.
Definition Selectable.h:334
static Ptr get(const PoolItem &pi_r)
Get the Selctable containing a specific PoolItem.
Definition Selectable.h:105
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:478
friend std::ostream & operator<<(std::ostream &str, const Selectable &obj)
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:295
void setLicenceConfirmed(bool val_r=true)
Set LicenceConfirmed bit.
bool setToDelete(ResStatus::TransactByValue causer_r=ResStatus::USER)
Set the item to be deleted (must be installed).
Definition Selectable.h:523
friend std::ostream & dumpOn(std::ostream &str, const Selectable &obj)
ResStatus::TransactByValue modifiedBy() const
Return who caused the modification.
static Ptr get(const ResObject::constPtr &resolvable_r)
Get the Selctable containing a specific ResObject.
Definition Selectable.h:101
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
intrusive_ptr< const Selectable > constPtr
Definition Selectable.h:59
SelectableTraits::picklist_size_type picklist_size_type
Definition Selectable.h:69
bool pickNoDelete(const PoolItem &pi_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Deselect a specific installed item from deletion.
Definition Selectable.h:391
bool hasLocks() const
True if it includes locked items (don't mix this with the locked status).
bool hasBothObjects() const
True if installed and candidate object is present.
Definition Selectable.h:326
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,...).
Iterable< available_iterator > available() const
Definition Selectable.h:262
static Ptr get(const sat::Solvable &solv_r)
Get the Selctable containing a specific sat::Solvable.
Definition Selectable.h:97
RW_pointer< Impl > _pimpl
Pointer to implementation.
Definition Selectable.h:572
IdString ident() const
The identifier.
Definition Selectable.cc:56
installed_iterator installedEnd() const
bool unset(ResStatus::TransactByValue causer_r=ResStatus::USER)
Set the item to stay unmodified.
Definition Selectable.h:530
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 identicalInstalledUpdateCandidate() const
True if the updateCandidateObj is installed (same content).
Definition Selectable.h:184
bool setUpToDate(ResStatus::TransactByValue causer_r=ResStatus::USER)
Take care the item gets installed if it is not, or is older.
bool unmodified() const
True if neither to delete or to install.
Definition Selectable.h:469
const std::string & name() const
The ResObjects name.
Definition Selectable.cc:62
bool hasPtf() const
True if this Selectable contains available ptf items.
Iterable< installed_iterator > installed() const
Definition Selectable.h:276
shared_ptr< Impl > Impl_Ptr
Definition Selectable.h:564
~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
static Ptr get(IdString ident_r)
Get the Selctable by its sat-identifier.
Definition Selectable.h:85
bool identicalInstalledCandidate() const
True if the candidateObj is installed (same content).
Definition Selectable.h:178
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 hasObject() const
True if either installed or candidate object is present.
Definition Selectable.h:314
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 toInstall() const
True if to install.
Definition Selectable.h:497
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:318
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
bool hasInstalledObjOnly() const
True if installed object is present but no candidate.
Definition Selectable.h:330
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 setToInstall(ResStatus::TransactByValue causer_r=ResStatus::USER)
Set the item to be installed (new- or re-install).
Definition Selectable.h:513
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.
String related utilities and Regular expression matching.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition NonCopyable.h:26
Status
UI status Status values calculated by Selectable.
Definition Status.h:35
@ S_Taboo
Definition Status.h:37
@ S_Protected
Definition Status.h:36
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.
Wrapper for const correct access via Smart pointer types.
Definition PtrTypes.h:292
intrusive_ptr< const TRes > constPtrType
Definition ResTraits.h:83
Solvable satSolvable() const
Return the corresponding sat::Solvable.
AvailableItemSet::size_type available_size_type
AvailableItemSet::iterator available_iterator
PickList::const_iterator picklist_iterator
PickList::size_type picklist_size_type
AvailableItemSet::iterator installed_iterator
AvailableItemSet::size_type installed_size_type
Solvable to Selectable transform functor.
Definition Selectable.h:587
Selectable_Ptr operator()(const sat::Solvable &solv_r) const
Selectable_Ptr operator()(const PoolItem &pi_r) const
Definition Selectable.h:592
Selectable_Ptr result_type
Definition Selectable.h:588
#define DEFINE_PTR_TYPE(NAME)
Forward declaration of Ptr types.
Definition PtrTypes.h:638