libzypp 17.32.2
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 {
53 class Solvable : protected detail::PoolMember
54 {
55 public:
57
58 static const IdString retractedToken;
59 static const IdString ptfMasterToken;
61
62 public:
65 : _id( detail::noSolvableId )
66 {}
67
68 Solvable(const Solvable &) = default;
70 Solvable &operator=(const Solvable &) = default;
72
75 : _id( id_r )
76 {}
77
78 public:
80 static const Solvable noSolvable;
81
83 explicit operator bool() const
84 { return get(); }
85
86 public:
91 IdString ident()const;
92
94 ResKind kind()const;
95
100 bool isKind( const ResKind & kind_r ) const;
102 template<class TRes>
103 bool isKind() const
104 { return isKind( resKind<TRes>() ); }
106 template<class TIterator>
107 bool isKind( TIterator begin, TIterator end ) const
108 { for_( it, begin, end ) if ( isKind( *it ) ) return true; return false; }
109
111 std::string name() const;
112
114 Edition edition() const;
115
117 Arch arch() const;
118
120 IdString vendor() const;
121
123 Repository repository() const;
125 RepoInfo repoInfo() const;
126
130 bool isSystem() const;
131
135 bool onSystemByUser() const;
136
140 bool onSystemByAuto() const;
141
144 { return identIsAutoInstalled( ident() ); }
146 static bool identIsAutoInstalled( const IdString & ident_r );
147
151 bool multiversionInstall() const;
152
154 bool isNeedreboot() const;
155
175 bool isBlacklisted() const;
176
178 bool isRetracted() const;
179
181 bool isPtf() const;
182
184 bool isPtfMaster() const;
185
187 bool isPtfPackage() const;
189
191 Date buildtime() const;
192
194 Date installtime() const;
195
196 public:
204 std::string asString() const;
205
207 std::string asUserString() const;
208
212 bool identical( const Solvable & rhs ) const;
213
215 bool sameNVRA( const Solvable & rhs ) const
216 { return( get() == rhs.get() || ( ident() == rhs.ident() && edition() == rhs.edition() && arch() == rhs.arch() ) ); }
217
218 public:
224 Capabilities provides() const;
225 Capabilities requires() const;
226 Capabilities conflicts() const;
227 Capabilities obsoletes() const;
228 Capabilities recommends() const;
229 Capabilities suggests() const;
230 Capabilities enhances() const;
233
236 {
237 switch( which_r.inSwitch() )
238 {
239 case Dep::PROVIDES_e: return provides(); break;
240 case Dep::REQUIRES_e: return requires(); break;
241 case Dep::CONFLICTS_e: return conflicts(); break;
242 case Dep::OBSOLETES_e: return obsoletes(); break;
243 case Dep::RECOMMENDS_e: return recommends(); break;
244 case Dep::SUGGESTS_e: return suggests(); break;
245 case Dep::ENHANCES_e: return enhances(); break;
246 case Dep::SUPPLEMENTS_e: return supplements(); break;
247 case Dep::PREREQUIRES_e: return prerequires(); break;
248 }
249 return Capabilities();
250 }
253 { return dep( which_r ); }
254
255
257 CapabilitySet providesNamespace( const std::string & namespace_r ) const;
258
266 CapabilitySet valuesOfNamespace( const std::string & namespace_r ) const;
268
269 std::pair<bool, CapabilitySet> matchesSolvable ( const SolvAttr &attr, const sat::Solvable &solv ) const;
270
271 public:
275 bool supportsLocales() const;
277 bool supportsLocale( const Locale & locale_r ) const;
279 bool supportsLocale( const LocaleSet & locales_r ) const;
283 bool supportsRequestedLocales() const;
290
291 public:
293 CpeId cpeId() const;
294
296 unsigned mediaNr() const;
297
319 ByteCount installSize() const;
320
322 ByteCount downloadSize() const;
323
325 std::string distribution() const;
326
328 std::string summary( const Locale & lang_r = Locale() ) const;
329
331 std::string description( const Locale & lang_r = Locale() ) const;
332
334 std::string insnotify( const Locale & lang_r = Locale() ) const;
336 std::string delnotify( const Locale & lang_r = Locale() ) const;
337
339 std::string licenseToConfirm( const Locale & lang_r = Locale() ) const;
341 bool needToAcceptLicense() const;
342
343 public:
350 {
351 public:
354 SplitIdent( const char * ident_r );
355 SplitIdent( const std::string & ident_r );
358
359 IdString ident() const { return _ident; }
360 ResKind kind() const { return _kind; }
361 IdString name() const { return _name; }
362
363 private:
367 };
368
369 public:
379 std::string lookupStrAttribute( const SolvAttr & attr ) const;
390 std::string lookupStrAttribute( const SolvAttr & attr, const Locale & lang_r ) const;
391
396 unsigned long long lookupNumAttribute( const SolvAttr & attr ) const;
398 unsigned long long lookupNumAttribute( const SolvAttr & attr, unsigned long long notfound_r ) const;
399
404 bool lookupBoolAttribute( const SolvAttr & attr ) const;
405
411
417
424
425 public:
427 Solvable nextInPool() const;
429 Solvable nextInRepo() const;
431 detail::CSolvable * get() const;
433 IdType id() const { return _id; }
434
435 private:
437 };
439
441 std::ostream & operator<<( std::ostream & str, const Solvable & obj );
442
444 std::ostream & dumpOn( std::ostream & str, const Solvable & obj );
445
447 std::ostream & dumpAsXmlOn( std::ostream & str, const Solvable & obj );
448
450 inline bool operator==( const Solvable & lhs, const Solvable & rhs )
451 { return lhs.get() == rhs.get(); }
452
454 inline bool operator!=( const Solvable & lhs, const Solvable & rhs )
455 { return lhs.get() != rhs.get(); }
456
458 inline bool operator<( const Solvable & lhs, const Solvable & rhs )
459 { return lhs.get() < rhs.get(); }
460
462 template<class TRes>
463 inline bool isKind( const Solvable & solvable_r )
464 { return solvable_r.isKind( ResTraits<TRes>::kind ); }
465
467 inline bool identical( const Solvable & lhs, const Solvable & rhs )
468 { return lhs.identical( rhs ); }
469
471 inline bool sameNVRA( const Solvable & lhs, const Solvable & rhs )
472 { return lhs.sameNVRA( rhs ); }
473
474
476 inline int compareByN( const Solvable & lhs, const Solvable & rhs )
477 {
478 int res = 0;
479 if ( lhs != rhs )
480 {
481 if ( (res = lhs.kind().compare( rhs.kind() )) == 0 )
482 res = lhs.name().compare( rhs.name() );
483 }
484 return res;
485 }
486
488 inline int compareByNVR( const Solvable & lhs, const Solvable & rhs )
489 {
490 int res = compareByN( lhs, rhs );
491 if ( res == 0 )
492 res = lhs.edition().compare( rhs.edition() );
493 return res;
494 }
495
497 inline int compareByNVRA( const Solvable & lhs, const Solvable & rhs )
498 {
499 int res = compareByNVR( lhs, rhs );
500 if ( res == 0 )
501 res = lhs.arch().compare( rhs.arch() );
502 return res;
503 }
504
506 namespace detail
507 {
514 class SolvableIterator : public boost::iterator_adaptor<
515 SolvableIterator // Derived
516 , CSolvable* // Base
517 , const Solvable // Value
518 , boost::forward_traversal_tag // CategoryOrTraversal
519 , const Solvable // Reference
520 >
521 {
522 public:
526
530
534
535 private:
537
539 { return _val; }
540
542 { assignVal( _val.nextInPool() ); }
543
544 private:
546 { assignVal( val_r ? val_r : val_r.nextInPool() ); }
547
548 void assignVal( const Solvable & val_r )
549 { _val = val_r; base_reference() = _val.get(); }
550
552 };
553 } // namespace detail
555 } // namespace sat
557
558 class PoolItem;
560 namespace sat
561 {
567 {
569
571 { return solv_r; }
572
573 Solvable operator()( const PoolItem & pi_r ) const;
574
576 };
577 } // namespace sat
579} // namespace zypp
581
583
584#endif // ZYPP_SAT_SOLVABLE_H
sat::SolvAttr attr
Definition PoolQuery.cc:312
Architecture.
Definition Arch.h:37
int compare(const Arch &rhs) const
Arch comparison.
Definition Arch.cc:560
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition AutoDispose.h:95
Store and operate with byte count.
Definition ByteCount.h:31
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string.
Definition String.h:91
Container of Capability (currently read only).
Common Platform Enumearation (2.3) See http://cpe.mitre.org/ for more information on the Common Platf...
Definition CpeId.h:32
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:43
'Language[_Country]' codes.
Definition Locale.h:50
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:350
A Solvable object within the sat Pool.
Definition Solvable.h:54
Capabilities suggests() const
Definition Solvable.cc:510
IdType id() const
Expert backdoor.
Definition Solvable.h:433
bool isKind(const Solvable &solvable_r)
Test whether a Solvable is of a certain Kind.
Definition Solvable.h:463
bool isPtfPackage() const
Subset of isPtf (provides ptfPackageToken).
Definition Solvable.cc:424
bool isNeedreboot() const
Whether this solvable triggers the reboot-needed hint if installed/updated.
Definition Solvable.cc:395
bool identIsAutoInstalled() const
Whether an installed solvable with the same ident is flagged as AutoInstalled.
Definition Solvable.h:143
OnMediaLocation lookupLocation() const
returns OnMediaLocation data: This is everything we need to download e.g.
Definition Solvable.cc:225
bool isKind(TIterator begin, TIterator end) const
Definition Solvable.h:107
Capabilities dep(Dep which_r) const
Return Capabilities selected by Dep constant.
Definition Solvable.h:235
bool identical(const Solvable &lhs, const Solvable &rhs)
Test for same content.
Definition Solvable.h:467
bool lookupBoolAttribute(const SolvAttr &attr) const
returns the boolean attribute value for attr or false if it does not exists.
Definition Solvable.cc:171
int compareByNVR(const Solvable &lhs, const Solvable &rhs)
Compare according to kind, name and edition.
Definition Solvable.h:488
IdString vendor() const
The vendor.
Definition Solvable.cc:358
void getSupportedLocales(LocaleSet &locales_r) const
Definition Solvable.h:287
ByteCount installSize() const
Installed (unpacked) size.
Definition Solvable.cc:702
Date buildtime() const
The items build time.
Definition Solvable.cc:437
bool needToAcceptLicense() const
True except for well known exceptions (i.e show license but no need to accept it).
Definition Solvable.cc:761
ResKind kind() const
The Solvables ResKind.
Definition Solvable.cc:276
CapabilitySet providesNamespace(const std::string &namespace_r) const
Return the namespaced provides 'namespace([value])[ op edition]' of this Solvable.
Definition Solvable.cc:534
static const Solvable noSolvable
Represents no Solvable.
Definition Solvable.h:80
std::string asString() const
String representation "ident-edition.arch" or "noSolvable".
Definition Solvable.cc:449
std::string distribution() const
The distribution string.
Definition Solvable.cc:714
unsigned mediaNr() const
Media number the solvable is located on (0 if no media access required).
Definition Solvable.cc:689
bool isBlacklisted() const
Whether this solvable is blacklisted (retracted,ptf,...).
Definition Solvable.cc:402
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:159
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:131
Solvable(const Solvable &)=default
bool multiversionInstall() const
Whether different versions of this package can be installed at the same time.
Definition Solvable.cc:431
int compareByN(const Solvable &lhs, const Solvable &rhs)
Compare according to kind and name.
Definition Solvable.h:476
Solvable(Solvable &&) noexcept=default
CpeId cpeId() const
The solvables CpeId if available.
Definition Solvable.cc:683
Solvable nextInRepo() const
Return next Solvable in Repo (or noSolvable).
Definition Solvable.cc:117
Capabilities operator[](Dep which_r) const
Definition Solvable.h:252
Date installtime() const
The items install time (false if not installed).
Definition Solvable.cc:443
Edition edition() const
The edition (version-release).
Definition Solvable.cc:338
bool sameNVRA(const Solvable &rhs) const
Test for same name-version-release.arch.
Definition Solvable.h:215
static const IdString ptfMasterToken
Indicator provides ptf()
Definition Solvable.h:59
Capabilities prerequires() const
Definition Solvable.cc:525
bool isPtfMaster() const
Subset of isPtf (provides ptfMasterToken).
Definition Solvable.cc:418
Solvable()
Default ctor creates noSolvable.
Definition Solvable.h:64
Capabilities enhances() const
Definition Solvable.cc:515
LocaleSet getSupportedLocales() const
Return the supported locales.
Definition Solvable.cc:676
bool supportsRequestedLocales() const
Whether this Solvable supports at least one requested locale.
Definition Solvable.cc:673
bool operator==(const Solvable &lhs, const Solvable &rhs)
Definition Solvable.h:450
detail::CSolvable * get() const
Expert backdoor.
Definition Solvable.cc:107
Arch arch() const
The architecture.
Definition Solvable.cc:344
static const IdString ptfPackageToken
Indicator provides ptf-package()
Definition Solvable.h:60
bool isSystem() const
Return whether this Solvable belongs to the system repo.
Definition Solvable.cc:374
Solvable nextInPool() const
Return next Solvable in Pool (or noSolvable).
Definition Solvable.cc:114
Capabilities const
Definition Solvable.h:225
std::string licenseToConfirm(const Locale &lang_r=Locale()) const
License or agreement to accept before installing the solvable (opt.
Definition Solvable.cc:744
bool operator!=(const Solvable &lhs, const Solvable &rhs)
Definition Solvable.h:454
bool supportsLocales() const
Whether this Solvable claims to support locales.
Definition Solvable.cc:653
Capabilities provides() const
Definition Solvable.cc:485
std::string asUserString() const
String representation "ident-edition.arch(repo)" or "noSolvable".
Definition Solvable.cc:458
static const IdString retractedToken
Indicator provides retracted-patch-package()
Definition Solvable.h:58
bool sameNVRA(const Solvable &lhs, const Solvable &rhs)
Test for same name version release and arch.
Definition Solvable.h:471
std::string summary(const Locale &lang_r=Locale()) const
Short (singleline) text describing the solvable (opt.
Definition Solvable.cc:720
Capabilities conflicts() const
Definition Solvable.cc:495
Capabilities obsoletes() const
Definition Solvable.cc:500
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:177
std::pair< bool, CapabilitySet > matchesSolvable(const SolvAttr &attr, const sat::Solvable &solv) const
Definition Solvable.cc:566
std::string name() const
The name (without any ResKind prefix).
Definition Solvable.cc:330
bool supportsLocale(const Locale &locale_r) const
Whether this Solvable supports a specific Locale.
Definition Solvable.cc:659
Capabilities supplements() const
Definition Solvable.cc:520
ByteCount downloadSize() const
Download size.
Definition Solvable.cc:708
bool operator<(const Solvable &lhs, const Solvable &rhs)
Definition Solvable.h:458
bool onSystemByAuto() const
Whether this is known to be automatically installed (as dependency of a user request package).
Definition Solvable.cc:385
std::string delnotify(const Locale &lang_r=Locale()) const
UI hint text when selecting the solvable for uninstall (opt.
Definition Solvable.cc:738
CapabilitySet valuesOfNamespace(const std::string &namespace_r) const
Return 'value[ op edition]' for namespaced provides 'namespace(value)[ op edition]'.
Definition Solvable.cc:548
IdString ident() const
The identifier.
Definition Solvable.cc:270
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:183
std::string description(const Locale &lang_r=Locale()) const
Long (multiline) text describing the solvable (opt.
Definition Solvable.cc:726
bool onSystemByUser() const
Whether this is known to be installed on behalf of a user request.
Definition Solvable.cc:380
Capabilities recommends() const
Definition Solvable.cc:505
int compareByNVRA(const Solvable &lhs, const Solvable &rhs)
Compare according to kind, name, edition and arch.
Definition Solvable.h:497
RepoInfo repoInfo() const
The repositories RepoInfo.
Definition Solvable.cc:370
Repository repository() const
The Repository this Solvable belongs to.
Definition Solvable.cc:364
bool isPtf() const
Whether this solvable belongs to a PTF (provides ptfMasterToken or ptfPackageToken).
Definition Solvable.cc:415
bool isRetracted() const
Whether this solvable is retracted (provides retractedToken).
Definition Solvable.cc:405
bool isKind() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition Solvable.h:103
std::string insnotify(const Locale &lang_r=Locale()) const
UI hint text when selecting the solvable for install (opt.
Definition Solvable.cc:732
bool identical(const Solvable &rhs) const
Test whether two Solvables have the same content.
Definition Solvable.cc:468
Iterate over valid Solvables in the pool.
Definition Solvable.h:521
void initialAssignVal(const Solvable &val_r)
Definition Solvable.h:545
SolvableIterator(SolvableIdType id_r)
Definition Solvable.h:531
void assignVal(const Solvable &val_r)
Definition Solvable.h:548
SolvableIterator(const Solvable &val_r)
Definition Solvable.h:527
friend class boost::iterator_core_access
Definition Solvable.h:536
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
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)
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...
Easy-to use interface to the ZYPP dependency resolver.
std::unordered_set< Locale > LocaleSet
Definition Locale.h:28
std::unordered_set< Capability > CapabilitySet
Definition Capability.h:35
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
ResTraits.
Definition ResTraits.h:80
To Solvable transform functor.
Definition Solvable.h:567
Solvable operator()(const Solvable &solv_r) const
Definition Solvable.h:570
Backlink to the associated PoolImpl.
Definition PoolMember.h:89
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition Easy.h:28
#define nullptr
Definition Easy.h:55
#define ZYPP_DEFINE_ID_HASHABLE(C)
Define hash function for id based classes.
Definition Hash.h:26