libzypp  13.10.6
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 
91  Capabilities dep( Dep which_r ) const
92  { return operator[]( which_r ); }
93 
94  Capabilities operator[]( Dep which_r ) const
95  { return sat::Solvable::operator[]( which_r ); }
96 
98  { return sat::Solvable::provides(); }
99 
101  { return sat::Solvable::requires(); }
102 
104  { return sat::Solvable::conflicts(); }
105 
107  { return sat::Solvable::obsoletes(); }
108 
110  { return sat::Solvable::recommends(); }
111 
113  { return sat::Solvable::suggests(); }
114 
116  { return sat::Solvable::enhances(); }
117 
119  { return sat::Solvable::supplements(); }
120 
122  { return sat::Solvable::prerequires(); }
123 
124  CapabilitySet providesNamespace( const std::string & namespace_r ) const
125  { return sat::Solvable::providesNamespace( namespace_r ); }
126 
127  CapabilitySet valuesOfNamespace( const std::string & namespace_r ) const
128  { return sat::Solvable::valuesOfNamespace( namespace_r ); }
130 
131  public:
133  const sat::Solvable & satSolvable() const { return *this; }
134 
136  PoolItem poolItem() const;
137 
138  protected:
140  Resolvable( const sat::Solvable & solvable_r );
142  virtual ~Resolvable();
144  virtual std::ostream & dumpOn( std::ostream & str ) const;
145  };
147 
149  inline std::ostream & operator<<( std::ostream & str, const Resolvable & obj )
150  { return obj.dumpOn( str ); }
151 
153  inline std::ostream & dumpOn( std::ostream & str, const Resolvable & obj )
154  { return dumpOn( str, obj.satSolvable() ); }
155 
164  template<class _Res>
165  inline bool isKind( const Resolvable::constPtr & p )
166  { return p && p->kind() == ResTraits<_Res>::kind; }
167 
168  // Specialization for Resolvable: Always true.
169  template<>
170  inline bool isKind<Resolvable>( const Resolvable::constPtr & p )
171  { return !!p; }
172 
173  // Specialization for ResObject: Always true.
174  template<>
175  inline bool isKind<ResObject>( const Resolvable::constPtr & p )
176  { return !!p; }
177 
178 
187  template<class _Res>
188  inline typename ResTraits<_Res>::PtrType asKind( const Resolvable::Ptr & p )
189  { return dynamic_pointer_cast<_Res>(p); }
190 
191  template<class _Res>
192  inline typename ResTraits<_Res>::constPtrType asKind( const Resolvable::constPtr & p )
193  { return dynamic_pointer_cast<const _Res>(p); }
194 
196 
200  inline int compareByN( const Resolvable::constPtr & lhs,
201  const Resolvable::constPtr & rhs )
202  {
203  if ( lhs == rhs )
204  return 0;
205  if ( ! (lhs && rhs) )
206  return lhs ? 1 : -1;
207  int res = 0;
208  if ( (res = lhs->kind().compare( rhs->kind() )) )
209  return res;
210  return lhs->name().compare( rhs->name() );
211  }
212 
216  inline int compareByNVR( const Resolvable::constPtr & lhs,
217  const Resolvable::constPtr & rhs )
218  {
219  if ( lhs == rhs )
220  return 0;
221  if ( ! (lhs && rhs) )
222  return lhs ? 1 : -1;
223  int res = 0;
224  if ( (res = lhs->kind().compare( rhs->kind() )) )
225  return res;
226  if ( (res = lhs->name().compare( rhs->name() )) )
227  return res;
228  return lhs->edition().compare( rhs->edition() );
229  }
230 
234  inline int compareByNVRA( const Resolvable::constPtr & lhs,
235  const Resolvable::constPtr & rhs )
236  {
237  if ( lhs == rhs )
238  return 0;
239  if ( ! (lhs && rhs) )
240  return lhs ? 1 : -1;
241  int res = 0;
242  if ( (res = lhs->kind().compare( rhs->kind() )) )
243  return res;
244  if ( (res = lhs->name().compare( rhs->name() )) )
245  return res;
246  if ( (res = lhs->edition().compare( rhs->edition() )) )
247  return res;
248  return lhs->arch().compare( rhs->arch() );
249  }
250 
252 } // namespace zypp
254 #endif // ZYPP_RESOLVABLE_H
bool isSystem() const
Whether this represents an installed solvable.
Definition: Resolvable.h:53
Capabilities enhances() const
Definition: Resolvable.h:115
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
Container of Capability (currently read only).
Definition: Capabilities.h:35
IdString ident() const
The identifier.
Definition: Solvable.cc:165
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:234
Capabilities supplements() const
Definition: Solvable.cc:459
Capabilities provides() const
Definition: Resolvable.h:97
bool isSystem() const
Return whether this Solvable belongs to the system repo.
Definition: Solvable.cc:154
bool isKind() const
Definition: Solvable.h:162
Capabilities suggests() const
Definition: Solvable.cc:449
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:255
ResTraits.
Definition: ResTraits.h:77
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::tr1::unordered_set< Capability > CapabilitySet
Definition: Capability.h:33
Capabilities provides() const
Definition: Solvable.cc:424
Resolvable(const sat::Solvable &solvable_r)
Ctor.
Definition: Resolvable.cc:27
Capabilities dep(Dep which_r) const
Select by Dep.
Definition: Resolvable.h:91
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:165
std::string name() const
Definition: Solvable.cc:364
bool isKind< Resolvable >(const Resolvable::constPtr &p)
Definition: Resolvable.h:170
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:127
std::ostream & dumpOn(std::ostream &str, const Resolvable &obj)
Definition: Resolvable.h:153
Capabilities requires() const
Definition: Resolvable.h:100
Capabilities operator[](Dep which_r) const
Definition: Resolvable.h:94
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:133
bool onSystemByUser() const
Whether this is known to be installed on behalf of a user request.
Definition: Solvable.cc:160
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:435
Capabilities suggests() const
Definition: Resolvable.h:112
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:121
Base class for reference counted objects.
Capabilities enhances() const
Definition: Solvable.cc:454
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:298
std::ostream & operator<<(std::ostream &str, const Resolvable &obj)
Definition: Resolvable.h:149
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
Capabilities conflicts() const
Definition: Resolvable.h:103
Capabilities recommends() const
Definition: Resolvable.h:109
Capabilities prerequires() const
Definition: Solvable.cc:464
int compareByN(const Resolvable::constPtr &lhs, const Resolvable::constPtr &rhs)
Definition: Resolvable.h:200
Capabilities operator[](Dep which_r) const
Definition: Solvable.cc:403
Capabilities requires() const
Definition: Solvable.cc:429
virtual ~Resolvable()
Dtor.
Definition: Resolvable.cc:36
Capabilities supplements() const
Definition: Resolvable.h:118
intrusive_ptr< _Res > PtrType
Definition: ResTraits.h:80
Capabilities obsoletes() const
Definition: Resolvable.h:106
bool isKind< ResObject >(const Resolvable::constPtr &p)
Definition: Resolvable.h:175
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:188
CapabilitySet providesNamespace(const std::string &namespace_r) const
Definition: Resolvable.h:124
ResKind kind() const
Definition: Resolvable.h:63
Resolvable kinds.
Definition: ResKind.h:35
Edition edition() const
Definition: Solvable.cc:372
int compareByNVR(const Resolvable::constPtr &lhs, const Resolvable::constPtr &rhs)
Definition: Resolvable.h:216
Capabilities obsoletes() const
Definition: Solvable.cc:439
intrusive_ptr< const _Res > constPtrType
Definition: ResTraits.h:81