libzypp  14.48.5
Resolvable.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_RESOLVABLE_H
13 #define ZYPP_RESOLVABLE_H
14 
15 #include <iosfwd>
16 #include <string>
17 
18 #include "zypp/APIConfig.h"
19 
21 #include "zypp/base/NonCopyable.h"
22 #include "zypp/base/PtrTypes.h"
23 
24 #include "zypp/sat/Solvable.h"
25 
27 namespace zypp
28 {
29 
30  class PoolItem;
31 
33  //
34  // CLASS NAME : Resolvable
35  //
39  class Resolvable : protected zypp::sat::Solvable, // Note: gcc bug #52841 prohibits using just sat::Solvable
41  {
42  friend std::ostream & operator<<( std::ostream & str, const Resolvable & obj );
43 
44  public:
45  typedef Resolvable Self;
50 
51  public:
53  bool isSystem() const
54  { return sat::Solvable::isSystem(); }
55 
57  bool onSystemByUser() const
58  { return sat::Solvable::onSystemByUser(); }
59 
60  IdString ident() const
61  { return sat::Solvable::ident(); }
62 
63  ResKind kind() const
64  { return sat::Solvable::kind(); }
65 
66  bool isKind( const ResKind & kind_r ) const
67  { return sat::Solvable::isKind( kind_r ); }
68 
69  template<class _Res>
70  bool isKind() const
71  { return sat::Solvable::isKind<_Res>(); }
72 
73  std::string name() const
74  { return sat::Solvable::name(); }
75 
76  Edition edition() const
77  { return sat::Solvable::edition(); }
78 
79  Arch arch() const
80  { return sat::Solvable::arch(); }
81 
85  bool multiversionInstall() const
87 
90 
94  Capabilities dep( Dep which_r ) const
95  { return operator[]( which_r ); }
96 
97  Capabilities operator[]( Dep which_r ) const
98  { return sat::Solvable::operator[]( which_r ); }
99 
101  { return sat::Solvable::provides(); }
102 
104  { return sat::Solvable::requires(); }
105 
107  { return sat::Solvable::conflicts(); }
108 
110  { return sat::Solvable::obsoletes(); }
111 
113  { return sat::Solvable::recommends(); }
114 
116  { return sat::Solvable::suggests(); }
117 
119  { return sat::Solvable::enhances(); }
120 
122  { return sat::Solvable::supplements(); }
123 
125  { return sat::Solvable::prerequires(); }
126 
127  CapabilitySet providesNamespace( const std::string & namespace_r ) const
128  { return sat::Solvable::providesNamespace( namespace_r ); }
129 
130  CapabilitySet valuesOfNamespace( const std::string & namespace_r ) const
131  { return sat::Solvable::valuesOfNamespace( namespace_r ); }
133 
134  public:
136  const sat::Solvable & satSolvable() const { return *this; }
137 
139  PoolItem poolItem() const;
140 
141  protected:
143  Resolvable( const sat::Solvable & solvable_r );
145  virtual ~Resolvable();
147  virtual std::ostream & dumpOn( std::ostream & str ) const;
148  };
150 
152  inline std::ostream & operator<<( std::ostream & str, const Resolvable & obj )
153  { return obj.dumpOn( str ); }
154 
156  inline std::ostream & dumpOn( std::ostream & str, const Resolvable & obj )
157  { return dumpOn( str, obj.satSolvable() ); }
158 
167  template<class _Res>
168  inline bool isKind( const Resolvable::constPtr & p )
169  { return p && p->kind() == ResTraits<_Res>::kind; }
170 
171  // Specialization for Resolvable: Always true.
172  template<>
173  inline bool isKind<Resolvable>( const Resolvable::constPtr & p )
174  { return !!p; }
175 
176  // Specialization for ResObject: Always true.
177  template<>
178  inline bool isKind<ResObject>( const Resolvable::constPtr & p )
179  { return !!p; }
180 
181 
190  template<class _Res>
191  inline typename ResTraits<_Res>::PtrType asKind( const Resolvable::Ptr & p )
192  { return dynamic_pointer_cast<_Res>(p); }
193 
194  template<class _Res>
195  inline typename ResTraits<_Res>::constPtrType asKind( const Resolvable::constPtr & p )
196  { return dynamic_pointer_cast<const _Res>(p); }
197 
199 
203  inline int compareByN( const Resolvable::constPtr & lhs,
204  const Resolvable::constPtr & rhs )
205  {
206  if ( lhs == rhs )
207  return 0;
208  if ( ! (lhs && rhs) )
209  return lhs ? 1 : -1;
210  int res = 0;
211  if ( (res = lhs->kind().compare( rhs->kind() )) )
212  return res;
213  return lhs->name().compare( rhs->name() );
214  }
215 
219  inline int compareByNVR( const Resolvable::constPtr & lhs,
220  const Resolvable::constPtr & rhs )
221  {
222  if ( lhs == rhs )
223  return 0;
224  if ( ! (lhs && rhs) )
225  return lhs ? 1 : -1;
226  int res = 0;
227  if ( (res = lhs->kind().compare( rhs->kind() )) )
228  return res;
229  if ( (res = lhs->name().compare( rhs->name() )) )
230  return res;
231  return lhs->edition().compare( rhs->edition() );
232  }
233 
237  inline int compareByNVRA( const Resolvable::constPtr & lhs,
238  const Resolvable::constPtr & rhs )
239  {
240  if ( lhs == rhs )
241  return 0;
242  if ( ! (lhs && rhs) )
243  return lhs ? 1 : -1;
244  int res = 0;
245  if ( (res = lhs->kind().compare( rhs->kind() )) )
246  return res;
247  if ( (res = lhs->name().compare( rhs->name() )) )
248  return res;
249  if ( (res = lhs->edition().compare( rhs->edition() )) )
250  return res;
251  return lhs->arch().compare( rhs->arch() );
252  }
253 
255 } // namespace zypp
257 #endif // ZYPP_RESOLVABLE_H
bool isSystem() const
Whether this represents an installed solvable.
Definition: Resolvable.h:53
Capabilities enhances() const
Definition: Resolvable.h:118
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
Enumeration class of dependency types.
Definition: Dep.h:29
Architecture.
Definition: Arch.h:36
TraitsType::KindType Kind
Definition: Resolvable.h:47
ResTraits< Self > TraitsType
Definition: Resolvable.h:46
Arch arch() const
Definition: Resolvable.h:79
int compareByNVRA(const Resolvable::constPtr &lhs, const Resolvable::constPtr &rhs)
Definition: Resolvable.h:237
Capabilities supplements() const
Definition: Solvable.cc:423
Capabilities provides() const
Definition: Resolvable.h:100
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
bool isKind() const
Definition: Solvable.h:162
Capabilities suggests() const
Definition: Solvable.cc:413
Access to the sat-pools string space.
Definition: IdString.h:39
Interface base for resolvable objects (identification and dependencies).
Definition: Resolvable.h:39
Edition represents [epoch:]version[-release]
Definition: Edition.h:60
ResTraits< _Res >::PtrType asKind(const sat::Solvable &solvable_r)
Directly create a certain kind of ResObject from sat::Solvable.
Definition: ResObject.h:262
ResTraits.
Definition: ResTraits.h:79
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
Resolvable(const sat::Solvable &solvable_r)
Ctor.
Definition: Resolvable.cc:27
Capabilities dep(Dep which_r) const
Select by Dep.
Definition: Resolvable.h:94
IdString ident() const
Definition: Resolvable.h:60
bool isKind(const Resolvable::constPtr &p)
Test whether a Resolvable::Ptr is of a certain Kind.
Definition: Resolvable.h:168
std::string name() const
Definition: Solvable.cc:328
bool isKind< Resolvable >(const Resolvable::constPtr &p)
Definition: Resolvable.h:173
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
std::string name() const
Definition: Resolvable.h:73
bool isKind() const
Definition: Resolvable.h:70
CapabilitySet valuesOfNamespace(const std::string &namespace_r) const
Definition: Resolvable.h:130
std::ostream & dumpOn(std::ostream &str, const Resolvable &obj)
Definition: Resolvable.h:156
Capabilities requires() const
Definition: Resolvable.h:103
Capabilities operator[](Dep which_r) const
Definition: Resolvable.h:97
Provides API related macros.
PoolItem poolItem() const
Access the corresponding PoolItem.
Definition: Resolvable.cc:44
const sat::Solvable & satSolvable() const
Access the corresponding ::Solvable.
Definition: Resolvable.h:136
bool onSystemByUser() const
Whether this is known to be installed on behalf of a user request.
Definition: Solvable.cc:133
TraitsType::PtrType Ptr
Definition: Resolvable.h:48
virtual std::ostream & dumpOn(std::ostream &str) const
Helper for stream output.
Definition: Resolvable.cc:52
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition: Capability.cc:437
Capabilities suggests() const
Definition: Resolvable.h:115
bool multiversionInstall() const
Whether different versions of this package can be installed at the same time.
Definition: Resolvable.h:85
Capabilities prerequires() const
Definition: Resolvable.h:124
Base class for reference counted objects.
Capabilities enhances() const
Definition: Solvable.cc:418
TraitsType::constPtrType constPtr
Definition: Resolvable.h:49
friend std::ostream & operator<<(std::ostream &str, const Resolvable &obj)
bool isKind(const ResKind &kind_r) const
Definition: Resolvable.h:66
ResKind kind() const
Definition: Solvable.cc:274
std::ostream & operator<<(std::ostream &str, const Resolvable &obj)
Definition: Resolvable.h:152
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
Capabilities conflicts() const
Definition: Resolvable.h:106
Capabilities recommends() const
Definition: Resolvable.h:112
Capabilities prerequires() const
Definition: Solvable.cc:428
int compareByN(const Resolvable::constPtr &lhs, const Resolvable::constPtr &rhs)
Definition: Resolvable.h:203
Capabilities operator[](Dep which_r) const
Definition: Solvable.cc:367
Capabilities requires() const
Definition: Solvable.cc:393
virtual ~Resolvable()
Dtor.
Definition: Resolvable.cc:36
Capabilities supplements() const
Definition: Resolvable.h:121
intrusive_ptr< _Res > PtrType
Definition: ResTraits.h:82
Capabilities obsoletes() const
Definition: Resolvable.h:109
bool isKind< ResObject >(const Resolvable::constPtr &p)
Definition: Resolvable.h:178
bool onSystemByUser() const
Whether this is known to be installed on behalf of a user request.
Definition: Resolvable.h:57
Resolvable Self
Definition: Resolvable.h:45
Reference to a PoolItem connecting ResObject and ResStatus.
Definition: PoolItem.h:50
Edition edition() const
Definition: Resolvable.h:76
ResTraits< _Res >::PtrType asKind(const Resolvable::Ptr &p)
Convert Resolvable::Ptr into Ptr of a certain Kind.
Definition: Resolvable.h:191
CapabilitySet providesNamespace(const std::string &namespace_r) const
Definition: Resolvable.h:127
ResKind kind() const
Definition: Resolvable.h:63
Resolvable kinds.
Definition: ResKind.h:32
Edition edition() const
Definition: Solvable.cc:336
int compareByNVR(const Resolvable::constPtr &lhs, const Resolvable::constPtr &rhs)
Definition: Resolvable.h:219
Capabilities obsoletes() const
Definition: Solvable.cc:403
intrusive_ptr< const _Res > constPtrType
Definition: ResTraits.h:83