libzypp  15.28.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().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(); }
81 
82  Date buildtime() const { return satSolvable().buildtime(); }
83  Date installtime() const { return satSolvable().installtime(); }
84 
85  std::string asString() const { return satSolvable().asString(); }
86  std::string asUserString() const { return satSolvable().asUserString(); }
87 
88  bool identical( const Solvable & rhs ) const { return satSolvable().identical( rhs ); }
89  template <class RDerived>
90  bool identical( const SolvableType<RDerived> & rhs ) const { return satSolvable().identical( rhs.satSolvable() ); }
91 
92  bool sameNVRA( const Solvable &rhs ) const { return satSolvable().sameNVRA( rhs ); }
93  template <class RDerived>
94  bool sameNVRA( const SolvableType<RDerived> & rhs ) const { return satSolvable().sameNVRA( rhs.satSolvable() ); }
95 
96  Capabilities provides() const { return satSolvable().provides(); }
97  Capabilities requires() const { return satSolvable().requires(); }
98  Capabilities conflicts() const { return satSolvable().conflicts(); }
99  Capabilities obsoletes() const { return satSolvable().obsoletes(); }
101  Capabilities suggests() const { return satSolvable().suggests(); }
102  Capabilities enhances() const { return satSolvable().enhances(); }
105  Capabilities dep( Dep which_r ) const { return satSolvable().dep(which_r); }
106  Capabilities operator[]( Dep which_r ) const { return satSolvable()[which_r]; }
107 
108  CapabilitySet providesNamespace( const std::string & namespace_r ) const { return satSolvable().providesNamespace( namespace_r ); }
109  CapabilitySet valuesOfNamespace( const std::string & namespace_r ) const { return satSolvable().valuesOfNamespace( namespace_r ); }
110 
111  bool supportsLocales() const { return satSolvable().supportsLocales(); }
112  bool supportsLocale( const Locale & locale_r ) const { return satSolvable().supportsLocale( locale_r ); }
113  bool supportsLocale( const LocaleSet & locales_r ) const { return satSolvable().supportsLocale( locales_r ); }
116 
117  CpeId cpeId() const { return satSolvable().cpeId(); }
118  unsigned mediaNr() const { return satSolvable().mediaNr(); }
121  std::string distribution() const { return satSolvable().distribution(); }
122 
123  std::string summary( const Locale & lang_r = Locale() ) const { return satSolvable().summary( lang_r ); }
124  std::string description( const Locale & lang_r = Locale() ) const { return satSolvable().description( lang_r ); }
125  std::string insnotify( const Locale & lang_r = Locale() ) const { return satSolvable().insnotify( lang_r ); }
126  std::string delnotify( const Locale & lang_r = Locale() ) const { return satSolvable().delnotify( lang_r ); }
127  std::string licenseToConfirm( const Locale & lang_r = Locale() ) const { return satSolvable().licenseToConfirm( lang_r ); }
129 
130  public:
131  std::string lookupStrAttribute( const SolvAttr & attr ) const { return satSolvable().lookupStrAttribute( attr ); }
132  std::string lookupStrAttribute( const SolvAttr & attr, const Locale & lang_r ) const { return satSolvable().lookupStrAttribute( attr, lang_r ); }
133  bool lookupBoolAttribute( const SolvAttr & attr ) const { return satSolvable().lookupBoolAttribute( attr ); }
135  unsigned long long lookupNumAttribute( const SolvAttr & attr ) const { return satSolvable().lookupNumAttribute( attr ); }
138  Solvable::IdType id() const { return satSolvable().id(); }
139 
140  protected:
143  void operator=( const SolvableType & ) {}
144 #ifndef SWIG
146  void operator=( SolvableType && ) {}
147 #endif
149  };
150 
152  template <class Derived>
153  inline std::ostream & operator<<( std::ostream & str, const SolvableType<Derived> & obj )
154  { return str << obj.satSolvable(); }
155 
157  template <class Derived>
158  inline std::ostream & dumpOn( std::ostream & str, const SolvableType<Derived> & obj )
159  { return dumpOn( str, obj.satSolvable() ); }
160 
162  template <class LDerived, class RDerived>
163  inline bool operator==( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
164  { return lhs.satSolvable() == rhs.satSolvable(); }
166  template <class Derived>
167  inline bool operator==( const SolvableType<Derived> & lhs, const Solvable & rhs )
168  { return lhs.satSolvable() == rhs; }
170  template <class Derived>
171  inline bool operator==( const Solvable & lhs, const SolvableType<Derived> & rhs )
172  { return lhs == rhs.satSolvable(); }
173 
175  template <class LDerived, class RDerived>
176  inline bool operator!=( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
177  { return lhs.satSolvable() != rhs.satSolvable(); }
179  template <class Derived>
180  inline bool operator!=( const SolvableType<Derived> & lhs, const Solvable & rhs )
181  { return lhs.satSolvable() != rhs; }
183  template <class Derived>
184  inline bool operator!=( const Solvable & lhs, const SolvableType<Derived> & rhs )
185  { return lhs != rhs.satSolvable(); }
186 
188  template <class LDerived, class RDerived>
189  inline bool operator<( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
190  { return lhs.satSolvable() < rhs.satSolvable(); }
192  template <class Derived>
193  inline bool operator<( const SolvableType<Derived> & lhs, const Solvable & rhs )
194  { return lhs.satSolvable() < rhs; }
196  template <class Derived>
197  inline bool operator<( const Solvable & lhs, const SolvableType<Derived> & rhs )
198  { return lhs < rhs.satSolvable(); }
199 
201  template<class TRes, class Derived>
202  inline bool isKind( const SolvableType<Derived> & solvable_r )
203  { return isKind<TRes>( solvable_r.satSolvable() ); }
204 
206  template <class LDerived, class RDerived>
207  inline bool identical( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
208  { return identical( lhs.satSolvable(), rhs.satSolvable() ); }
210  template <class Derived>
211  inline bool identical( const SolvableType<Derived> & lhs, const Solvable & rhs )
212  { return identical( lhs.satSolvable(), rhs ); }
214  template <class Derived>
215  inline bool identical( const Solvable & lhs, const SolvableType<Derived> & rhs )
216  { return identical( lhs, rhs.satSolvable() ); }
217 
219  template <class LDerived, class RDerived>
220  inline bool sameNVRA( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
221  { return sameNVRA( lhs.satSolvable(), rhs.satSolvable() ); }
223  template <class Derived>
224  inline bool sameNVRA( const SolvableType<Derived> & lhs, const Solvable & rhs )
225  { return sameNVRA( lhs.satSolvable(), rhs ); }
227  template <class Derived>
228  inline bool sameNVRA( const Solvable & lhs, const SolvableType<Derived> & rhs )
229  { return sameNVRA( lhs, rhs.satSolvable() ); }
230 
231 
233  template <class LDerived, class RDerived>
234  inline int compareByN( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
235  { return compareByN( lhs.satSolvable(), rhs.satSolvable() ); }
237  template <class Derived>
238  inline bool compareByN( const SolvableType<Derived> & lhs, const Solvable & rhs )
239  { return compareByN( lhs.satSolvable(), rhs ); }
241  template <class Derived>
242  inline bool compareByN( const Solvable & lhs, const SolvableType<Derived> & rhs )
243  { return compareByN( lhs, rhs.satSolvable() ); }
244 
245 
247  template <class LDerived, class RDerived>
248  inline int compareByNVR( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
249  { return compareByNVR( lhs.satSolvable(), rhs.satSolvable() ); }
251  template <class Derived>
252  inline bool compareByNVR( const SolvableType<Derived> & lhs, const Solvable & rhs )
253  { return compareByNVR( lhs.satSolvable(), rhs ); }
255  template <class Derived>
256  inline bool compareByNVR( const Solvable & lhs, const SolvableType<Derived> & rhs )
257  { return compareByNVR( lhs, rhs.satSolvable() ); }
258 
260  template <class LDerived, class RDerived>
261  inline int compareByNVRA( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
262  { return compareByNVRA( lhs.satSolvable(), rhs.satSolvable() ); }
264  template <class Derived>
265  inline bool compareByNVRA( const SolvableType<Derived> & lhs, const Solvable & rhs )
266  { return compareByNVRA( lhs.satSolvable(), rhs ); }
268  template <class Derived>
269  inline bool compareByNVRA( const Solvable & lhs, const SolvableType<Derived> & rhs )
270  { return compareByNVRA( lhs, rhs.satSolvable() ); }
271 
272  } // namespace sat
274 } // namespace zypp
276 #endif // ZYPP_SAT_SOLVABLETYPE_H
Repository repository() const
The Repository this Solvable belongs to.
Definition: Solvable.cc:351
bool needToAcceptLicense() const
True except for well known exceptions (i.e show license but no need to accept it).
Definition: Solvable.cc:681
std::ostream & dumpOn(std::ostream &str, const SolvableType< Derived > &obj)
Definition: SolvableType.h:158
Capabilities recommends() const
Definition: SolvableType.h:100
int IdType
Generic Id type.
Definition: PoolMember.h:130
Solvable::IdType id() const
Definition: SolvableType.h:138
A Solvable object within the sat Pool.
Definition: Solvable.h:53
Arch arch() const
The architecture.
Definition: Solvable.cc:331
Capabilities recommends() const
Definition: Solvable.cc:446
CapabilitySet providesNamespace(const std::string &namespace_r) const
Return the namespaced provides 'namespace([value])[ op edition]' of this Solvable.
Definition: Solvable.cc:475
CapabilitySet providesNamespace(const std::string &namespace_r) const
Definition: SolvableType.h:108
Container of Capability (currently read only).
Definition: Capabilities.h:35
Date buildtime() const
The items build time.
Definition: Solvable.cc:378
IdString ident() const
The identifier.
Definition: Solvable.cc:257
Describes a path on a certain media amongs as the information required to download it...
Date buildtime() const
Definition: SolvableType.h:82
LocaleSet getSupportedLocales() const
Definition: SolvableType.h:115
Enumeration class of dependency types.
Definition: Dep.h:29
std::string lookupStrAttribute(const SolvAttr &attr) const
Definition: SolvableType.h:131
bool compareByNVRA(const SolvableType< Derived > &lhs, const Solvable &rhs)
Definition: SolvableType.h:265
Architecture.
Definition: Arch.h:36
bool supportsLocale(const Locale &locale_r) const
Whether this Solvable supports a specific Locale.
Definition: Solvable.cc:590
detail::IdType lookupIdAttribute(const SolvAttr &attr) const
Definition: SolvableType.h:134
Store and operate with byte count.
Definition: ByteCount.h:30
unsigned mediaNr() const
Definition: SolvableType.h:118
bool identical(const Solvable &rhs) const
Definition: SolvableType.h:88
bool operator==(const Map &lhs, const Map &rhs)
Definition: Map.cc:123
bool supportsLocales() const
Definition: SolvableType.h:111
sat::SolvAttr attr
Definition: PoolQuery.cc:314
bool supportsLocales() const
Whether this Solvable claims to support locales.
Definition: Solvable.cc:584
Capabilities supplements() const
Definition: Solvable.cc:461
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:234
std::string asString() const
String representation "ident-edition.arch" or "noSolvable".
Definition: Solvable.cc:390
bool isSystem() const
Return whether this Solvable belongs to the system repo.
Definition: Solvable.cc:361
Capabilities suggests() const
Definition: Solvable.cc:451
ByteCount downloadSize() const
Download size.
Definition: Solvable.cc:632
int compareByNVR(const SolvableType< LDerived > &lhs, const SolvableType< RDerived > &rhs)
Definition: SolvableType.h:248
What is known about a repository.
Definition: RepoInfo.h:72
std::string insnotify(const Locale &lang_r=Locale()) const
UI hint text when selecting the solvable for install (opt.
Definition: Solvable.cc:656
Access to the sat-pools string space.
Definition: IdString.h:41
Capabilities prerequires() const
Definition: SolvableType.h:104
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:97
void operator=(SolvableType &&)
Definition: SolvableType.h:146
Edition represents [epoch:]version[-release]
Definition: Edition.h:60
Capabilities suggests() const
Definition: SolvableType.h:101
bool sameNVRA(const SolvableType< Derived > &lhs, const Solvable &rhs)
Definition: SolvableType.h:224
bool sameNVRA(const Solvable &rhs) const
Definition: SolvableType.h:92
CapabilitySet valuesOfNamespace(const std::string &namespace_r) const
Return 'value[ op edition]' for namespaced provides 'namespace(value)[ op edition]'.
Definition: Solvable.cc:489
bool compareByN(const SolvableType< Derived > &lhs, const Solvable &rhs)
Definition: SolvableType.h:238
Capabilities dep(Dep which_r) const
Definition: SolvableType.h:105
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:399
std::string licenseToConfirm(const Locale &lang_r=Locale()) const
License or agreement to accept before installing the solvable (opt.
Definition: Solvable.cc:668
bool multiversionInstall() const
Definition: SolvableType.h:80
Capabilities provides() const
Definition: Solvable.cc:426
Capabilities operator[](Dep which_r) const
Definition: SolvableType.h:106
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:164
IdString vendor() const
Definition: SolvableType.h:73
bool identical(const SolvableType< RDerived > &rhs) const
Definition: SolvableType.h:90
Repository repository() const
Definition: SolvableType.h:75
Capabilities supplements() const
Definition: SolvableType.h:103
std::string name() const
The name (without any ResKind prefix).
Definition: Solvable.cc:317
CapabilitySet valuesOfNamespace(const std::string &namespace_r) const
Definition: SolvableType.h:109
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:357
OnMediaLocation lookupLocation() const
returns OnMediaLocation data: This is everything we need to download e.g.
Definition: Solvable.cc:212
Capabilities enhances() const
Definition: SolvableType.h:102
bool identical(const SolvableType< LDerived > &lhs, const SolvableType< RDerived > &rhs)
Definition: SolvableType.h:207
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:170
bool sameNVRA(const Solvable &rhs) const
Test for same name-version-release.arch.
Definition: Solvable.h:160
bool sameNVRA(const SolvableType< LDerived > &lhs, const SolvableType< RDerived > &rhs)
Definition: SolvableType.h:220
unsigned mediaNr() const
Media number the solvable is located on (0 if no media access required).
Definition: Solvable.cc:620
bool operator==(const SolvableType< LDerived > &lhs, const SolvableType< RDerived > &rhs)
Definition: SolvableType.h:163
std::string description(const Locale &lang_r=Locale()) const
Long (multiline) text describing the solvable (opt.
Definition: Solvable.cc:650
bool identical(const SolvableType< Derived > &lhs, const Solvable &rhs)
Definition: SolvableType.h:211
bool supportsRequestedLocales() const
Whether this Solvable supports at least one requested locale.
Definition: Solvable.cc:604
bool lookupBoolAttribute(const SolvAttr &attr) const
returns the boolean attribute value for attr or false if it does not exists.
Definition: Solvable.cc:158
std::string description(const Locale &lang_r=Locale()) const
Definition: SolvableType.h:124
SolvableType(const SolvableType &)
Definition: SolvableType.h:142
bool onSystemByUser() const
Whether this is known to be installed on behalf of a user request.
Definition: Solvable.cc:367
OnMediaLocation lookupLocation() const
Definition: SolvableType.h:137
void operator=(const SolvableType &)
Definition: SolvableType.h:143
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:152
LocaleSet getSupportedLocales() const
Return the supported locales.
Definition: Solvable.cc:607
Date installtime() const
The items install time (false if not installed).
Definition: Solvable.cc:384
bool operator!=(const SolvableType< Derived > &lhs, const Solvable &rhs)
Definition: SolvableType.h:180
bool identical(const Solvable &rhs) const
Test whether two Solvables have the same content.
Definition: Solvable.cc:409
std::string distribution() const
Definition: SolvableType.h:121
int compareByNVRA(const SolvableType< LDerived > &lhs, const SolvableType< RDerived > &rhs)
Definition: SolvableType.h:261
std::string lookupStrAttribute(const SolvAttr &attr, const Locale &lang_r) const
Definition: SolvableType.h:132
CpeId cpeId() const
Definition: SolvableType.h:117
Capabilities dep(Dep which_r) const
Return Capabilities selected by Dep constant.
Definition: Solvable.h:180
std::string delnotify(const Locale &lang_r=Locale()) const
Definition: SolvableType.h:126
Capabilities obsoletes() const
Definition: SolvableType.h:99
std::ostream & dumpOn(std::ostream &str, const LocaleSupport &obj)
ByteCount downloadSize() const
Definition: SolvableType.h:120
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:128
bool sameNVRA(const SolvableType< RDerived > &rhs) const
Definition: SolvableType.h:94
bool operator!=(const SolvableType< LDerived > &lhs, const SolvableType< RDerived > &rhs)
Definition: SolvableType.h:176
Capabilities enhances() const
Definition: Solvable.cc:456
'Language[_Country]' codes.
Definition: Locale.h:49
bool compareByNVR(const SolvableType< Derived > &lhs, const Solvable &rhs)
Definition: SolvableType.h:252
std::unordered_set< Capability > CapabilitySet
Definition: Capability.h:33
IdString vendor() const
The vendor.
Definition: Solvable.cc:345
ResKind kind() const
The Solvables ResKind.
Definition: Solvable.cc:263
Capabilities conflicts() const
Definition: Solvable.cc:436
bool multiversionInstall() const
Whether different versions of this package can be installed at the same time.
Definition: Solvable.cc:372
bool onSystemByUser() const
Definition: SolvableType.h:79
Capabilities prerequires() const
Definition: Solvable.cc:466
Capabilities conflicts() const
Definition: SolvableType.h:98
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:644
std::string delnotify(const Locale &lang_r=Locale()) const
UI hint text when selecting the solvable for uninstall (opt.
Definition: Solvable.cc:662
bool lookupBoolAttribute(const SolvAttr &attr) const
Definition: SolvableType.h:133
SolvableType(SolvableType &&)
Definition: SolvableType.h:145
bool supportsLocale(const Locale &locale_r) const
Definition: SolvableType.h:112
ByteCount installSize() const
Installed (unpacked) size.
Definition: Solvable.cc:626
Capabilities requires() const
Definition: Solvable.cc:431
IdString ident() const
Definition: SolvableType.h:61
bool supportsRequestedLocales() const
Definition: SolvableType.h:114
CpeId cpeId() const
The solvables CpeId if available.
Definition: Solvable.cc:614
bool isKind(const SolvableType< Derived > &solvable_r)
Definition: SolvableType.h:202
bool supportsLocale(const LocaleSet &locales_r) const
Definition: SolvableType.h:113
IdType id() const
Expert backdoor.
Definition: Solvable.h:374
Base class for creating Solvable based types.
Definition: SolvableType.h:54
std::string licenseToConfirm(const Locale &lang_r=Locale()) const
Definition: SolvableType.h:127
bool isKind(const ResKind &kind_r) const
Test whether a Solvable is of a certain ResKind.
Definition: Solvable.cc:290
Date installtime() const
Definition: SolvableType.h:83
CheckSum lookupCheckSumAttribute(const SolvAttr &attr) const
Definition: SolvableType.h:136
sat::detail::SolvableIdType IdType
Definition: Solvable.h:56
Capabilities provides() const
Definition: SolvableType.h:96
Resolvable kinds.
Definition: ResKind.h:32
std::string distribution() const
The distribution string.
Definition: Solvable.cc:638
unsigned long long lookupNumAttribute(const SolvAttr &attr) const
Definition: SolvableType.h:135
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:119
Edition edition() const
The edition (version-release).
Definition: Solvable.cc:325
std::string asString() const
Definition: SolvableType.h:85
Edition edition() const
Definition: SolvableType.h:71
std::string asUserString() const
Definition: SolvableType.h:86
Capabilities obsoletes() const
Definition: Solvable.cc:441
std::string summary(const Locale &lang_r=Locale()) const
Definition: SolvableType.h:123
RepoInfo repoInfo() const
Definition: SolvableType.h:76
std::string insnotify(const Locale &lang_r=Locale()) const
Definition: SolvableType.h:125