libzypp  17.35.15
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 
19 #include <zypp/base/NonCopyable.h>
20 #include <zypp/base/PtrTypes.h>
21 #include <zypp/base/Iterator.h>
22 
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  //
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 
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 
179  { return identicalInstalled( candidateObj() ); }
180 
185  { return identicalInstalled( updateCandidateObj() ); }
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 );
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;
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;
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;
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:
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 
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 {
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 
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 
517  bool setInstalled( ResStatus::TransactByValue causer_r = ResStatus::USER );
518 
520  bool setUpToDate( ResStatus::TransactByValue causer_r = ResStatus::USER );
521 
524  { return setFate( TO_DELETE, causer_r ); }
525 
527  bool setDeleted( ResStatus::TransactByValue causer_r = ResStatus::USER );
528 
531  { return setFate( UNMODIFIED, causer_r ); }
533 
534  public:
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:
573  };
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 
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
bool locked() const
True if locked (subclass of unmodified).
Definition: Selectable.h:478
A Solvable object within the sat Pool.
Definition: Solvable.h:53
SelectableTraits::available_size_type available_size_type
Definition: Selectable.h:63
Status
UI status Status values calculated by Selectable.
Definition: Status.h:35
bool toModify() const
True if either to delete or to install.
Definition: Selectable.h:489
static const ResKind package
Definition: ResKind.h:40
Collects PoolItems of same kind and name.
Definition: Selectable.h:52
AvailableItemSet::size_type available_size_type
bool unmodified() const
True if neither to delete or to install.
Definition: Selectable.h:469
AvailableItemSet::iterator installed_iterator
bool hasCandidateObj() const
True if candidate object is present.
Definition: Selectable.h:322
shared_ptr< Impl > Impl_Ptr
Definition: Selectable.h:564
bool toInstall() const
True if to install.
Definition: Selectable.h:497
String related utilities and Regular expression matching.
Iterable< installed_iterator > installed() const
Definition: Selectable.h:276
Access to the sat-pools string space.
Definition: IdString.h:43
bool setToInstall(ResStatus::TransactByValue causer_r=ResStatus::USER)
Set the item to be installed (new- or re-install).
Definition: Selectable.h:513
bool offSystem() const
True if would be off system after commit.
Definition: Selectable.h:506
bool onSystem() const
True if would be on system after commit.
Definition: Selectable.h:501
intrusive_ptr< const Selectable > constPtr
Definition: Selectable.h:59
AvailableItemSet::size_type installed_size_type
intrusive_ptr< const TRes > constPtrType
Definition: ResTraits.h:83
bool pickNoInstall(const PoolItem &pi_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Deselect a specific available item from installation.
Definition: Selectable.h:382
bool identicalInstalledUpdateCandidate() const
True if the updateCandidateObj is installed (same content).
Definition: Selectable.h:184
bool hasInstalledObjOnly() const
True if installed object is present but no candidate.
Definition: Selectable.h:330
ResTraits< TRes >::constPtrType candidateAsKind() const
Return the candidateObj resolvable casted to a specific kind.
Definition: Selectable.h:216
SelectableTraits::available_iterator available_iterator
Iterates over ResObject::constPtr.
Definition: Selectable.h:62
bool identicalInstalledCandidate() const
True if the candidateObj is installed (same content).
Definition: Selectable.h:178
Selectable_Ptr result_type
Definition: Selectable.h:588
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition: ResTraits.h:93
bool setToDelete(ResStatus::TransactByValue causer_r=ResStatus::USER)
Set the item to be deleted (must be installed).
Definition: Selectable.h:523
Iterable< available_iterator > available() const
Definition: Selectable.h:262
std::ostream & operator<<(std::ostream &str, const Selectable &obj)
Definition: Selectable.cc:331
std::ostream & dumpOn(std::ostream &str, const Selectable &obj)
Definition: Selectable.cc:334
PickList::size_type picklist_size_type
PickList::const_iterator picklist_iterator
TraitsType::constPtrType constPtr
Definition: ResObject.h:43
SelectableTraits::installed_size_type installed_size_type
Definition: Selectable.h:66
Base class for reference counted objects.
bool hasCandidateObjOnly() const
True if candidate object is present but no installed.
Definition: Selectable.h:334
SelectableTraits::picklist_iterator picklist_iterator
Definition: Selectable.h:68
ResTraits< TRes >::constPtrType installedAsKind() const
Return the installedObj resolvable casted to a specific kind.
Definition: Selectable.h:206
bool hasBothObjects() const
True if installed and candidate object is present.
Definition: Selectable.h:326
bool unset(ResStatus::TransactByValue causer_r=ResStatus::USER)
Set the item to stay unmodified.
Definition: Selectable.h:530
DEFINE_PTR_TYPE(Selectable)
bool hasObject() const
True if either installed or candidate object is present.
Definition: Selectable.h:314
Iterable< picklist_iterator > picklist() const
Definition: Selectable.h:291
Selectable_Ptr operator()(const PoolItem &pi_r) const
Definition: Selectable.h:592
bool toDelete() const
True if to delete.
Definition: Selectable.h:493
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:50
AvailableItemSet::iterator available_iterator
SelectableTraits::installed_iterator installed_iterator
Definition: Selectable.h:65
Resolvable kinds.
Definition: ResKind.h:32
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
bool pickNoDelete(const PoolItem &pi_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Deselect a specific installed item from deletion.
Definition: Selectable.h:391
Solvable to Selectable transform functor.
Definition: Selectable.h:586
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57
bool hasInstalledObj() const
True if installed object is present.
Definition: Selectable.h:318
SelectableTraits::picklist_size_type picklist_size_type
Definition: Selectable.h:69
Main filter selecting PoolItems by name and kind.
Definition: ByIdent.h:28
RW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: Selectable.h:572
intrusive_ptr< Selectable > Ptr
Definition: Selectable.h:58
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26