libzypp  17.14.0
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  ResKind 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 
154  bool identIsAutoInstalled() const;
155 
160  bool identicalAvailable( const PoolItem & rhs ) const;
161 
166  bool identicalInstalled( const PoolItem & rhs ) const;
167 
172  { return identicalInstalled( candidateObj() ); }
173 
178  { return identicalInstalled( updateCandidateObj() ); }
179 
184  PoolItem identicalAvailableObj( const PoolItem & rhs ) const;
185 
190  PoolItem identicalInstalledObj( const PoolItem & rhs ) const;
191 
198  template<class TRes>
200  { return asKind<TRes>( candidateObj() ); }
201 
208  template<class TRes>
210  { return asKind<TRes>( candidateObj() ); }
211 
220  PoolItem setCandidate( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
223 
230  bool setOnSystem( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
231 
237  PoolItem theObj() const;
238 
240 
245  bool availableEmpty() const;
250  { return makeIterable( availableBegin(), availableEnd() ); }
252 
254 
259  bool installedEmpty() const;
264  { return makeIterable( installedBegin(), installedEnd() ); }
266 
268 
274  bool picklistEmpty() const;
279  { return makeIterable( picklistBegin(), picklistEnd() ); }
280 
283 
288  picklist_size_type picklistPos( const PoolItem & pi_r ) const;
289 
291  picklist_size_type picklistPos( const sat::Solvable & solv_r ) const;
293 
295 
296  public:
301  bool hasObject() const
302  { return (! installedEmpty()) || candidateObj(); }
303 
305  bool hasInstalledObj() const
306  { return ! installedEmpty(); }
307 
309  bool hasCandidateObj() const
310  { return bool(candidateObj()); }
311 
313  bool hasBothObjects() const
314  { return (! installedEmpty()) && candidateObj(); }
315 
317  bool hasInstalledObjOnly() const
318  { return (! installedEmpty()) && ! candidateObj(); }
319 
321  bool hasCandidateObjOnly() const
322  { return ( installedEmpty() ) && candidateObj(); }
324 
329  bool isUnmaintained() const;
330 
342  bool multiversionInstall() const;
343 
346  bool pickInstall( const PoolItem & pi_r, ResStatus::TransactByValue causer_r = ResStatus::USER, bool yesno_r = true );
347 
351  { return pickInstall( pi_r, causer_r, false ); }
352 
355  bool pickDelete( const PoolItem & pi_r, ResStatus::TransactByValue causer_r = ResStatus::USER, bool yesno_r = true );
356 
360  { return pickDelete( pi_r, causer_r, false ); }
361 
385  Status pickStatus( const PoolItem & pi_r ) const;
386 
388  bool setPickStatus( const PoolItem & pi_r, Status state_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
390 
400  bool isUndetermined() const;
401 
405  bool isRelevant() const;
406 
408  bool isSatisfied() const;
409 
411  bool isBroken() const;
412 
418  bool isNeeded() const;
419 
421  bool isUnwanted() const;
423 
424  public:
428  enum Fate {
429  TO_DELETE = -1,
432  };
434  Fate fate() const;
435 
437  bool unmodified() const
438  { return fate() == UNMODIFIED; }
439 
446  bool locked() const
447  { Status st( status() ); return( st == S_Protected || st == S_Taboo ); }
448 
454  bool hasLocks() const;
455 
457  bool toModify() const
458  { return fate() != UNMODIFIED; }
459 
461  bool toDelete() const
462  { return fate() == TO_DELETE; }
463 
465  bool toInstall() const
466  { return fate() == TO_INSTALL; }
467 
469  bool onSystem() const
470  { return( ( hasInstalledObj() && !toDelete() )
471  ||( hasCandidateObj() && toInstall() ) ); }
472 
474  bool offSystem() const
475  { return ! onSystem(); }
476 
478  bool setFate( Fate fate_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
479 
482  { return setFate( TO_INSTALL, causer_r ); }
483 
486 
489 
492  { return setFate( TO_DELETE, causer_r ); }
493 
496 
499  { return setFate( UNMODIFIED, causer_r ); }
501 
502  public:
511  Status status() const;
512 
517  bool setStatus( Status state_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
518 
521 
523  bool hasLicenceConfirmed() const;
524 
526  void setLicenceConfirmed( bool val_r = true );
528 
529  public:
531  struct Impl;
532  typedef shared_ptr<Impl> Impl_Ptr;
534  Selectable( Impl_Ptr pimpl_r );
535  private:
537  ~Selectable();
538  private:
541  };
543 
545  std::ostream & operator<<( std::ostream & str, const Selectable & obj );
546 
548  std::ostream & dumpOn( std::ostream & str, const Selectable & obj );
549 
555  {
556  typedef Selectable_Ptr result_type;
557 
558  Selectable_Ptr operator()( const sat::Solvable & solv_r ) const;
559 
560  Selectable_Ptr operator()( const PoolItem & pi_r ) const
561  { return operator()( pi_r.satSolvable() ); }
562  };
563 
565  } // namespace ui
568 } // namespace zypp
570 #endif // ZYPP_UI_SELECTABLE_H