libzypp 17.37.17
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-core/Globals.h>
19
22#include <zypp/base/PtrTypes.h>
23
25
27namespace zypp
28{
29 class PoolItem;
49 class ZYPP_API 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 ~Resolvable() override;
75 std::ostream & dumpOn( std::ostream & str ) const override;
76
77 private:
79 };
80
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
Base for resolvable objects.
Definition Resolvable.h:51
Resolvable Self
Definition Resolvable.h:55
ResTraits< Self > TraitsType
Definition Resolvable.h:56
TraitsType::PtrType Ptr
Definition Resolvable.h:58
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
TraitsType::constPtrType constPtr
Definition Resolvable.h:59
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
int compareByNVRA(const Resolvable::constPtr &lhs, const Resolvable::constPtr &rhs)
Compare Resolvable::constPtr according to kind, name, edition and arch.
Definition Resolvable.h:162
std::ostream & dumpOn(std::ostream &str) const override
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
TraitsType::KindType Kind
Definition Resolvable.h:57
int compareByNVR(const Resolvable::constPtr &lhs, const Resolvable::constPtr &rhs)
Compare according to kind, name and edition.
Definition Resolvable.h:148
bool isKind(const Resolvable::constPtr &p)
Test whether a Resolvable::Ptr is of a certain Kind.
Definition Resolvable.h:99
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
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
bool isKind< ResObject >(const Resolvable::constPtr &p)
Definition Resolvable.h:109
bool isKind< Resolvable >(const Resolvable::constPtr &p)
Definition Resolvable.h:104
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
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< Self > PtrType
Definition ResTraits.h:82
intrusive_ptr< const Self > constPtrType
Definition ResTraits.h:83
Base class for creating Solvable based types.
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Provides API related macros.