libzypp  17.38.8
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 
19 #include <zypp-core/ByteCount.h>
20 #include <zypp-core/Date.h>
21 #include <zypp-core/CheckSum.h>
22 
24 #include <zypp/ng/sat/poolmember.h>
25 #include <zypp/ng/sat/solvattr.h>
26 #include <zypp/ng/restraits.h>
27 #include <zypp/ng/idstring.h>
28 #include <zypp/ng/edition.h>
29 #include <zypp/ng/arch.h>
30 #include <zypp/ng/cpeid.h>
31 #include <zypp/ng/dep.h>
33 #include <zypp/ng/sat/capability.h>
34 #include <zypp/ng/reskind.h>
35 #include <zypp/ng/locale.h>
36 
37 
38 
39 namespace zyppng
40 {
42  namespace sat
43  {
44  class Solvable;
45 
46  namespace detail {
47  template<> Pool & poolFromType( Solvable & );
48  template<> const Pool & poolFromType( const Solvable & );
49  }
50 
65  class Solvable : public PoolMember<Solvable>
66  {
67  public:
69 
70  static const IdString patternToken;
71  static const IdString productToken;
72 
73  static const IdString retractedToken;
74  static const IdString ptfMasterToken;
75  static const IdString ptfPackageToken;
76 
77  public:
80  : _id( detail::noSolvableId )
81  {}
82 
83  Solvable(const Solvable &) = default;
84  Solvable(Solvable &&) noexcept = default;
85  Solvable &operator=(const Solvable &) = default;
86  Solvable &operator=(Solvable &&) noexcept = default;
87 
89  explicit Solvable( IdType id_r )
90  : _id( id_r )
91  {}
92 
93  public:
95  static const Solvable noSolvable;
96 
98  explicit operator bool() const
99  { return get(); }
100 
101  public:
106  IdString ident()const;
107 
109  ResKind kind()const;
110 
115  bool isKind( const ResKind & kind_r ) const;
117  template<class TRes>
118  bool isKind() const
119  { return isKind( resKind<TRes>() ); }
121  template<class TIterator>
122  bool isKind( TIterator begin, TIterator end ) const
123  { return ranges::any_of( begin, end, [this]( const ResKind & k ){ return isKind(k); } ); }
125  bool isKind( std::initializer_list<ResKind> range ) const
126  { return isKind( range.begin(), range.end() ); }
127 
129  std::string name() const;
130 
132  Edition edition() const;
133 
135  Arch arch() const;
136 
138  IdString vendor() const;
139 
142 
146  bool isSystem() const;
147 
149  zypp::Date buildtime() const;
150 
152  zypp::Date installtime() 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 dep_provides() const;
170  Capabilities dep_requires() const;
171  Capabilities dep_conflicts() const;
172  Capabilities dep_obsoletes() const;
174  Capabilities dep_suggests() const;
175  Capabilities dep_enhances() const;
178 
180  Capabilities dep( Dep which_r ) const
181  {
182  switch( which_r.inSwitch() )
183  {
184  case Dep::PROVIDES_e: return dep_provides(); break;
185  case Dep::REQUIRES_e: return dep_requires(); break;
186  case Dep::CONFLICTS_e: return dep_conflicts(); break;
187  case Dep::OBSOLETES_e: return dep_obsoletes(); break;
188  case Dep::RECOMMENDS_e: return dep_recommends(); break;
189  case Dep::SUGGESTS_e: return dep_suggests(); break;
190  case Dep::ENHANCES_e: return dep_enhances(); break;
191  case Dep::SUPPLEMENTS_e: return dep_supplements(); break;
192  case Dep::PREREQUIRES_e: return dep_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  std::pair<bool, CapabilitySet> matchesSolvable ( const SolvAttr &attr, const Solvable &solv ) const;
215 
216  public:
220  bool supportsLocales() const;
222  bool supportsLocale( const Locale & locale_r ) const;
224  bool supportsLocale( const LocaleSet & locales_r ) const;
232 
235 
238 
261 
264 
267 
270 
273 
276 
278 
281 
283 
295 
306 
312 
314 
320 
326 
332 
336 
338 
340 
348 
362 
406 
495 
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:65
bool supportsLocales() const
Whether this Solvable claims to support locales.
Definition: solvable.cc:508
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:75
Architecture.
Definition: Arch.h:36
Capabilities dep(Dep which_r) const
Return Capabilities selected by Dep constant.
Definition: solvable.h:180
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
Edition represents [epoch:]version[-release]
Definition: Edition.h:59
static const IdString patternToken
Indicator provides pattern()
Definition: solvable.h:70
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:122
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:197
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:79
std::pair< bool, CapabilitySet > matchesSolvable(const SolvAttr &attr, const Solvable &solv) const
Definition: solvable.cc:421
Capabilities dep_provides() const
Definition: solvable.cc:335
bool sameNVRA(const Solvable &rhs) const
Test for same name-version-release.arch.
Definition: solvable.h:160
bool isKind(std::initializer_list< ResKind > range) const
Definition: solvable.h:125
std::unordered_set< Capability > CapabilitySet
Definition: capability.h:35
Namespace routing for C++20 ranges and C++23 ranges::to<T>() backport.
&#39;Language[_Country]&#39; codes.
Definition: Locale.h:50
static const IdString retractedToken
Indicator provides retracted-patch-package()
Definition: solvable.h:73
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:528
bool any_of(const Container &c, Fnc &&cb)
Definition: Algorithm.h:76
bool isKind() const
Definition: solvable.h:118
static const Solvable noSolvable
Represents no Solvable.
Definition: solvable.h:95
zypp::Date installtime() const
The items install time (false if not installed).
Definition: solvable.cc:291
detail::SolvableIdType IdType
Definition: solvable.h:68
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:74
Capabilities dep_suggests() const
Definition: solvable.cc:360
static const IdString productToken
Indicator provides product()
Definition: solvable.h:71
Resolvable kinds.
Definition: ResKind.h:32
bool supportsLocale(const Locale &locale_r) const
Whether this Solvable supports a specific Locale.
Definition: solvable.cc:514
zypp::sat::detail::RepoIdType RepoIdType
Definition: poolconstants.h:45