libzypp 17.31.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
20#include <zypp/base/ReferenceCounted.h>
21#include <zypp/base/NonCopyable.h>
22#include <zypp/base/PtrTypes.h>
23
25
27namespace 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:
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<>
105 { return !!p; }
106
107 // Specialization for ResObject: Always true.
108 template<>
110 { return !!p; }
111
112
121 template<class TRes>
123 { return dynamic_pointer_cast<TRes>(p); }
124
125 template<class TRes>
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
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:51
Resolvable kinds.
Definition: ResKind.h:33
Base for resolvable objects.
Definition: Resolvable.h:51
TraitsType::PtrType Ptr
Definition: Resolvable.h:58
TraitsType::constPtrType constPtr
Definition: Resolvable.h:59
ResTraits< Self > TraitsType
Definition: Resolvable.h:56
int compareByN(const Resolvable::constPtr &lhs, const Resolvable::constPtr &rhs)
Compare Resolvable::constPtr according to kind and name.
Definition: Resolvable.h:134
std::ostream & dumpOn(std::ostream &str, const Resolvable &obj)
More verbose stream output including dependencies.
Definition: Resolvable.h:87
friend std::ostream & operator<<(std::ostream &str, const Resolvable &obj)
Resolvable(const sat::Solvable &solvable_r)
Ctor.
Definition: Resolvable.cc:21
sat::Solvable _solvable
Definition: Resolvable.h:78
TraitsType::KindType Kind
Definition: Resolvable.h:57
int compareByNVRA(const Resolvable::constPtr &lhs, const Resolvable::constPtr &rhs)
Compare Resolvable::constPtr according to kind, name, edition and arch.
Definition: Resolvable.h:162
PoolItem poolItem() const
Access the corresponding PoolItem.
Definition: Resolvable.cc:28
virtual std::ostream & dumpOn(std::ostream &str) const
Helper for stream output.
Definition: Resolvable.cc:31
ResTraits< TRes >::PtrType asKind(const Resolvable::Ptr &p)
Convert Resolvable::Ptr into Ptr of a certain Kind.
Definition: Resolvable.h:122
int compareByNVR(const Resolvable::constPtr &lhs, const Resolvable::constPtr &rhs)
Compare according to kind, name and edition.
Definition: Resolvable.h:148
virtual ~Resolvable()
Dtor.
Definition: Resolvable.cc:25
bool isKind(const Resolvable::constPtr &p)
Test whether a Resolvable::Ptr is of a certain Kind.
Definition: Resolvable.h:99
Resolvable Self
Definition: Resolvable.h:55
Base class for reference counted objects.
A Solvable object within the sat Pool.
Definition: Solvable.h:54
String related utilities and Regular expression matching.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
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:260
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:273
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:246
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition: Capability.cc:567
bool isKind< ResObject >(const Resolvable::constPtr &p)
Definition: Resolvable.h:109
bool isKind< Resolvable >(const Resolvable::constPtr &p)
Definition: Resolvable.h:104
ResTraits< TRes >::PtrType asKind(const sat::Solvable &solvable_r)
Directly create a certain kind of ResObject from sat::Solvable.
Definition: ResObject.h:127
ResTraits.
Definition: ResTraits.h:80
intrusive_ptr< const TRes > constPtrType
Definition: ResTraits.h:83
intrusive_ptr< TRes > PtrType
Definition: ResTraits.h:82
Base class for creating Solvable based types.
Definition: SolvableType.h:55
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57