libzypp 17.35.14
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
20#include <zypp/base/PtrTypes.h>
21#include <zypp/base/Iterator.h>
22
24#include <zypp/ui/Status.h>
25
27namespace zypp
28{
29
31 namespace ui
32 {
33
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 );
85 static Ptr get( IdString ident_r )
86 { return get( pool::ByIdent( ident_r ) ); }
89 static Ptr get( ResKind kind_r, const std::string & name_r )
90 { return get( pool::ByIdent( std::move(kind_r), name_r ) ); }
93 static Ptr get( const std::string & name_r )
94 { return get( pool::ByIdent( ResKind::package, name_r ) ); }
97 static Ptr get( const sat::Solvable & solv_r )
98 { return get( pool::ByIdent( solv_r ) ); }
101 static Ptr get( const ResObject::constPtr & resolvable_r )
102 { return resolvable_r ? get( resolvable_r->satSolvable() ) : Ptr(); }
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
178 bool identicalInstalledCandidate() const
179 { return identicalInstalled( candidateObj() ); }
180
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
205 template<class TRes>
206 typename ResTraits<TRes>::constPtrType installedAsKind() const
207 { return asKind<TRes>( candidateObj() ); }
208
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() ); }
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(); }
318 bool hasInstalledObj() const
319 { return ! installedEmpty(); }
322 bool hasCandidateObj() const
323 { return bool(candidateObj()); }
326 bool hasBothObjects() const
327 { return (! installedEmpty()) && candidateObj(); }
330 bool hasInstalledObjOnly() const
331 { return (! installedEmpty()) && ! candidateObj(); }
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
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
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
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;
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;
489 bool toModify() const
490 { return fate() != UNMODIFIED; }
493 bool toDelete() const
494 { return fate() == TO_DELETE; }
497 bool toInstall() const
498 { return fate() == TO_INSTALL; }
501 bool onSystem() const
502 { return( ( hasInstalledObj() && !toDelete() )
503 ||( hasCandidateObj() && toInstall() ) ); }
506 bool offSystem() const
507 { return ! onSystem(); }
508
510 bool setFate( Fate fate_r, ResStatus::TransactByValue causer_r = ResStatus::USER );
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 );
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 );
530 bool unset( ResStatus::TransactByValue causer_r = ResStatus::USER )
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:
572 RW_pointer<Impl> _pimpl;
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
std::ostream & operator<<(std::ostream &str, const zypp::sat::detail::CDataiterator *obj)
bool operator()(const zypp::Arch &lhs, const zypp::Arch &rhs) const
Default order for std::container based Arch::compare.
Definition Arch.h:370
Access to the sat-pools string space.
Definition IdString.h:44
Iterable< TIterator > makeIterable(TIterator &&begin_r, TIterator &&end_r)
convenient construction.
Definition Iterable.h:88
Combining sat::Solvable and ResStatus.
Definition PoolItem.h:51
Resolvable kinds.
Definition ResKind.h:33
TraitsType::constPtrType constPtr
Definition ResObject.h:43
Base class for reference counted objects.
Main filter selecting PoolItems by name and kind.
Definition ByIdent.h:29
A Solvable object within the sat Pool.
Definition Solvable.h:54
Collects PoolItems of same kind and name.
Definition Selectable.h:53
SelectableTraits::available_size_type available_size_type
Definition Selectable.h:63
SelectableTraits::installed_size_type installed_size_type
Definition Selectable.h:66
SelectableTraits::installed_iterator installed_iterator
Definition Selectable.h:65
intrusive_ptr< const Selectable > constPtr
Definition Selectable.h:59
SelectableTraits::picklist_size_type picklist_size_type
Definition Selectable.h:69
SelectableTraits::picklist_iterator picklist_iterator
Definition Selectable.h:68
intrusive_ptr< Selectable > Ptr
Definition Selectable.h:58
SelectableTraits::available_iterator available_iterator
Iterates over ResObject::constPtr.
Definition Selectable.h:62
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:36
std::ostream & operator<<(std::ostream &str, const Selectable &obj)
std::ostream & dumpOn(std::ostream &str, const Selectable &obj)
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
Wrapper for const correct access via Smart pointer types.
Definition PtrTypes.h:293
Solvable satSolvable() const
Return the corresponding sat::Solvable.
AvailableItemSet::size_type available_size_type
AvailableItemSet::iterator available_iterator
PickList::const_iterator picklist_iterator
PickList::size_type picklist_size_type
AvailableItemSet::iterator installed_iterator
AvailableItemSet::size_type installed_size_type
Solvable to Selectable transform functor.
Definition Selectable.h:587
Selectable_Ptr operator()(const PoolItem &pi_r) const
Definition Selectable.h:592
Selectable_Ptr result_type
Definition Selectable.h:588
#define DEFINE_PTR_TYPE(NAME)
Forward declaration of Ptr types.
Definition PtrTypes.h:639