libzypp: zypp/Resolvable.h Source File

libzypp 17.38.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-core/Globals.h>
19
20#include <zypp/base/ReferenceCounted.h>
21#include <zypp-core/base/NonCopyable.h>
22#include <zypp-core/base/PtrTypes.h>
23
24#include <zypp/sat/SolvableType.h>
25
27namespace zypp
28{
29 class PoolItem;
49 class ZYPP_API Resolvable : public sat::SolvableType<Resolvable>,
50 public base::ReferenceCounted, private base::NonCopyable
51 {
52 friend std::ostream & operator<<( std::ostream & str, const Resolvable & obj );
53
54 public:
55 using Self = Resolvable;
56 using TraitsType = ResTraits<Self>;
57 using Kind = TraitsType::KindType;
58 using Ptr = TraitsType::PtrType;
59 using constPtr = TraitsType::constPtrType;
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:
78 sat::Solvable _solvable;
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<>
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
Globals.h
Provides API related macros.
NonCopyable.h
PtrTypes.h
SolvableType.h
zypp::PoolItem
Combining sat::Solvable and ResStatus.
Definition PoolItem.h:51
zypp::Resolvable
Base for resolvable objects.
Definition Resolvable.h:51
zypp::Resolvable::Self
Resolvable Self
Definition Resolvable.h:55
zypp::Resolvable::TraitsType
ResTraits< Self > TraitsType
Definition Resolvable.h:56
zypp::Resolvable::Ptr
TraitsType::PtrType Ptr
Definition Resolvable.h:58
zypp::Resolvable::compareByN
int compareByN(const Resolvable::constPtr &lhs, const Resolvable::constPtr &rhs)
Compare Resolvable::constPtr according to kind and name.
Definition Resolvable.h:134
zypp::Resolvable::dumpOn
std::ostream & dumpOn(std::ostream &str, const Resolvable &obj)
More verbose stream output including dependencies.
Definition Resolvable.h:87
zypp::Resolvable::constPtr
TraitsType::constPtrType constPtr
Definition Resolvable.h:59
zypp::Resolvable::operator<<
friend std::ostream & operator<<(std::ostream &str, const Resolvable &obj)
zypp::Resolvable::Resolvable
Resolvable(const sat::Solvable &solvable_r)
Ctor.
Definition Resolvable.cc:21
zypp::Resolvable::_solvable
sat::Solvable _solvable
Definition Resolvable.h:78
zypp::Resolvable::compareByNVRA
int compareByNVRA(const Resolvable::constPtr &lhs, const Resolvable::constPtr &rhs)
Compare Resolvable::constPtr according to kind, name, edition and arch.
Definition Resolvable.h:162
zypp::Resolvable::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Helper for stream output.
Definition Resolvable.cc:31
zypp::Resolvable::asKind
ResTraits< TRes >::PtrType asKind(const Resolvable::Ptr &p)
Convert Resolvable::Ptr into Ptr of a certain Kind.
Definition Resolvable.h:122
zypp::Resolvable::Kind
TraitsType::KindType Kind
Definition Resolvable.h:57
zypp::Resolvable::compareByNVR
int compareByNVR(const Resolvable::constPtr &lhs, const Resolvable::constPtr &rhs)
Compare according to kind, name and edition.
Definition Resolvable.h:148
zypp::Resolvable::isKind
bool isKind(const Resolvable::constPtr &p)
Test whether a Resolvable::Ptr is of a certain Kind.
Definition Resolvable.h:99
zypp::base::ReferenceCounted
Base class for reference counted objects.
Definition ReferenceCounted.h:35
zypp::sat::Solvable
A Solvable object within the sat Pool.
Definition Solvable.h:54
str
String related utilities and Regular expression matching.
zypp::base::NonCopyable
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition NonCopyable.h:26
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::dumpOn
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition Capability.cc:588
zypp::isKind< ResObject >
bool isKind< ResObject >(const Resolvable::constPtr &p)
Definition Resolvable.h:109
zypp::isKind< Resolvable >
bool isKind< Resolvable >(const Resolvable::constPtr &p)
Definition Resolvable.h:104
zypp::ZYPP_API
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
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
zypp::ResTraits
ResTraits.
Definition ResTraits.h:80
zypp::ResTraits< Self >::PtrType
intrusive_ptr< Self > PtrType
Definition ResTraits.h:82
zypp::ResTraits< Self >::KindType
ResKind KindType
Definition ResTraits.h:81
zypp::ResTraits< Self >::constPtrType
intrusive_ptr< const Self > constPtrType
Definition ResTraits.h:83
zypp::sat::SolvableType
Base class for creating Solvable based types.
Definition SolvableType.h:55
zypp::sat::SolvableType::satSolvable
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition SolvableType.h:57
ReferenceCounted.h