libzypp  13.10.6
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 
282  static ResKind explicitKind( IdString ident_r ) { return explicitKind( ident_r.c_str() ); }
283  static ResKind explicitKind( const char * ident_r );
284  static ResKind explicitKind( const std::string & ident_r ) { return explicitKind( ident_r.c_str() ); }
285 
286  private:
290  };
291 
292  public:
294  ::_Solvable * get() const;
296  IdType id() const { return _id; }
297 
298  private:
300  };
302 
304  std::ostream & operator<<( std::ostream & str, const Solvable & obj );
305 
307  std::ostream & dumpOn( std::ostream & str, const Solvable & obj );
308 
310  std::ostream & dumpAsXmlOn( std::ostream & str, const Solvable & obj );
311 
313  inline bool operator==( const Solvable & lhs, const Solvable & rhs )
314  { return lhs.get() == rhs.get(); }
315 
317  inline bool operator!=( const Solvable & lhs, const Solvable & rhs )
318  { return lhs.get() != rhs.get(); }
319 
321  inline bool operator<( const Solvable & lhs, const Solvable & rhs )
322  { return lhs.get() < rhs.get(); }
323 
325  inline bool identical( Solvable lhs, Solvable rhs )
326  { return lhs.identical( rhs ); }
327 
329  inline bool sameNVRA( Solvable lhs, Solvable rhs )
330  { return lhs.sameNVRA( rhs ); }
331 
333  namespace detail
334  {
335  //
337  // CLASS NAME : SolvableIterator
338  //
340  class SolvableIterator : public boost::iterator_adaptor<
341  SolvableIterator // Derived
342  , ::_Solvable* // Base
343  , const Solvable // Value
344  , boost::forward_traversal_tag // CategoryOrTraversal
345  , const Solvable // Reference
346  >
347  {
348  public:
350  : SolvableIterator::iterator_adaptor_( 0 )
351  {}
352 
353  explicit SolvableIterator( const Solvable & val_r )
354  : SolvableIterator::iterator_adaptor_( 0 )
355  { assignVal( val_r ); }
356 
358  : SolvableIterator::iterator_adaptor_( 0 )
359  { assignVal( Solvable( id_r ) ); }
360 
361  private:
363 
365  { return _val; }
366 
367  void increment()
368  { assignVal( _val.nextInPool() ); }
369 
370  private:
371  void assignVal( const Solvable & val_r )
372  { _val = val_r; base_reference() = _val.get(); }
373 
375  };
378  } // namespace detail
380 
382  } // namespace sat
384 
386  template<class _Res>
387  inline bool isKind( const sat::Solvable & solvable_r )
388  { return solvable_r.isKind( ResTraits<_Res>::kind ); }
389 
390  class PoolItem;
392  namespace sat
393  {
394 
398  struct asSolvable
399  {
401 
402  Solvable operator()( Solvable solv_r ) const
403  { return solv_r; }
404 
405  Solvable operator()( const PoolItem & pi_r ) const;
406 
407  Solvable operator()( const ResObject_constPtr & res_r ) const;
408  };
410  } // namespace sat
412 
414 } // namespace zypp
416 
418 
419 #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:148
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:378
Capabilities recommends() const
Definition: Solvable.cc:444
CapabilitySet providesNamespace(const std::string &namespace_r) const
Return the namespaced provides &#39;namespace([value])[ op edition]&#39; of this Solvable.
Definition: Solvable.cc:473
static ResKind explicitKind(const std::string &ident_r)
Definition: Solvable.h:284
Container of Capability (currently read only).
Definition: Capabilities.h:35
IdString ident() const
The identifier.
Definition: Solvable.cc:165
Describes a path on a certain media amongs as the information required to download it...
std::ostream & operator<<(std::ostream &str, const LocaleSupport &obj)
SolvableIterator(const Solvable &val_r)
Definition: Solvable.h:353
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:615
sat::SolvAttr attr
Definition: PoolQuery.cc:303
bool operator==(const Solvable &lhs, const Solvable &rhs)
Definition: Solvable.h:313
bool supportsLocales() const
Whether this Solvable claims to support locales.
Definition: Solvable.cc:609
Capabilities supplements() const
Definition: Solvable.cc:459
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:171
std::string asString() const
String representation &quot;ident-edition.arch&quot; or &quot;noSolvable&quot;.
Definition: Solvable.cc:506
bool isSystem() const
Return whether this Solvable belongs to the system repo.
Definition: Solvable.cc:154
static ResKind explicitKind(IdString ident_r)
Return an idents explicit kind prefix, or ResKind() if none.
Definition: Solvable.h:282
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:449
::_Solvable * get() const
Expert backdoor.
Definition: Solvable.cc:124
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:77
bool identical(Solvable lhs, Solvable rhs)
Definition: Solvable.h:325
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:487
std::string asUserString() const
String representation &quot;ident-edition.arch(repo)&quot; or &quot;noSolvable&quot;.
Definition: Solvable.cc:515
std::tr1::unordered_set< Capability > CapabilitySet
Definition: Capability.h:33
Capabilities provides() const
Definition: Solvable.cc:424
static const Solvable noSolvable
Represents no Solvable.
Definition: Solvable.h:71
std::ostream & dumpAsXmlOn(std::ostream &str, const Solvable &obj)
Definition: Solvable.cc:679
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:209
std::string name() const
Definition: Solvable.cc:364
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:254
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:215
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string...
Definition: String.h:81
IdString ident() const
Definition: Solvable.h:274
bool supportsRequestedLocales() const
Whether this Solvable supports at least one requested locale.
Definition: Solvable.cc:629
bool lookupBoolAttribute(const SolvAttr &attr) const
returns the boolean attribute value for attr or false if it does not exists.
Definition: Solvable.cc:203
bool onSystemByUser() const
Whether this is known to be installed on behalf of a user request.
Definition: Solvable.cc:160
Solvable operator()(Solvable solv_r) const
Definition: Solvable.h:402
#define ZYPP_DEFINE_ID_HASHABLE(C)
Define hash function for id based classes.
Definition: Tr1hash.h:26
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:197
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:371
std::ostream & dumpOn(std::ostream &str, const LocaleSupport &obj)
const char * c_str() const
Conversion to const char *
Definition: IdString.cc:42
Solvable nextInRepo() const
Return next Solvable in Repo (or noSolvable).
Definition: Solvable.cc:134
Capabilities enhances() const
Definition: Solvable.cc:454
friend class boost::iterator_core_access
Definition: Solvable.h:362
IdString vendor() const
Definition: Solvable.cc:397
ResKind kind() const
Definition: Solvable.cc:298
Solvable nextInPool() const
Return next Solvable in Pool (or noSolvable).
Definition: Solvable.cc:131
Solvable()
Default ctor creates noSolvable.
Definition: Solvable.h:62
Capabilities conflicts() const
Definition: Solvable.cc:434
bool multiversionInstall() const
Whether different versions of this package can be installed at the same time.
Definition: Solvable.cc:392
SolvableIterator(SolvableIdType id_r)
Definition: Solvable.h:357
Capabilities prerequires() const
Definition: Solvable.cc:464
Helper that splits an identifier into kind and name or vice versa.
Definition: Solvable.h:264
Solvable result_type
Definition: Solvable.h:400
Capabilities operator[](Dep which_r) const
Definition: Solvable.cc:403
Capabilities requires() const
Definition: Solvable.cc:429
bool operator<(const Solvable &lhs, const Solvable &rhs)
Definition: Solvable.h:321
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:296
bool isKind(const ResKind &kind_r) const
Test whether a Solvable is of a certain ResKind.
Definition: Solvable.cc:337
sat::detail::SolvableIdType IdType
Definition: Solvable.h:58
Resolvable kinds.
Definition: ResKind.h:35
To Solvable transform functor.
Definition: Solvable.h:398
IdString name() const
Definition: Solvable.h:276
bool isKind(const sat::Solvable &solvable_r)
Definition: Solvable.h:387
bool isKind(_Iterator begin, _Iterator end)
Definition: Solvable.h:166
Edition edition() const
Definition: Solvable.cc:372
bool sameNVRA(Solvable lhs, Solvable rhs)
Definition: Solvable.h:329
Capabilities obsoletes() const
Definition: Solvable.cc:439
bool operator!=(const Solvable &lhs, const Solvable &rhs)
Definition: Solvable.h:317
bool identical(Solvable rhs) const
Test whether two Solvables have the same content.
Definition: Solvable.cc:525