libzypp  15.3.0
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 
29 namespace zypp
30 {
31 
32  class CheckSum;
33  class OnMediaLocation;
34 
36  namespace sat
37  {
38 
40  //
41  // CLASS NAME : Solvable
42  //
55  class Solvable : protected detail::PoolMember
56  {
57  public:
59 
60  public:
63  : _id( detail::noSolvableId ) {}
64 
66  explicit Solvable( IdType id_r )
67  : _id( id_r ) {}
68 
69  public:
71  static const Solvable noSolvable;
72 
74  explicit operator bool() const
75  { return get(); }
76 
80  bool isSystem() const;
81 
87  bool onSystemByUser() const;
88 
90  Repository repository() const;
91 
92  public:
93 
103  std::string lookupStrAttribute( const SolvAttr & attr ) const;
114  std::string lookupStrAttribute( const SolvAttr & attr, const Locale & lang_r ) const;
115 
120  unsigned long long lookupNumAttribute( const SolvAttr & attr ) const;
121 
126  bool lookupBoolAttribute( const SolvAttr & attr ) const;
127 
133 
139 
145 
147  public:
152  IdString ident() const;
153 
154  ResKind kind() const;
159  bool isKind( const ResKind & kind_r ) const;
161  template<class _Res>
162  bool isKind() const
163  { return isKind( resKind<_Res>() ); }
165  template<class _Iterator>
166  bool isKind( _Iterator begin, _Iterator end )
167  { for_( it, begin, end ) if ( isKind( *it ) ) return true; return false; }
168 
169  std::string name() const;
170  Edition edition() const;
171  Arch arch() const;
172 
173  IdString vendor() const;
174 
178  bool multiversionInstall() const;
179 
187  std::string asString() const;
188 
190  std::string asUserString() const;
191 
195  bool identical( Solvable rhs ) const;
196 
198  bool sameNVRA( Solvable rhs ) const
199  { return( ident() == rhs.ident() && edition() == rhs.edition() && arch() == rhs.arch() ); }
200 
201  public:
202 
208  Capabilities operator[]( Dep which_r ) const;
209 
210  Capabilities provides() const;
211  Capabilities requires() const;
212  Capabilities conflicts() const;
213  Capabilities obsoletes() const;
214  Capabilities recommends() const;
215  Capabilities suggests() const;
216  Capabilities enhances() const;
217  Capabilities supplements() const;
218  Capabilities prerequires() const;
219 
221  CapabilitySet providesNamespace( const std::string & namespace_r ) const;
222 
230  CapabilitySet valuesOfNamespace( const std::string & namespace_r ) const;
232 
233  public:
237  bool supportsLocales() const;
239  bool supportsLocale( const Locale & locale_r ) const;
241  bool supportsLocale( const LocaleSet & locales_r ) const;
245  bool supportsRequestedLocales() const;
247  void getSupportedLocales( LocaleSet & locales_r ) const;
250  { LocaleSet ret; getSupportedLocales( ret ); return ret; }
252 
253  public:
255  Solvable nextInPool() const;
257  Solvable nextInRepo() const;
258 
265  {
266  public:
268  SplitIdent( IdString ident_r );
269  SplitIdent( const char * ident_r );
270  SplitIdent( const std::string & ident_r );
271  SplitIdent( ResKind kind_r, IdString name_r );
272  SplitIdent( ResKind kind_r, const C_Str & name_r );
273 
274  IdString ident() const { return _ident; }
275  ResKind kind() const { return _kind; }
276  IdString name() const { return _name; }
277 
278  private:
282  };
283 
284  public:
286  ::_Solvable * get() const;
288  IdType id() const { return _id; }
289 
290  private:
291  IdType _id;
292  };
294 
296  std::ostream & operator<<( std::ostream & str, const Solvable & obj );
297 
299  std::ostream & dumpOn( std::ostream & str, const Solvable & obj );
300 
302  std::ostream & dumpAsXmlOn( std::ostream & str, const Solvable & obj );
303 
305  inline bool operator==( const Solvable & lhs, const Solvable & rhs )
306  { return lhs.get() == rhs.get(); }
307 
309  inline bool operator!=( const Solvable & lhs, const Solvable & rhs )
310  { return lhs.get() != rhs.get(); }
311 
313  inline bool operator<( const Solvable & lhs, const Solvable & rhs )
314  { return lhs.get() < rhs.get(); }
315 
317  inline bool identical( Solvable lhs, Solvable rhs )
318  { return lhs.identical( rhs ); }
319 
321  inline bool sameNVRA( Solvable lhs, Solvable rhs )
322  { return lhs.sameNVRA( rhs ); }
323 
325  namespace detail
326  {
327  //
329  // CLASS NAME : SolvableIterator
330  //
332  class SolvableIterator : public boost::iterator_adaptor<
333  SolvableIterator // Derived
334  , ::_Solvable* // Base
335  , const Solvable // Value
336  , boost::forward_traversal_tag // CategoryOrTraversal
337  , const Solvable // Reference
338  >
339  {
340  public:
342  : SolvableIterator::iterator_adaptor_( 0 )
343  {}
344 
345  explicit SolvableIterator( const Solvable & val_r )
346  : SolvableIterator::iterator_adaptor_( 0 )
347  { assignVal( val_r ); }
348 
350  : SolvableIterator::iterator_adaptor_( 0 )
351  { assignVal( Solvable( id_r ) ); }
352 
353  private:
355 
357  { return _val; }
358 
359  void increment()
360  { assignVal( _val.nextInPool() ); }
361 
362  private:
363  void assignVal( const Solvable & val_r )
364  { _val = val_r; base_reference() = _val.get(); }
365 
367  };
370  } // namespace detail
372 
374  } // namespace sat
376 
378  template<class _Res>
379  inline bool isKind( const sat::Solvable & solvable_r )
380  { return solvable_r.isKind( ResTraits<_Res>::kind ); }
381 
382  class PoolItem;
384  namespace sat
385  {
386 
390  struct asSolvable
391  {
393 
394  Solvable operator()( Solvable solv_r ) const
395  { return solv_r; }
396 
397  Solvable operator()( const PoolItem & pi_r ) const;
398 
399  Solvable operator()( const ResObject_constPtr & res_r ) const;
400  };
402  } // namespace sat
404 
406 } // namespace zypp
408 
410 
411 #endif // ZYPP_SAT_SOLVABLE_H
static const SolvableIdType noSolvableId(0)
Id to denote Solvable::noSolvable.
Repository repository() const
The Repository this Solvable belongs to.
Definition: Solvable.cc:121
int IdType
Generic Id type.
Definition: PoolMember.h:82
A Solvable object within the sat Pool.
Definition: Solvable.h:55
Arch arch() const
Definition: Solvable.cc:342
Capabilities recommends() const
Definition: Solvable.cc:408
CapabilitySet providesNamespace(const std::string &namespace_r) const
Return the namespaced provides 'namespace([value])[ op edition]' of this Solvable.
Definition: Solvable.cc:437
Container of Capability (currently read only).
Definition: Capabilities.h:35
IdString ident() const
The identifier.
Definition: Solvable.cc:138
Describes a path on a certain media amongs as the information required to download it...
SolvableIterator(const Solvable &val_r)
Definition: Solvable.h:345
Enumeration class of dependency types.
Definition: Dep.h:29
Architecture.
Definition: Arch.h:36
bool supportsLocale(const Locale &locale_r) const
Whether this Solvable supports a specific Locale.
Definition: Solvable.cc:579
sat::SolvAttr attr
Definition: PoolQuery.cc:303
std::ostream & operator<<(std::ostream &str, const FileConflicts &obj)
bool operator==(const Solvable &lhs, const Solvable &rhs)
Definition: Solvable.h:305
bool supportsLocales() const
Whether this Solvable claims to support locales.
Definition: Solvable.cc:573
Capabilities supplements() const
Definition: Solvable.cc:423
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:144
ZYPP_DEFINE_ID_HASHABLE(::zypp::sat::Solvable)
std::string asString() const
String representation "ident-edition.arch" or "noSolvable".
Definition: Solvable.cc:470
bool isSystem() const
Return whether this Solvable belongs to the system repo.
Definition: Solvable.cc:127
String related utilities and Regular expression matching.
bool isKind() const
Definition: Solvable.h:162
unsigned SolvableIdType
Id type to connect Solvable and sat-solvable.
Definition: PoolMember.h:98
Capabilities suggests() const
Definition: Solvable.cc:413
::_Solvable * get() const
Expert backdoor.
Definition: Solvable.cc:97
Access to the sat-pools string space.
Definition: IdString.h:39
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:27
Edition represents [epoch:]version[-release]
Definition: Edition.h:60
ResTraits.
Definition: ResTraits.h:79
bool identical(Solvable lhs, Solvable rhs)
Definition: Solvable.h:317
CapabilitySet valuesOfNamespace(const std::string &namespace_r) const
Return 'value[ op edition]' for namespaced provides 'namespace(value)[ op edition]'.
Definition: Solvable.cc:451
std::string asUserString() const
String representation "ident-edition.arch(repo)" or "noSolvable".
Definition: Solvable.cc:479
std::tr1::unordered_set< Capability > CapabilitySet
Definition: Capability.h:33
Capabilities provides() const
Definition: Solvable.cc:388
static const Solvable noSolvable
Represents no Solvable.
Definition: Solvable.h:71
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:182
std::string name() const
Definition: Solvable.cc:328
Solvable attribute keys.
Definition: SolvAttr.h:40
Backlink to the associated PoolImpl.
Definition: PoolMember.h:66
OnMediaLocation lookupLocation() const
returns OnMediaLocation data: This is everything we need to download e.g.
Definition: Solvable.cc:230
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:188
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string...
Definition: String.h:115
IdString ident() const
Definition: Solvable.h:274
bool supportsRequestedLocales() const
Whether this Solvable supports at least one requested locale.
Definition: Solvable.cc:593
bool lookupBoolAttribute(const SolvAttr &attr) const
returns the boolean attribute value for attr or false if it does not exists.
Definition: Solvable.cc:176
bool onSystemByUser() const
Whether this is known to be installed on behalf of a user request.
Definition: Solvable.cc:133
Solvable operator()(Solvable solv_r) const
Definition: Solvable.h:394
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:170
LocaleSet getSupportedLocales() const
Definition: Solvable.h:249
std::tr1::unordered_set< Locale > LocaleSet
Definition: Locale.h:28
Solvable(IdType id_r)
PoolImpl ctor.
Definition: Solvable.h:66
void assignVal(const Solvable &val_r)
Definition: Solvable.h:363
std::ostream & dumpOn(std::ostream &str, const LocaleSupport &obj)
Solvable nextInRepo() const
Return next Solvable in Repo (or noSolvable).
Definition: Solvable.cc:107
Capabilities enhances() const
Definition: Solvable.cc:418
friend class boost::iterator_core_access
Definition: Solvable.h:354
IdString vendor() const
Definition: Solvable.cc:361
ResKind kind() const
Definition: Solvable.cc:274
Solvable nextInPool() const
Return next Solvable in Pool (or noSolvable).
Definition: Solvable.cc:104
Solvable()
Default ctor creates noSolvable.
Definition: Solvable.h:62
Capabilities conflicts() const
Definition: Solvable.cc:398
bool multiversionInstall() const
Whether different versions of this package can be installed at the same time.
Definition: Solvable.cc:356
SolvableIterator(SolvableIdType id_r)
Definition: Solvable.h:349
Capabilities prerequires() const
Definition: Solvable.cc:428
Helper that splits an identifier into kind and name or vice versa.
Definition: Solvable.h:264
Solvable result_type
Definition: Solvable.h:392
Capabilities operator[](Dep which_r) const
Definition: Solvable.cc:367
Capabilities requires() const
Definition: Solvable.cc:393
bool operator<(const Solvable &lhs, const Solvable &rhs)
Definition: Solvable.h:313
bool sameNVRA(Solvable rhs) const
Test for same name-version-release.arch.
Definition: Solvable.h:198
Reference to a PoolItem connecting ResObject and ResStatus.
Definition: PoolItem.h:50
IdType id() const
Expert backdoor.
Definition: Solvable.h:288
std::ostream & dumpAsXmlOn(std::ostream &str, const FileConflicts &obj)
bool isKind(const ResKind &kind_r) const
Test whether a Solvable is of a certain ResKind.
Definition: Solvable.cc:301
sat::detail::SolvableIdType IdType
Definition: Solvable.h:58
Resolvable kinds.
Definition: ResKind.h:32
To Solvable transform functor.
Definition: Solvable.h:390
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
IdString name() const
Definition: Solvable.h:276
bool isKind(const sat::Solvable &solvable_r)
Definition: Solvable.h:379
bool isKind(_Iterator begin, _Iterator end)
Definition: Solvable.h:166
Edition edition() const
Definition: Solvable.cc:336
bool sameNVRA(Solvable lhs, Solvable rhs)
Definition: Solvable.h:321
Capabilities obsoletes() const
Definition: Solvable.cc:403
bool operator!=(const Solvable &lhs, const Solvable &rhs)
Definition: Solvable.h:309
bool identical(Solvable rhs) const
Test whether two Solvables have the same content.
Definition: Solvable.cc:489