libzypp  17.14.0
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 
23  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 
86  { return _pimpl->identIsAutoInstalled(); }
87 
88  bool Selectable::identicalAvailable( const PoolItem & rhs ) const
89  { return _pimpl->identicalAvailable( rhs ); }
90 
91  bool Selectable::identicalInstalled( const PoolItem & rhs ) const
92  { return _pimpl->identicalInstalled( rhs ); }
93 
95  { return _pimpl->identicalAvailableObj( rhs ); }
96 
98  { return _pimpl->identicalInstalledObj( rhs ); }
99 
101  { return _pimpl->setCandidate( newCandidate_r, causer_r ); }
102 
104  { return _pimpl->setCandidate( PoolItem( newCandidate_r ), causer_r ); }
105 
106  bool Selectable::setOnSystem( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r )
107  {
108  if ( identicalInstalled( newCandidate_r ) )
109  return setFate( UNMODIFIED, causer_r );
110  return setCandidate( newCandidate_r, causer_r ) && setFate( TO_INSTALL, causer_r );
111  }
112 
114  { return _pimpl->theObj(); }
115 
117 
119  { return _pimpl->availableEmpty(); }
120 
122  { return _pimpl->availableSize(); }
123 
125  { return _pimpl->availableBegin(); }
126 
128  { return _pimpl->availableEnd(); }
129 
131 
133  { return _pimpl->installedEmpty(); }
134 
136  { return _pimpl->installedSize(); }
137 
139  { return _pimpl->installedBegin(); }
140 
142  { return _pimpl->installedEnd(); }
143 
145 
147  { return _pimpl->picklistEmpty(); }
148 
150  { return _pimpl->picklistSize(); }
151 
153  { return _pimpl->picklistBegin(); }
154 
156  { return _pimpl->picklistEnd(); }
157 
159  { return picklistPos( pi_r.satSolvable() ); }
160 
162  {
164  for ( const auto & pi : picklist() )
165  {
166  if ( pi == solv_r )
167  return idx;
168  ++idx;
169  }
170  return picklistNoPos;
171  }
172 
174 
176  { return _pimpl->isUnmaintained(); }
177 
179  { return _pimpl->multiversionInstall(); }
180 
181  bool Selectable::pickInstall( const PoolItem & pi_r, ResStatus::TransactByValue causer_r, bool yesno_r )
182  { return _pimpl->pickInstall( pi_r, causer_r, yesno_r ); }
183 
184  bool Selectable::pickDelete( const PoolItem & pi_r, ResStatus::TransactByValue causer_r, bool yesno_r )
185  { return _pimpl->pickDelete( pi_r, causer_r, yesno_r ); }
186 
187  Status Selectable::pickStatus( const PoolItem & pi_r ) const
188  { return _pimpl->pickStatus( pi_r ); }
189 
190  bool Selectable::setPickStatus( const PoolItem & pi_r, Status state_r, ResStatus::TransactByValue causer_r )
191  { return _pimpl->setPickStatus( pi_r, state_r, causer_r ); }
192 
194 
196  { return _pimpl->isUndetermined(); }
197 
199  { return _pimpl->isRelevant(); }
200 
202  { return _pimpl->isSatisfied(); }
203 
204  bool Selectable::isBroken() const
205  { return _pimpl->isBroken(); }
206 
207  bool Selectable::isNeeded() const
208  {
209  return fate() == TO_INSTALL || ( ! locked() && isBroken() );
210  }
211 
213  {
214  return locked() && isBroken() ;
215  }
216 
218  { return _pimpl->modifiedBy(); }
219 
221  { return _pimpl->hasLicenceConfirmed(); }
222 
224  { _pimpl->setLicenceConfirmed( val_r ); }
225 
226  bool Selectable::hasLocks() const
227  { return _pimpl->hasLocks(); }
228 
230  {
231  switch ( status() ) {
232  case S_Update:
233  case S_Install:
234  case S_AutoUpdate:
235  case S_AutoInstall:
236  return TO_INSTALL;
237  break;
238 
239  case S_Del:
240  case S_AutoDel:
241  return TO_DELETE;
242  break;
243 
244  case S_Protected:
245  case S_Taboo:
246  case S_KeepInstalled:
247  case S_NoInst:
248  break;
249  }
250  return UNMODIFIED;
251  };
252 
254  {
255  switch ( fate_r )
256  {
257  case TO_INSTALL:
258  return setStatus( hasInstalledObj() ? S_Update : S_Install, causer_r );
259  break;
260 
261  case TO_DELETE:
262  return setStatus( S_Del, causer_r );
263  break;
264 
265  case UNMODIFIED:
266  switch ( status() ) {
267  case S_Protected:
268  case S_Taboo:
269  return true;
270  break;
271  default:
272  return setStatus( hasInstalledObj() ? S_KeepInstalled : S_NoInst, causer_r );
273  break;
274  }
275  break;
276  }
277  return false;
278  }
279 
281  {
282  return( hasInstalledObj() || setStatus( S_Install, causer_r ) );
283  }
284 
286  {
287  if ( ! hasInstalledObj() )
288  return setStatus( S_Install, causer_r );
289 
290  PoolItem cand( candidateObj() );
291  if ( ! cand )
292  return true;
293 
294  return( installedObj()->edition() >= cand->edition()
295  || setStatus( S_Update, causer_r ) );
296  }
297 
299  {
300  return( ! hasInstalledObj() || setStatus( S_Del, causer_r ) );
301  }
302 
303  /******************************************************************
304  **
305  ** FUNCTION NAME : operator<<
306  ** FUNCTION TYPE : std::ostream &
307  */
308  std::ostream & operator<<( std::ostream & str, const Selectable & obj )
309  { return str << *(obj._pimpl); }
310 
311  std::ostream & dumpOn( std::ostream & str, const Selectable & obj )
312  { return dumpOn( str, *(obj._pimpl) ); }
313 
315  } // namespace ui
318 } // namespace zypp