PoolItem.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00012 #ifndef ZYPP_POOLITEM_H
00013 #define ZYPP_POOLITEM_H
00014
00015 #include <iosfwd>
00016 #include <functional>
00017
00018 #include "zypp/base/PtrTypes.h"
00019 #include "zypp/ResObject.h"
00020 #include "zypp/ResStatus.h"
00021
00023 namespace zypp
00024 {
00025
00026 class ResPool;
00027
00028 namespace pool
00029 {
00030 class PoolImpl;
00031 }
00032
00034
00035
00036
00050 class PoolItem
00051 {
00052 friend std::ostream & operator<<( std::ostream & str, const PoolItem & obj );
00053
00054 public:
00056 class Impl;
00057
00058 public:
00060 PoolItem();
00061
00063 explicit PoolItem( const sat::Solvable & solvable_r );
00064
00066 explicit PoolItem( const ResObject::constPtr & resolvable_r );
00067
00069 ~PoolItem();
00070
00071 public:
00075 ResStatus & status() const;
00076
00078 ResStatus & statusReset() const;
00079
00080
00086 bool isUndetermined() const;
00087
00091 bool isRelevant() const;
00092
00094 bool isSatisfied() const;
00095
00097 bool isBroken() const;
00098
00102 bool isNeeded() const;
00103
00105 bool isUnwanted() const;
00107
00109 public:
00111 ResPool pool() const;
00112
00114 sat::Solvable satSolvable() const
00115 { return resolvable() ? resolvable()->satSolvable() : sat::Solvable::noSolvable; }
00116
00120 sat::Solvable buddy() const;
00121
00122 public:
00126 ResObject::constPtr resolvable() const;
00127
00131 operator ResObject::constPtr() const
00132 { return resolvable(); }
00133
00135 ResObject::constPtr operator->() const
00136 { return resolvable(); }
00137
00140 operator ResObject::constPtr::unspecified_bool_type() const
00141 { return resolvable(); }
00142
00143 private:
00144 friend class Impl;
00145 friend class pool::PoolImpl;
00147 static PoolItem makePoolItem( const sat::Solvable & solvable_r );
00149 void setBuddy( sat::Solvable solv_r );
00151 explicit PoolItem( Impl * implptr_r );
00153 RW_pointer<Impl> _pimpl;
00154
00155 private:
00159 friend class PoolItemSaver;
00160 void saveState() const;
00161 void restoreState() const;
00162 bool sameState() const;
00164 };
00166
00168 std::ostream & operator<<( std::ostream & str, const PoolItem & obj );
00169
00171 inline bool operator==( const PoolItem & lhs, const PoolItem & rhs )
00172 { return lhs.resolvable() == rhs.resolvable(); }
00173
00175 inline bool operator==( const PoolItem & lhs, const ResObject::constPtr & rhs )
00176 { return lhs.resolvable() == rhs; }
00177
00179 inline bool operator==( const ResObject::constPtr & lhs, const PoolItem & rhs )
00180 { return lhs == rhs.resolvable(); }
00181
00182
00184 inline bool operator!=( const PoolItem & lhs, const PoolItem & rhs )
00185 { return ! (lhs==rhs); }
00186
00188 inline bool operator!=( const PoolItem & lhs, const ResObject::constPtr & rhs )
00189 { return ! (lhs==rhs); }
00190
00192 inline bool operator!=( const ResObject::constPtr & lhs, const PoolItem & rhs )
00193 { return ! (lhs==rhs); }
00194
00195
00197 inline bool identical( const PoolItem & lhs, const PoolItem & rhs )
00198 { return lhs == rhs || lhs.satSolvable().identical( rhs.satSolvable() ); }
00199
00201 inline bool identical( const PoolItem & lhs, sat::Solvable rhs )
00202 { return lhs.satSolvable().identical( rhs ); }
00203
00205 inline bool identical( sat::Solvable lhs, const PoolItem & rhs )
00206 { return lhs.identical( rhs.satSolvable() ); }
00207
00208
00210 inline bool sameNVRA( const PoolItem & lhs, const PoolItem & rhs )
00211 { return lhs == rhs || lhs.satSolvable().sameNVRA( rhs.satSolvable() ); }
00212
00214 inline bool sameNVRA( const PoolItem & lhs, sat::Solvable rhs )
00215 { return lhs.satSolvable().sameNVRA( rhs ); }
00216
00218 inline bool sameNVRA( sat::Solvable lhs, const PoolItem & rhs )
00219 { return lhs.sameNVRA( rhs.satSolvable() ); }
00220
00225 struct asPoolItem
00226 {
00227 typedef PoolItem result_type;
00228
00229 PoolItem operator()( const sat::Solvable & solv_r ) const
00230 { return PoolItem( solv_r ); }
00231 };
00232
00234 }
00237 namespace std
00238 {
00239
00241 template<>
00242 inline bool less<zypp::PoolItem>::operator()( const zypp::PoolItem & lhs, const zypp::PoolItem & rhs ) const
00243 { return lhs.resolvable() < rhs.resolvable(); }
00244
00246 }
00248 #endif // ZYPP_POOLITEM_H