libzypp  15.28.6
Selectable.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #include <iostream>
13 //#include "zypp/base/Logger.h"
14 
15 #include "zypp/ui/Selectable.h"
16 #include "zypp/ui/SelectableImpl.h"
17 #include "zypp/ResPool.h"
18 
20 namespace zypp
21 {
22  namespace ui
24  {
25 
26  IMPL_PTR_TYPE(Selectable);
27 
29  { return ResPool::instance().proxy().lookup( ident_r ); }
30 
32  //
33  // METHOD NAME : Selectable::Selectable
34  // METHOD TYPE : Ctor
35  //
37  : _pimpl( pimpl_r )
38  {}
39 
41  //
42  // METHOD NAME : Selectable::~Selectable
43  // METHOD TYPE : Dtor
44  //
46  {}
47 
49  //
50  // Forward to implementation.
51  // Restrict PoolItems to ResObject::constPtr!
52  //
54 
56  { return _pimpl->ident(); }
57 
59  { return _pimpl->kind(); }
60 
61  const std::string & Selectable::name() const
62  { return _pimpl->name(); }
63 
65  { return _pimpl->status(); }
66 
68  { return _pimpl->setStatus( state_r, causer_r ); }
69 
71  { return _pimpl->installedObj(); }
72 
74  { return _pimpl->candidateObj(); }
75 
77  { return _pimpl->candidateObjFrom( repo_r ); }
78 
80  { return _pimpl->updateCandidateObj(); }
81 
83  { return _pimpl->highestAvailableVersionObj(); }
84 
85  bool Selectable::identicalAvailable( const PoolItem & rhs ) const
86  { return _pimpl->identicalAvailable( rhs ); }
87 
88  bool Selectable::identicalInstalled( const PoolItem & rhs ) const
89  { return _pimpl->identicalInstalled( rhs ); }
90 
92  { return _pimpl->identicalAvailableObj( rhs ); }
93 
95  { return _pimpl->identicalInstalledObj( rhs ); }
96 
98  { return _pimpl->setCandidate( newCandidate_r, causer_r ); }
99 
101  { return _pimpl->setCandidate( PoolItem( newCandidate_r ), causer_r ); }
102 
103  bool Selectable::setOnSystem( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r )
104  {
105  if ( identicalInstalled( newCandidate_r ) )
106  return setFate( UNMODIFIED, causer_r );
107  return setCandidate( newCandidate_r, causer_r ) && setFate( TO_INSTALL, causer_r );
108  }
109 
111  { return _pimpl->theObj(); }
112 
114 
116  { return _pimpl->availableEmpty(); }
117 
119  { return _pimpl->availableSize(); }
120 
122  { return _pimpl->availableBegin(); }
123 
125  { return _pimpl->availableEnd(); }
126 
128 
130  { return _pimpl->installedEmpty(); }
131 
133  { return _pimpl->installedSize(); }
134 
136  { return _pimpl->installedBegin(); }
137 
139  { return _pimpl->installedEnd(); }
140 
142 
144  { return _pimpl->picklistEmpty(); }
145 
147  { return _pimpl->picklistSize(); }
148 
150  { return _pimpl->picklistBegin(); }
151 
153  { return _pimpl->picklistEnd(); }
154 
156 
158  { return _pimpl->isUnmaintained(); }
159 
161  { return _pimpl->multiversionInstall(); }
162 
163  bool Selectable::pickInstall( const PoolItem & pi_r, ResStatus::TransactByValue causer_r, bool yesno_r )
164  { return _pimpl->pickInstall( pi_r, causer_r, yesno_r ); }
165 
166  bool Selectable::pickDelete( const PoolItem & pi_r, ResStatus::TransactByValue causer_r, bool yesno_r )
167  { return _pimpl->pickDelete( pi_r, causer_r, yesno_r ); }
168 
169  Status Selectable::pickStatus( const PoolItem & pi_r ) const
170  { return _pimpl->pickStatus( pi_r ); }
171 
172  bool Selectable::setPickStatus( const PoolItem & pi_r, Status state_r, ResStatus::TransactByValue causer_r )
173  { return _pimpl->setPickStatus( pi_r, state_r, causer_r ); }
174 
176 
178  { return _pimpl->isUndetermined(); }
179 
181  { return _pimpl->isRelevant(); }
182 
184  { return _pimpl->isSatisfied(); }
185 
186  bool Selectable::isBroken() const
187  { return _pimpl->isBroken(); }
188 
189  bool Selectable::isNeeded() const
190  {
191  return fate() == TO_INSTALL || ( ! locked() && isBroken() );
192  }
193 
195  {
196  return locked() && isBroken() ;
197  }
198 
200  { return _pimpl->modifiedBy(); }
201 
203  { return _pimpl->hasLicenceConfirmed(); }
204 
206  { _pimpl->setLicenceConfirmed( val_r ); }
207 
208  bool Selectable::hasLocks() const
209  { return _pimpl->hasLocks(); }
210 
212  {
213  switch ( status() ) {
214  case S_Update:
215  case S_Install:
216  case S_AutoUpdate:
217  case S_AutoInstall:
218  return TO_INSTALL;
219  break;
220 
221  case S_Del:
222  case S_AutoDel:
223  return TO_DELETE;
224  break;
225 
226  case S_Protected:
227  case S_Taboo:
228  case S_KeepInstalled:
229  case S_NoInst:
230  break;
231  }
232  return UNMODIFIED;
233  };
234 
236  {
237  switch ( fate_r )
238  {
239  case TO_INSTALL:
240  return setStatus( hasInstalledObj() ? S_Update : S_Install, causer_r );
241  break;
242 
243  case TO_DELETE:
244  return setStatus( S_Del, causer_r );
245  break;
246 
247  case UNMODIFIED:
248  switch ( status() ) {
249  case S_Protected:
250  case S_Taboo:
251  return true;
252  break;
253  default:
254  return setStatus( hasInstalledObj() ? S_KeepInstalled : S_NoInst, causer_r );
255  break;
256  }
257  break;
258  }
259  return false;
260  }
261 
263  {
264  return( hasInstalledObj() || setStatus( S_Install, causer_r ) );
265  }
266 
268  {
269  if ( ! hasInstalledObj() )
270  return setStatus( S_Install, causer_r );
271 
272  PoolItem cand( candidateObj() );
273  if ( ! cand )
274  return true;
275 
276  return( installedObj()->edition() >= cand->edition()
277  || setStatus( S_Update, causer_r ) );
278  }
279 
281  {
282  return( ! hasInstalledObj() || setStatus( S_Del, causer_r ) );
283  }
284 
285  /******************************************************************
286  **
287  ** FUNCTION NAME : operator<<
288  ** FUNCTION TYPE : std::ostream &
289  */
290  std::ostream & operator<<( std::ostream & str, const Selectable & obj )
291  { return str << *(obj._pimpl); }
292 
293  std::ostream & dumpOn( std::ostream & str, const Selectable & obj )
294  { return dumpOn( str, *(obj._pimpl) ); }
295 
297  } // namespace ui
300 } // namespace zypp
available_iterator availableEnd() const
Definition: Selectable.cc:124
PoolItem updateCandidateObj() const
The best candidate for update, if there is one.
Definition: Selectable.cc:79
ui::Selectable::Ptr lookup(const pool::ByIdent &ident_r) const
ResStatus::TransactByValue modifiedBy() const
Return who caused the modification.
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
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
picklist_size_type picklistSize() const
SelectableTraits::installed_iterator installed_iterator
Definition: Selectable.h:64
PoolItem theObj() const
Best among all objects.
bool setStatus(Status state_r, ResStatus::TransactByValue causer_r)
Status pickStatus(const PoolItem &pi_r) const
Status status() const
Return the current Status.
Definition: Selectable.cc:64
bool hasLicenceConfirmed() const
Return value of LicenceConfirmed bit.
PoolItem identicalAvailableObj(const PoolItem &rhs) const
Return an available Object with the same content as rhs.
Definition: Selectable.cc:91
bool multiversionInstall() const
Access to the sat-pools string space.
Definition: IdString.h:41
bool identicalAvailable(const PoolItem &rhs) const
True if rhs is installed and one with the same content is available.
bool hasLicenceConfirmed() const
Return value of LicenceConfirmed bit.
Definition: Selectable.cc:202
Fate fate() const
Definition: Selectable.cc:211
PoolItem candidateObj() const
Best among available objects.
bool hasInstalledObj() const
True if installed object is present.
Definition: Selectable.h:290
TraitsType::constPtrType constPtr
Definition: ResObject.h:44
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
PoolItem setCandidate(const PoolItem &newCandidate_r, ResStatus::TransactByValue causer_r)
Set a userCandidate (out of available objects).
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
PoolItem highestAvailableVersionObj() const
Simply the highest available version, ignoring priorities and policies.
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
bool setInstalled(ResStatus::TransactByValue causer_r=ResStatus::USER)
Take care the item gets installed if it is not.
Definition: Selectable.cc:262
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:431
ResPoolProxy proxy() const
preliminary
Definition: ResPool.cc:54
bool isUndetermined() const
Returns true for packages, because packages are not classified by the solver.
Definition: Selectable.cc:177
PoolItem identicalAvailableObj(const PoolItem &rhs) const
Return an available Object with the same content as rhs.
const std::string & name() const
bool picklistEmpty() const
Definition: Selectable.cc:143
picklist_iterator picklistEnd() const
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 identicalInstalled(const PoolItem &rhs) const
True if rhs has the same content as an installed one.
bool hasLocks() const
True if it includes locked items (don't mix this with the locked status).
std::ostream & operator<<(std::ostream &str, const Selectable &obj)
Definition: Selectable.cc:290
std::ostream & dumpOn(std::ostream &str, const Selectable &obj)
Definition: Selectable.cc:293
IdString ident() const
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
installed_iterator installedBegin() const
Status pickStatus(const PoolItem &pi_r) const
Compute the ui::Status for an individual PoolItem.
Definition: Selectable.cc:169
bool setDeleted(ResStatus::TransactByValue causer_r=ResStatus::USER)
Take care the item gets deleted if it is installed.
Definition: Selectable.cc:280
bool multiversionInstall() const
Whether at least one of the available packages has multiversionInstall set.
Definition: Selectable.cc:160
shared_ptr< Impl > Impl_Ptr
Definition: Selectable.h:516
bool availableEmpty() const
Definition: Selectable.cc:115
SelectableTraits::available_iterator available_iterator
Iterates over ResObject::constPtr.
Definition: Selectable.h:61
PoolItem installedObj() const
Installed object (transacting ot highest version).
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
PoolItem candidateObj() const
The 'best' or 'most interesting' 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 hasLocks() const
True if it includes locked items (don't mix this with the locked status).
Definition: Selectable.cc:208
available_iterator availableBegin() const
available_iterator availableEnd() const
static Ptr get(const pool::ByIdent &ident_r)
Get the Selctable.
Definition: Selectable.cc:28
installed_size_type installedSize() const
IMPL_PTR_TYPE(Selectable)
PoolItem updateCandidateObj() const
The best candidate for update, if there is one.
ResKind kind() const
The ResObjects kind.
Definition: Selectable.cc:58
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
picklist_iterator picklistBegin() const
Selectable(Impl_Ptr pimpl_r)
Default ctor.
Definition: Selectable.cc:36
void setLicenceConfirmed(bool val_r)
Set LicenceConfirmed bit.
bool setUpToDate(ResStatus::TransactByValue causer_r=ResStatus::USER)
Take care the item gets installed if it is not, or is older.
Definition: Selectable.cc:267
installed_iterator installedEnd() const
PoolItem candidateObjFrom(Repository repo_r) const
The best candidate provided by a specific Repository, if there is one.
SelectableTraits::picklist_iterator picklist_iterator
Definition: Selectable.h:67
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:50
bool setFate(Fate fate_r, ResStatus::TransactByValue causer_r=ResStatus::USER)
Definition: Selectable.cc:235
bool setPickStatus(const PoolItem &pi_r, Status state_r, ResStatus::TransactByValue causer_r)
PoolItem identicalInstalledObj(const PoolItem &rhs) const
an installed Object with the same content as rhs.
bool pickInstall(const PoolItem &pi_r, ResStatus::TransactByValue causer_r, bool yesno_r)
picklist_iterator picklistEnd() const
Definition: Selectable.cc:152
Resolvable kinds.
Definition: ResKind.h:32
const std::string & name() const
The ResObjects name.
Definition: Selectable.cc:61
SelectableTraits::picklist_size_type picklist_size_type
Definition: Selectable.h:68
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
available_size_type availableSize() const
SelectableTraits::installed_size_type installed_size_type
Definition: Selectable.h:65
Edition edition() const
Definition: SolvableType.h:71
bool pickDelete(const PoolItem &pi_r, ResStatus::TransactByValue causer_r, bool yesno_r)
Main filter selecting PoolItems by name and kind.
Definition: ByIdent.h:26
RW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: Selectable.h:525
SelectableTraits::available_size_type available_size_type
Definition: Selectable.h:62
installed_iterator installedBegin() const
Definition: Selectable.cc:135
static ResPool instance()
Singleton ctor.
Definition: ResPool.cc:33