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().template 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 onSystemByAuto() const { return satSolvable().onSystemByAuto(); }
81 bool identIsAutoInstalled() const { return satSolvable().identIsAutoInstalled(); }
82 bool multiversionInstall() const { return satSolvable().multiversionInstall(); }
84 Date buildtime() const { return satSolvable().buildtime(); }
85 Date installtime() const { return satSolvable().installtime(); }
87 std::string asString() const { return satSolvable().asString(); }
88 std::string asUserString() const { return satSolvable().asUserString(); }
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() ); }
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() ); }
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(); }
102 Capabilities recommends() const { return satSolvable().recommends(); }
103 Capabilities suggests() const { return satSolvable().suggests(); }
104 Capabilities enhances() const { return satSolvable().enhances(); }
105 Capabilities supplements() const { return satSolvable().supplements(); }
106 Capabilities prerequires() const { return satSolvable().prerequires(); }
107 Capabilities dep( Dep which_r ) const { return satSolvable().dep(which_r); }
108 Capabilities operator[]( Dep which_r ) const { return satSolvable()[which_r]; }
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 ); }
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 ); }
116 bool supportsRequestedLocales() const { return satSolvable().supportsRequestedLocales(); }
117 LocaleSet getSupportedLocales() const { return satSolvable().getSupportedLocales(); }
119 CpeId cpeId() const { return satSolvable().cpeId(); }
120 unsigned mediaNr() const { return satSolvable().mediaNr(); }
121 ByteCount installSize() const { return satSolvable().installSize(); }
122 ByteCount downloadSize() const { return satSolvable().downloadSize(); }
123 std::string distribution() const { return satSolvable().distribution(); }
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 ); }
130 bool needToAcceptLicense() const { return satSolvable().needToAcceptLicense(); }
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 ); }
136 detail::IdType lookupIdAttribute( const SolvAttr & attr ) const { return satSolvable().lookupIdAttribute( 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 ); }
139 CheckSum lookupCheckSumAttribute( const SolvAttr & attr ) const { return satSolvable().lookupCheckSumAttribute( attr ); }
140 OnMediaLocation lookupLocation() const { return satSolvable().lookupLocation(); }
141 Solvable::IdType id() const { return satSolvable().id(); }
145 SolvableType( const SolvableType & ) {}
146 void operator=( const SolvableType & ) {}
148 SolvableType( SolvableType && ) {}
149 void operator=( SolvableType && ) {}
154 /** \relates SolvableType Stream output */
155 template <class Derived>
156 inline std::ostream & operator<<( std::ostream & str, const SolvableType<Derived> & obj )
157 { return str << obj.satSolvable(); }
159 /** \relates SolvableType More verbose stream output including dependencies */
160 template <class Derived>
161 inline std::ostream & dumpOn( std::ostream & str, const SolvableType<Derived> & obj )
162 { return dumpOn( str, obj.satSolvable() ); }
164 /** \relates SolvableType Equal*/
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(); }
177 /** \relates SolvableType NotEqual */
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(); }
190 /** \relates SolvableType Less*/
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(); }
203 /** \relates SolvableType Test whether the \ref Solvable is of a certain \ref ResKind. */
204 template<class TRes, class Derived>
205 inline bool isKind( const SolvableType<Derived> & solvable_r )
206 { return isKind<TRes>( solvable_r.satSolvable() ); }
208 /** \relates SolvableType Test for same content. */
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() ); }
221 /** \relates SolvableType Test for same name version release and arch. */
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() ); }
235 /** \relates SolvableType Compare according to \a kind and \a name. */
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() ); }
249 /** \relates SolvableType Compare according to \a kind, \a name and \a edition. */
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() ); }
262 /** \relates SolvableType Compare according to \a kind, \a name, \a edition and \a arch. */
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() ); }
276 ///////////////////////////////////////////////////////////////////
278 ///////////////////////////////////////////////////////////////////
279 #endif // ZYPP_SAT_SOLVABLETYPE_H