libzypp 17.38.3
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
29namespace zypp
30{
31 class ByteCount;
32 class CheckSum;
33 class CpeId;
34 class Date;
35 class OnMediaLocation;
37 namespace sat
38 {
54 {
55 public:
57
58 static const IdString patternToken;
59 static const IdString productToken;
60
61 static const IdString retractedToken;
62 static const IdString ptfMasterToken;
64
65 public:
69 {}
70
71 Solvable(const Solvable &) = default;
72 Solvable(Solvable &&) noexcept = default;
73 Solvable &operator=(const Solvable &) = default;
74 Solvable &operator=(Solvable &&) noexcept = default;
75
77 explicit Solvable( IdType id_r )
78 : _id( id_r )
79 {}
80
81 public:
83 static const Solvable noSolvable;
84
86 explicit operator bool() const
87 { return get(); }
88
89 public:
94 IdString ident()const;
95
97 ResKind kind()const;
98
103 bool isKind( const ResKind & kind_r ) const;
105 template<class TRes>
106 bool isKind() const
107 { return isKind( resKind<TRes>() ); }
108
109 template<class TIterator>
110 bool isKind( TIterator begin, TIterator end ) const
111 { for_( it, begin, end ) if ( isKind( *it ) ) return true; return false; }
112
114 std::string name() const;
115
117 Edition edition() const;
118
120 Arch arch() const;
121
123 IdString vendor() const;
124
126 Repository repository() const;
128 RepoInfo repoInfo() const;
129
133 bool isSystem() const;
134
138 bool onSystemByUser() const;
139
143 bool onSystemByAuto() const;
144
147 { return identIsAutoInstalled( ident() ); }
148
149 static bool identIsAutoInstalled( const IdString & ident_r );
150
154 bool multiversionInstall() const;
155
157 bool isNeedreboot() const;
158
161 { return dep_provides().findFirstMatch( Capability(patternToken.id()) ); }
162
164 bool isPatternPackage() const
165 { return bool(patternProvides()); }
166
169 { return dep_provides().findFirstMatch( Capability(productToken.id()) ); }
170
172 bool isProductPackage() const
173 { return bool(productProvides()); }
174
193
194 bool isBlacklisted() const;
195
197 bool isRetracted() const;
198
200 bool isPtf() const;
201
203 bool isPtfMaster() const;
204
206 bool isPtfPackage() const;
208
210 Date buildtime() const;
211
213 Date installtime() const;
214
215 public:
223 std::string asString() const;
224
226 std::string asUserString() const;
227
231 bool identical( const Solvable & rhs ) const;
232
234 bool sameNVRA( const Solvable & rhs ) const
235 { return( get() == rhs.get() || ( ident() == rhs.ident() && edition() == rhs.edition() && arch() == rhs.arch() ) ); }
236
237 public:
243 Capabilities dep_provides() const;
244 Capabilities dep_requires() const;
245 Capabilities dep_conflicts() const;
246 Capabilities dep_obsoletes() const;
247 Capabilities dep_recommends() const;
248 Capabilities dep_suggests() const;
249 Capabilities dep_enhances() const;
250 Capabilities dep_supplements() const;
251 Capabilities dep_prerequires() const;
252
253#if __cplusplus < 202002L
254 Capabilities provides() const ZYPP_DEPRECATED; // use dep_ prefixed version instead
255 Capabilities requires() const ZYPP_DEPRECATED; // use dep_ prefixed version instead
256 Capabilities conflicts() const ZYPP_DEPRECATED; // use dep_ prefixed version instead
257 Capabilities obsoletes() const ZYPP_DEPRECATED; // use dep_ prefixed version instead
258 Capabilities recommends() const ZYPP_DEPRECATED; // use dep_ prefixed version instead
259 Capabilities suggests() const ZYPP_DEPRECATED; // use dep_ prefixed version instead
260 Capabilities enhances() const ZYPP_DEPRECATED; // use dep_ prefixed version instead
261 Capabilities supplements() const ZYPP_DEPRECATED; // use dep_ prefixed version instead
262 Capabilities prerequires() const ZYPP_DEPRECATED; // use dep_ prefixed version instead
263#endif
264
266 Capabilities dep( Dep which_r ) const
267 {
268 switch( which_r.inSwitch() )
269 {
270 case Dep::PROVIDES_e: return dep_provides(); break;
271 case Dep::REQUIRES_e: return dep_requires(); break;
272 case Dep::CONFLICTS_e: return dep_conflicts(); break;
273 case Dep::OBSOLETES_e: return dep_obsoletes(); break;
274 case Dep::RECOMMENDS_e: return dep_recommends(); break;
275 case Dep::SUGGESTS_e: return dep_suggests(); break;
276 case Dep::ENHANCES_e: return dep_enhances(); break;
277 case Dep::SUPPLEMENTS_e: return dep_supplements(); break;
278 case Dep::PREREQUIRES_e: return dep_prerequires(); break;
279 }
280 return Capabilities();
281 }
282
283 Capabilities operator[]( Dep which_r ) const
284 { return dep( which_r ); }
285
286
288 CapabilitySet providesNamespace( const std::string & namespace_r ) const;
289
297 CapabilitySet valuesOfNamespace( const std::string & namespace_r ) const;
299
300 std::pair<bool, CapabilitySet> matchesSolvable ( const SolvAttr &attr, const sat::Solvable &solv ) const;
301
302 public:
305
306 bool supportsLocales() const;
308 bool supportsLocale( const Locale & locale_r ) const;
310 bool supportsLocale( const LocaleSet & locales_r ) const;
314 bool supportsRequestedLocales() const;
316 LocaleSet getSupportedLocales() const;
318 void getSupportedLocales( LocaleSet & locales_r ) const
319 { locales_r = getSupportedLocales(); }
320
321
322 public:
324 CpeId cpeId() const;
325
327 unsigned mediaNr() const;
328
350 ByteCount installSize() const;
351
353 ByteCount downloadSize() const;
354
356 std::string distribution() const;
357
359 std::string summary( const Locale & lang_r = Locale() ) const;
360
362 std::string description( const Locale & lang_r = Locale() ) const;
363
365 std::string insnotify( const Locale & lang_r = Locale() ) const;
367 std::string delnotify( const Locale & lang_r = Locale() ) const;
368
370 std::string licenseToConfirm( const Locale & lang_r = Locale() ) const;
372 bool needToAcceptLicense() const;
373
374 public:
381 {
382 public:
384 SplitIdent( IdString ident_r );
385 SplitIdent( const char * ident_r );
386 SplitIdent( const std::string & ident_r );
387 SplitIdent( ResKind kind_r, IdString name_r );
388 SplitIdent( ResKind kind_r, const C_Str & name_r );
389
390 IdString ident() const { return _ident; }
391 ResKind kind() const { return _kind; }
392 IdString name() const { return _name; }
393
394 private:
398 };
399
400 public:
406
410 std::string lookupStrAttribute( const SolvAttr & attr ) const;
421 std::string lookupStrAttribute( const SolvAttr & attr, const Locale & lang_r ) const;
422
427 unsigned long long lookupNumAttribute( const SolvAttr & attr ) const;
429 unsigned long long lookupNumAttribute( const SolvAttr & attr, unsigned long long notfound_r ) const;
430
435 bool lookupBoolAttribute( const SolvAttr & attr ) const;
436
441 detail::IdType lookupIdAttribute( const SolvAttr & attr ) const;
442
447 CheckSum lookupCheckSumAttribute( const SolvAttr & attr ) const;
448
455
456 public:
458 Solvable nextInPool() const;
460 Solvable nextInRepo() const;
462 detail::CSolvable * get() const;
464 IdType id() const { return _id; }
465
466 private:
468 };
469
470
472 std::ostream & operator<<( std::ostream & str, const Solvable & obj ) ZYPP_API;
473
475 std::ostream & dumpOn( std::ostream & str, const Solvable & obj ) ZYPP_API;
476
478 std::ostream & dumpAsXmlOn( std::ostream & str, const Solvable & obj ) ZYPP_API;
479
481 inline bool operator==( const Solvable & lhs, const Solvable & rhs )
482 { return lhs.get() == rhs.get(); }
483
485 inline bool operator!=( const Solvable & lhs, const Solvable & rhs )
486 { return lhs.get() != rhs.get(); }
487
489 inline bool operator<( const Solvable & lhs, const Solvable & rhs )
490 { return lhs.get() < rhs.get(); }
491
493 template<class TRes>
494 inline bool isKind( const Solvable & solvable_r )
495 { return solvable_r.isKind( ResTraits<TRes>::kind ); }
496
498 inline bool identical( const Solvable & lhs, const Solvable & rhs )
499 { return lhs.identical( rhs ); }
500
502 inline bool sameNVRA( const Solvable & lhs, const Solvable & rhs )
503 { return lhs.sameNVRA( rhs ); }
504
505
507 inline int compareByN( const Solvable & lhs, const Solvable & rhs )
508 {
509 int res = 0;
510 if ( lhs != rhs )
511 {
512 if ( (res = lhs.kind().compare( rhs.kind() )) == 0 )
513 res = lhs.name().compare( rhs.name() );
514 }
515 return res;
516 }
517
519 inline int compareByNVR( const Solvable & lhs, const Solvable & rhs )
520 {
521 int res = compareByN( lhs, rhs );
522 if ( res == 0 )
523 res = lhs.edition().compare( rhs.edition() );
524 return res;
525 }
526
528 inline int compareByNVRA( const Solvable & lhs, const Solvable & rhs )
529 {
530 int res = compareByNVR( lhs, rhs );
531 if ( res == 0 )
532 res = lhs.arch().compare( rhs.arch() );
533 return res;
534 }
535
537 namespace detail
538 {
545 class SolvableIterator : public boost::iterator_adaptor<
546 SolvableIterator // Derived
547 , CSolvable* // Base
548 , const Solvable // Value
549 , boost::forward_traversal_tag // CategoryOrTraversal
550 , const Solvable // Reference
551 >
552 {
553 public:
555 : SolvableIterator::iterator_adaptor_( nullptr )
556 {}
557
558 explicit SolvableIterator( const Solvable & val_r )
559 : SolvableIterator::iterator_adaptor_( nullptr )
560 { initialAssignVal( val_r ); }
561
563 : SolvableIterator::iterator_adaptor_( nullptr )
564 { initialAssignVal( Solvable(id_r) ); }
565
566 private:
568
570 { return _val; }
571
573 { assignVal( _val.nextInPool() ); }
574
575 private:
576 void initialAssignVal( const Solvable & val_r )
577 { assignVal( val_r ? val_r : val_r.nextInPool() ); }
578
579 void assignVal( const Solvable & val_r )
580 { _val = val_r; base_reference() = _val.get(); }
581
583 };
584 } // namespace detail
586 } // namespace sat
588
589 class PoolItem;
591 namespace sat
592 {
598 {
600
601 Solvable operator()( const Solvable & solv_r ) const
602 { return solv_r; }
603
604 Solvable operator()( const PoolItem & pi_r ) const;
605
606 Solvable operator()( const ResObject_constPtr & res_r ) const;
607 };
608 } // namespace sat
610} // namespace zypp
612
614
615#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:560
bool operator()(const zypp::Arch &lhs, const zypp::Arch &rhs) const
Default order for std::container based Arch::compare.
Definition Arch.h:370
Store and operate with byte count.
Definition ByteCount.h:32
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string.
Definition String.h:92
Container of Capability (currently read only).
A sat capability.
Definition Capability.h:63
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:61
static int compare(const Derived &lhs, const Derived &rhs)
Access to the sat-pools string space.
Definition IdString.h:44
'Language[_Country]' codes.
Definition Locale.h:51
Describes a resource file located on a medium.
Combining sat::Solvable and ResStatus.
Definition PoolItem.h:51
What is known about a repository.
Definition RepoInfo.h:72
Resolvable kinds.
Definition ResKind.h:33
Solvable attribute keys.
Definition SolvAttr.h:41
Helper that splits an identifier into kind and name or vice versa.
Definition Solvable.h:381
A Solvable object within the sat Pool.
Definition Solvable.h:54
IdType id() const
Expert backdoor.
Definition Solvable.h:464
bool isKind(const Solvable &solvable_r)
Test whether a Solvable is of a certain Kind.
Definition Solvable.h:494
Capabilities supplements() const ZYPP_DEPRECATED
bool identIsAutoInstalled() const
Whether an installed solvable with the same ident is flagged as AutoInstalled.
Definition Solvable.h:146
OnMediaLocation lookupLocation() const
returns OnMediaLocation data: This is everything we need to download e.g.
Definition Solvable.cc:228
bool isProductPackage() const
Whether this solvable provides the productToken.
Definition Solvable.h:172
bool isKind(TIterator begin, TIterator end) const
Definition Solvable.h:110
Capabilities dep_suggests() const
Definition Solvable.cc:513
Capabilities dep(Dep which_r) const
Return Capabilities selected by Dep constant.
Definition Solvable.h:266
static const IdString patternToken
Indicator provides pattern().
Definition Solvable.h:58
bool identical(const Solvable &lhs, const Solvable &rhs)
Test for same content.
Definition Solvable.h:498
Capabilities dep_conflicts() const
Definition Solvable.cc:498
bool lookupBoolAttribute(const SolvAttr &attr) const
returns the boolean attribute value for attr or false if it does not exists.
Definition Solvable.cc:174
int compareByNVR(const Solvable &lhs, const Solvable &rhs)
Compare according to kind, name and edition.
Definition Solvable.h:519
Capabilities recommends() const ZYPP_DEPRECATED
void getSupportedLocales(LocaleSet &locales_r) const
Definition Solvable.h:318
Capabilities const ZYPP_DEPRECATED
Definition Solvable.h:255
ResKind kind() const
The Solvables ResKind.
Definition Solvable.cc:279
static const Solvable noSolvable
Represents no Solvable.
Definition Solvable.h:83
Capabilities dep_supplements() const
Definition Solvable.cc:523
Capabilities suggests() const ZYPP_DEPRECATED
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:162
Capabilities dep_enhances() const
Definition Solvable.cc:518
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:134
Capabilities dep_recommends() const
Definition Solvable.cc:508
Solvable(const Solvable &)=default
Capabilities conflicts() const ZYPP_DEPRECATED
int compareByN(const Solvable &lhs, const Solvable &rhs)
Compare according to kind and name.
Definition Solvable.h:507
Solvable(Solvable &&) noexcept=default
bool isPatternPackage() const
Whether this solvable provides the patternToken.
Definition Solvable.h:164
Solvable nextInRepo() const
Return next Solvable in Repo (or noSolvable).
Definition Solvable.cc:120
Capabilities operator[](Dep which_r) const
Definition Solvable.h:283
Edition edition() const
The edition (version-release).
Definition Solvable.cc:341
bool sameNVRA(const Solvable &rhs) const
Test for same name-version-release.arch.
Definition Solvable.h:234
static const IdString ptfMasterToken
Indicator provides ptf().
Definition Solvable.h:62
Solvable()
Default ctor creates noSolvable.
Definition Solvable.h:67
Capabilities dep_obsoletes() const
Definition Solvable.cc:503
LocaleSet getSupportedLocales() const
Return the supported locales.
Definition Solvable.cc:696
bool operator==(const Solvable &lhs, const Solvable &rhs)
Definition Solvable.h:481
detail::CSolvable * get() const
Expert backdoor.
Definition Solvable.cc:110
Arch arch() const
The architecture.
Definition Solvable.cc:347
static const IdString ptfPackageToken
Indicator provides ptf-package().
Definition Solvable.h:63
Solvable nextInPool() const
Return next Solvable in Pool (or noSolvable).
Definition Solvable.cc:117
bool operator!=(const Solvable &lhs, const Solvable &rhs)
Definition Solvable.h:485
Capability patternProvides() const
Return the provided patternToken or Capability::Null.
Definition Solvable.h:160
static const IdString retractedToken
Indicator provides retracted-patch-package().
Definition Solvable.h:61
bool sameNVRA(const Solvable &lhs, const Solvable &rhs)
Test for same name version release and arch.
Definition Solvable.h:502
Capabilities obsoletes() const ZYPP_DEPRECATED
Capabilities dep_prerequires() const
Definition Solvable.cc:528
Capabilities dep_provides() const
Definition Solvable.cc:488
Capability productProvides() const
Return the provided productToken or Capability::Null.
Definition Solvable.h:168
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:180
std::string name() const
The name (without any ResKind prefix).
Definition Solvable.cc:333
Capabilities dep_requires() const
Definition Solvable.cc:493
bool isKind(const ResKind &kind_r) const
Test whether a Solvable is of a certain ResKind.
Definition Solvable.cc:306
bool operator<(const Solvable &lhs, const Solvable &rhs)
Definition Solvable.h:489
IdString ident() const
The identifier.
Definition Solvable.cc:273
static const IdString productToken
Indicator provides product().
Definition Solvable.h:59
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:186
int compareByNVRA(const Solvable &lhs, const Solvable &rhs)
Compare according to kind, name, edition and arch.
Definition Solvable.h:528
Capabilities provides() const ZYPP_DEPRECATED
Capabilities enhances() const ZYPP_DEPRECATED
Capabilities prerequires() const ZYPP_DEPRECATED
sat::detail::SolvableIdType IdType
Definition Solvable.h:56
bool isKind() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition Solvable.h:106
bool identical(const Solvable &rhs) const
Test whether two Solvables have the same content.
Definition Solvable.cc:471
void initialAssignVal(const Solvable &val_r)
Definition Solvable.h:576
SolvableIterator(SolvableIdType id_r)
Definition Solvable.h:562
void assignVal(const Solvable &val_r)
Definition Solvable.h:579
SolvableIterator(const Solvable &val_r)
Definition Solvable.h:558
friend class boost::iterator_core_access
Definition Solvable.h:567
String related utilities and Regular expression matching.
unsigned int SolvableIdType
Id type to connect Solvable and sat-solvable.
Definition PoolMember.h:125
int IdType
Generic Id type.
Definition PoolMember.h:104
::s_Solvable CSolvable
Wrapped libsolv C data type exposed as backdoor.
Definition PoolMember.h:64
Libsolv interface
bool compareByNVR(const SolvableType< Derived > &lhs, const Solvable &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::ostream & operator<<(std::ostream &str, const FileConflicts &obj)
static const SolvableIdType noSolvableId(0)
Id to denote Solvable::noSolvable.
std::ostream & dumpOn(std::ostream &str, const LocaleSupport &obj)
std::ostream & dumpAsXmlOn(std::ostream &str, const FileConflicts &obj)
bool compareByN(const SolvableType< Derived > &lhs, const Solvable &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool identical(const SolvableType< Derived > &lhs, const Solvable &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Easy-to use interface to the ZYPP dependency resolver.
std::unordered_set< Locale > LocaleSet
Definition Locale.h:29
std::unordered_set< Capability > CapabilitySet
Definition Capability.h:35
const ResKind ResTraits< Package >::kind(ResKind::package)
std::string asUserString(VendorSupportOption opt)
converts the support option to a name intended to be printed to the user.
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
std::string asString(const Patch::Category &obj)
Definition Patch.cc:122
ResKind resKind()
Convenient access to well known ResKinds.
Definition ResTraits.h:129
Enumeration class of dependency types.
Definition Dep.h:30
@ SUGGESTS_e
Definition Dep.h:63
@ REQUIRES_e
Definition Dep.h:59
@ PREREQUIRES_e
Definition Dep.h:58
@ RECOMMENDS_e
Definition Dep.h:62
@ SUPPLEMENTS_e
Definition Dep.h:65
@ PROVIDES_e
Definition Dep.h:57
@ CONFLICTS_e
Definition Dep.h:60
@ ENHANCES_e
Definition Dep.h:64
@ OBSOLETES_e
Definition Dep.h:61
for_use_in_switch inSwitch() const
Enumarator provided for use in switch statement.
Definition Dep.h:89
ResTraits.
Definition ResTraits.h:80
To Solvable transform functor.
Definition Solvable.h:598
Solvable operator()(const Solvable &solv_r) const
Definition Solvable.h:601
Backlink to the associated PoolImpl.
Definition PoolMember.h:89