libzypp  17.23.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/SolvableType.h>
25 
27 namespace zypp
28 {
29  class PoolItem;
49  class Resolvable : public sat::SolvableType<Resolvable>,
51  {
52  friend std::ostream & operator<<( std::ostream & str, const Resolvable & obj );
53 
54  public:
55  typedef Resolvable Self;
60 
61  public:
63  explicit operator sat::Solvable() const
64  { return _solvable; }
65 
67  PoolItem poolItem() const;
68 
69  protected:
71  Resolvable( const sat::Solvable & solvable_r );
73  virtual ~Resolvable();
75  virtual std::ostream & dumpOn( std::ostream & str ) const;
76 
77  private:
79  };
81 
83  inline std::ostream & operator<<( std::ostream & str, const Resolvable & obj )
84  { return obj.dumpOn( str ); }
85 
87  inline std::ostream & dumpOn( std::ostream & str, const Resolvable & obj )
88  { return dumpOn( str, obj.satSolvable() ); }
89 
98  template<class TRes>
99  inline bool isKind( const Resolvable::constPtr & p )
100  { return p && p->isKind<TRes>(); }
101 
102  // Specialization for Resolvable: Always true.
103  template<>
104  inline bool isKind<Resolvable>( const Resolvable::constPtr & p )
105  { return !!p; }
106 
107  // Specialization for ResObject: Always true.
108  template<>
109  inline bool isKind<ResObject>( const Resolvable::constPtr & p )
110  { return !!p; }
111 
112 
121  template<class TRes>
122  inline typename ResTraits<TRes>::PtrType asKind( const Resolvable::Ptr & p )
123  { return dynamic_pointer_cast<TRes>(p); }
124 
125  template<class TRes>
126  inline typename ResTraits<TRes>::constPtrType asKind( const Resolvable::constPtr & p )
127  { return dynamic_pointer_cast<const TRes>(p); }
128 
130 
134  inline int compareByN( const Resolvable::constPtr & lhs, const Resolvable::constPtr & rhs )
135  {
136  int ret = 0;
137  if ( lhs != rhs )
138  {
139  if ( lhs && rhs )
140  ret = compareByN( *lhs, *rhs );
141  else
142  ret = lhs ? 1 : -1;
143  }
144  return ret;
145  }
146 
148  inline int compareByNVR( const Resolvable::constPtr & lhs, const Resolvable::constPtr & rhs )
149  {
150  int ret = 0;
151  if ( lhs != rhs )
152  {
153  if ( lhs && rhs )
154  ret = compareByNVR( *lhs, *rhs );
155  else
156  ret = lhs ? 1 : -1;
157  }
158  return ret;
159  }
160 
162  inline int compareByNVRA( const Resolvable::constPtr & lhs, const Resolvable::constPtr & rhs )
163  {
164  int ret = 0;
165  if ( lhs != rhs )
166  {
167  if ( lhs && rhs )
168  ret = compareByNVRA( *lhs, *rhs );
169  else
170  ret = lhs ? 1 : -1;
171  }
172  return ret;
173  }
174 } // namespace zypp
176 #endif // ZYPP_RESOLVABLE_H
zypp::ResTraits
ResTraits.
Definition: ResTraits.h:79
zypp::PoolItem
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:50
zypp::Resolvable::dumpOn
virtual std::ostream & dumpOn(std::ostream &str) const
Helper for stream output.
Definition: Resolvable.cc:31
zypp::ResTraits::constPtrType
intrusive_ptr< const TRes > constPtrType
Definition: ResTraits.h:83
zypp::sat::Solvable
A Solvable object within the sat Pool.
Definition: Solvable.h:53
zypp::Resolvable::dumpOn
std::ostream & dumpOn(std::ostream &str, const Resolvable &obj)
Definition: Resolvable.h:87
zypp::Resolvable::poolItem
PoolItem poolItem() const
Access the corresponding PoolItem.
Definition: Resolvable.cc:28
zypp::Resolvable::~Resolvable
virtual ~Resolvable()
Dtor.
Definition: Resolvable.cc:25
zypp::sat::SolvableType::satSolvable
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57
zypp::Resolvable::Self
Resolvable Self
Definition: Resolvable.h:55
zypp::Resolvable::constPtr
TraitsType::constPtrType constPtr
Definition: Resolvable.h:59
zypp::Resolvable::TraitsType
ResTraits< Self > TraitsType
Definition: Resolvable.h:56
zypp::base::ReferenceCounted
Base class for reference counted objects.
Definition: ReferenceCounted.h:33
zypp::Resolvable::compareByN
int compareByN(const Resolvable::constPtr &lhs, const Resolvable::constPtr &rhs)
Definition: Resolvable.h:134
zypp::sat::compareByNVR
bool compareByNVR(const SolvableType< Derived > &lhs, const Solvable &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: SolvableType.h:256
zypp::asKind
ResTraits< TRes >::PtrType asKind(const sat::Solvable &solvable_r)
Directly create a certain kind of ResObject from sat::Solvable.
Definition: ResObject.h:127
PtrTypes.h
zypp::Resolvable::Resolvable
Resolvable(const sat::Solvable &solvable_r)
Ctor.
Definition: Resolvable.cc:21
zypp::sat::compareByNVRA
bool compareByNVRA(const SolvableType< Derived > &lhs, const Solvable &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: SolvableType.h:269
zypp::base::NonCopyable
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
zypp::sat::compareByN
bool compareByN(const SolvableType< Derived > &lhs, const Solvable &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: SolvableType.h:242
zypp::Resolvable::compareByNVR
int compareByNVR(const Resolvable::constPtr &lhs, const Resolvable::constPtr &rhs)
Definition: Resolvable.h:148
zypp::ResTraits::PtrType
intrusive_ptr< TRes > PtrType
Definition: ResTraits.h:82
zypp::Resolvable::_solvable
sat::Solvable _solvable
Definition: Resolvable.h:78
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
SolvableType.h
zypp::Resolvable::Ptr
TraitsType::PtrType Ptr
Definition: Resolvable.h:58
zypp::isKind< Resolvable >
bool isKind< Resolvable >(const Resolvable::constPtr &p)
Definition: Resolvable.h:104
zypp::Resolvable
Base for resolvable objects.
Definition: Resolvable.h:49
zypp::Resolvable::operator<<
friend std::ostream & operator<<(std::ostream &str, const Resolvable &obj)
zypp::isKind< ResObject >
bool isKind< ResObject >(const Resolvable::constPtr &p)
Definition: Resolvable.h:109
zypp::Resolvable::Kind
TraitsType::KindType Kind
Definition: Resolvable.h:57
zypp::sat::SolvableType
Base class for creating Solvable based types.
Definition: SolvableType.h:54
zypp::Resolvable::compareByNVRA
int compareByNVRA(const Resolvable::constPtr &lhs, const Resolvable::constPtr &rhs)
Definition: Resolvable.h:162
ReferenceCounted.h
zypp::Resolvable::operator<<
std::ostream & operator<<(std::ostream &str, const Resolvable &obj)
Definition: Resolvable.h:83
zypp::Resolvable::isKind
bool isKind(const Resolvable::constPtr &p)
Test whether a Resolvable::Ptr is of a certain Kind.
Definition: Resolvable.h:99
zypp::Resolvable::asKind
ResTraits< TRes >::PtrType asKind(const Resolvable::Ptr &p)
Convert Resolvable::Ptr into Ptr of a certain Kind.
Definition: Resolvable.h:122
str
String related utilities and Regular expression matching.
zypp::dumpOn
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition: Capability.cc:443
zypp::ResKind
Resolvable kinds. A lowercased string and used as identification. Comparison against string values is...
Definition: ResKind.h:32
NonCopyable.h