libzypp 17.36.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 retractedToken;
59 static const IdString ptfMasterToken;
61
62 public:
66 {}
67
68 Solvable(const Solvable &) = default;
69 Solvable(Solvable &&) noexcept = default;
70 Solvable &operator=(const Solvable &) = default;
71 Solvable &operator=(Solvable &&) noexcept = default;
72
74 explicit Solvable( IdType id_r )
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>() ); }
105
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() ); }
145
146 static bool identIsAutoInstalled( const IdString & ident_r );
147
151 bool multiversionInstall() const;
152
154 bool isNeedreboot() const;
155
174
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 dep_provides() const;
225 Capabilities dep_requires() const;
226 Capabilities dep_conflicts() const;
227 Capabilities dep_obsoletes() const;
228 Capabilities dep_recommends() const;
229 Capabilities dep_suggests() const;
230 Capabilities dep_enhances() const;
231 Capabilities dep_supplements() const;
232 Capabilities prerequires() const;
233
234#if __cplusplus < 202002L
235 Capabilities provides() const ZYPP_DEPRECATED; // use dep_ prefixed version instead
236 Capabilities requires() const ZYPP_DEPRECATED; // use dep_ prefixed version instead
237 Capabilities conflicts() const ZYPP_DEPRECATED; // use dep_ prefixed version instead
238 Capabilities obsoletes() const ZYPP_DEPRECATED; // use dep_ prefixed version instead
239 Capabilities recommends() const ZYPP_DEPRECATED; // use dep_ prefixed version instead
240 Capabilities suggests() const ZYPP_DEPRECATED; // use dep_ prefixed version instead
241 Capabilities enhances() const ZYPP_DEPRECATED; // use dep_ prefixed version instead
242 Capabilities supplements() const ZYPP_DEPRECATED; // use dep_ prefixed version instead
243#endif
244
246 Capabilities dep( Dep which_r ) const
247 {
248 switch( which_r.inSwitch() )
249 {
250 case Dep::PROVIDES_e: return dep_provides(); break;
251 case Dep::REQUIRES_e: return dep_requires(); break;
252 case Dep::CONFLICTS_e: return dep_conflicts(); break;
253 case Dep::OBSOLETES_e: return dep_obsoletes(); break;
254 case Dep::RECOMMENDS_e: return dep_recommends(); break;
255 case Dep::SUGGESTS_e: return dep_suggests(); break;
256 case Dep::ENHANCES_e: return dep_enhances(); break;
257 case Dep::SUPPLEMENTS_e: return dep_supplements(); break;
258 case Dep::PREREQUIRES_e: return prerequires(); break;
259 }
260 return Capabilities();
261 }
262
263 Capabilities operator[]( Dep which_r ) const
264 { return dep( which_r ); }
265
266
268 CapabilitySet providesNamespace( const std::string & namespace_r ) const;
269
277 CapabilitySet valuesOfNamespace( const std::string & namespace_r ) const;
279
280 std::pair<bool, CapabilitySet> matchesSolvable ( const SolvAttr &attr, const sat::Solvable &solv ) const;
281
282 public:
285
286 bool supportsLocales() const;
288 bool supportsLocale( const Locale & locale_r ) const;
290 bool supportsLocale( const LocaleSet & locales_r ) const;
294 bool supportsRequestedLocales() const;
296 LocaleSet getSupportedLocales() const;
298 void getSupportedLocales( LocaleSet & locales_r ) const
299 { locales_r = getSupportedLocales(); }
300
301
302 public:
304 CpeId cpeId() const;
305
307 unsigned mediaNr() const;
308
330 ByteCount installSize() const;
331
333 ByteCount downloadSize() const;
334
336 std::string distribution() const;
337
339 std::string summary( const Locale & lang_r = Locale() ) const;
340
342 std::string description( const Locale & lang_r = Locale() ) const;
343
345 std::string insnotify( const Locale & lang_r = Locale() ) const;
347 std::string delnotify( const Locale & lang_r = Locale() ) const;
348
350 std::string licenseToConfirm( const Locale & lang_r = Locale() ) const;
352 bool needToAcceptLicense() const;
353
354 public:
361 {
362 public:
364 SplitIdent( IdString ident_r );
365 SplitIdent( const char * ident_r );
366 SplitIdent( const std::string & ident_r );
367 SplitIdent( ResKind kind_r, IdString name_r );
368 SplitIdent( ResKind kind_r, const C_Str & name_r );
369
370 IdString ident() const { return _ident; }
371 ResKind kind() const { return _kind; }
372 IdString name() const { return _name; }
373
374 private:
378 };
379
380 public:
386
390 std::string lookupStrAttribute( const SolvAttr & attr ) const;
401 std::string lookupStrAttribute( const SolvAttr & attr, const Locale & lang_r ) const;
402
407 unsigned long long lookupNumAttribute( const SolvAttr & attr ) const;
409 unsigned long long lookupNumAttribute( const SolvAttr & attr, unsigned long long notfound_r ) const;
410
415 bool lookupBoolAttribute( const SolvAttr & attr ) const;
416
421 detail::IdType lookupIdAttribute( const SolvAttr & attr ) const;
422
427 CheckSum lookupCheckSumAttribute( const SolvAttr & attr ) const;
428
435
436 public:
438 Solvable nextInPool() const;
440 Solvable nextInRepo() const;
442 detail::CSolvable * get() const;
444 IdType id() const { return _id; }
445
446 private:
448 };
449
450
452 std::ostream & operator<<( std::ostream & str, const Solvable & obj ) ZYPP_API;
453
455 std::ostream & dumpOn( std::ostream & str, const Solvable & obj ) ZYPP_API;
456
458 std::ostream & dumpAsXmlOn( std::ostream & str, const Solvable & obj ) ZYPP_API;
459
461 inline bool operator==( const Solvable & lhs, const Solvable & rhs )
462 { return lhs.get() == rhs.get(); }
463
465 inline bool operator!=( const Solvable & lhs, const Solvable & rhs )
466 { return lhs.get() != rhs.get(); }
467
469 inline bool operator<( const Solvable & lhs, const Solvable & rhs )
470 { return lhs.get() < rhs.get(); }
471
473 template<class TRes>
474 inline bool isKind( const Solvable & solvable_r )
475 { return solvable_r.isKind( ResTraits<TRes>::kind ); }
476
478 inline bool identical( const Solvable & lhs, const Solvable & rhs )
479 { return lhs.identical( rhs ); }
480
482 inline bool sameNVRA( const Solvable & lhs, const Solvable & rhs )
483 { return lhs.sameNVRA( rhs ); }
484
485
487 inline int compareByN( const Solvable & lhs, const Solvable & rhs )
488 {
489 int res = 0;
490 if ( lhs != rhs )
491 {
492 if ( (res = lhs.kind().compare( rhs.kind() )) == 0 )
493 res = lhs.name().compare( rhs.name() );
494 }
495 return res;
496 }
497
499 inline int compareByNVR( const Solvable & lhs, const Solvable & rhs )
500 {
501 int res = compareByN( lhs, rhs );
502 if ( res == 0 )
503 res = lhs.edition().compare( rhs.edition() );
504 return res;
505 }
506
508 inline int compareByNVRA( const Solvable & lhs, const Solvable & rhs )
509 {
510 int res = compareByNVR( lhs, rhs );
511 if ( res == 0 )
512 res = lhs.arch().compare( rhs.arch() );
513 return res;
514 }
515
517 namespace detail
518 {
525 class SolvableIterator : public boost::iterator_adaptor<
526 SolvableIterator // Derived
527 , CSolvable* // Base
528 , const Solvable // Value
529 , boost::forward_traversal_tag // CategoryOrTraversal
530 , const Solvable // Reference
531 >
532 {
533 public:
535 : SolvableIterator::iterator_adaptor_( nullptr )
536 {}
537
538 explicit SolvableIterator( const Solvable & val_r )
539 : SolvableIterator::iterator_adaptor_( nullptr )
540 { initialAssignVal( val_r ); }
541
543 : SolvableIterator::iterator_adaptor_( nullptr )
544 { initialAssignVal( Solvable(id_r) ); }
545
546 private:
548
550 { return _val; }
551
553 { assignVal( _val.nextInPool() ); }
554
555 private:
556 void initialAssignVal( const Solvable & val_r )
557 { assignVal( val_r ? val_r : val_r.nextInPool() ); }
558
559 void assignVal( const Solvable & val_r )
560 { _val = val_r; base_reference() = _val.get(); }
561
563 };
564 } // namespace detail
566 } // namespace sat
568
569 class PoolItem;
571 namespace sat
572 {
578 {
580
581 Solvable operator()( const Solvable & solv_r ) const
582 { return solv_r; }
583
584 Solvable operator()( const PoolItem & pi_r ) const;
585
586 Solvable operator()( const ResObject_constPtr & res_r ) const;
587 };
588 } // namespace sat
590} // namespace zypp
592
594
595#endif // ZYPP_SAT_SOLVABLE_H
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: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: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:361
A Solvable object within the sat Pool.
Definition Solvable.h:54
IdType id() const
Expert backdoor.
Definition Solvable.h:444
bool isKind(const Solvable &solvable_r)
Test whether a Solvable is of a certain Kind.
Definition Solvable.h:474
Capabilities supplements() const ZYPP_DEPRECATED
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_suggests() const
Definition Solvable.cc:510
Capabilities dep(Dep which_r) const
Return Capabilities selected by Dep constant.
Definition Solvable.h:246
bool identical(const Solvable &lhs, const Solvable &rhs)
Test for same content.
Definition Solvable.h:478
Capabilities dep_conflicts() const
Definition Solvable.cc:495
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:499
Capabilities recommends() const ZYPP_DEPRECATED
void getSupportedLocales(LocaleSet &locales_r) const
Definition Solvable.h:298
Capabilities const ZYPP_DEPRECATED
Definition Solvable.h:236
ResKind kind() const
The Solvables ResKind.
Definition Solvable.cc:276
static const Solvable noSolvable
Represents no Solvable.
Definition Solvable.h:80
Capabilities dep_supplements() const
Definition Solvable.cc:520
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:159
Capabilities dep_enhances() const
Definition Solvable.cc:515
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
Capabilities dep_recommends() const
Definition Solvable.cc:505
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:487
Solvable(Solvable &&) noexcept=default
Solvable nextInRepo() const
Return next Solvable in Repo (or noSolvable).
Definition Solvable.cc:117
Capabilities operator[](Dep which_r) const
Definition Solvable.h:263
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
Solvable()
Default ctor creates noSolvable.
Definition Solvable.h:64
Capabilities dep_obsoletes() const
Definition Solvable.cc:500
LocaleSet getSupportedLocales() const
Return the supported locales.
Definition Solvable.cc:692
bool operator==(const Solvable &lhs, const Solvable &rhs)
Definition Solvable.h:461
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
Solvable nextInPool() const
Return next Solvable in Pool (or noSolvable).
Definition Solvable.cc:114
bool operator!=(const Solvable &lhs, const Solvable &rhs)
Definition Solvable.h:465
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:482
Capabilities obsoletes() const ZYPP_DEPRECATED
Capabilities dep_provides() const
Definition Solvable.cc:485
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::string name() const
The name (without any ResKind prefix).
Definition Solvable.cc:330
Capabilities dep_requires() const
Definition Solvable.cc:490
bool isKind(const ResKind &kind_r) const
Test whether a Solvable is of a certain ResKind.
Definition Solvable.cc:303
bool operator<(const Solvable &lhs, const Solvable &rhs)
Definition Solvable.h:469
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
int compareByNVRA(const Solvable &lhs, const Solvable &rhs)
Compare according to kind, name, edition and arch.
Definition Solvable.h:508
Capabilities provides() const ZYPP_DEPRECATED
Capabilities enhances() 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:103
bool identical(const Solvable &rhs) const
Test whether two Solvables have the same content.
Definition Solvable.cc:468
void initialAssignVal(const Solvable &val_r)
Definition Solvable.h:556
SolvableIterator(SolvableIdType id_r)
Definition Solvable.h:542
void assignVal(const Solvable &val_r)
Definition Solvable.h:559
SolvableIterator(const Solvable &val_r)
Definition Solvable.h:538
friend class boost::iterator_core_access
Definition Solvable.h:547
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
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:578
Solvable operator()(const Solvable &solv_r) const
Definition Solvable.h:581
Backlink to the associated PoolImpl.
Definition PoolMember.h:89
#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