libzypp  11.13.5
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 
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 
210  {
211  switch ( status() ) {
212  case S_Update:
213  case S_Install:
214  case S_AutoUpdate:
215  case S_AutoInstall:
216  return TO_INSTALL;
217  break;
218 
219  case S_Del:
220  case S_AutoDel:
221  return TO_DELETE;
222  break;
223 
224  case S_Protected:
225  case S_Taboo:
226  case S_KeepInstalled:
227  case S_NoInst:
228  break;
229  }
230  return UNMODIFIED;
231  };
232 
234  {
235  switch ( fate_r )
236  {
237  case TO_INSTALL:
238  return setStatus( hasInstalledObj() ? S_Update : S_Install, causer_r );
239  break;
240 
241  case TO_DELETE:
242  return setStatus( S_Del, causer_r );
243  break;
244 
245  case UNMODIFIED:
246  switch ( status() ) {
247  case S_Protected:
248  case S_Taboo:
249  return true;
250  break;
251  default:
252  return setStatus( hasInstalledObj() ? S_KeepInstalled : S_NoInst, causer_r );
253  break;
254  }
255  break;
256  }
257  return false;
258  }
259 
261  {
262  return( hasInstalledObj() || setStatus( S_Install, causer_r ) );
263  }
264 
266  {
267  if ( ! hasInstalledObj() )
268  return setStatus( S_Install, causer_r );
269 
270  PoolItem cand( candidateObj() );
271  if ( ! cand )
272  return true;
273 
274  return( installedObj()->edition() >= cand->edition()
275  || setStatus( S_Update, causer_r ) );
276  }
277 
279  {
280  return( ! hasInstalledObj() || setStatus( S_Del, causer_r ) );
281  }
282 
283  /******************************************************************
284  **
285  ** FUNCTION NAME : operator<<
286  ** FUNCTION TYPE : std::ostream &
287  */
288  std::ostream & operator<<( std::ostream & str, const Selectable & obj )
289  { return str << *(obj._pimpl); }
290 
291  std::ostream & dumpOn( std::ostream & str, const Selectable & obj )
292  { return dumpOn( str, *(obj._pimpl) ); }
293 
295  } // namespace ui
298 } // namespace zypp