libzypp  15.28.6
Solvable.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_SAT_SOLVABLE_H
13 #define ZYPP_SAT_SOLVABLE_H
14 
15 #include <iosfwd>
16 
18 #include "zypp/sat/SolvAttr.h"
19 #include "zypp/ResTraits.h"
20 #include "zypp/IdString.h"
21 #include "zypp/Edition.h"
22 #include "zypp/Arch.h"
23 #include "zypp/Dep.h"
24 #include "zypp/Capabilities.h"
25 #include "zypp/Capability.h"
26 #include "zypp/Locale.h"
27 
29 namespace zypp
30 {
31  class ByteCount;
32  class CheckSum;
33  class CpeId;
34  class Date;
35  class OnMediaLocation;
37  namespace sat
38  {
53  class Solvable : protected detail::PoolMember
54  {
55  public:
57 
58  public:
61  : _id( detail::noSolvableId )
62  {}
63 
65  explicit Solvable( IdType id_r )
66  : _id( id_r )
67  {}
68 
69  public:
71  static const Solvable noSolvable;
72 
74  explicit operator bool() const
75  { return get(); }
76 
77  public:
82  IdString ident()const;
83 
85  ResKind kind()const;
86 
91  bool isKind( const ResKind & kind_r ) const;
93  template<class TRes>
94  bool isKind() const
95  { return isKind( resKind<TRes>() ); }
97  template<class TIterator>
98  bool isKind( TIterator begin, TIterator end ) const
99  { for_( it, begin, end ) if ( isKind( *it ) ) return true; return false; }
100 
102  std::string name() const;
103 
105  Edition edition() const;
106 
108  Arch arch() const;
109 
111  IdString vendor() const;
112 
114  Repository repository() const;
116  RepoInfo repoInfo() const;
117 
121  bool isSystem() const;
122 
128  bool onSystemByUser() const;
129 
133  bool multiversionInstall() const;
134 
136  Date buildtime() const;
137 
139  Date installtime() const;
140 
141  public:
149  std::string asString() const;
150 
152  std::string asUserString() const;
153 
157  bool identical( const Solvable & rhs ) const;
158 
160  bool sameNVRA( const Solvable & rhs ) const
161  { return( get() == rhs.get() || ( ident() == rhs.ident() && edition() == rhs.edition() && arch() == rhs.arch() ) ); }
162 
163  public:
169  Capabilities provides() const;
170  Capabilities requires() const;
171  Capabilities conflicts() const;
172  Capabilities obsoletes() const;
173  Capabilities recommends() const;
174  Capabilities suggests() const;
175  Capabilities enhances() const;
176  Capabilities supplements() const;
177  Capabilities prerequires() const;
178 
180  Capabilities dep( Dep which_r ) const
181  {
182  switch( which_r.inSwitch() )
183  {
184  case Dep::PROVIDES_e: return provides(); break;
185  case Dep::REQUIRES_e: return requires(); break;
186  case Dep::CONFLICTS_e: return conflicts(); break;
187  case Dep::OBSOLETES_e: return obsoletes(); break;
188  case Dep::RECOMMENDS_e: return recommends(); break;
189  case Dep::SUGGESTS_e: return suggests(); break;
190  case Dep::ENHANCES_e: return enhances(); break;
191  case Dep::SUPPLEMENTS_e: return supplements(); break;
192  case Dep::PREREQUIRES_e: return prerequires(); break;
193  }
194  return Capabilities();
195  }
197  Capabilities operator[]( Dep which_r ) const
198  { return dep( which_r ); }
199 
200 
202  CapabilitySet providesNamespace( const std::string & namespace_r ) const;
203 
211  CapabilitySet valuesOfNamespace( const std::string & namespace_r ) const;
213 
214  public:
218  bool supportsLocales() const;
220  bool supportsLocale( const Locale & locale_r ) const;
222  bool supportsLocale( const LocaleSet & locales_r ) const;
226  bool supportsRequestedLocales() const;
230  void getSupportedLocales( LocaleSet & locales_r ) const
231  { locales_r = getSupportedLocales(); }
233 
234  public:
236  CpeId cpeId() const;
237 
239  unsigned mediaNr() const;
240 
262  ByteCount installSize() const;
263 
265  ByteCount downloadSize() const;
266 
268  std::string distribution() const;
269 
271  std::string summary( const Locale & lang_r = Locale() ) const;
272 
274  std::string description( const Locale & lang_r = Locale() ) const;
275 
277  std::string insnotify( const Locale & lang_r = Locale() ) const;
279  std::string delnotify( const Locale & lang_r = Locale() ) const;
280 
282  std::string licenseToConfirm( const Locale & lang_r = Locale() ) const;
284  bool needToAcceptLicense() const;
285 
286  public:
293  {
294  public:
296  SplitIdent( IdString ident_r );
297  SplitIdent( const char * ident_r );
298  SplitIdent( const std::string & ident_r );
299  SplitIdent( ResKind kind_r, IdString name_r );
300  SplitIdent( ResKind kind_r, const C_Str & name_r );
301 
302  IdString ident() const { return _ident; }
303  ResKind kind() const { return _kind; }
304  IdString name() const { return _name; }
305 
306  private:
310  };
311 
312  public:
322  std::string lookupStrAttribute( const SolvAttr & attr ) const;
333  std::string lookupStrAttribute( const SolvAttr & attr, const Locale & lang_r ) const;
334 
339  unsigned long long lookupNumAttribute( const SolvAttr & attr ) const;
340 
345  bool lookupBoolAttribute( const SolvAttr & attr ) const;
346 
352 
358 
365 
366  public:
368  Solvable nextInPool() const;
370  Solvable nextInRepo() const;
372  detail::CSolvable * get() const;
374  IdType id() const { return _id; }
375 
376  private:
378  };
380 
382  std::ostream & operator<<( std::ostream & str, const Solvable & obj );
383 
385  std::ostream & dumpOn( std::ostream & str, const Solvable & obj );
386 
388  std::ostream & dumpAsXmlOn( std::ostream & str, const Solvable & obj );
389 
391  inline bool operator==( const Solvable & lhs, const Solvable & rhs )
392  { return lhs.get() == rhs.get(); }
393 
395  inline bool operator!=( const Solvable & lhs, const Solvable & rhs )
396  { return lhs.get() != rhs.get(); }
397 
399  inline bool operator<( const Solvable & lhs, const Solvable & rhs )
400  { return lhs.get() < rhs.get(); }
401 
403  template<class TRes>
404  inline bool isKind( const Solvable & solvable_r )
405  { return solvable_r.isKind( ResTraits<TRes>::kind ); }
406 
408  inline bool identical( const Solvable & lhs, const Solvable & rhs )
409  { return lhs.identical( rhs ); }
410 
412  inline bool sameNVRA( const Solvable & lhs, const Solvable & rhs )
413  { return lhs.sameNVRA( rhs ); }
414 
415 
417  inline int compareByN( const Solvable & lhs, const Solvable & rhs )
418  {
419  int res = 0;
420  if ( lhs != rhs )
421  {
422  if ( (res = lhs.kind().compare( rhs.kind() )) == 0 )
423  res = lhs.name().compare( rhs.name() );
424  }
425  return res;
426  }
427 
429  inline int compareByNVR( const Solvable & lhs, const Solvable & rhs )
430  {
431  int res = compareByN( lhs, rhs );
432  if ( res == 0 )
433  res = lhs.edition().compare( rhs.edition() );
434  return res;
435  }
436 
438  inline int compareByNVRA( const Solvable & lhs, const Solvable & rhs )
439  {
440  int res = compareByNVR( lhs, rhs );
441  if ( res == 0 )
442  res = lhs.arch().compare( rhs.arch() );
443  return res;
444  }
445 
447  namespace detail
448  {
450  //
451  // CLASS NAME : SolvableIterator
452  //
454  class SolvableIterator : public boost::iterator_adaptor<
455  SolvableIterator // Derived
456  , CSolvable* // Base
457  , const Solvable // Value
458  , boost::forward_traversal_tag // CategoryOrTraversal
459  , const Solvable // Reference
460  >
461  {
462  public:
464  : SolvableIterator::iterator_adaptor_( 0 )
465  {}
466 
467  explicit SolvableIterator( const Solvable & val_r )
468  : SolvableIterator::iterator_adaptor_( 0 )
469  { assignVal( val_r ); }
470 
472  : SolvableIterator::iterator_adaptor_( 0 )
473  { assignVal( Solvable( id_r ) ); }
474 
475  private:
477 
479  { return _val; }
480 
481  void increment()
482  { assignVal( _val.nextInPool() ); }
483 
484  private:
485  void assignVal( const Solvable & val_r )
486  { _val = val_r; base_reference() = _val.get(); }
487 
489  };
490  } // namespace detail
492  } // namespace sat
494 
495  class PoolItem;
497  namespace sat
498  {
503  struct asSolvable
504  {
506 
507  Solvable operator()( const Solvable & solv_r ) const
508  { return solv_r; }
509 
510  Solvable operator()( const PoolItem & pi_r ) const;
511 
512  Solvable operator()( const ResObject_constPtr & res_r ) const;
513  };
514  } // namespace sat
516 } // namespace zypp
518 
520 
521 #endif // ZYPP_SAT_SOLVABLE_H
static const SolvableIdType noSolvableId(0)
Id to denote Solvable::noSolvable.
Repository repository() const
The Repository this Solvable belongs to.
Definition: Solvable.cc:351
bool needToAcceptLicense() const
True except for well known exceptions (i.e show license but no need to accept it).
Definition: Solvable.cc:681
int IdType
Generic Id type.
Definition: PoolMember.h:130
A Solvable object within the sat Pool.
Definition: Solvable.h:53
Arch arch() const
The architecture.
Definition: Solvable.cc:331
Capabilities recommends() const
Definition: Solvable.cc:446
detail::CSolvable * get() const
Expert backdoor.
Definition: Solvable.cc:102
CapabilitySet providesNamespace(const std::string &namespace_r) const
Return the namespaced provides 'namespace([value])[ op edition]' of this Solvable.
Definition: Solvable.cc:475
Container of Capability (currently read only).
Definition: Capabilities.h:35
Date buildtime() const
The items build time.
Definition: Solvable.cc:378
IdString ident() const
The identifier.
Definition: Solvable.cc:257
Describes a path on a certain media amongs as the information required to download it...
SolvableIterator(const Solvable &val_r)
Definition: Solvable.h:467
Enumeration class of dependency types.
Definition: Dep.h:29
bool isKind(const Solvable &solvable_r)
Definition: Solvable.h:404
Architecture.
Definition: Arch.h:36
bool supportsLocale(const Locale &locale_r) const
Whether this Solvable supports a specific Locale.
Definition: Solvable.cc:590
Store and operate with byte count.
Definition: ByteCount.h:30
sat::SolvAttr attr
Definition: PoolQuery.cc:314
std::ostream & operator<<(std::ostream &str, const FileConflicts &obj)
bool operator==(const Solvable &lhs, const Solvable &rhs)
Definition: Solvable.h:391
bool supportsLocales() const
Whether this Solvable claims to support locales.
Definition: Solvable.cc:584
Capabilities supplements() const
Definition: Solvable.cc:461
std::string lookupStrAttribute(const SolvAttr &attr) const
returns the string attribute value for attr or an empty string if it does not exists.
Definition: Solvable.cc:126
ZYPP_DEFINE_ID_HASHABLE(::zypp::sat::Solvable)
std::string asString() const
String representation "ident-edition.arch" or "noSolvable".
Definition: Solvable.cc:390
bool isSystem() const
Return whether this Solvable belongs to the system repo.
Definition: Solvable.cc:361
bool isKind() const
Definition: Solvable.h:94
unsigned SolvableIdType
Id type to connect Solvable and sat-solvable.
Definition: PoolMember.h:151
bool isKind(TIterator begin, TIterator end) const
Definition: Solvable.h:98
Capabilities suggests() const
Definition: Solvable.cc:451
ByteCount downloadSize() const
Download size.
Definition: Solvable.cc:632
Solvable operator()(const Solvable &solv_r) const
Definition: Solvable.h:507
What is known about a repository.
Definition: RepoInfo.h:72
std::string insnotify(const Locale &lang_r=Locale()) const
UI hint text when selecting the solvable for install (opt.
Definition: Solvable.cc:656
Access to the sat-pools string space.
Definition: IdString.h:41
Common Platform Enumearation (2.3) See http://cpe.mitre.org/ for more information on the Common Platf...
Definition: CpeId.h:31
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:27
Edition represents [epoch:]version[-release]
Definition: Edition.h:60
::_Solvable CSolvable
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:89
ResTraits.
Definition: ResTraits.h:79
CapabilitySet valuesOfNamespace(const std::string &namespace_r) const
Return 'value[ op edition]' for namespaced provides 'namespace(value)[ op edition]'.
Definition: Solvable.cc:489
bool compareByN(const SolvableType< Derived > &lhs, const Solvable &rhs)
Definition: SolvableType.h:238
std::string asUserString() const
String representation "ident-edition.arch(repo)" or "noSolvable".
Definition: Solvable.cc:399
std::string licenseToConfirm(const Locale &lang_r=Locale()) const
License or agreement to accept before installing the solvable (opt.
Definition: Solvable.cc:668
Capabilities provides() const
Definition: Solvable.cc:426
static const Solvable noSolvable
Represents no Solvable.
Definition: Solvable.h:71
detail::IdType lookupIdAttribute(const SolvAttr &attr) const
returns the id attribute value for attr or detail::noId if it does not exists.
Definition: Solvable.cc:164
int compareByNVRA(const Solvable &lhs, const Solvable &rhs)
Definition: Solvable.h:438
bool identical(const Solvable &lhs, const Solvable &rhs)
Definition: Solvable.h:408
int compare(const Arch &rhs) const
Arch comparison.
Definition: Arch.cc:532
bool sameNVRA(const Solvable &lhs, const Solvable &rhs)
Definition: Solvable.h:412
static int compare(const Derived &lhs, const Derived &rhs)
Definition: IdStringType.h:127
std::string name() const
The name (without any ResKind prefix).
Definition: Solvable.cc:317
Store and operate on date (time_t).
Definition: Date.h:32
Solvable attribute keys.
Definition: SolvAttr.h:40
RepoInfo repoInfo() const
The repositories RepoInfo.
Definition: Solvable.cc:357
Backlink to the associated PoolImpl.
Definition: PoolMember.h:114
OnMediaLocation lookupLocation() const
returns OnMediaLocation data: This is everything we need to download e.g.
Definition: Solvable.cc:212
CheckSum lookupCheckSumAttribute(const SolvAttr &attr) const
returns the CheckSum attribute value for attr or an empty CheckSum if ir does not exist...
Definition: Solvable.cc:170
bool sameNVRA(const Solvable &rhs) const
Test for same name-version-release.arch.
Definition: Solvable.h:160
unsigned mediaNr() const
Media number the solvable is located on (0 if no media access required).
Definition: Solvable.cc:620
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string...
Definition: String.h:90
std::string description(const Locale &lang_r=Locale()) const
Long (multiline) text describing the solvable (opt.
Definition: Solvable.cc:650
IdString ident() const
Definition: Solvable.h:302
bool supportsRequestedLocales() const
Whether this Solvable supports at least one requested locale.
Definition: Solvable.cc:604
bool lookupBoolAttribute(const SolvAttr &attr) const
returns the boolean attribute value for attr or false if it does not exists.
Definition: Solvable.cc:158
int compareByNVR(const Solvable &lhs, const Solvable &rhs)
Definition: Solvable.h:429
bool onSystemByUser() const
Whether this is known to be installed on behalf of a user request.
Definition: Solvable.cc:367
unsigned long long lookupNumAttribute(const SolvAttr &attr) const
returns the numeric attribute value for attr or 0 if it does not exists.
Definition: Solvable.cc:152
LocaleSet getSupportedLocales() const
Return the supported locales.
Definition: Solvable.cc:607
Date installtime() const
The items install time (false if not installed).
Definition: Solvable.cc:384
bool identical(const Solvable &rhs) const
Test whether two Solvables have the same content.
Definition: Solvable.cc:409
Solvable(IdType id_r)
PoolImpl ctor.
Definition: Solvable.h:65
Capabilities dep(Dep which_r) const
Return Capabilities selected by Dep constant.
Definition: Solvable.h:180
void assignVal(const Solvable &val_r)
Definition: Solvable.h:485
std::ostream & dumpOn(std::ostream &str, const LocaleSupport &obj)
Solvable nextInRepo() const
Return next Solvable in Repo (or noSolvable).
Definition: Solvable.cc:112
Capabilities enhances() const
Definition: Solvable.cc:456
'Language[_Country]' codes.
Definition: Locale.h:49
friend class boost::iterator_core_access
Definition: Solvable.h:476
bool compareByNVR(const SolvableType< Derived > &lhs, const Solvable &rhs)
Definition: SolvableType.h:252
std::unordered_set< Capability > CapabilitySet
Definition: Capability.h:33
IdString vendor() const
The vendor.
Definition: Solvable.cc:345
ResKind kind() const
The Solvables ResKind.
Definition: Solvable.cc:263
Solvable nextInPool() const
Return next Solvable in Pool (or noSolvable).
Definition: Solvable.cc:109
Solvable()
Default ctor creates noSolvable.
Definition: Solvable.h:60
void getSupportedLocales(LocaleSet &locales_r) const
Definition: Solvable.h:230
Capabilities conflicts() const
Definition: Solvable.cc:436
bool multiversionInstall() const
Whether different versions of this package can be installed at the same time.
Definition: Solvable.cc:372
SolvableIterator(SolvableIdType id_r)
Definition: Solvable.h:471
Capabilities prerequires() const
Definition: Solvable.cc:466
std::string summary(const Locale &lang_r=Locale()) const
Short (singleline) text describing the solvable (opt.
Definition: Solvable.cc:644
std::string delnotify(const Locale &lang_r=Locale()) const
UI hint text when selecting the solvable for uninstall (opt.
Definition: Solvable.cc:662
Helper that splits an identifier into kind and name or vice versa.
Definition: Solvable.h:292
Solvable result_type
Definition: Solvable.h:505
ByteCount installSize() const
Installed (unpacked) size.
Definition: Solvable.cc:626
int compareByN(const Solvable &lhs, const Solvable &rhs)
Definition: Solvable.h:417
Capabilities operator[](Dep which_r) const
Definition: Solvable.h:197
Capabilities requires() const
Definition: Solvable.cc:431
bool operator<(const Solvable &lhs, const Solvable &rhs)
Definition: Solvable.h:399
for_use_in_switch inSwitch() const
Enumarator provided for use in switch statement.
Definition: Dep.h:89
CpeId cpeId() const
The solvables CpeId if available.
Definition: Solvable.cc:614
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:50
IdType id() const
Expert backdoor.
Definition: Solvable.h:374
std::ostream & dumpAsXmlOn(std::ostream &str, const FileConflicts &obj)
bool isKind(const ResKind &kind_r) const
Test whether a Solvable is of a certain ResKind.
Definition: Solvable.cc:290
sat::detail::SolvableIdType IdType
Definition: Solvable.h:56
Resolvable kinds.
Definition: ResKind.h:32
To Solvable transform functor.
Definition: Solvable.h:503
IdString name() const
Definition: Solvable.h:304
std::string distribution() const
The distribution string.
Definition: Solvable.cc:638
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:27
Edition edition() const
The edition (version-release).
Definition: Solvable.cc:325
Capabilities obsoletes() const
Definition: Solvable.cc:441
bool operator!=(const Solvable &lhs, const Solvable &rhs)
Definition: Solvable.h:395