libzypp 17.37.10

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
18#include <zypp/base/ReferenceCounted.h>
19#include <zypp/base/NonCopyable.h>
20#include <zypp/base/PtrTypes.h>
21#include <zypp/base/Iterator.h>
22
23#include <zypp/ui/SelectableTraits.h>
24#include <zypp/ui/Status.h>
25
27 namespace zypp
28{
29
31 namespace ui
32 {
33
34 DEFINE_PTR_TYPE(Selectable);
35
37 //
38 // CLASS NAME : Selectable
39 //
52 class ZYPP_API Selectable : public base::ReferenceCounted, private base::NonCopyable
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
62 using available_iterator = SelectableTraits::available_iterator;
63 using available_size_type = SelectableTraits::available_size_type;
64
65 using installed_iterator = SelectableTraits::installed_iterator;
66 using installed_size_type = SelectableTraits::installed_size_type;
67
68 using picklist_iterator = SelectableTraits::picklist_iterator;
69 using picklist_size_type = SelectableTraits::picklist_size_type;
70
71 public:
81
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
150 PoolItem updateCandidateObj() const;
151
158 PoolItem highestAvailableVersionObj() const;
159
161 bool identIsAutoInstalled() const;
162
167 bool identicalAvailable( const PoolItem & rhs ) const;
168
173 bool identicalInstalled( const PoolItem & rhs ) const;
174
176 * \see \ref identicalInstalled.
177 */
178 bool identicalInstalledCandidate() const
179 { return identicalInstalled( candidateObj() ); }
180
182 * \see \ref identicalInstalled.
183 */
184 bool identicalInstalledUpdateCandidate() const
185 { return identicalInstalled( updateCandidateObj() ); }
186
191 PoolItem identicalAvailableObj( const PoolItem & rhs ) const;
192
197 PoolItem identicalInstalledObj( const PoolItem & rhs ) const;
198
204 */
205 template<class TRes>
206 typename ResTraits<TRes>::constPtrType installedAsKind() const
207 { return asKind<TRes>( candidateObj() ); }
208
214 */
215 template<class TRes>
216 typename ResTraits<TRes>::constPtrType candidateAsKind() const
217 { return asKind<TRes>( candidateObj() ); }
218
227 PoolItem setCandidate( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
229 PoolItem setCandidate( const ResObject::constPtr& 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;
259 available_size_type availableSize() const;
260 available_iterator availableBegin() const;
261 available_iterator availableEnd() const;
262 inline Iterable<available_iterator> available() const
263 { return makeIterable( availableBegin(), availableEnd() ); }
265
267
272 bool installedEmpty() const;
273 installed_size_type installedSize() const;
274 installed_iterator installedBegin() const;
275 installed_iterator installedEnd() const;
276 inline Iterable<installed_iterator> installed() const
277 { return makeIterable( installedBegin(), installedEnd() ); }
279
281
287 bool picklistEmpty() const;
288 picklist_size_type picklistSize() const;
289 picklist_iterator picklistBegin() const;
290 picklist_iterator picklistEnd() const;
291 inline Iterable<picklist_iterator> picklist() const
292 { return makeIterable( picklistBegin(), picklistEnd() ); }
293
295 static constexpr const picklist_size_type picklistNoPos = picklist_size_type(-1);
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:
312 //@{
313
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
330 bool hasInstalledObjOnly() const
331 { return (! installedEmpty()) && ! candidateObj(); }
332
334 bool hasCandidateObjOnly() const
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
370
374 bool multiversionInstall() const;
375
378 bool pickInstall( const PoolItem & pi_r, ResStatus::TransactByValue causer_r = ResStatus::USER, bool yesno_r = true );
379
380 /** Deselect a specific available item from installation.
381 */
382 bool pickNoInstall( const PoolItem & pi_r, ResStatus::TransactByValue causer_r = ResStatus::USER )
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
389 /** Deselect a specific installed item from deletion.
390 */
391 bool pickNoDelete( const PoolItem & pi_r, ResStatus::TransactByValue causer_r = ResStatus::USER )
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
429
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:
458 */
460 enum Fate {
461 TO_DELETE = -1,
462 UNMODIFIED = 0,
463 TO_INSTALL = 1
464 };
466 Fate fate() const;
467
469 bool unmodified() const
470 { return fate() == UNMODIFIED; }
471
476 * \see \ref hasLocks
477 */
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
513 bool setToInstall( ResStatus::TransactByValue causer_r = ResStatus::USER )
514 { return setFate( TO_INSTALL, causer_r ); }
515
517 bool setInstalled( ResStatus::TransactByValue causer_r = ResStatus::USER );
518
520 bool setUpToDate( ResStatus::TransactByValue causer_r = ResStatus::USER );
521
523 bool setToDelete( ResStatus::TransactByValue causer_r = ResStatus::USER )
524 { return setFate( TO_DELETE, causer_r ); }
525
527 bool setDeleted( ResStatus::TransactByValue causer_r = ResStatus::USER );
528
530 bool unset( ResStatus::TransactByValue causer_r = ResStatus::USER )
531 { return setFate( UNMODIFIED, causer_r ); }
533
534 public:
542
543 Status status() const;
544
549 bool setStatus( Status state_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
550
552 ResStatus::TransactByValue modifiedBy() const;
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:
572 RW_pointer<Impl> _pimpl;
573 };
574
575
577 std::ostream & operator<<( std::ostream & str, const Selectable & obj ) ZYPP_API;
578
580 std::ostream & dumpOn( std::ostream & str, const Selectable & obj ) ZYPP_API;
581
586 struct ZYPP_API asSelectable
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
operator<<
std::ostream & operator<<(std::ostream &str, const zypp::sat::detail::CDataiterator *obj)
Definition LookupAttr.cc:808
SelectableTraits.h
Status.h
bool
intrusive_ptr
shared_ptr
zypp::IdString
Access to the sat-pools string space.
Definition IdString.h:44
zypp::Iterable
Definition Iterable.h:37
zypp::Iterable::makeIterable
Iterable< TIterator > makeIterable(TIterator &&begin_r, TIterator &&end_r)
convenient construction.
Definition Iterable.h:88
zypp::PoolItem
Combining sat::Solvable and ResStatus.
Definition PoolItem.h:51
zypp::Repository
Definition Repository.h:40
zypp::ResKind
Resolvable kinds.
Definition ResKind.h:33
zypp::ResKind::package
static const ResKind package
Definition ResKind.h:40
zypp::ResObject::constPtr
TraitsType::constPtrType constPtr
Definition ResObject.h:43
zypp::ResStatus::TransactByValue
TransactByValue
Definition ResStatus.h:108
zypp::ResStatus::USER
@ USER
Definition ResStatus.h:112
zypp::base::ReferenceCounted
Base class for reference counted objects.
Definition ReferenceCounted.h:35
zypp::pool::ByIdent
Main filter selecting PoolItems by name and kind.
Definition ByIdent.h:29
zypp::sat::Solvable
A Solvable object within the sat Pool.
Definition Solvable.h:54
zypp::ui::Selectable
Collects PoolItems of same kind and name.
Definition Selectable.h:53
zypp::ui::Selectable::available_size_type
SelectableTraits::available_size_type available_size_type
Definition Selectable.h:63
zypp::ui::Selectable::availableEnd
available_iterator availableEnd() const
Definition Selectable.cc:131
zypp::ui::Selectable::onSystem
bool onSystem() const
True if would be on system after commit.
Definition Selectable.h:499
zypp::ui::Selectable::installed_size_type
SelectableTraits::installed_size_type installed_size_type
Definition Selectable.h:66
zypp::ui::Selectable::pickNoInstall
bool pickNoInstall(const PoolItem &pi_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Deselect a specific available item from installation.
Definition Selectable.h:380
zypp::ui::Selectable::installed_iterator
SelectableTraits::installed_iterator installed_iterator
Definition Selectable.h:65
zypp::ui::Selectable::installedAsKind
ResTraits< TRes >::constPtrType installedAsKind() const
Return the installedObj resolvable casted to a specific kind.
Definition Selectable.h:204
zypp::ui::Selectable::offSystem
bool offSystem() const
True if would be off system after commit.
Definition Selectable.h:504
zypp::ui::Selectable::toModify
bool toModify() const
True if either to delete or to install.
Definition Selectable.h:487
zypp::ui::Selectable::picklistBegin
picklist_iterator picklistBegin() const
Definition Selectable.cc:156
zypp::ui::Selectable::hasCandidateObj
bool hasCandidateObj() const
True if candidate object is present.
Definition Selectable.h:320
zypp::ui::Selectable::picklist
Iterable< picklist_iterator > picklist() const
Definition Selectable.h:289
zypp::ui::Selectable::candidateAsKind
ResTraits< TRes >::constPtrType candidateAsKind() const
Return the candidateObj resolvable casted to a specific kind.
Definition Selectable.h:214
zypp::ui::Selectable::toDelete
bool toDelete() const
True if to delete.
Definition Selectable.h:491
zypp::ui::Selectable::hasCandidateObjOnly
bool hasCandidateObjOnly() const
True if candidate object is present but no installed.
Definition Selectable.h:332
zypp::ui::Selectable::get
static Ptr get(const pool::ByIdent &ident_r)
Get the Selctable.
Definition Selectable.cc:29
zypp::ui::Selectable::installedBegin
installed_iterator installedBegin() const
Definition Selectable.cc:142
zypp::ui::Selectable::locked
bool locked() const
True if locked (subclass of unmodified).
Definition Selectable.h:476
zypp::ui::Selectable::picklistNoPos
static constexpr const picklist_size_type picklistNoPos
Returned by picklistPos if the Item does not belong to the picklist.
Definition Selectable.h:293
zypp::ui::Selectable::setToDelete
bool setToDelete(ResStatus::TransactByValue causer_r=ResStatus::USER)
Set the item to be deleted (must be installed).
Definition Selectable.h:521
zypp::ui::Selectable::dumpOn
friend std::ostream & dumpOn(std::ostream &str, const Selectable &obj)
Definition Selectable.cc:334
zypp::ui::Selectable::constPtr
intrusive_ptr< const Selectable > constPtr
Definition Selectable.h:59
zypp::ui::Selectable::picklist_size_type
SelectableTraits::picklist_size_type picklist_size_type
Definition Selectable.h:69
zypp::ui::Selectable::pickNoDelete
bool pickNoDelete(const PoolItem &pi_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Deselect a specific installed item from deletion.
Definition Selectable.h:389
zypp::ui::Selectable::hasBothObjects
bool hasBothObjects() const
True if installed and candidate object is present.
Definition Selectable.h:324
zypp::ui::Selectable::picklistEnd
picklist_iterator picklistEnd() const
Definition Selectable.cc:159
zypp::ui::Selectable::available
Iterable< available_iterator > available() const
Definition Selectable.h:260
zypp::ui::Selectable::Selectable
Selectable(Impl_Ptr pimpl_r)
Default ctor.
Definition Selectable.cc:37
zypp::ui::Selectable::_pimpl
RW_pointer< Impl > _pimpl
Pointer to implementation.
Definition Selectable.h:570
zypp::ui::Selectable::installedEnd
installed_iterator installedEnd() const
Definition Selectable.cc:145
zypp::ui::Selectable::unset
bool unset(ResStatus::TransactByValue causer_r=ResStatus::USER)
Set the item to stay unmodified.
Definition Selectable.h:528
zypp::ui::Selectable::updateCandidateObj
PoolItem updateCandidateObj() const
The best candidate for update, if there is one.
Definition Selectable.cc:80
zypp::ui::Selectable::identicalInstalledUpdateCandidate
bool identicalInstalledUpdateCandidate() const
True if the updateCandidateObj is installed (same content).
Definition Selectable.h:182
zypp::ui::Selectable::unmodified
bool unmodified() const
True if neither to delete or to install.
Definition Selectable.h:467
zypp::ui::Selectable::fate
Fate fate() const
Definition Selectable.cc:252
zypp::ui::Selectable::installed
Iterable< installed_iterator > installed() const
Definition Selectable.h:274
zypp::ui::Selectable::Impl_Ptr
shared_ptr< Impl > Impl_Ptr
Definition Selectable.h:562
zypp::ui::Selectable::availableBegin
available_iterator availableBegin() const
Definition Selectable.cc:128
zypp::ui::Selectable::identicalInstalledCandidate
bool identicalInstalledCandidate() const
True if the candidateObj is installed (same content).
Definition Selectable.h:176
zypp::ui::Selectable::Fate
Fate
Definition Selectable.h:458
zypp::ui::Selectable::UNMODIFIED
@ UNMODIFIED
Definition Selectable.h:460
zypp::ui::Selectable::TO_INSTALL
@ TO_INSTALL
Definition Selectable.h:461
zypp::ui::Selectable::TO_DELETE
@ TO_DELETE
Definition Selectable.h:459
zypp::ui::Selectable::pickInstall
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:204
zypp::ui::Selectable::hasObject
bool hasObject() const
True if either installed or candidate object is present.
Definition Selectable.h:312
zypp::ui::Selectable::candidateObj
PoolItem candidateObj() const
The 'best' or 'most interesting' among all available objects.
Definition Selectable.cc:74
zypp::ui::Selectable::toInstall
bool toInstall() const
True if to install.
Definition Selectable.h:495
zypp::ui::Selectable::hasInstalledObj
bool hasInstalledObj() const
True if installed object is present.
Definition Selectable.h:316
zypp::ui::Selectable::picklist_iterator
SelectableTraits::picklist_iterator picklist_iterator
Definition Selectable.h:68
zypp::ui::Selectable::status
Status status() const
Return the current Status.
Definition Selectable.cc:65
zypp::ui::Selectable::identicalInstalled
bool identicalInstalled(const PoolItem &rhs) const
True if rhs has the same content as an installed one.
Definition Selectable.cc:92
zypp::ui::Selectable::hasInstalledObjOnly
bool hasInstalledObjOnly() const
True if installed object is present but no candidate.
Definition Selectable.h:328
zypp::ui::Selectable::Ptr
intrusive_ptr< Selectable > Ptr
Definition Selectable.h:58
zypp::ui::Selectable::setToInstall
bool setToInstall(ResStatus::TransactByValue causer_r=ResStatus::USER)
Set the item to be installed (new- or re-install).
Definition Selectable.h:511
zypp::ui::Selectable::setFate
bool setFate(Fate fate_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Definition Selectable.cc:276
zypp::ui::Selectable::pickDelete
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:207
zypp::ui::Selectable::available_iterator
SelectableTraits::available_iterator available_iterator
Iterates over ResObject::constPtr.
Definition Selectable.h:62
zypp::ui::Selectable::installedEmpty
bool installedEmpty() const
Definition Selectable.cc:136
zypp::ui::Selectable::picklistPos
picklist_size_type picklistPos(const PoolItem &pi_r) const
Return the position of pi_r in the piclist or picklistNoPos.
Definition Selectable.cc:162
str
String related utilities and Regular expression matching.
zypp::base::NonCopyable
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition NonCopyable.h:26
zypp::ui
Definition SolvIterMixin.cc:57
zypp::ui::Status
Status
UI status Status values calculated by Selectable.
Definition Status.h:36
zypp::ui::S_Taboo
@ S_Taboo
Definition Status.h:38
zypp::ui::S_Protected
@ S_Protected
Definition Status.h:37
zypp::ui::operator<<
std::ostream & operator<<(std::ostream &str, const Selectable &obj)
Definition Selectable.cc:331
zypp::ui::dumpOn
std::ostream & dumpOn(std::ostream &str, const Selectable &obj)
Definition Selectable.cc:334
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::kind
const ResKind ResTraits< Package >::kind(ResKind::package)
zypp::ZYPP_API
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
zypp::asKind
ResTraits< TRes >::PtrType asKind(const sat::Solvable &solvable_r)
Directly create a certain kind of ResObject from sat::Solvable.
Definition ResObject.h:127
zypp::RW_pointer
Wrapper for const correct access via Smart pointer types.
Definition PtrTypes.h:293
zypp::ResTraits::constPtrType
intrusive_ptr< const TRes > constPtrType
Definition ResTraits.h:83
zypp::sat::SolvableType::satSolvable
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition SolvableType.h:57
zypp::ui::SelectableTraits::available_size_type
AvailableItemSet::size_type available_size_type
Definition SelectableTraits.h:121
zypp::ui::SelectableTraits::available_iterator
AvailableItemSet::iterator available_iterator
Definition SelectableTraits.h:119
zypp::ui::SelectableTraits::picklist_iterator
PickList::const_iterator picklist_iterator
Definition SelectableTraits.h:129
zypp::ui::SelectableTraits::picklist_size_type
PickList::size_type picklist_size_type
Definition SelectableTraits.h:130
zypp::ui::SelectableTraits::installed_iterator
AvailableItemSet::iterator installed_iterator
Definition SelectableTraits.h:124
zypp::ui::SelectableTraits::installed_size_type
AvailableItemSet::size_type installed_size_type
Definition SelectableTraits.h:126
zypp::ui::Selectable::Impl
Selectable implementation.
Definition SelectableImpl.h:44
zypp::ui::asSelectable
Solvable to Selectable transform functor.
Definition Selectable.h:587
zypp::ui::asSelectable::operator()
Selectable_Ptr operator()(const sat::Solvable &solv_r) const
Definition SolvIterMixin.cc:59
zypp::ui::asSelectable::operator()
Selectable_Ptr operator()(const PoolItem &pi_r) const
Definition Selectable.h:592
zypp::ui::asSelectable::result_type
Selectable_Ptr result_type
Definition Selectable.h:588
DEFINE_PTR_TYPE
#define DEFINE_PTR_TYPE(NAME)
Forward declaration of Ptr types.
Definition PtrTypes.h:639
Iterator.h
NonCopyable.h
PtrTypes.h
ReferenceCounted.h