libzypp 17.38.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-core/ByteCount.h>
19#include <zypp-core/Date.h>
20#include <zypp-core/CheckSum.h>
21
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>
33#include <zypp/ng/reskind.h>
34#include <zypp/ng/locale.h>
35
36
37
38namespace 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;
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>() ); }
119
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:
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 }
192
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:
215
216 bool supportsLocales() const;
218 bool supportsLocale( const Locale & locale_r ) const;
220 bool supportsLocale( const LocaleSet & locales_r ) const;
225 void getSupportedLocales( LocaleSet & locales_r ) const
226 { locales_r = getSupportedLocales(); }
227
228
229 public:
231 CpeId cpeId() const;
232
234 unsigned mediaNr() const;
235
258
261
263 std::string distribution() const;
264
266 std::string summary( const Locale & lang_r = Locale() ) const;
267
269 std::string description( const Locale & lang_r = Locale() ) const;
270
272 std::string insnotify( const Locale & lang_r = Locale() ) const;
274 std::string delnotify( const Locale & lang_r = Locale() ) const;
275
277 std::string licenseToConfirm( const Locale & lang_r = Locale() ) const;
280
281 public:
287
291 std::string lookupStrAttribute( const SolvAttr & attr ) const;
302 std::string lookupStrAttribute( const SolvAttr & attr, const Locale & lang_r ) const;
303
308 unsigned long long lookupNumAttribute( const SolvAttr & attr ) const;
310 unsigned long long lookupNumAttribute( const SolvAttr & attr, unsigned long long notfound_r ) const;
311
316 bool lookupBoolAttribute( const SolvAttr & attr ) const;
317
322 detail::IdType lookupIdAttribute( const SolvAttr & attr ) const;
323
328 zypp::CheckSum lookupCheckSumAttribute( const SolvAttr & attr ) const;
329
330 public:
332 Solvable nextInPool() const;
334 Solvable nextInRepo() const;
336 detail::CSolvable * get() const;
338 IdType id() const { return _id; }
339
340 private:
342 };
343
344
346 inline bool operator==( const Solvable & lhs, const Solvable & rhs )
347 { return lhs.get() == rhs.get(); }
348
350 inline bool operator!=( const Solvable & lhs, const Solvable & rhs )
351 { return lhs.get() != rhs.get(); }
352
354 inline bool operator<( const Solvable & lhs, const Solvable & rhs )
355 { return lhs.get() < rhs.get(); }
356
358 template<class TRes>
359 inline bool isKind( const Solvable & solvable_r )
360 { return solvable_r.isKind( ResTraits<TRes>::kind ); }
361
363 inline bool identical( const Solvable & lhs, const Solvable & rhs )
364 { return lhs.identical( rhs ); }
365
367 inline bool sameNVRA( const Solvable & lhs, const Solvable & rhs )
368 { return lhs.sameNVRA( rhs ); }
369
370
372 inline int compareByN( const Solvable & lhs, const Solvable & rhs )
373 {
374 int res = 0;
375 if ( lhs != rhs )
376 {
377 if ( (res = lhs.kind().compare( rhs.kind() )) == 0 )
378 res = lhs.name().compare( rhs.name() );
379 }
380 return res;
381 }
382
384 inline int compareByNVR( const Solvable & lhs, const Solvable & rhs )
385 {
386 int res = compareByN( lhs, rhs );
387 if ( res == 0 )
388 res = lhs.edition().compare( rhs.edition() );
389 return res;
390 }
391
393 inline int compareByNVRA( const Solvable & lhs, const Solvable & rhs )
394 {
395 int res = compareByNVR( lhs, rhs );
396 if ( res == 0 )
397 res = lhs.arch().compare( rhs.arch() );
398 return res;
399 }
400
402 namespace detail
403 {
410 class SolvableIterator : public boost::iterator_adaptor<
411 SolvableIterator // Derived
412 , CSolvable* // Base
413 , const Solvable // Value
414 , boost::forward_traversal_tag // CategoryOrTraversal
415 , const Solvable // Reference
416 >
417 {
418 public:
420 : SolvableIterator::iterator_adaptor_( nullptr )
421 {}
422
423 explicit SolvableIterator( const Solvable & val_r )
424 : SolvableIterator::iterator_adaptor_( nullptr )
425 { initialAssignVal( val_r ); }
426
428 : SolvableIterator::iterator_adaptor_( nullptr )
429 { initialAssignVal( Solvable(id_r) ); }
430
431 private:
433
435 { return _val; }
436
438 { assignVal( _val.nextInPool() ); }
439
440 private:
441 void initialAssignVal( const Solvable & val_r )
442 { assignVal( val_r ? val_r : val_r.nextInPool() ); }
443
444 void assignVal( const Solvable & val_r )
445 { _val = val_r; base_reference() = _val.get(); }
446
448 };
449 } // namespace detail
450
451 namespace detail {
452
453 template <typename T>
454 using satSolvable_t = decltype(std::declval<T>().satSolvable());
455
456 template <typename T>
458
459 template <typename T, typename = void >
461 // static_assert to force specialization/implementation
462 static_assert( always_false_v<T>, "Type must have .satSolvable() or a specialization of detail::convert_to_solvable" );
463 };
464
465 template <typename T>
466 struct convert_to_solvable<T, std::void_t<satSolvable_t<T>>> {
467 template <typename SType = T>
468 static Solvable asSolvable( SType && obj ) {
469 return std::forward<SType>(obj).satSolvable();
470 }
471 };
472 }
473
479 {
481
482 Solvable operator()( const Solvable & solv_r ) const
483 { return solv_r; }
484
485 template <typename T>
486 Solvable operator()( T&& obj )const {
487 return detail::convert_to_solvable<T>::asSolvable( std::forward<T>(obj));
488 }
489 };
490
491 } // namespace sat
492} // namespace zypp
493
495
496#endif // ZYPP_SAT_SOLVABLE_H
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition Easy.h:27
#define ZYPP_DEFINE_ID_HASHABLE(C)
Define hash function for id based classes.
Definition Hash.h:26
Architecture.
Definition Arch.h:37
int compare(const Arch &rhs) const
Arch comparison.
Definition Arch.cc:785
Store and operate with byte count.
Definition ByteCount.h:32
Common Platform Enumearation (2.3) See http://cpe.mitre.org/ for more information on the Common Platf...
Definition CpeId.h:33
Store and operate on date (time_t).
Definition Date.h:33
Edition represents [epoch:]version[-release].
Definition Edition.h:60
Access to the sat-pools string space.
Definition IdString.h:55
'Language[_Country]' codes.
Definition Locale.h:51
Resolvable kinds.
Definition ResKind.h:33
Solvable attribute keys.
Definition SolvAttr.h:41
static int compare(const Derived &lhs, const Derived &rhs)
Container of Capability (currently read only).
A Solvable object within the sat Pool.
Definition solvable.h:65
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:107
Capabilities dep(Dep which_r) const
Return Capabilities selected by Dep constant.
Definition solvable.h:176
static const IdString ptfPackageToken
Indicator provides ptf-package().
Definition solvable.h:74
detail::CSolvable * get() const
Expert backdoor.
Definition solvable.cc:76
bool lookupBoolAttribute(const SolvAttr &attr) const
returns the boolean attribute value for attr or false if it does not exists.
Definition solvable.cc:147
Capabilities dep_conflicts() const
Definition solvable.cc:344
std::string summary(const Locale &lang_r=Locale()) const
Short (singleline) text describing the solvable (opt.
Definition solvable.cc:569
bool identical(const Solvable &rhs) const
Test whether two Solvables have the same content.
Definition solvable.cc:317
Solvable()
Default ctor creates noSolvable.
Definition solvable.h:78
std::string name() const
The name (without any ResKind prefix).
Definition solvable.cc:238
bool needToAcceptLicense() const
True except for well known exceptions (i.e show license but no need to accept it).
Capabilities operator[](Dep which_r) const
Definition solvable.h:193
bool isKind(TIterator begin, TIterator end) const
Definition solvable.h:121
CapabilitySet valuesOfNamespace(const std::string &namespace_r) const
Return 'value[ op edition]' for namespaced provides 'namespace(value)[ op edition]'.
Definition solvable.cc:397
Solvable(const Solvable &)=default
static const IdString productToken
Indicator provides product().
Definition solvable.h:70
ResKind kind() const
The Solvables ResKind.
Definition solvable.cc:184
CpeId cpeId() const
The solvables CpeId if available.
Definition solvable.cc:532
zypp::ByteCount installSize() const
Installed (unpacked) size.
Definition solvable.cc:551
bool isKind() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition solvable.h:117
static const IdString retractedToken
Indicator provides retracted-patch-package().
Definition solvable.h:72
Capabilities dep_prerequires() const
Definition solvable.cc:374
Solvable nextInPool() const
Return next Solvable in Pool (or noSolvable).
Definition solvable.cc:87
static const IdString patternToken
Indicator provides pattern().
Definition solvable.h:69
bool isSystem() const
Return whether this Solvable belongs to the system repo.
Definition solvable.cc:278
bool sameNVRA(const Solvable &rhs) const
Test for same name-version-release.arch.
Definition solvable.h:156
std::string delnotify(const Locale &lang_r=Locale()) const
UI hint text when selecting the solvable for uninstall (opt.
Definition solvable.cc:587
Capabilities dep_enhances() const
Definition solvable.cc:364
std::string licenseToConfirm(const Locale &lang_r=Locale()) const
License or agreement to accept before installing the solvable (opt.
Edition edition() const
The edition (version-release).
Definition solvable.cc:246
bool supportsLocale(const Locale &locale_r) const
Whether this Solvable supports a specific Locale.
Definition solvable.cc:508
std::string description(const Locale &lang_r=Locale()) const
Long (multiline) text describing the solvable (opt.
Definition solvable.cc:575
LocaleSet getSupportedLocales() const
Return the supported locales.
Definition solvable.cc:522
Capabilities dep_requires() const
Definition solvable.cc:339
Capabilities dep_supplements() const
Definition solvable.cc:369
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:153
IdString ident() const
The identifier.
Definition solvable.cc:178
zypp::Date installtime() const
The items install time (false if not installed).
Definition solvable.cc:290
Capabilities dep_obsoletes() const
Definition solvable.cc:349
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:135
Capabilities dep_suggests() const
Definition solvable.cc:359
detail::SolvableIdType IdType
Definition solvable.h:67
IdType id() const
Expert backdoor.
Definition solvable.h:338
std::string insnotify(const Locale &lang_r=Locale()) const
UI hint text when selecting the solvable for install (opt.
Definition solvable.cc:581
zypp::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:159
Capabilities dep_recommends() const
Definition solvable.cc:354
Capabilities dep_provides() const
Definition solvable.cc:334
CapabilitySet providesNamespace(const std::string &namespace_r) const
Return the namespaced provides 'namespace([value])[ op edition]' of this Solvable.
Definition solvable.cc:383
std::string distribution() const
The distribution string.
Definition solvable.cc:563
static const Solvable noSolvable
Represents no Solvable.
Definition solvable.h:94
Arch arch() const
The architecture.
Definition solvable.cc:252
zypp::ByteCount downloadSize() const
Download size.
Definition solvable.cc:557
bool isKind(const ResKind &kind_r) const
Test whether a Solvable is of a certain ResKind.
Definition solvable.cc:211
IdString vendor() const
The vendor.
Definition solvable.cc:266
Solvable nextInRepo() const
Return next Solvable in Repo (or noSolvable).
Definition solvable.cc:93
detail::RepoIdType repository() const
The repo id this Solvable belongs to.
Definition solvable.cc:272
zypp::Date buildtime() const
The items build time.
Definition solvable.cc:284
Solvable(Solvable &&) noexcept=default
unsigned mediaNr() const
Media number the solvable is located on (0 if no media access required).
Definition solvable.cc:538
std::pair< bool, CapabilitySet > matchesSolvable(const SolvAttr &attr, const Solvable &solv) const
Definition solvable.cc:415
static const IdString ptfMasterToken
Indicator provides ptf().
Definition solvable.h:73
bool supportsLocales() const
Whether this Solvable claims to support locales.
Definition solvable.cc:502
SolvableIterator(const Solvable &val_r)
Definition solvable.h:423
void initialAssignVal(const Solvable &val_r)
Definition solvable.h:441
SolvableIterator(SolvableIdType id_r)
Definition solvable.h:427
void assignVal(const Solvable &val_r)
Definition solvable.h:444
friend class boost::iterator_core_access
Definition solvable.h:432
Definition ansi.h:855
constexpr bool is_detected_v
Definition type_traits.h:57
int compareByN(const Solvable &lhs, const Solvable &rhs)
relates: Solvable Compare according to kind and name.
Definition Solvable.h:507
bool identical(const Solvable &lhs, const Solvable &rhs)
relates: Solvable Test for same content.
Definition Solvable.h:498
bool operator!=(const FileConflicts &lhs, const FileConflicts &rhs)
relates: FileConflicts
bool isKind(const Solvable &solvable_r)
relates: Solvable Test whether a Solvable is of a certain Kind.
Definition Solvable.h:494
bool operator<(const LocaleSupport &lhs, const LocaleSupport &rhs)
relates: LocaleSupport
bool operator==(const FileConflicts &lhs, const FileConflicts &rhs)
relates: FileConflicts
bool sameNVRA(const Solvable &lhs, const Solvable &rhs)
relates: Solvable Test for same name version release and arch.
Definition Solvable.h:502
int compareByNVRA(const Solvable &lhs, const Solvable &rhs)
relates: Solvable Compare according to kind, name, edition and arch.
Definition Solvable.h:528
int compareByNVR(const Solvable &lhs, const Solvable &rhs)
relates: Solvable Compare according to kind, name and edition.
Definition Solvable.h:519
std::unordered_set< Locale > LocaleSet
Definition Locale.h:29
constexpr bool always_false_v
Definition LogControl.cc:60
ResKind resKind()
Convenient access to well known ResKinds.
Definition ResTraits.h:129
CLASS NAME : detail::DIWrap.
Definition cap2str.cc:14
zypp::sat::detail::CSolvable CSolvable
zypp::sat::detail::RepoIdType RepoIdType
Pool & poolFromType(T &)
zypp::sat::detail::SolvableIdType SolvableIdType
decltype(std::declval< T >().satSolvable()) satSolvable_t
Definition solvable.h:454
zypp::sat::detail::IdType IdType
constexpr bool has_satSolvable_v
Definition solvable.h:457
This file contains private API, this might break at any time between releases.
std::unordered_set< Capability > CapabilitySet
Definition capability.h:35
Enumeration class of dependency types.
Definition Dep.h:31
for_use_in_switch inSwitch() const
Enumarator provided for use in switch statement.
Definition Dep.h:90
ResTraits.
Definition ResTraits.h:80
@ SUGGESTS_e
Definition Dep.h:64
@ REQUIRES_e
Definition Dep.h:60
@ PREREQUIRES_e
Definition Dep.h:59
@ RECOMMENDS_e
Definition Dep.h:63
@ SUPPLEMENTS_e
Definition Dep.h:66
@ PROVIDES_e
Definition Dep.h:58
@ CONFLICTS_e
Definition Dep.h:61
@ ENHANCES_e
Definition Dep.h:65
@ OBSOLETES_e
Definition Dep.h:62
To Solvable transform functor.
Definition solvable.h:479
Solvable operator()(T &&obj) const
Definition solvable.h:486
Solvable operator()(const Solvable &solv_r) const
Definition solvable.h:482