libzypp  17.38.7
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-core/ByteCount.h>
19 #include <zypp-core/Date.h>
20 #include <zypp-core/CheckSum.h>
21 
23 #include <zypp/ng/sat/poolmember.h>
24 #include <zypp/ng/sat/solvattr.h>
25 #include <zypp/ng/restraits.h>
26 #include <zypp/ng/idstring.h>
27 #include <zypp/ng/edition.h>
28 #include <zypp/ng/arch.h>
29 #include <zypp/ng/cpeid.h>
30 #include <zypp/ng/dep.h>
32 #include <zypp/ng/sat/capability.h>
33 #include <zypp/ng/reskind.h>
34 #include <zypp/ng/locale.h>
35 
36 
37 
38 namespace zyppng
39 {
41  namespace sat
42  {
43  class Solvable;
44 
45  namespace detail {
46  template<> Pool & poolFromType( Solvable & );
47  template<> const Pool & poolFromType( const Solvable & );
48  }
49 
64  class Solvable : public PoolMember<Solvable>
65  {
66  public:
68 
69  static const IdString patternToken;
70  static const IdString productToken;
71 
72  static const IdString retractedToken;
73  static const IdString ptfMasterToken;
74  static const IdString ptfPackageToken;
75 
76  public:
79  : _id( detail::noSolvableId )
80  {}
81 
82  Solvable(const Solvable &) = default;
83  Solvable(Solvable &&) noexcept = default;
84  Solvable &operator=(const Solvable &) = default;
85  Solvable &operator=(Solvable &&) noexcept = default;
86 
88  explicit Solvable( IdType id_r )
89  : _id( id_r )
90  {}
91 
92  public:
94  static const Solvable noSolvable;
95 
97  explicit operator bool() const
98  { return get(); }
99 
100  public:
105  IdString ident()const;
106 
108  ResKind kind()const;
109 
114  bool isKind( const ResKind & kind_r ) const;
116  template<class TRes>
117  bool isKind() const
118  { return isKind( resKind<TRes>() ); }
120  template<class TIterator>
121  bool isKind( TIterator begin, TIterator end ) const
122  { for_( it, begin, end ) if ( isKind( *it ) ) return true; return false; }
123 
125  std::string name() const;
126 
128  Edition edition() const;
129 
131  Arch arch() const;
132 
134  IdString vendor() const;
135 
138 
142  bool isSystem() const;
143 
145  zypp::Date buildtime() const;
146 
148  zypp::Date installtime() const;
149 
153  bool identical( const Solvable & rhs ) const;
154 
156  bool sameNVRA( const Solvable & rhs ) const
157  { return( get() == rhs.get() || ( ident() == rhs.ident() && edition() == rhs.edition() && arch() == rhs.arch() ) ); }
158 
159  public:
165  Capabilities dep_provides() const;
166  Capabilities dep_requires() const;
167  Capabilities dep_conflicts() const;
168  Capabilities dep_obsoletes() const;
170  Capabilities dep_suggests() const;
171  Capabilities dep_enhances() const;
174 
176  Capabilities dep( Dep which_r ) const
177  {
178  switch( which_r.inSwitch() )
179  {
180  case Dep::PROVIDES_e: return dep_provides(); break;
181  case Dep::REQUIRES_e: return dep_requires(); break;
182  case Dep::CONFLICTS_e: return dep_conflicts(); break;
183  case Dep::OBSOLETES_e: return dep_obsoletes(); break;
184  case Dep::RECOMMENDS_e: return dep_recommends(); break;
185  case Dep::SUGGESTS_e: return dep_suggests(); break;
186  case Dep::ENHANCES_e: return dep_enhances(); break;
187  case Dep::SUPPLEMENTS_e: return dep_supplements(); break;
188  case Dep::PREREQUIRES_e: return dep_prerequires(); break;
189  }
190  return Capabilities();
191  }
193  Capabilities operator[]( Dep which_r ) const
194  { return dep( which_r ); }
195 
196 
198  CapabilitySet providesNamespace( const std::string & namespace_r ) const;
199 
207  CapabilitySet valuesOfNamespace( const std::string & namespace_r ) const;
209 
210  std::pair<bool, CapabilitySet> matchesSolvable ( const SolvAttr &attr, const Solvable &solv ) const;
211 
212  public:
216  bool supportsLocales() const;
218  bool supportsLocale( const Locale & locale_r ) const;
220  bool supportsLocale( const LocaleSet & locales_r ) const;
228 
231 
234 
257 
260 
263 
266 
269 
272 
274 
277 
279 
291 
302 
308 
310 
316 
322 
328 
332 
334 
336 
344 
358 
402 
491 
static const SolvableIdType noSolvableId(0)
Id to denote Solvable::noSolvable.
IdString vendor() const
The vendor.
Definition: solvable.cc:267
A Solvable object within the sat Pool.
Definition: solvable.h:64
bool supportsLocales() const
Whether this Solvable claims to support locales.
Definition: solvable.cc:505
Capabilities dep_supplements() const
Definition: solvable.cc:370
Capabilities dep_conflicts() const
Definition: solvable.cc:345
Pool & poolFromType(T &)
Enumeration class of dependency types.
Definition: Dep.h:30
Arch arch() const
The architecture.
Definition: solvable.cc:253
static const IdString ptfPackageToken
Indicator provides ptf-package()
Definition: solvable.h:74
Architecture.
Definition: Arch.h:36
Capabilities dep(Dep which_r) const
Return Capabilities selected by Dep constant.
Definition: solvable.h:176
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:29
Capabilities dep_enhances() const
Definition: solvable.cc:365
sat::SolvAttr attr
Definition: PoolQuery.cc:312
Capabilities dep_obsoletes() const
Definition: solvable.cc:350
Access to the sat-pools string space.
Definition: IdString.h:51
std::string name() const
The name (without any ResKind prefix).
Definition: solvable.cc:239
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:27
Edition represents [epoch:]version[-release]
Definition: Edition.h:59
static const IdString patternToken
Indicator provides pattern()
Definition: solvable.h:69
CapabilitySet providesNamespace(const std::string &namespace_r) const
Return the namespaced provides &#39;namespace([value])[ op edition]&#39; of this Solvable.
Definition: solvable.cc:384
ResKind kind() const
The Solvables ResKind.
Definition: solvable.cc:185
zypp::sat::detail::SolvableIdType SolvableIdType
Definition: poolconstants.h:44
bool identical(const Solvable &rhs) const
Test whether two Solvables have the same content.
Definition: solvable.cc:318
Store and operate on date (time_t).
Definition: Date.h:32
bool isKind(TIterator begin, TIterator end) const
Definition: solvable.h:121
for_use_in_switch inSwitch() const
Enumarator provided for use in switch statement.
Definition: Dep.h:90
Capabilities operator[](Dep which_r) const
Definition: solvable.h:193
zypp::Date buildtime() const
The items build time.
Definition: solvable.cc:285
bool isSystem() const
Return whether this Solvable belongs to the system repo.
Definition: solvable.cc:279
Capabilities dep_prerequires() const
Definition: solvable.cc:375
Container of Capability (currently read only).
Definition: capabilities.h:32
detail::CSolvable * get() const
Expert backdoor.
Definition: solvable.cc:77
Edition edition() const
The edition (version-release).
Definition: solvable.cc:247
Solvable()
Default ctor creates noSolvable.
Definition: solvable.h:78
std::pair< bool, CapabilitySet > matchesSolvable(const SolvAttr &attr, const Solvable &solv) const
Definition: solvable.cc:418
Capabilities dep_provides() const
Definition: solvable.cc:335
bool sameNVRA(const Solvable &rhs) const
Test for same name-version-release.arch.
Definition: solvable.h:156
std::unordered_set< Capability > CapabilitySet
Definition: capability.h:35
&#39;Language[_Country]&#39; codes.
Definition: Locale.h:50
static const IdString retractedToken
Indicator provides retracted-patch-package()
Definition: solvable.h:72
CapabilitySet valuesOfNamespace(const std::string &namespace_r) const
Return &#39;value[ op edition]&#39; for namespaced provides &#39;namespace(value)[ op edition]&#39;.
Definition: solvable.cc:400
Capabilities dep_recommends() const
Definition: solvable.cc:355
detail::RepoIdType repository() const
The repo id this Solvable belongs to.
Definition: solvable.cc:273
LocaleSet getSupportedLocales() const
Return the supported locales.
Definition: solvable.cc:525
bool isKind() const
Definition: solvable.h:117
static const Solvable noSolvable
Represents no Solvable.
Definition: solvable.h:94
zypp::Date installtime() const
The items install time (false if not installed).
Definition: solvable.cc:291
detail::SolvableIdType IdType
Definition: solvable.h:67
Capabilities dep_requires() const
Definition: solvable.cc:340
IdString ident() const
The identifier.
Definition: solvable.cc:179
static const IdString ptfMasterToken
Indicator provides ptf()
Definition: solvable.h:73
Capabilities dep_suggests() const
Definition: solvable.cc:360
static const IdString productToken
Indicator provides product()
Definition: solvable.h:70
Resolvable kinds.
Definition: ResKind.h:32
bool supportsLocale(const Locale &locale_r) const
Whether this Solvable supports a specific Locale.
Definition: solvable.cc:511
zypp::sat::detail::RepoIdType RepoIdType
Definition: poolconstants.h:45