libzypp  13.10.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 
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 
26 namespace zypp
27 {
28 
30  namespace ui
31  {
32 
33  DEFINE_PTR_TYPE(Selectable);
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  ResObject::Kind kind() const;
118 
120  const std::string & name() const;
121 
123  PoolItem installedObj() const;
124 
129  PoolItem candidateObj() const;
130 
136  PoolItem candidateObjFrom( Repository repo_r ) const;
137 
145 
152 
157  bool identicalAvailable( const PoolItem & rhs ) const;
158 
163  bool identicalInstalled( const PoolItem & rhs ) const;
164 
169  { return identicalInstalled( candidateObj() ); }
170 
175  { return identicalInstalled( updateCandidateObj() ); }
176 
181  PoolItem identicalAvailableObj( const PoolItem & rhs ) const;
182 
187  PoolItem identicalInstalledObj( const PoolItem & rhs ) const;
188 
195  template<class _Res>
197  { return asKind<_Res>( candidateObj() ); }
198 
205  template<class _Res>
207  { return asKind<_Res>( candidateObj() ); }
208 
217  PoolItem setCandidate( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
220 
227  bool setOnSystem( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
228 
234  PoolItem theObj() const;
235 
237 
242  bool availableEmpty() const;
247 
249 
254  bool installedEmpty() const;
258  //}
259 
261 
267  bool picklistEmpty() const;
271  //}
272 
274 
275  public:
280  bool hasObject() const
281  { return (! installedEmpty()) || candidateObj(); }
282 
284  bool hasInstalledObj() const
285  { return ! installedEmpty(); }
286 
288  bool hasCandidateObj() const
289  { return bool(candidateObj()); }
290 
292  bool hasBothObjects() const
293  { return (! installedEmpty()) && candidateObj(); }
294 
296  bool hasInstalledObjOnly() const
297  { return (! installedEmpty()) && ! candidateObj(); }
298 
300  bool hasCandidateObjOnly() const
301  { return ( installedEmpty() ) && candidateObj(); }
303 
308  bool isUnmaintained() const;
309 
320  bool multiversionInstall() const;
321 
324  bool pickInstall( const PoolItem & pi_r, ResStatus::TransactByValue causer_r = ResStatus::USER, bool yesno_r = true );
325 
329  { return pickInstall( pi_r, causer_r, false ); }
330 
333  bool pickDelete( const PoolItem & pi_r, ResStatus::TransactByValue causer_r = ResStatus::USER, bool yesno_r = true );
334 
338  { return pickDelete( pi_r, causer_r, false ); }
339 
363  Status pickStatus( const PoolItem & pi_r ) const;
364 
366  bool setPickStatus( const PoolItem & pi_r, Status state_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
368 
378  bool isUndetermined() const;
379 
383  bool isRelevant() const;
384 
386  bool isSatisfied() const;
387 
389  bool isBroken() const;
390 
396  bool isNeeded() const;
397 
399  bool isUnwanted() const;
401 
402  public:
406  enum Fate {
407  TO_DELETE = -1,
410  };
412  Fate fate() const;
413 
415  bool unmodified() const
416  { return fate() == UNMODIFIED; }
417 
419  bool locked() const
420  { Status st( status() ); return( st == S_Protected || st == S_Taboo ); }
421 
423  bool toModify() const
424  { return fate() != UNMODIFIED; }
425 
427  bool toDelete() const
428  { return fate() == TO_DELETE; }
429 
431  bool toInstall() const
432  { return fate() == TO_INSTALL; }
433 
435  bool onSystem() const
436  { return( ( hasInstalledObj() && !toDelete() )
437  ||( hasCandidateObj() && toInstall() ) ); }
438 
440  bool offSystem() const
441  { return ! onSystem(); }
442 
444  bool setFate( Fate fate_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
445 
448  { return setFate( TO_INSTALL, causer_r ); }
449 
452 
455 
458  { return setFate( TO_DELETE, causer_r ); }
459 
462 
465  { return setFate( UNMODIFIED, causer_r ); }
467 
468  public:
477  Status status() const;
478 
483  bool setStatus( Status state_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
484 
487 
489  bool hasLicenceConfirmed() const;
490 
492  void setLicenceConfirmed( bool val_r = true );
494 
495  public:
497  class Impl;
498  typedef shared_ptr<Impl> Impl_Ptr;
500  Selectable( Impl_Ptr pimpl_r );
501  private:
503  ~Selectable();
504  private:
507  };
509 
511  std::ostream & operator<<( std::ostream & str, const Selectable & obj );
512 
514  std::ostream & dumpOn( std::ostream & str, const Selectable & obj );
515 
521  {
522  typedef Selectable_Ptr result_type;
523 
524  Selectable_Ptr operator()( const sat::Solvable & solv_r ) const;
525 
526  Selectable_Ptr operator()( const PoolItem & pi_r ) const
527  { return operator()( pi_r.satSolvable() ); }
528  };
529 
531  } // namespace ui
534 } // namespace zypp
536 #endif // ZYPP_UI_SELECTABLE_H
Selectable_Ptr operator()(const PoolItem &pi_r) const
Definition: Selectable.h:526
available_iterator availableEnd() const
Definition: Selectable.cc:124
PoolItem updateCandidateObj() const
The best candidate for update, if there is one.
Definition: Selectable.cc:79
PickList::const_iterator picklist_iterator
A Solvable object within the sat Pool.
Definition: Solvable.h:55
IdString ident() const
The identifier.
Definition: Selectable.cc:55
installed_iterator installedEnd() const
Definition: Selectable.cc:138
Status
UI status Status values calculated by Selectable.
Definition: Status.h:34
bool isSatisfied() const
Whether a relevant patchs requirements are met.
Definition: Selectable.cc:183
picklist_iterator picklistBegin() const
Definition: Selectable.cc:149
bool identicalAvailable(const PoolItem &rhs) const
True if rhs is installed and one with the same content is available.
Definition: Selectable.cc:85
ResStatus::TransactByValue modifiedBy() const
Return who caused the modification.
Definition: Selectable.cc:199
static const ResKind package
Definition: ResKind.h:43
Collects PoolItems of same kind and name.
Definition: Selectable.h:51
bool isUnwanted() const
Broken (needed) but locked patches.
Definition: Selectable.cc:194
PoolItem installedObj() const
The last Installed object.
Definition: Selectable.cc:70
PoolItem setCandidate(const PoolItem &newCandidate_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Set a candidate (out of available objects).
Definition: Selectable.cc:97
intrusive_ptr< Selectable > Ptr
Definition: Selectable.h:57
SelectableTraits::installed_iterator installed_iterator
Definition: Selectable.h:64
bool hasInstalledObjOnly() const
True if installed object is present but no candidate.
Definition: Selectable.h:296
ResObject::Kind kind() const
The ResObjects kind.
Definition: Selectable.cc:58
bool hasObject() const
True if either installed or candidate object is present.
Definition: Selectable.h:280
Status status() const
Return the current Status.
Definition: Selectable.cc:64
PoolItem identicalAvailableObj(const PoolItem &rhs) const
Return an available Object with the same content as rhs.
Definition: Selectable.cc:91
Access to the sat-pools string space.
Definition: IdString.h:39
bool hasLicenceConfirmed() const
Return value of LicenceConfirmed bit.
Definition: Selectable.cc:202
bool setToInstall(ResStatus::TransactByValue causer_r=ResStatus::USER)
Set the item to be installed (new- or re-install).
Definition: Selectable.h:447
bool onSystem() const
True if would be on system after commit.
Definition: Selectable.h:435
Fate fate() const
Definition: Selectable.cc:209
bool hasInstalledObj() const
True if installed object is present.
Definition: Selectable.h:284
TraitsType::constPtrType constPtr
Definition: ResObject.h:50
bool unmodified() const
True if neither to delete or to install.
Definition: Selectable.h:415
Selectable_Ptr operator()(const sat::Solvable &solv_r) const
PoolItem theObj() const
An object you could use as pars pro toto.
Definition: Selectable.cc:110
available_size_type availableSize() const
Definition: Selectable.cc:118
bool pickNoInstall(const PoolItem &pi_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Deselect a specific available item from installation.
Definition: Selectable.h:328
PoolItem identicalInstalledObj(const PoolItem &rhs) const
an installed Object with the same content as rhs.
Definition: Selectable.cc:94
bool setStatus(Status state_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Try to set a new Status.
Definition: Selectable.cc:67
bool isUnmaintained() const
True if this package has no replacement from the available repositories.
Definition: Selectable.cc:157
bool hasBothObjects() const
True if installed and candidate object is present.
Definition: Selectable.h:292
bool isBroken() const
Whether a relevant patchs requirements are broken.
Definition: Selectable.cc:186
void setLicenceConfirmed(bool val_r=true)
Set LicenceConfirmed bit.
Definition: Selectable.cc:205
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:103
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
bool setInstalled(ResStatus::TransactByValue causer_r=ResStatus::USER)
Take care the item gets installed if it is not.
Definition: Selectable.cc:260
bool identicalInstalled(const PoolItem &rhs) const
True if rhs has the same content as an installed one.
Definition: Selectable.cc:88
bool locked() const
True if locked (subclass of unmodified).
Definition: Selectable.h:419
bool toModify() const
True if either to delete or to install.
Definition: Selectable.h:423
ResTraits< _Res >::constPtrType candidateAsKind() const
Return the candidateObj resolvable casted to a specific kind.
Definition: Selectable.h:206
ResTraits< _Res >::constPtrType installedAsKind() const
Return the installedObj resolvable casted to a specific kind.
Definition: Selectable.h:196
bool isUndetermined() const
Returns true for packages, because packages are not classified by the solver.
Definition: Selectable.cc:177
bool toInstall() const
True if to install.
Definition: Selectable.h:431
bool picklistEmpty() const
Definition: Selectable.cc:143
available_iterator availableBegin() const
Definition: Selectable.cc:121
bool isNeeded() const
This includes unlocked broken patches, as well as those already selected to be installed.
Definition: Selectable.cc:189
PoolItem candidateObjFrom(Repository repo_r) const
The best candidate provided by a specific Repository, if there is one.
Definition: Selectable.cc:76
bool setToDelete(ResStatus::TransactByValue causer_r=ResStatus::USER)
Set the item to be deleted (must be installed).
Definition: Selectable.h:457
std::ostream & operator<<(std::ostream &str, const Selectable &obj)
Definition: Selectable.cc:288
std::ostream & dumpOn(std::ostream &str, const Selectable &obj)
Definition: Selectable.cc:291
installed_size_type installedSize() const
Definition: Selectable.cc:132
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:180
Status pickStatus(const PoolItem &pi_r) const
Compute the ui::Status for an individual PoolItem.
Definition: Selectable.cc:169
friend std::ostream & operator<<(std::ostream &str, const Selectable &obj)
Definition: Selectable.cc:288
bool setDeleted(ResStatus::TransactByValue causer_r=ResStatus::USER)
Take care the item gets deleted if it is installed.
Definition: Selectable.cc:278
bool multiversionInstall() const
Whether different versions of this package can be installed at the same time.
Definition: Selectable.cc:160
shared_ptr< Impl > Impl_Ptr
Definition: Selectable.h:497
bool availableEmpty() const
Definition: Selectable.cc:115
Base class for reference counted objects.
SelectableTraits::available_iterator available_iterator
Iterates over ResObject::constPtr.
Definition: Selectable.h:61
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:172
bool installedEmpty() const
Definition: Selectable.cc:129
intrusive_ptr< const Selectable > constPtr
Definition: Selectable.h:58
PoolItem candidateObj() const
The &#39;best&#39; or &#39;most interesting&#39; among all available objects.
Definition: Selectable.cc:73
picklist_size_type picklistSize() const
Definition: Selectable.cc:146
PoolItem highestAvailableVersionObj() const
Simply the highest available version, ignoring priorities and policies.
Definition: Selectable.cc:82
bool hasCandidateObjOnly() const
True if candidate object is present but no installed.
Definition: Selectable.h:300
Selectable implementation.
PickList::size_type picklist_size_type
bool offSystem() const
True if would be off system after commit.
Definition: Selectable.h:440
bool unset(ResStatus::TransactByValue causer_r=ResStatus::USER)
Set the item to stay unmodified.
Definition: Selectable.h:464
bool identicalInstalledUpdateCandidate() const
True if the updateCandidateObj is installed (same content).
Definition: Selectable.h:174
DEFINE_PTR_TYPE(Selectable)
AvailableItemSet::iterator installed_iterator
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:163
Selectable(Impl_Ptr pimpl_r)
Default ctor.
Definition: Selectable.cc:36
Wrapper for const correct access via Smart pointer types.
Definition: PtrTypes.h:265
sat::Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: PoolItem.h:114
bool toDelete() const
True if to delete.
Definition: Selectable.h:427
bool setUpToDate(ResStatus::TransactByValue causer_r=ResStatus::USER)
Take care the item gets installed if it is not, or is older.
Definition: Selectable.cc:265
AvailableItemSet::size_type installed_size_type
SelectableTraits::picklist_iterator picklist_iterator
Definition: Selectable.h:67
Selectable_Ptr result_type
Definition: Selectable.h:522
Reference to a PoolItem connecting ResObject and ResStatus.
Definition: PoolItem.h:50
bool setFate(Fate fate_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Definition: Selectable.cc:233
bool hasCandidateObj() const
True if candidate object is present.
Definition: Selectable.h:288
picklist_iterator picklistEnd() const
Definition: Selectable.cc:152
Resolvable kinds.
Definition: ResKind.h:35
const std::string & name() const
The ResObjects name.
Definition: Selectable.cc:61
bool identicalInstalledCandidate() const
True if the candidateObj is installed (same content).
Definition: Selectable.h:168
SelectableTraits::picklist_size_type picklist_size_type
Definition: Selectable.h:68
friend std::ostream & dumpOn(std::ostream &str, const Selectable &obj)
Definition: Selectable.cc:291
bool pickNoDelete(const PoolItem &pi_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Deselect a specific installed item from deletion.
Definition: Selectable.h:337
Solvable to Selectable transform functor.
Definition: Selectable.h:520
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:166
SelectableTraits::installed_size_type installed_size_type
Definition: Selectable.h:65
Main filter selecting PoolItems by name and kind.
Definition: ByIdent.h:26
RW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: Selectable.h:506
AvailableItemSet::size_type available_size_type
AvailableItemSet::iterator available_iterator
SelectableTraits::available_size_type available_size_type
Definition: Selectable.h:62
installed_iterator installedBegin() const
Definition: Selectable.cc:135
intrusive_ptr< const _Res > constPtrType
Definition: ResTraits.h:81