libzypp 17.37.17
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:
60
64
67
70
71 public:
81
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
176 * \see \ref identicalInstalled.
177 */
178 bool identicalInstalledCandidate() const
179 { return identicalInstalled( candidateObj() ); }
180
182 * \see \ref identicalInstalled.
183 */
186
191 PoolItem identicalAvailableObj( const PoolItem & rhs ) const;
192
197 PoolItem identicalInstalledObj( const PoolItem & rhs ) const;
198
204 */
205 template<class TRes>
207 { return asKind<TRes>( candidateObj() ); }
208
214 */
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;
263 { return makeIterable( availableBegin(), availableEnd() ); }
265
267
272 bool installedEmpty() const;
273 installed_size_type installedSize() const;
277 { return makeIterable( installedBegin(), installedEnd() ); }
279
281
287 bool picklistEmpty() const;
288 picklist_size_type picklistSize() 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:
312 //@{
313
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
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 */
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 {
462 UNMODIFIED = 0,
463 TO_INSTALL = 1
464 };
466 Fate fate() const;
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;
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 );
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 );
524 { return setFate( TO_DELETE, causer_r ); }
525
527 bool setDeleted( 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;
566 Selectable( Impl_Ptr pimpl_r );
567 private:
569 ~Selectable() override;
570 private:
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
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)
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
static const ResKind package
Definition ResKind.h:40
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
available_iterator availableEnd() const
bool onSystem() const
True if would be on system after commit.
Definition Selectable.h:499
SelectableTraits::installed_size_type installed_size_type
Definition Selectable.h:66
bool pickNoInstall(const PoolItem &pi_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Deselect a specific available item from installation.
Definition Selectable.h:380
SelectableTraits::installed_iterator installed_iterator
Definition Selectable.h:65
ResTraits< TRes >::constPtrType installedAsKind() const
Return the installedObj resolvable casted to a specific kind.
Definition Selectable.h:204
bool offSystem() const
True if would be off system after commit.
Definition Selectable.h:504
bool toModify() const
True if either to delete or to install.
Definition Selectable.h:487
picklist_iterator picklistBegin() const
bool hasCandidateObj() const
True if candidate object is present.
Definition Selectable.h:320
Iterable< picklist_iterator > picklist() const
Definition Selectable.h:289
ResTraits< TRes >::constPtrType candidateAsKind() const
Return the candidateObj resolvable casted to a specific kind.
Definition Selectable.h:214
bool toDelete() const
True if to delete.
Definition Selectable.h:491
bool hasCandidateObjOnly() const
True if candidate object is present but no installed.
Definition Selectable.h:332
static Ptr get(const pool::ByIdent &ident_r)
Get the Selctable.
Definition Selectable.cc:29
installed_iterator installedBegin() const
bool locked() const
True if locked (subclass of unmodified).
Definition Selectable.h:476
static constexpr const picklist_size_type picklistNoPos
Returned by picklistPos if the Item does not belong to the picklist.
Definition Selectable.h:293
bool setToDelete(ResStatus::TransactByValue causer_r=ResStatus::USER)
Set the item to be deleted (must be installed).
Definition Selectable.h:521
friend std::ostream & dumpOn(std::ostream &str, const Selectable &obj)
intrusive_ptr< const Selectable > constPtr
Definition Selectable.h:59
SelectableTraits::picklist_size_type picklist_size_type
Definition Selectable.h:69
bool pickNoDelete(const PoolItem &pi_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Deselect a specific installed item from deletion.
Definition Selectable.h:389
bool hasBothObjects() const
True if installed and candidate object is present.
Definition Selectable.h:324
picklist_iterator picklistEnd() const
Iterable< available_iterator > available() const
Definition Selectable.h:260
Selectable(Impl_Ptr pimpl_r)
Default ctor.
Definition Selectable.cc:37
RW_pointer< Impl > _pimpl
Pointer to implementation.
Definition Selectable.h:570
installed_iterator installedEnd() const
bool unset(ResStatus::TransactByValue causer_r=ResStatus::USER)
Set the item to stay unmodified.
Definition Selectable.h:528
PoolItem updateCandidateObj() const
The best candidate for update, if there is one.
Definition Selectable.cc:80
bool identicalInstalledUpdateCandidate() const
True if the updateCandidateObj is installed (same content).
Definition Selectable.h:182
bool unmodified() const
True if neither to delete or to install.
Definition Selectable.h:467
Iterable< installed_iterator > installed() const
Definition Selectable.h:274
shared_ptr< Impl > Impl_Ptr
Definition Selectable.h:562
available_iterator availableBegin() const
bool identicalInstalledCandidate() const
True if the candidateObj is installed (same content).
Definition Selectable.h:176
bool pickInstall(const PoolItem &pi_r, ResStatus::TransactByValue causer_r=ResStatus::USER, bool yesno_r=true)
Select a specific available item for installation.
bool hasObject() const
True if either installed or candidate object is present.
Definition Selectable.h:312
PoolItem candidateObj() const
The 'best' or 'most interesting' among all available objects.
Definition Selectable.cc:74
bool toInstall() const
True if to install.
Definition Selectable.h:495
bool hasInstalledObj() const
True if installed object is present.
Definition Selectable.h:316
SelectableTraits::picklist_iterator picklist_iterator
Definition Selectable.h:68
Status status() const
Return the current Status.
Definition Selectable.cc:65
bool identicalInstalled(const PoolItem &rhs) const
True if rhs has the same content as an installed one.
Definition Selectable.cc:92
bool hasInstalledObjOnly() const
True if installed object is present but no candidate.
Definition Selectable.h:328
intrusive_ptr< Selectable > Ptr
Definition Selectable.h:58
bool setToInstall(ResStatus::TransactByValue causer_r=ResStatus::USER)
Set the item to be installed (new- or re-install).
Definition Selectable.h:511
bool setFate(Fate fate_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
bool pickDelete(const PoolItem &pi_r, ResStatus::TransactByValue causer_r=ResStatus::USER, bool yesno_r=true)
Select a specific installed item for deletion.
SelectableTraits::available_iterator available_iterator
Iterates over ResObject::constPtr.
Definition Selectable.h:62
bool installedEmpty() const
picklist_size_type picklistPos(const PoolItem &pi_r) const
Return the position of pi_r in the piclist or picklistNoPos.
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
@ S_Taboo
Definition Status.h:38
@ S_Protected
Definition Status.h:37
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.
const ResKind ResTraits< Package >::kind(ResKind::package)
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
ResTraits< TRes >::PtrType asKind(const sat::Solvable &solvable_r)
Directly create a certain kind of ResObject from sat::Solvable.
Definition ResObject.h:127
Wrapper for const correct access via Smart pointer types.
Definition PtrTypes.h:293
intrusive_ptr< const TRes > constPtrType
Definition ResTraits.h:83
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
Selectable implementation.
Solvable to Selectable transform functor.
Definition Selectable.h:587
Selectable_Ptr operator()(const sat::Solvable &solv_r) const
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