libzypp  16.15.6
SolvableType.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
11 #ifndef ZYPP_SAT_SOLVABLETYPE_H
12 #define ZYPP_SAT_SOLVABLETYPE_H
13 
14 #include <iosfwd>
15 
16 #include "zypp/sat/Solvable.h"
17 #include "zypp/Repository.h"
18 #include "zypp/OnMediaLocation.h"
19 #include "zypp/ByteCount.h"
20 #include "zypp/CheckSum.h"
21 #include "zypp/CpeId.h"
22 #include "zypp/Date.h"
23 
25 namespace zypp
26 {
28  namespace sat
29  {
53  template <class Derived>
54  struct SolvableType
55  {
57  Solvable satSolvable() const { return Solvable(static_cast<const Derived&>(*this)); }
58 
59  explicit operator bool() const { return bool(satSolvable()); }
60 
61  IdString ident() const { return satSolvable().ident(); }
62 
63  ResKind kind() const { return satSolvable().kind(); }
64  bool isKind( const ResKind & kind_r ) const { return satSolvable().isKind( kind_r ); }
65  template<class TRes>
66  bool isKind() const { return satSolvable().template isKind<TRes>(); }
67  template<class TIterator>
68  bool isKind( TIterator begin, TIterator end ) const { return satSolvable().isKind( begin, end ); }
69 
70  std::string name() const { return satSolvable().name(); }
71  Edition edition() const { return satSolvable().edition(); }
72  Arch arch() const { return satSolvable().arch(); }
73  IdString vendor() const { return satSolvable().vendor(); }
74 
75  Repository repository() const { return satSolvable().repository(); }
76  RepoInfo repoInfo() const { return satSolvable().repoInfo(); }
77 
78  bool isSystem() const { return satSolvable().isSystem(); }
79  bool onSystemByUser() const { return satSolvable().onSystemByUser(); }
80  bool onSystemByAuto() const { return satSolvable().onSystemByAuto(); }
83 
84  Date buildtime() const { return satSolvable().buildtime(); }
85  Date installtime() const { return satSolvable().installtime(); }
86 
87  std::string asString() const { return satSolvable().asString(); }
88  std::string asUserString() const { return satSolvable().asUserString(); }
89 
90  bool identical( const Solvable & rhs ) const { return satSolvable().identical( rhs ); }
91  template <class RDerived>
92  bool identical( const SolvableType<RDerived> & rhs ) const { return satSolvable().identical( rhs.satSolvable() ); }
93 
94  bool sameNVRA( const Solvable &rhs ) const { return satSolvable().sameNVRA( rhs ); }
95  template <class RDerived>
96  bool sameNVRA( const SolvableType<RDerived> & rhs ) const { return satSolvable().sameNVRA( rhs.satSolvable() ); }
97 
98  Capabilities provides() const { return satSolvable().provides(); }
99  Capabilities requires() const { return satSolvable().requires(); }
100  Capabilities conflicts() const { return satSolvable().conflicts(); }
101  Capabilities obsoletes() const { return satSolvable().obsoletes(); }
103  Capabilities suggests() const { return satSolvable().suggests(); }
104  Capabilities enhances() const { return satSolvable().enhances(); }
107  Capabilities dep( Dep which_r ) const { return satSolvable().dep(which_r); }
108  Capabilities operator[]( Dep which_r ) const { return satSolvable()[which_r]; }
109 
110  CapabilitySet providesNamespace( const std::string & namespace_r ) const { return satSolvable().providesNamespace( namespace_r ); }
111  CapabilitySet valuesOfNamespace( const std::string & namespace_r ) const { return satSolvable().valuesOfNamespace( namespace_r ); }
112 
113  bool supportsLocales() const { return satSolvable().supportsLocales(); }
114  bool supportsLocale( const Locale & locale_r ) const { return satSolvable().supportsLocale( locale_r ); }
115  bool supportsLocale( const LocaleSet & locales_r ) const { return satSolvable().supportsLocale( locales_r ); }
118 
119  CpeId cpeId() const { return satSolvable().cpeId(); }
120  unsigned mediaNr() const { return satSolvable().mediaNr(); }
123  std::string distribution() const { return satSolvable().distribution(); }
124 
125  std::string summary( const Locale & lang_r = Locale() ) const { return satSolvable().summary( lang_r ); }
126  std::string description( const Locale & lang_r = Locale() ) const { return satSolvable().description( lang_r ); }
127  std::string insnotify( const Locale & lang_r = Locale() ) const { return satSolvable().insnotify( lang_r ); }
128  std::string delnotify( const Locale & lang_r = Locale() ) const { return satSolvable().delnotify( lang_r ); }
129  std::string licenseToConfirm( const Locale & lang_r = Locale() ) const { return satSolvable().licenseToConfirm( lang_r ); }
131 
132  public:
133  std::string lookupStrAttribute( const SolvAttr & attr ) const { return satSolvable().lookupStrAttribute( attr ); }
134  std::string lookupStrAttribute( const SolvAttr & attr, const Locale & lang_r ) const { return satSolvable().lookupStrAttribute( attr, lang_r ); }
135  bool lookupBoolAttribute( const SolvAttr & attr ) const { return satSolvable().lookupBoolAttribute( attr ); }
137  unsigned long long lookupNumAttribute( const SolvAttr & attr ) const { return satSolvable().lookupNumAttribute( attr ); }
138  unsigned long long lookupNumAttribute( const SolvAttr & attr, unsigned long long notfound_r ) const { return satSolvable().lookupNumAttribute( attr, notfound_r ); }
141  Solvable::IdType id() const { return satSolvable().id(); }
142 
143  protected:
146  void operator=( const SolvableType & ) {}
147 #ifndef SWIG
149  void operator=( SolvableType && ) {}
150 #endif
152  };
153 
155  template <class Derived>
156  inline std::ostream & operator<<( std::ostream & str, const SolvableType<Derived> & obj )
157  { return str << obj.satSolvable(); }
158 
160  template <class Derived>
161  inline std::ostream & dumpOn( std::ostream & str, const SolvableType<Derived> & obj )
162  { return dumpOn( str, obj.satSolvable() ); }
163 
165  template <class LDerived, class RDerived>
166  inline bool operator==( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
167  { return lhs.satSolvable() == rhs.satSolvable(); }
169  template <class Derived>
170  inline bool operator==( const SolvableType<Derived> & lhs, const Solvable & rhs )
171  { return lhs.satSolvable() == rhs; }
173  template <class Derived>
174  inline bool operator==( const Solvable & lhs, const SolvableType<Derived> & rhs )
175  { return lhs == rhs.satSolvable(); }
176 
178  template <class LDerived, class RDerived>
179  inline bool operator!=( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
180  { return lhs.satSolvable() != rhs.satSolvable(); }
182  template <class Derived>
183  inline bool operator!=( const SolvableType<Derived> & lhs, const Solvable & rhs )
184  { return lhs.satSolvable() != rhs; }
186  template <class Derived>
187  inline bool operator!=( const Solvable & lhs, const SolvableType<Derived> & rhs )
188  { return lhs != rhs.satSolvable(); }
189 
191  template <class LDerived, class RDerived>
192  inline bool operator<( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
193  { return lhs.satSolvable() < rhs.satSolvable(); }
195  template <class Derived>
196  inline bool operator<( const SolvableType<Derived> & lhs, const Solvable & rhs )
197  { return lhs.satSolvable() < rhs; }
199  template <class Derived>
200  inline bool operator<( const Solvable & lhs, const SolvableType<Derived> & rhs )
201  { return lhs < rhs.satSolvable(); }
202 
204  template<class TRes, class Derived>
205  inline bool isKind( const SolvableType<Derived> & solvable_r )
206  { return isKind<TRes>( solvable_r.satSolvable() ); }
207 
209  template <class LDerived, class RDerived>
210  inline bool identical( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
211  { return identical( lhs.satSolvable(), rhs.satSolvable() ); }
213  template <class Derived>
214  inline bool identical( const SolvableType<Derived> & lhs, const Solvable & rhs )
215  { return identical( lhs.satSolvable(), rhs ); }
217  template <class Derived>
218  inline bool identical( const Solvable & lhs, const SolvableType<Derived> & rhs )
219  { return identical( lhs, rhs.satSolvable() ); }
220 
222  template <class LDerived, class RDerived>
223  inline bool sameNVRA( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
224  { return sameNVRA( lhs.satSolvable(), rhs.satSolvable() ); }
226  template <class Derived>
227  inline bool sameNVRA( const SolvableType<Derived> & lhs, const Solvable & rhs )
228  { return sameNVRA( lhs.satSolvable(), rhs ); }
230  template <class Derived>
231  inline bool sameNVRA( const Solvable & lhs, const SolvableType<Derived> & rhs )
232  { return sameNVRA( lhs, rhs.satSolvable() ); }
233 
234 
236  template <class LDerived, class RDerived>
237  inline int compareByN( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
238  { return compareByN( lhs.satSolvable(), rhs.satSolvable() ); }
240  template <class Derived>
241  inline bool compareByN( const SolvableType<Derived> & lhs, const Solvable & rhs )
242  { return compareByN( lhs.satSolvable(), rhs ); }
244  template <class Derived>
245  inline bool compareByN( const Solvable & lhs, const SolvableType<Derived> & rhs )
246  { return compareByN( lhs, rhs.satSolvable() ); }
247 
248 
250  template <class LDerived, class RDerived>
251  inline int compareByNVR( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
252  { return compareByNVR( lhs.satSolvable(), rhs.satSolvable() ); }
254  template <class Derived>
255  inline bool compareByNVR( const SolvableType<Derived> & lhs, const Solvable & rhs )
256  { return compareByNVR( lhs.satSolvable(), rhs ); }
258  template <class Derived>
259  inline bool compareByNVR( const Solvable & lhs, const SolvableType<Derived> & rhs )
260  { return compareByNVR( lhs, rhs.satSolvable() ); }
261 
263  template <class LDerived, class RDerived>
264  inline int compareByNVRA( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
265  { return compareByNVRA( lhs.satSolvable(), rhs.satSolvable() ); }
267  template <class Derived>
268  inline bool compareByNVRA( const SolvableType<Derived> & lhs, const Solvable & rhs )
269  { return compareByNVRA( lhs.satSolvable(), rhs ); }
271  template <class Derived>
272  inline bool compareByNVRA( const Solvable & lhs, const SolvableType<Derived> & rhs )
273  { return compareByNVRA( lhs, rhs.satSolvable() ); }
274 
275  } // namespace sat
277 } // namespace zypp
279 #endif // ZYPP_SAT_SOLVABLETYPE_H
Repository repository() const
The Repository this Solvable belongs to.
Definition: Solvable.cc:359
bool needToAcceptLicense() const
True except for well known exceptions (i.e show license but no need to accept it).
Definition: Solvable.cc:699
std::ostream & dumpOn(std::ostream &str, const SolvableType< Derived > &obj)
Definition: SolvableType.h:161
Capabilities recommends() const
Definition: SolvableType.h:102
int IdType
Generic Id type.
Definition: PoolMember.h:104
Solvable::IdType id() const
Definition: SolvableType.h:141
A Solvable object within the sat Pool.
Definition: Solvable.h:53
Arch arch() const
The architecture.
Definition: Solvable.cc:339
Capabilities recommends() const
Definition: Solvable.cc:464
CapabilitySet providesNamespace(const std::string &namespace_r) const
Return the namespaced provides &#39;namespace([value])[ op edition]&#39; of this Solvable.
Definition: Solvable.cc:493
CapabilitySet providesNamespace(const std::string &namespace_r) const
Definition: SolvableType.h:110
Container of Capability (currently read only).
Definition: Capabilities.h:35
Date buildtime() const
The items build time.
Definition: Solvable.cc:396
unsigned long long lookupNumAttribute(const SolvAttr &attr, unsigned long long notfound_r) const
Definition: SolvableType.h:138
IdString ident() const
The identifier.
Definition: Solvable.cc:265
Describes a path on a certain media amongs as the information required to download it...
Date buildtime() const
Definition: SolvableType.h:84
LocaleSet getSupportedLocales() const
Definition: SolvableType.h:117
Enumeration class of dependency types.
Definition: Dep.h:29
std::string lookupStrAttribute(const SolvAttr &attr) const
Definition: SolvableType.h:133
Architecture.
Definition: Arch.h:36
bool supportsLocale(const Locale &locale_r) const
Whether this Solvable supports a specific Locale.
Definition: Solvable.cc:608
detail::IdType lookupIdAttribute(const SolvAttr &attr) const
Definition: SolvableType.h:136
Store and operate with byte count.
Definition: ByteCount.h:30
unsigned mediaNr() const
Definition: SolvableType.h:120
bool identical(const Solvable &rhs) const
Definition: SolvableType.h:90
bool supportsLocales() const
Definition: SolvableType.h:113
sat::SolvAttr attr
Definition: PoolQuery.cc:314
bool supportsLocales() const
Whether this Solvable claims to support locales.
Definition: Solvable.cc:602
Capabilities supplements() const
Definition: Solvable.cc:479
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:126
int compareByN(const SolvableType< LDerived > &lhs, const SolvableType< RDerived > &rhs)
Definition: SolvableType.h:237
std::string asString() const
String representation "ident-edition.arch" or "noSolvable".
Definition: Solvable.cc:408
bool isSystem() const
Return whether this Solvable belongs to the system repo.
Definition: Solvable.cc:369
String related utilities and Regular expression matching.
Capabilities suggests() const
Definition: Solvable.cc:469
ByteCount downloadSize() const
Download size.
Definition: Solvable.cc:650
int compareByNVR(const SolvableType< LDerived > &lhs, const SolvableType< RDerived > &rhs)
Definition: SolvableType.h:251
What is known about a repository.
Definition: RepoInfo.h:71
bool identIsAutoInstalled() const
Definition: SolvableType.h:81
std::string insnotify(const Locale &lang_r=Locale()) const
UI hint text when selecting the solvable for install (opt.
Definition: Solvable.cc:674
Access to the sat-pools string space.
Definition: IdString.h:41
Capabilities prerequires() const
Definition: SolvableType.h:106
Common Platform Enumearation (2.3) See http://cpe.mitre.org/ for more information on the Common Platf...
Definition: CpeId.h:31
Capabilities requires() const
Definition: SolvableType.h:99
void operator=(SolvableType &&)
Definition: SolvableType.h:149
Edition represents [epoch:]version[-release]
Definition: Edition.h:60
Capabilities suggests() const
Definition: SolvableType.h:103
bool sameNVRA(const Solvable &rhs) const
Definition: SolvableType.h:94
CapabilitySet valuesOfNamespace(const std::string &namespace_r) const
Return &#39;value[ op edition]&#39; for namespaced provides &#39;namespace(value)[ op edition]&#39;.
Definition: Solvable.cc:507
bool identIsAutoInstalled() const
Whether an installed solvable with the same ident is flagged as AutoInstalled.
Definition: Solvable.h:134
Capabilities dep(Dep which_r) const
Definition: SolvableType.h:107
bool isKind(const ResKind &kind_r) const
Definition: SolvableType.h:64
std::string asUserString() const
String representation "ident-edition.arch(repo)" or "noSolvable".
Definition: Solvable.cc:417
std::string licenseToConfirm(const Locale &lang_r=Locale()) const
License or agreement to accept before installing the solvable (opt.
Definition: Solvable.cc:686
bool multiversionInstall() const
Definition: SolvableType.h:82
Capabilities provides() const
Definition: Solvable.cc:444
Capabilities operator[](Dep which_r) const
Definition: SolvableType.h:108
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:172
IdString vendor() const
Definition: SolvableType.h:73
bool identical(const SolvableType< RDerived > &rhs) const
Definition: SolvableType.h:92
Repository repository() const
Definition: SolvableType.h:75
Capabilities supplements() const
Definition: SolvableType.h:105
std::string name() const
The name (without any ResKind prefix).
Definition: Solvable.cc:325
CapabilitySet valuesOfNamespace(const std::string &namespace_r) const
Definition: SolvableType.h:111
ResKind kind() const
Definition: SolvableType.h:63
Store and operate on date (time_t).
Definition: Date.h:32
Solvable attribute keys.
Definition: SolvAttr.h:40
RepoInfo repoInfo() const
The repositories RepoInfo.
Definition: Solvable.cc:365
OnMediaLocation lookupLocation() const
returns OnMediaLocation data: This is everything we need to download e.g.
Definition: Solvable.cc:220
Capabilities enhances() const
Definition: SolvableType.h:104
bool identical(const SolvableType< LDerived > &lhs, const SolvableType< RDerived > &rhs)
Definition: SolvableType.h:210
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:178
bool sameNVRA(const Solvable &rhs) const
Test for same name-version-release.arch.
Definition: Solvable.h:169
bool sameNVRA(const SolvableType< LDerived > &lhs, const SolvableType< RDerived > &rhs)
Definition: SolvableType.h:223
unsigned mediaNr() const
Media number the solvable is located on (0 if no media access required).
Definition: Solvable.cc:638
bool operator==(const SolvableType< LDerived > &lhs, const SolvableType< RDerived > &rhs)
Definition: SolvableType.h:166
std::string description(const Locale &lang_r=Locale()) const
Long (multiline) text describing the solvable (opt.
Definition: Solvable.cc:668
bool supportsRequestedLocales() const
Whether this Solvable supports at least one requested locale.
Definition: Solvable.cc:622
bool lookupBoolAttribute(const SolvAttr &attr) const
returns the boolean attribute value for attr or false if it does not exists.
Definition: Solvable.cc:166
std::string description(const Locale &lang_r=Locale()) const
Definition: SolvableType.h:126
SolvableType(const SolvableType &)
Definition: SolvableType.h:145
bool onSystemByUser() const
Whether this is known to be installed on behalf of a user request.
Definition: Solvable.cc:375
OnMediaLocation lookupLocation() const
Definition: SolvableType.h:140
void operator=(const SolvableType &)
Definition: SolvableType.h:146
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:154
LocaleSet getSupportedLocales() const
Return the supported locales.
Definition: Solvable.cc:625
Date installtime() const
The items install time (false if not installed).
Definition: Solvable.cc:402
bool identical(const Solvable &rhs) const
Test whether two Solvables have the same content.
Definition: Solvable.cc:427
std::string distribution() const
Definition: SolvableType.h:123
int compareByNVRA(const SolvableType< LDerived > &lhs, const SolvableType< RDerived > &rhs)
Definition: SolvableType.h:264
std::string lookupStrAttribute(const SolvAttr &attr, const Locale &lang_r) const
Definition: SolvableType.h:134
CpeId cpeId() const
Definition: SolvableType.h:119
Capabilities dep(Dep which_r) const
Return Capabilities selected by Dep constant.
Definition: Solvable.h:189
std::string delnotify(const Locale &lang_r=Locale()) const
Definition: SolvableType.h:128
Capabilities obsoletes() const
Definition: SolvableType.h:101
bool onSystemByAuto() const
Definition: SolvableType.h:80
ByteCount downloadSize() const
Definition: SolvableType.h:122
bool isKind() const
Definition: SolvableType.h:66
bool isSystem() const
Definition: SolvableType.h:78
std::string name() const
Definition: SolvableType.h:70
bool needToAcceptLicense() const
Definition: SolvableType.h:130
bool sameNVRA(const SolvableType< RDerived > &rhs) const
Definition: SolvableType.h:96
bool operator!=(const SolvableType< LDerived > &lhs, const SolvableType< RDerived > &rhs)
Definition: SolvableType.h:179
Capabilities enhances() const
Definition: Solvable.cc:474
&#39;Language[_Country]&#39; codes.
Definition: Locale.h:49
std::unordered_set< Capability > CapabilitySet
Definition: Capability.h:33
IdString vendor() const
The vendor.
Definition: Solvable.cc:353
ResKind kind() const
The Solvables ResKind.
Definition: Solvable.cc:271
Capabilities conflicts() const
Definition: Solvable.cc:454
bool multiversionInstall() const
Whether different versions of this package can be installed at the same time.
Definition: Solvable.cc:390
bool onSystemByUser() const
Definition: SolvableType.h:79
Capabilities prerequires() const
Definition: Solvable.cc:484
Capabilities conflicts() const
Definition: SolvableType.h:100
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57
std::string summary(const Locale &lang_r=Locale()) const
Short (singleline) text describing the solvable (opt.
Definition: Solvable.cc:662
std::string delnotify(const Locale &lang_r=Locale()) const
UI hint text when selecting the solvable for uninstall (opt.
Definition: Solvable.cc:680
bool lookupBoolAttribute(const SolvAttr &attr) const
Definition: SolvableType.h:135
SolvableType(SolvableType &&)
Definition: SolvableType.h:148
bool supportsLocale(const Locale &locale_r) const
Definition: SolvableType.h:114
ByteCount installSize() const
Installed (unpacked) size.
Definition: Solvable.cc:644
Capabilities requires() const
Definition: Solvable.cc:449
IdString ident() const
Definition: SolvableType.h:61
bool supportsRequestedLocales() const
Definition: SolvableType.h:116
CpeId cpeId() const
The solvables CpeId if available.
Definition: Solvable.cc:632
bool isKind(const SolvableType< Derived > &solvable_r)
Definition: SolvableType.h:205
bool supportsLocale(const LocaleSet &locales_r) const
Definition: SolvableType.h:115
IdType id() const
Expert backdoor.
Definition: Solvable.h:385
Base class for creating Solvable based types.
Definition: SolvableType.h:54
std::string licenseToConfirm(const Locale &lang_r=Locale()) const
Definition: SolvableType.h:129
bool isKind(const ResKind &kind_r) const
Test whether a Solvable is of a certain ResKind.
Definition: Solvable.cc:298
Date installtime() const
Definition: SolvableType.h:85
CheckSum lookupCheckSumAttribute(const SolvAttr &attr) const
Definition: SolvableType.h:139
sat::detail::SolvableIdType IdType
Definition: Solvable.h:56
Capabilities provides() const
Definition: SolvableType.h:98
Resolvable kinds.
Definition: ResKind.h:32
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
std::string distribution() const
The distribution string.
Definition: Solvable.cc:656
unsigned long long lookupNumAttribute(const SolvAttr &attr) const
Definition: SolvableType.h:137
bool isKind(TIterator begin, TIterator end) const
Definition: SolvableType.h:68
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:27
ByteCount installSize() const
Definition: SolvableType.h:121
Edition edition() const
The edition (version-release).
Definition: Solvable.cc:333
std::string asString() const
Definition: SolvableType.h:87
Edition edition() const
Definition: SolvableType.h:71
bool onSystemByAuto() const
Whether this is known to be automatically installed (as dependency of a user request package)...
Definition: Solvable.cc:380
std::string asUserString() const
Definition: SolvableType.h:88
Capabilities obsoletes() const
Definition: Solvable.cc:459
std::string summary(const Locale &lang_r=Locale()) const
Definition: SolvableType.h:125
RepoInfo repoInfo() const
Definition: SolvableType.h:76
std::string insnotify(const Locale &lang_r=Locale()) const
Definition: SolvableType.h:127