libzypp 17.25.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/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 ptfToken;
60
61 public:
64 : _id( detail::noSolvableId )
65 {}
66
68 explicit Solvable( IdType id_r )
69 : _id( id_r )
70 {}
71
72 public:
74 static const Solvable noSolvable;
75
77 explicit operator bool() const
78 { return get(); }
79
80 public:
85 IdString ident()const;
86
88 ResKind kind()const;
89
94 bool isKind( const ResKind & kind_r ) const;
96 template<class TRes>
97 bool isKind() const
98 { return isKind( resKind<TRes>() ); }
100 template<class TIterator>
101 bool isKind( TIterator begin, TIterator end ) const
102 { for_( it, begin, end ) if ( isKind( *it ) ) return true; return false; }
103
105 std::string name() const;
106
108 Edition edition() const;
109
111 Arch arch() const;
112
114 IdString vendor() const;
115
117 Repository repository() const;
119 RepoInfo repoInfo() const;
120
124 bool isSystem() const;
125
129 bool onSystemByUser() const;
130
134 bool onSystemByAuto() const;
135
138 { return identIsAutoInstalled( ident() ); }
140 static bool identIsAutoInstalled( const IdString & ident_r );
141
145 bool multiversionInstall() const;
146
148 bool isNeedreboot() const;
149
151 bool isRetracted() const;
152
154 bool isPtf() const;
155
157 Date buildtime() const;
158
160 Date installtime() const;
161
162 public:
170 std::string asString() const;
171
173 std::string asUserString() const;
174
178 bool identical( const Solvable & rhs ) const;
179
181 bool sameNVRA( const Solvable & rhs ) const
182 { return( get() == rhs.get() || ( ident() == rhs.ident() && edition() == rhs.edition() && arch() == rhs.arch() ) ); }
183
184 public:
190 Capabilities provides() const;
191 Capabilities requires() const;
192 Capabilities conflicts() const;
193 Capabilities obsoletes() const;
194 Capabilities recommends() const;
195 Capabilities suggests() const;
196 Capabilities enhances() const;
199
201 Capabilities dep( Dep which_r ) const
202 {
203 switch( which_r.inSwitch() )
204 {
205 case Dep::PROVIDES_e: return provides(); break;
206 case Dep::REQUIRES_e: return requires(); break;
207 case Dep::CONFLICTS_e: return conflicts(); break;
208 case Dep::OBSOLETES_e: return obsoletes(); break;
209 case Dep::RECOMMENDS_e: return recommends(); break;
210 case Dep::SUGGESTS_e: return suggests(); break;
211 case Dep::ENHANCES_e: return enhances(); break;
212 case Dep::SUPPLEMENTS_e: return supplements(); break;
213 case Dep::PREREQUIRES_e: return prerequires(); break;
214 }
215 return Capabilities();
216 }
218 Capabilities operator[]( Dep which_r ) const
219 { return dep( which_r ); }
220
221
223 CapabilitySet providesNamespace( const std::string & namespace_r ) const;
224
232 CapabilitySet valuesOfNamespace( const std::string & namespace_r ) const;
234
235 std::pair<bool, CapabilitySet> matchesSolvable ( const SolvAttr &attr, const sat::Solvable &solv ) const;
236
237 public:
241 bool supportsLocales() const;
243 bool supportsLocale( const Locale & locale_r ) const;
245 bool supportsLocale( const LocaleSet & locales_r ) const;
249 bool supportsRequestedLocales() const;
253 void getSupportedLocales( LocaleSet & locales_r ) const
254 { locales_r = getSupportedLocales(); }
256
257 public:
259 CpeId cpeId() const;
260
262 unsigned mediaNr() const;
263
285 ByteCount installSize() const;
286
288 ByteCount downloadSize() const;
289
291 std::string distribution() const;
292
294 std::string summary( const Locale & lang_r = Locale() ) const;
295
297 std::string description( const Locale & lang_r = Locale() ) const;
298
300 std::string insnotify( const Locale & lang_r = Locale() ) const;
302 std::string delnotify( const Locale & lang_r = Locale() ) const;
303
305 std::string licenseToConfirm( const Locale & lang_r = Locale() ) const;
307 bool needToAcceptLicense() const;
308
309 public:
316 {
317 public:
319 SplitIdent( IdString ident_r );
320 SplitIdent( const char * ident_r );
321 SplitIdent( const std::string & ident_r );
322 SplitIdent( ResKind kind_r, IdString name_r );
323 SplitIdent( ResKind kind_r, const C_Str & name_r );
324
325 IdString ident() const { return _ident; }
326 ResKind kind() const { return _kind; }
327 IdString name() const { return _name; }
328
329 private:
333 };
334
335 public:
345 std::string lookupStrAttribute( const SolvAttr & attr ) const;
356 std::string lookupStrAttribute( const SolvAttr & attr, const Locale & lang_r ) const;
357
362 unsigned long long lookupNumAttribute( const SolvAttr & attr ) const;
364 unsigned long long lookupNumAttribute( const SolvAttr & attr, unsigned long long notfound_r ) const;
365
370 bool lookupBoolAttribute( const SolvAttr & attr ) const;
371
377
383
390
391 public:
393 Solvable nextInPool() const;
395 Solvable nextInRepo() const;
397 detail::CSolvable * get() const;
399 IdType id() const { return _id; }
400
401 private:
403 };
405
407 std::ostream & operator<<( std::ostream & str, const Solvable & obj );
408
410 std::ostream & dumpOn( std::ostream & str, const Solvable & obj );
411
413 std::ostream & dumpAsXmlOn( std::ostream & str, const Solvable & obj );
414
416 inline bool operator==( const Solvable & lhs, const Solvable & rhs )
417 { return lhs.get() == rhs.get(); }
418
420 inline bool operator!=( const Solvable & lhs, const Solvable & rhs )
421 { return lhs.get() != rhs.get(); }
422
424 inline bool operator<( const Solvable & lhs, const Solvable & rhs )
425 { return lhs.get() < rhs.get(); }
426
428 template<class TRes>
429 inline bool isKind( const Solvable & solvable_r )
430 { return solvable_r.isKind( ResTraits<TRes>::kind ); }
431
433 inline bool identical( const Solvable & lhs, const Solvable & rhs )
434 { return lhs.identical( rhs ); }
435
437 inline bool sameNVRA( const Solvable & lhs, const Solvable & rhs )
438 { return lhs.sameNVRA( rhs ); }
439
440
442 inline int compareByN( const Solvable & lhs, const Solvable & rhs )
443 {
444 int res = 0;
445 if ( lhs != rhs )
446 {
447 if ( (res = lhs.kind().compare( rhs.kind() )) == 0 )
448 res = lhs.name().compare( rhs.name() );
449 }
450 return res;
451 }
452
454 inline int compareByNVR( const Solvable & lhs, const Solvable & rhs )
455 {
456 int res = compareByN( lhs, rhs );
457 if ( res == 0 )
458 res = lhs.edition().compare( rhs.edition() );
459 return res;
460 }
461
463 inline int compareByNVRA( const Solvable & lhs, const Solvable & rhs )
464 {
465 int res = compareByNVR( lhs, rhs );
466 if ( res == 0 )
467 res = lhs.arch().compare( rhs.arch() );
468 return res;
469 }
470
472 namespace detail
473 {
475 //
476 // CLASS NAME : SolvableIterator
477 //
479 class SolvableIterator : public boost::iterator_adaptor<
480 SolvableIterator // Derived
481 , CSolvable* // Base
482 , const Solvable // Value
483 , boost::forward_traversal_tag // CategoryOrTraversal
484 , const Solvable // Reference
485 >
486 {
487 public:
489 : SolvableIterator::iterator_adaptor_( 0 )
490 {}
491
492 explicit SolvableIterator( const Solvable & val_r )
493 : SolvableIterator::iterator_adaptor_( 0 )
494 { assignVal( val_r ); }
495
497 : SolvableIterator::iterator_adaptor_( 0 )
498 { assignVal( Solvable( id_r ) ); }
499
500 private:
502
504 { return _val; }
505
507 { assignVal( _val.nextInPool() ); }
508
509 private:
510 void assignVal( const Solvable & val_r )
511 { _val = val_r; base_reference() = _val.get(); }
512
514 };
515 } // namespace detail
517 } // namespace sat
519
520 class PoolItem;
522 namespace sat
523 {
529 {
531
532 Solvable operator()( const Solvable & solv_r ) const
533 { return solv_r; }
534
535 Solvable operator()( const PoolItem & pi_r ) const;
536
537 Solvable operator()( const ResObject_constPtr & res_r ) const;
538 };
539 } // namespace sat
541} // namespace zypp
543
545
546#endif // ZYPP_SAT_SOLVABLE_H
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:28
sat::SolvAttr attr
Definition: PoolQuery.cc:311
ZYPP_DEFINE_ID_HASHABLE(::zypp::sat::Solvable)
Architecture.
Definition: Arch.h:37
int compare(const Arch &rhs) const
Arch comparison.
Definition: Arch.cc:546
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).
Definition: Capabilities.h:36
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)
Definition: IdStringType.h:127
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:316
A Solvable object within the sat Pool.
Definition: Solvable.h:54
Capabilities suggests() const
Definition: Solvable.cc:494
IdType id() const
Expert backdoor.
Definition: Solvable.h:399
bool isKind(const Solvable &solvable_r)
Test whether a Solvable is of a certain Kind.
Definition: Solvable.h:429
bool isNeedreboot() const
Whether this solvable triggers the reboot-needed hint if installed/updated.
Definition: Solvable.cc:393
bool identIsAutoInstalled() const
Whether an installed solvable with the same ident is flagged as AutoInstalled.
Definition: Solvable.h:137
OnMediaLocation lookupLocation() const
returns OnMediaLocation data: This is everything we need to download e.g.
Definition: Solvable.cc:223
bool isKind(TIterator begin, TIterator end) const
Definition: Solvable.h:101
Capabilities dep(Dep which_r) const
Return Capabilities selected by Dep constant.
Definition: Solvable.h:201
bool identical(const Solvable &lhs, const Solvable &rhs)
Test for same content.
Definition: Solvable.h:433
bool lookupBoolAttribute(const SolvAttr &attr) const
returns the boolean attribute value for attr or false if it does not exists.
Definition: Solvable.cc:169
int compareByNVR(const Solvable &lhs, const Solvable &rhs)
Compare according to kind, name and edition.
Definition: Solvable.h:454
IdString vendor() const
The vendor.
Definition: Solvable.cc:356
void getSupportedLocales(LocaleSet &locales_r) const
Definition: Solvable.h:253
ByteCount installSize() const
Installed (unpacked) size.
Definition: Solvable.cc:688
Date buildtime() const
The items build time.
Definition: Solvable.cc:421
bool needToAcceptLicense() const
True except for well known exceptions (i.e show license but no need to accept it).
Definition: Solvable.cc:747
ResKind kind() const
The Solvables ResKind.
Definition: Solvable.cc:274
CapabilitySet providesNamespace(const std::string &namespace_r) const
Return the namespaced provides 'namespace([value])[ op edition]' of this Solvable.
Definition: Solvable.cc:518
static const Solvable noSolvable
Represents no Solvable.
Definition: Solvable.h:74
std::string asString() const
String representation "ident-edition.arch" or "noSolvable".
Definition: Solvable.cc:433
std::string distribution() const
The distribution string.
Definition: Solvable.cc:700
unsigned mediaNr() const
Media number the solvable is located on (0 if no media access required).
Definition: Solvable.cc:675
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:157
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:129
bool multiversionInstall() const
Whether different versions of this package can be installed at the same time.
Definition: Solvable.cc:415
int compareByN(const Solvable &lhs, const Solvable &rhs)
Compare according to kind and name.
Definition: Solvable.h:442
CpeId cpeId() const
The solvables CpeId if available.
Definition: Solvable.cc:669
Solvable nextInRepo() const
Return next Solvable in Repo (or noSolvable).
Definition: Solvable.cc:115
Capabilities operator[](Dep which_r) const
Definition: Solvable.h:218
Date installtime() const
The items install time (false if not installed).
Definition: Solvable.cc:427
Edition edition() const
The edition (version-release).
Definition: Solvable.cc:336
bool sameNVRA(const Solvable &rhs) const
Test for same name-version-release.arch.
Definition: Solvable.h:181
Capabilities prerequires() const
Definition: Solvable.cc:509
Solvable()
Default ctor creates noSolvable.
Definition: Solvable.h:63
Capabilities enhances() const
Definition: Solvable.cc:499
LocaleSet getSupportedLocales() const
Return the supported locales.
Definition: Solvable.cc:662
bool supportsRequestedLocales() const
Whether this Solvable supports at least one requested locale.
Definition: Solvable.cc:659
Solvable(IdType id_r)
PoolImpl ctor.
Definition: Solvable.h:68
bool operator==(const Solvable &lhs, const Solvable &rhs)
Definition: Solvable.h:416
detail::CSolvable * get() const
Expert backdoor.
Definition: Solvable.cc:105
Arch arch() const
The architecture.
Definition: Solvable.cc:342
bool isSystem() const
Return whether this Solvable belongs to the system repo.
Definition: Solvable.cc:372
Solvable nextInPool() const
Return next Solvable in Pool (or noSolvable).
Definition: Solvable.cc:112
std::string licenseToConfirm(const Locale &lang_r=Locale()) const
License or agreement to accept before installing the solvable (opt.
Definition: Solvable.cc:730
bool operator!=(const Solvable &lhs, const Solvable &rhs)
Definition: Solvable.h:420
bool supportsLocales() const
Whether this Solvable claims to support locales.
Definition: Solvable.cc:639
Capabilities provides() const
Definition: Solvable.cc:469
std::string asUserString() const
String representation "ident-edition.arch(repo)" or "noSolvable".
Definition: Solvable.cc:442
static const IdString ptfToken
Indicator provides ptf()
Definition: Solvable.h:59
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:437
std::string summary(const Locale &lang_r=Locale()) const
Short (singleline) text describing the solvable (opt.
Definition: Solvable.cc:706
Capabilities conflicts() const
Definition: Solvable.cc:479
Capabilities obsoletes() const
Definition: Solvable.cc:484
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:175
std::pair< bool, CapabilitySet > matchesSolvable(const SolvAttr &attr, const sat::Solvable &solv) const
Definition: Solvable.cc:550
std::string name() const
The name (without any ResKind prefix).
Definition: Solvable.cc:328
sat::detail::SolvableIdType IdType
Definition: Solvable.h:56
bool supportsLocale(const Locale &locale_r) const
Whether this Solvable supports a specific Locale.
Definition: Solvable.cc:645
Capabilities supplements() const
Definition: Solvable.cc:504
ByteCount downloadSize() const
Download size.
Definition: Solvable.cc:694
bool isKind(const ResKind &kind_r) const
Test whether a Solvable is of a certain ResKind.
Definition: Solvable.cc:301
bool operator<(const Solvable &lhs, const Solvable &rhs)
Definition: Solvable.h:424
bool onSystemByAuto() const
Whether this is known to be automatically installed (as dependency of a user request package).
Definition: Solvable.cc:383
std::string delnotify(const Locale &lang_r=Locale()) const
UI hint text when selecting the solvable for uninstall (opt.
Definition: Solvable.cc:724
CapabilitySet valuesOfNamespace(const std::string &namespace_r) const
Return 'value[ op edition]' for namespaced provides 'namespace(value)[ op edition]'.
Definition: Solvable.cc:532
IdString ident() const
The identifier.
Definition: Solvable.cc:268
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:181
std::string description(const Locale &lang_r=Locale()) const
Long (multiline) text describing the solvable (opt.
Definition: Solvable.cc:712
bool onSystemByUser() const
Whether this is known to be installed on behalf of a user request.
Definition: Solvable.cc:378
Capabilities recommends() const
Definition: Solvable.cc:489
int compareByNVRA(const Solvable &lhs, const Solvable &rhs)
Compare according to kind, name, edition and arch.
Definition: Solvable.h:463
RepoInfo repoInfo() const
The repositories RepoInfo.
Definition: Solvable.cc:368
Repository repository() const
The Repository this Solvable belongs to.
Definition: Solvable.cc:362
bool isPtf() const
Whether this solvable is a PTF (provides ptfToken).
Definition: Solvable.cc:409
bool isRetracted() const
Whether this solvable is retracted (provides retractedToken).
Definition: Solvable.cc:399
bool isKind() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: Solvable.h:97
std::string insnotify(const Locale &lang_r=Locale()) const
UI hint text when selecting the solvable for install (opt.
Definition: Solvable.cc:718
bool identical(const Solvable &rhs) const
Test whether two Solvables have the same content.
Definition: Solvable.cc:452
SolvableIterator(SolvableIdType id_r)
Definition: Solvable.h:496
void assignVal(const Solvable &val_r)
Definition: Solvable.h:510
SolvableIterator(const Solvable &val_r)
Definition: Solvable.h:492
friend class boost::iterator_core_access
Definition: Solvable.h:501
String related utilities and Regular expression matching.
static const SolvableIdType noSolvableId(0)
Id to denote Solvable::noSolvable.
int IdType
Generic Id type.
Definition: PoolMember.h:104
::s_Solvable CSolvable
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:64
unsigned SolvableIdType
Id type to connect Solvable and sat-solvable.
Definition: PoolMember.h:125
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...
Definition: SolvableType.h:256
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...
Definition: SolvableType.h:242
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
std::unordered_set< Capability > CapabilitySet
Definition: Capability.h:35
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:28
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:529
Solvable operator()(const Solvable &solv_r) const
Definition: Solvable.h:532
Solvable result_type
Definition: Solvable.h:530
Backlink to the associated PoolImpl.
Definition: PoolMember.h:89