libzypp 17.31.6
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
17#include <zypp/base/ReferenceCounted.h>
18#include <zypp/base/NonCopyable.h>
19#include <zypp/base/PtrTypes.h>
20#include <zypp/base/Iterator.h>
21
23#include <zypp/ui/Status.h>
24
26namespace zypp
27{
28
30 namespace ui
31 {
32
34
36 //
37 // CLASS NAME : Selectable
38 //
52 {
53 friend std::ostream & operator<<( std::ostream & str, const Selectable & obj );
54 friend std::ostream & dumpOn( std::ostream & str, const Selectable & obj );
55
56 public:
57 typedef intrusive_ptr<Selectable> Ptr;
58 typedef intrusive_ptr<const Selectable> constPtr;
59
63
66
69
70 public:
81 static Ptr get( const pool::ByIdent & ident_r );
82
84 static Ptr get( IdString ident_r )
85 { return get( pool::ByIdent( ident_r ) ); }
86
88 static Ptr get( ResKind kind_r, const std::string & name_r )
89 { return get( pool::ByIdent( kind_r, name_r ) ); }
90
92 static Ptr get( const std::string & name_r )
93 { return get( pool::ByIdent( ResKind::package, name_r ) ); }
94
96 static Ptr get( const sat::Solvable & solv_r )
97 { return get( pool::ByIdent( solv_r ) ); }
98
100 static Ptr get( const ResObject::constPtr & resolvable_r )
101 { return resolvable_r ? get( resolvable_r->satSolvable() ) : Ptr(); }
102
104 static Ptr get( const PoolItem & pi_r )
105 { return get( pi_r.satSolvable() ); }
107
108 public:
114 IdString ident() const;
115
117 ResKind kind() const;
118
120 const std::string & name() const;
121
123 PoolItem installedObj() const;
124
131 PoolItem candidateObj() const;
132
139 PoolItem candidateObjFrom( Repository repo_r ) const;
140
150
158
160 bool identIsAutoInstalled() const;
161
166 bool identicalAvailable( const PoolItem & rhs ) const;
167
172 bool identicalInstalled( const PoolItem & rhs ) const;
173
178 { return identicalInstalled( candidateObj() ); }
179
185
190 PoolItem identicalAvailableObj( const PoolItem & rhs ) const;
191
196 PoolItem identicalInstalledObj( const PoolItem & rhs ) const;
197
204 template<class TRes>
206 { return asKind<TRes>( candidateObj() ); }
207
214 template<class TRes>
216 { return asKind<TRes>( candidateObj() ); }
217
226 PoolItem setCandidate( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
229
236 bool setOnSystem( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
237
243 PoolItem theObj() const;
244
246
251 bool availableEmpty() const;
256 { return makeIterable( availableBegin(), availableEnd() ); }
258
260
265 bool installedEmpty() const;
270 { return makeIterable( installedBegin(), installedEnd() ); }
272
274
280 bool picklistEmpty() const;
285 { return makeIterable( picklistBegin(), picklistEnd() ); }
286
289
294 picklist_size_type picklistPos( const PoolItem & pi_r ) const;
295
297 picklist_size_type picklistPos( const sat::Solvable & solv_r ) const;
299
301
302 public:
307 bool hasObject() const
308 { return (! installedEmpty()) || candidateObj(); }
309
311 bool hasInstalledObj() const
312 { return ! installedEmpty(); }
313
315 bool hasCandidateObj() const
316 { return bool(candidateObj()); }
317
319 bool hasBothObjects() const
320 { return (! installedEmpty()) && candidateObj(); }
321
324 { return (! installedEmpty()) && ! candidateObj(); }
325
328 { return ( installedEmpty() ) && candidateObj(); }
329
330
332 bool hasBlacklisted() const;
333
335 bool hasBlacklistedInstalled() const;
336
338 bool hasRetracted() const;
339
341 bool hasRetractedInstalled() const;
342
344 bool hasPtf() const;
345
347 bool hasPtfInstalled() const;
349
354 bool isUnmaintained() const;
355
367 bool multiversionInstall() const;
368
371 bool pickInstall( const PoolItem & pi_r, ResStatus::TransactByValue causer_r = ResStatus::USER, bool yesno_r = true );
372
376 { return pickInstall( pi_r, causer_r, false ); }
377
380 bool pickDelete( const PoolItem & pi_r, ResStatus::TransactByValue causer_r = ResStatus::USER, bool yesno_r = true );
381
385 { return pickDelete( pi_r, causer_r, false ); }
386
410 Status pickStatus( const PoolItem & pi_r ) const;
411
413 bool setPickStatus( const PoolItem & pi_r, Status state_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
415
425 bool isUndetermined() const;
426
430 bool isRelevant() const;
431
433 bool isSatisfied() const;
434
436 bool isBroken() const;
437
443 bool isNeeded() const;
444
446 bool isUnwanted() const;
448
449 public:
453 enum Fate {
456 TO_INSTALL = 1
457 };
459 Fate fate() const;
460
462 bool unmodified() const
463 { return fate() == UNMODIFIED; }
464
471 bool locked() const
472 { Status st( status() ); return( st == S_Protected || st == S_Taboo ); }
473
479 bool hasLocks() const;
480
482 bool toModify() const
483 { return fate() != UNMODIFIED; }
484
486 bool toDelete() const
487 { return fate() == TO_DELETE; }
488
490 bool toInstall() const
491 { return fate() == TO_INSTALL; }
492
494 bool onSystem() const
495 { return( ( hasInstalledObj() && !toDelete() )
496 ||( hasCandidateObj() && toInstall() ) ); }
497
499 bool offSystem() const
500 { return ! onSystem(); }
501
503 bool setFate( Fate fate_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
504
507 { return setFate( TO_INSTALL, causer_r ); }
508
511
514
517 { return setFate( TO_DELETE, causer_r ); }
518
521
524 { return setFate( UNMODIFIED, causer_r ); }
526
527 public:
536 Status status() const;
537
543
546
548 bool hasLicenceConfirmed() const;
549
551 void setLicenceConfirmed( bool val_r = true );
553
554 public:
556 struct Impl;
557 typedef shared_ptr<Impl> Impl_Ptr;
559 Selectable( Impl_Ptr pimpl_r );
560 private:
562 ~Selectable();
563 private:
566 };
568
570 std::ostream & operator<<( std::ostream & str, const Selectable & obj );
571
573 std::ostream & dumpOn( std::ostream & str, const Selectable & obj );
574
580 {
581 typedef Selectable_Ptr result_type;
582
583 Selectable_Ptr operator()( const sat::Solvable & solv_r ) const;
584
585 Selectable_Ptr operator()( const PoolItem & pi_r ) const
586 { return operator()( pi_r.satSolvable() ); }
587 };
588
590 } // namespace ui
593} // namespace zypp
595#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: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:184
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
bool hasPtfInstalled() const
True if this Selectable contains an installed ptf item.
Definition: Selectable.cc:190
bool onSystem() const
True if would be on system after commit.
Definition: Selectable.h:494
static Ptr get(ResKind kind_r, const std::string &name_r)
Get the Selctable by kind and name.
Definition: Selectable.h:88
bool pickNoInstall(const PoolItem &pi_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Deselect a specific available item from installation.
Definition: Selectable.h:375
SelectableTraits::available_size_type available_size_type
Definition: Selectable.h:62
ResTraits< TRes >::constPtrType installedAsKind() const
Return the installedObj resolvable casted to a specific kind.
Definition: Selectable.h:205
bool offSystem() const
True if would be off system after commit.
Definition: Selectable.h:499
installed_size_type installedSize() const
Definition: Selectable.cc:135
SelectableTraits::picklist_iterator picklist_iterator
Definition: Selectable.h:67
bool toModify() const
True if either to delete or to install.
Definition: Selectable.h:482
picklist_iterator picklistBegin() const
Definition: Selectable.cc:152
bool hasCandidateObj() const
True if candidate object is present.
Definition: Selectable.h:315
bool multiversionInstall() const
Whether at least one of the available packages has multiversionInstall set.
Definition: Selectable.cc:197
Iterable< picklist_iterator > picklist() const
Definition: Selectable.h:284
ResTraits< TRes >::constPtrType candidateAsKind() const
Return the candidateObj resolvable casted to a specific kind.
Definition: Selectable.h:215
Status pickStatus(const PoolItem &pi_r) const
Compute the ui::Status for an individual PoolItem.
Definition: Selectable.cc:206
bool toDelete() const
True if to delete.
Definition: Selectable.h:486
bool isUnmaintained() const
True if this package has no replacement from the available repositories.
Definition: Selectable.cc:194
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:317
bool isSatisfied() const
Whether a relevant patchs requirements are met.
Definition: Selectable.cc:220
static Ptr get(const std::string &name_r)
Get the Package Selctable by name.
Definition: Selectable.h:92
bool hasCandidateObjOnly() const
True if candidate object is present but no installed.
Definition: Selectable.h:327
static Ptr get(const PoolItem &pi_r)
Get the Selctable containing a specific PoolItem.
Definition: Selectable.h:104
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:471
friend std::ostream & operator<<(std::ostream &str, const Selectable &obj)
Definition: Selectable.cc:327
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:288
void setLicenceConfirmed(bool val_r=true)
Set LicenceConfirmed bit.
Definition: Selectable.cc:242
bool setToDelete(ResStatus::TransactByValue causer_r=ResStatus::USER)
Set the item to be deleted (must be installed).
Definition: Selectable.h:516
friend std::ostream & dumpOn(std::ostream &str, const Selectable &obj)
Definition: Selectable.cc:330
ResStatus::TransactByValue modifiedBy() const
Return who caused the modification.
Definition: Selectable.cc:236
static Ptr get(const ResObject::constPtr &resolvable_r)
Get the Selctable containing a specific ResObject.
Definition: Selectable.h:100
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 pickNoDelete(const PoolItem &pi_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Deselect a specific installed item from deletion.
Definition: Selectable.h:384
bool hasLocks() const
True if it includes locked items (don't mix this with the locked status).
Definition: Selectable.cc:245
bool hasBothObjects() const
True if installed and candidate object is present.
Definition: Selectable.h:319
bool hasRetracted() const
True if this Selectable contains available retracted items.
Definition: Selectable.cc:181
bool hasBlacklistedInstalled() const
True if this Selectable contains an installed blacklisted item (retracted,ptf,...).
Definition: Selectable.cc:178
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:299
bool hasBlacklisted() const
True if this Selectable contains available blacklisted items (retracted,ptf,...).
Definition: Selectable.cc:175
Iterable< available_iterator > available() const
Definition: Selectable.h:255
static Ptr get(const sat::Solvable &solv_r)
Get the Selctable containing a specific sat::Solvable.
Definition: Selectable.h:96
Selectable(Impl_Ptr pimpl_r)
Default ctor.
Definition: Selectable.cc:36
RW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: Selectable.h:565
intrusive_ptr< const Selectable > constPtr
Definition: Selectable.h:58
IdString ident() const
The identifier.
Definition: Selectable.cc:55
installed_iterator installedEnd() const
Definition: Selectable.cc:141
bool unset(ResStatus::TransactByValue causer_r=ResStatus::USER)
Set the item to stay unmodified.
Definition: Selectable.h:523
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 identicalInstalledUpdateCandidate() const
True if the updateCandidateObj is installed (same content).
Definition: Selectable.h:183
bool setUpToDate(ResStatus::TransactByValue causer_r=ResStatus::USER)
Take care the item gets installed if it is not, or is older.
Definition: Selectable.cc:304
bool unmodified() const
True if neither to delete or to install.
Definition: Selectable.h:462
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:248
bool hasPtf() const
True if this Selectable contains available ptf items.
Definition: Selectable.cc:187
SelectableTraits::available_iterator available_iterator
Iterates over ResObject::constPtr.
Definition: Selectable.h:61
Iterable< installed_iterator > installed() const
Definition: Selectable.h:269
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:556
bool identIsAutoInstalled() const
Whether this ident is flagged as AutoInstalled.
Definition: Selectable.cc:85
available_iterator availableBegin() const
Definition: Selectable.cc:124
static Ptr get(IdString ident_r)
Get the Selctable by its sat-identifier.
Definition: Selectable.h:84
bool identicalInstalledCandidate() const
True if the candidateObj is installed (same content).
Definition: Selectable.h:177
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:200
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 hasObject() const
True if either installed or candidate object is present.
Definition: Selectable.h:307
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:217
bool isUnwanted() const
Broken (needed) but locked patches.
Definition: Selectable.cc:231
PoolItem candidateObj() const
The 'best' or 'most interesting' among all available objects.
Definition: Selectable.cc:73
bool toInstall() const
True if to install.
Definition: Selectable.h:490
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:223
bool hasInstalledObj() const
True if installed object is present.
Definition: Selectable.h:311
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:209
Status status() const
Return the current Status.
Definition: Selectable.cc:64
bool hasLicenceConfirmed() const
Return value of LicenceConfirmed bit.
Definition: Selectable.cc:239
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 hasInstalledObjOnly() const
True if installed object is present but no candidate.
Definition: Selectable.h:323
bool isUndetermined() const
Returns true for packages, because packages are not classified by the solver.
Definition: Selectable.cc:214
ResKind kind() const
The ResObjects kind.
Definition: Selectable.cc:58
bool setToInstall(ResStatus::TransactByValue causer_r=ResStatus::USER)
Set the item to be installed (new- or re-install).
Definition: Selectable.h:506
bool setFate(Fate fate_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Definition: Selectable.cc:272
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:203
bool isNeeded() const
This includes unlocked broken patches, as well as those already selected to be installed.
Definition: Selectable.cc:226
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.
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
DEFINE_PTR_TYPE(Selectable)
std::ostream & operator<<(std::ostream &str, const Selectable &obj)
Definition: Selectable.cc:327
std::ostream & dumpOn(std::ostream &str, const Selectable &obj)
Definition: Selectable.cc:330
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
Wrapper for const correct access via Smart pointer types.
Definition: PtrTypes.h:286
intrusive_ptr< const TRes > constPtrType
Definition: ResTraits.h:83
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57
AvailableItemSet::size_type available_size_type
AvailableItemSet::iterator installed_iterator
PickList::size_type picklist_size_type
AvailableItemSet::size_type installed_size_type
PickList::const_iterator picklist_iterator
AvailableItemSet::iterator available_iterator
Solvable to Selectable transform functor.
Definition: Selectable.h:580
Selectable_Ptr operator()(const sat::Solvable &solv_r) const
Selectable_Ptr operator()(const PoolItem &pi_r) const
Definition: Selectable.h:585
Selectable_Ptr result_type
Definition: Selectable.h:581