libzypp
10.5.0
|
00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00012 #ifndef ZYPP_POOLITEMBEST_H 00013 #define ZYPP_POOLITEMBEST_H 00014 00015 #include <iosfwd> 00016 00017 #include "zypp/base/PtrTypes.h" 00018 #include "zypp/base/Function.h" 00019 #include "zypp/base/Iterator.h" 00020 #include "zypp/base/Tr1hash.h" 00021 00022 #include "zypp/PoolItem.h" 00023 00025 namespace zypp 00026 { 00027 00029 // 00030 // CLASS NAME : PoolItemBest 00031 // 00060 class PoolItemBest 00061 { 00062 typedef std::tr1::unordered_map<IdString,PoolItem> Container; 00063 public: 00065 typedef boost::function<bool ( const PoolItem & lhs, const PoolItem & rhs )> Predicate; 00066 00067 typedef Container::size_type size_type; 00068 typedef Container::value_type value_type; 00069 typedef MapKVIteratorTraits<Container>::Value_const_iterator iterator; 00070 typedef MapKVIteratorTraits<Container>::Key_const_iterator ident_iterator; 00071 00072 public: 00074 PoolItemBest() 00075 {} 00076 00078 PoolItemBest( sat::Solvable slv_r ) 00079 { _ctor_init(); add( slv_r ); } 00080 00082 PoolItemBest( const PoolItem & pi_r ) 00083 { _ctor_init(); add( pi_r ); } 00084 00086 template<class _Iterator> 00087 PoolItemBest( _Iterator begin_r, _Iterator end_r ) 00088 { _ctor_init(); add( begin_r, end_r ); } 00089 00090 public: 00092 void add( sat::Solvable slv_r ) 00093 { add( PoolItem( slv_r ) ); } 00094 00096 void add( const PoolItem & pi_r ); 00097 00099 template<class _Iterator> 00100 void add( _Iterator begin_r, _Iterator end_r ) 00101 { 00102 for_( it, begin_r, end_r ) 00103 add( *it ); 00104 } 00105 00106 public: 00110 bool empty() const { return container().empty(); } 00112 size_type size() const { return container().size(); } 00114 iterator begin() const { return make_map_value_begin( container() ); } 00116 iterator end() const { return make_map_value_end( container() ); } 00117 00119 PoolItem find( IdString ident_r ) const; 00121 PoolItem find( sat::Solvable slv_r ) const { return find( slv_r.ident() ); } 00123 PoolItem find( const PoolItem & pi_r ) const { return find( pi_r.satSolvable().ident() ); } 00125 00129 ident_iterator identBegin() const { return make_map_key_begin( container() ); } 00131 ident_iterator identEnd() const { return make_map_key_end( container() ); } 00133 00134 private: 00135 void _ctor_init(); 00136 const Container & container() const; 00137 private: 00139 class Impl; 00141 RWCOW_pointer<Impl> & pimpl() { return *(reinterpret_cast<RWCOW_pointer<Impl>*>( _dont_use_this_use_pimpl.get() )); } 00143 const RWCOW_pointer<Impl> & pimpl() const { return *(reinterpret_cast<RWCOW_pointer<Impl>*>( _dont_use_this_use_pimpl.get() )); } 00145 shared_ptr<void> _dont_use_this_use_pimpl; 00146 }; 00148 00150 std::ostream & operator<<( std::ostream & str, const PoolItemBest & obj ); 00151 00153 } // namespace zypp 00155 #endif // ZYPP_POOLITEMBEST_H