1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/sat/SolvableType.h
11 #ifndef ZYPP_SAT_SOLVABLETYPE_H
12 #define ZYPP_SAT_SOLVABLETYPE_H
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"
24 ///////////////////////////////////////////////////////////////////
27 ///////////////////////////////////////////////////////////////////
30 ///////////////////////////////////////////////////////////////////
31 /// \class SolvableType
32 /// \brief Base class for creating \ref Solvable based types.
35 /// Derive from this and offer explicit conversion to \ref Solvable
36 /// to make the \ref Solvable properties directly accessible.
38 /// Different SolvableTypes are comparable based on the underlying
41 /// \see \ref Solvable
44 /// class MySolvable : public SolvableType<MySolvable>
48 /// explicit operator sat::Solvable() const;
52 ///////////////////////////////////////////////////////////////////
53 template <class Derived>
56 /** Return the corresponding \ref sat::Solvable. */
57 Solvable satSolvable() const { return Solvable(static_cast<const Derived&>(*this)); }
59 explicit operator bool() const { return bool(satSolvable()); }
61 IdString ident() const { return satSolvable().ident(); }
63 ResKind kind() const { return satSolvable().kind(); }
64 bool isKind( const ResKind & kind_r ) const { return satSolvable().isKind( kind_r ); }
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 ); }
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(); }
75 Repository repository() const { return satSolvable().repository(); }
76 RepoInfo repoInfo() const { return satSolvable().repoInfo(); }
78 bool isSystem() const { return satSolvable().isSystem(); }
79 bool onSystemByUser() const { return satSolvable().onSystemByUser(); }
80 bool multiversionInstall() const { return satSolvable().multiversionInstall(); }
82 Date buildtime() const { return satSolvable().buildtime(); }
83 Date installtime() const { return satSolvable().installtime(); }
85 std::string asString() const { return satSolvable().asString(); }
86 std::string asUserString() const { return satSolvable().asUserString(); }
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() ); }
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() ); }
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(); }
100 Capabilities recommends() const { return satSolvable().recommends(); }
101 Capabilities suggests() const { return satSolvable().suggests(); }
102 Capabilities enhances() const { return satSolvable().enhances(); }
103 Capabilities supplements() const { return satSolvable().supplements(); }
104 Capabilities prerequires() const { return satSolvable().prerequires(); }
105 Capabilities dep( Dep which_r ) const { return satSolvable().dep(which_r); }
106 Capabilities operator[]( Dep which_r ) const { return satSolvable()[which_r]; }
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 ); }
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 ); }
114 bool supportsRequestedLocales() const { return satSolvable().supportsRequestedLocales(); }
115 LocaleSet getSupportedLocales() const { return satSolvable().getSupportedLocales(); }
117 CpeId cpeId() const { return satSolvable().cpeId(); }
118 unsigned mediaNr() const { return satSolvable().mediaNr(); }
119 ByteCount installSize() const { return satSolvable().installSize(); }
120 ByteCount downloadSize() const { return satSolvable().downloadSize(); }
121 std::string distribution() const { return satSolvable().distribution(); }
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 ); }
128 bool needToAcceptLicense() const { return satSolvable().needToAcceptLicense(); }
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 ); }
134 detail::IdType lookupIdAttribute( const SolvAttr & attr ) const { return satSolvable().lookupIdAttribute( attr ); }
135 unsigned long long lookupNumAttribute( const SolvAttr & attr ) const { return satSolvable().lookupNumAttribute( attr ); }
136 unsigned long long lookupNumAttribute( const SolvAttr & attr, unsigned long long notfound_r ) const { return satSolvable().lookupNumAttribute( attr, notfound_r ); }
137 CheckSum lookupCheckSumAttribute( const SolvAttr & attr ) const { return satSolvable().lookupCheckSumAttribute( attr ); }
138 OnMediaLocation lookupLocation() const { return satSolvable().lookupLocation(); }
139 Solvable::IdType id() const { return satSolvable().id(); }
143 SolvableType( const SolvableType & ) {}
144 void operator=( const SolvableType & ) {}
146 SolvableType( SolvableType && ) {}
147 void operator=( SolvableType && ) {}
152 /** \relates SolvableType Stream output */
153 template <class Derived>
154 inline std::ostream & operator<<( std::ostream & str, const SolvableType<Derived> & obj )
155 { return str << obj.satSolvable(); }
157 /** \relates SolvableType More verbose stream output including dependencies */
158 template <class Derived>
159 inline std::ostream & dumpOn( std::ostream & str, const SolvableType<Derived> & obj )
160 { return dumpOn( str, obj.satSolvable() ); }
162 /** \relates SolvableType Equal*/
163 template <class LDerived, class RDerived>
164 inline bool operator==( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
165 { return lhs.satSolvable() == rhs.satSolvable(); }
167 template <class Derived>
168 inline bool operator==( const SolvableType<Derived> & lhs, const Solvable & rhs )
169 { return lhs.satSolvable() == rhs; }
171 template <class Derived>
172 inline bool operator==( const Solvable & lhs, const SolvableType<Derived> & rhs )
173 { return lhs == rhs.satSolvable(); }
175 /** \relates SolvableType NotEqual */
176 template <class LDerived, class RDerived>
177 inline bool operator!=( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
178 { return lhs.satSolvable() != rhs.satSolvable(); }
180 template <class Derived>
181 inline bool operator!=( const SolvableType<Derived> & lhs, const Solvable & rhs )
182 { return lhs.satSolvable() != rhs; }
184 template <class Derived>
185 inline bool operator!=( const Solvable & lhs, const SolvableType<Derived> & rhs )
186 { return lhs != rhs.satSolvable(); }
188 /** \relates SolvableType Less*/
189 template <class LDerived, class RDerived>
190 inline bool operator<( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
191 { return lhs.satSolvable() < rhs.satSolvable(); }
193 template <class Derived>
194 inline bool operator<( const SolvableType<Derived> & lhs, const Solvable & rhs )
195 { return lhs.satSolvable() < rhs; }
197 template <class Derived>
198 inline bool operator<( const Solvable & lhs, const SolvableType<Derived> & rhs )
199 { return lhs < rhs.satSolvable(); }
201 /** \relates SolvableType Test whether the \ref Solvable is of a certain \ref ResKind. */
202 template<class TRes, class Derived>
203 inline bool isKind( const SolvableType<Derived> & solvable_r )
204 { return isKind<TRes>( solvable_r.satSolvable() ); }
206 /** \relates SolvableType Test for same content. */
207 template <class LDerived, class RDerived>
208 inline bool identical( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
209 { return identical( lhs.satSolvable(), rhs.satSolvable() ); }
211 template <class Derived>
212 inline bool identical( const SolvableType<Derived> & lhs, const Solvable & rhs )
213 { return identical( lhs.satSolvable(), rhs ); }
215 template <class Derived>
216 inline bool identical( const Solvable & lhs, const SolvableType<Derived> & rhs )
217 { return identical( lhs, rhs.satSolvable() ); }
219 /** \relates SolvableType Test for same name version release and arch. */
220 template <class LDerived, class RDerived>
221 inline bool sameNVRA( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
222 { return sameNVRA( lhs.satSolvable(), rhs.satSolvable() ); }
224 template <class Derived>
225 inline bool sameNVRA( const SolvableType<Derived> & lhs, const Solvable & rhs )
226 { return sameNVRA( lhs.satSolvable(), rhs ); }
228 template <class Derived>
229 inline bool sameNVRA( const Solvable & lhs, const SolvableType<Derived> & rhs )
230 { return sameNVRA( lhs, rhs.satSolvable() ); }
233 /** \relates SolvableType Compare according to \a kind and \a name. */
234 template <class LDerived, class RDerived>
235 inline int compareByN( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
236 { return compareByN( lhs.satSolvable(), rhs.satSolvable() ); }
238 template <class Derived>
239 inline bool compareByN( const SolvableType<Derived> & lhs, const Solvable & rhs )
240 { return compareByN( lhs.satSolvable(), rhs ); }
242 template <class Derived>
243 inline bool compareByN( const Solvable & lhs, const SolvableType<Derived> & rhs )
244 { return compareByN( lhs, rhs.satSolvable() ); }
247 /** \relates SolvableType Compare according to \a kind, \a name and \a edition. */
248 template <class LDerived, class RDerived>
249 inline int compareByNVR( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
250 { return compareByNVR( lhs.satSolvable(), rhs.satSolvable() ); }
252 template <class Derived>
253 inline bool compareByNVR( const SolvableType<Derived> & lhs, const Solvable & rhs )
254 { return compareByNVR( lhs.satSolvable(), rhs ); }
256 template <class Derived>
257 inline bool compareByNVR( const Solvable & lhs, const SolvableType<Derived> & rhs )
258 { return compareByNVR( lhs, rhs.satSolvable() ); }
260 /** \relates SolvableType Compare according to \a kind, \a name, \a edition and \a arch. */
261 template <class LDerived, class RDerived>
262 inline int compareByNVRA( const SolvableType<LDerived> & lhs, const SolvableType<RDerived> & rhs )
263 { return compareByNVRA( lhs.satSolvable(), rhs.satSolvable() ); }
265 template <class Derived>
266 inline bool compareByNVRA( const SolvableType<Derived> & lhs, const Solvable & rhs )
267 { return compareByNVRA( lhs.satSolvable(), rhs ); }
269 template <class Derived>
270 inline bool compareByNVRA( const Solvable & lhs, const SolvableType<Derived> & rhs )
271 { return compareByNVRA( lhs, rhs.satSolvable() ); }
274 ///////////////////////////////////////////////////////////////////
276 ///////////////////////////////////////////////////////////////////
277 #endif // ZYPP_SAT_SOLVABLETYPE_H